* Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
* 2001, 2002, 2003, 2004, 2005 by Theodore Ts'o.
*
- * Copyright (C) 2009, 2012 Karel Zak <kzak@redhat.com>
+ * Copyright (C) 2009-2014 Karel Zak <kzak@redhat.com>
*
* This file may be redistributed under the terms of the GNU Public
* License.
extern int get_fd_tabsize(void);
+extern int mkdir_p(const char *path, mode_t mode);
+
#endif /* UTIL_LINUX_FILEUTILS */
return EXIT_FAILURE;
}
#endif
+
+
+int mkdir_p(const char *path, mode_t mode)
+{
+ char *p, *dir;
+ int rc = 0;
+
+ if (!path || !*path)
+ return -EINVAL;
+
+ dir = p = strdup(path);
+ if (!dir)
+ return -ENOMEM;
+
+ if (*p == '/')
+ p++;
+
+ while (p && *p) {
+ char *e = strchr(p, '/');
+ if (e)
+ *e = '\0';
+ if (*p) {
+ rc = mkdir(dir, mode);
+ if (rc && errno != EEXIST)
+ break;
+ rc = 0;
+ }
+ if (!e)
+ break;
+ *e = '/';
+ p = e + 1;
+ }
+
+ free(dir);
+ return rc;
+}
*/
#include "mountP.h"
+#include "fileutils.h"
#include <sys/wait.h>
#include "canonicalize.h"
#include "env.h"
#include "match.h"
+#include "fileutils.h"
#include "statfs_magic.h"
int append_string(char **a, const char *b)
return res;
}
-int mkdir_p(const char *path, mode_t mode)
-{
- char *p, *dir;
- int rc = 0;
-
- if (!path || !*path)
- return -EINVAL;
-
- dir = p = strdup(path);
- if (!dir)
- return -ENOMEM;
-
- if (*p == '/')
- p++;
-
- while (p && *p) {
- char *e = strchr(p, '/');
- if (e)
- *e = '\0';
- if (*p) {
- rc = mkdir(dir, mode);
- if (rc && errno != EEXIST)
- break;
- rc = 0;
- }
- if (!e)
- break;
- *e = '/';
- p = e + 1;
- }
-
- DBG(UTILS, ul_debug("%s mkdir %s", path, rc ? "FAILED" : "SUCCESS"));
-
- free(dir);
- return rc;
-}
-
#ifdef TEST_PROGRAM
int test_match_fstype(struct libmnt_test *ts, int argc, char *argv[])
{