}
/**
- * A wrapper for mkdir(2).
+ * Create a directory, don't fail if it already exists.
*
* \param path Name of the directory to create.
- * \param mode The permissions to use.
*
- * \return Standard.
+ * This function passes the fixed mode value 0777 to mkdir(3) (which consults
+ * the file creation mask and restricts this value).
+ *
+ * \return Zero if the directory already existed, one if the directory has been
+ * created, negative error code if the mkdir(3) call failed for any reason
+ * other than EEXIST.
*/
-int para_mkdir(const char *path, mode_t mode)
+int para_mkdir(const char *path)
{
- if (!mkdir(path, mode))
+ if (mkdir(path, 0777) == 0)
return 1;
+ if (errno == EEXIST)
+ return 0;
return -ERRNO_TO_PARA_ERROR(errno);
}