1 #ifndef MKDIR_PARENTS_H 2 #define MKDIR_PARENTS_H 3 4 #include <sys/stat.h> 5 6 /* Create path and all the directories under it if needed. Permissions for 7 existing directories isn't changed. Returns 0 if ok. If directory already 8 exists, returns -1 with errno=EEXIST. */ 9 int mkdir_parents(const char *path, mode_t mode); 10 11 /* Like mkdir_parents(), but use the given uid/gid for newly created 12 directories. (uid_t)-1 or (gid_t)-1 can be used to indicate that it 13 doesn't need to be changed. If gid isn't (gid_t)-1 and the parent directory 14 had setgid-bit enabled, it's removed unless explicitly included in the 15 mode. */ 16 int mkdir_parents_chown(const char *path, mode_t mode, uid_t uid, gid_t gid); 17 /* Like mkdir_parents_chown(), but change only group. If chown() fails with 18 EACCES, use gid_origin in the error message. */ 19 int mkdir_parents_chgrp(const char *path, mode_t mode, 20 gid_t gid, const char *gid_origin); 21 22 /* Like mkdir_parents_chown(), but don't actually create any parents. */ 23 int mkdir_chown(const char *path, mode_t mode, uid_t uid, gid_t gid); 24 int mkdir_chgrp(const char *path, mode_t mode, 25 gid_t gid, const char *gid_origin); 26 27 /* stat() the path or its first parent that exists. Returns 0 if ok, -1 if 28 failed. root_dir is set to the last stat()ed directory (on success and 29 on failure). */ 30 int stat_first_parent(const char *path, const char **root_dir_r, 31 struct stat *st_r); 32 33 #endif 34