X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Futils%2Fos.c;h=ecca206a1e57c11d98343c680531373cfd918f24;hb=76796f4b618f839aed33ca37f39782d44c3f04f3;hp=b1e143a6a651d140e0ee10ce36fdff7f05da421b;hpb=42e0a931f1424c2d13794e3a064d328669ed7767;p=sysdb.git diff --git a/src/utils/os.c b/src/utils/os.c index b1e143a..ecca206 100644 --- a/src/utils/os.c +++ b/src/utils/os.c @@ -43,16 +43,11 @@ #include /* - * private helper functions + * public API */ -/* - * Recursively create the directory 'pathname' using the specified 'mode'. If - * 'enforce_mode' is true, the mode will be enforced even if the directory - * exists already. - */ -static int -mkdir_rec(const char *pathname, mode_t mode, _Bool enforce_mode) +int +sdb_mkdir_all(const char *pathname, mode_t mode) { struct stat st; char *base_dir; @@ -70,9 +65,6 @@ mkdir_rec(const char *pathname, mode_t mode, _Bool enforce_mode) errno = ENOTDIR; return -1; } - - if ((st.st_mode != mode) && enforce_mode) - return chmod(pathname, mode); return 0; } @@ -85,23 +77,12 @@ mkdir_rec(const char *pathname, mode_t mode, _Bool enforce_mode) return -1; base_dir = dirname(base_dir); - /* don't enforce the mode on parent directories */ - status = mkdir_rec(base_dir, mode, 0); + status = sdb_mkdir_all(base_dir, mode); if (! status) status = mkdir(pathname, mode); free(base_dir); return status; -} /* mkdir_rec */ - -/* - * public API - */ - -int -sdb_mkdir_all(const char *pathname, mode_t mode) -{ - return mkdir_rec(pathname, mode, 1); } /* sdb_mkdir_all */ /* vim: set tw=78 sw=4 ts=4 noexpandtab : */