summaryrefslogtreecommitdiff
path: root/src/shared/mkdir.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-06-10 23:42:16 +0200
committerLennart Poettering <lennart@poettering.net>2014-06-10 23:42:16 +0200
commite73a03e059830a3df8fac811f923704311e93731 (patch)
tree43e68b863f40aac29f942695c1544a112204eece /src/shared/mkdir.c
parent849958d1ba3533c953fad46d4d41c0ec6e48316d (diff)
tmpfiles: get rid of "m" lines, make them redundant by "z"
"m" so far has been a non-globbing version of "z". Since this makes it quite redundant, let's get rid of it. Remove "m" from the man pages, beef up "z" docs instead, and make "m" nothing more than a compatibility alias for "z".
Diffstat (limited to 'src/shared/mkdir.c')
-rw-r--r--src/shared/mkdir.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/shared/mkdir.c b/src/shared/mkdir.c
index ba083d6d67..f941efb401 100644
--- a/src/shared/mkdir.c
+++ b/src/shared/mkdir.c
@@ -58,11 +58,16 @@ int mkdir_safe(const char *path, mode_t mode, uid_t uid, gid_t gid) {
return mkdir_safe_internal(path, mode, uid, gid, mkdir);
}
-int is_dir(const char* path) {
+int is_dir(const char* path, bool follow) {
struct stat st;
- if (stat(path, &st) < 0)
- return -errno;
+ if (follow) {
+ if (stat(path, &st) < 0)
+ return -errno;
+ } else {
+ if (lstat(path, &st) < 0)
+ return -errno;
+ }
return S_ISDIR(st.st_mode);
}
@@ -85,7 +90,7 @@ int mkdir_parents_internal(const char *prefix, const char *path, mode_t mode, mk
return 0;
p = strndupa(path, e - path);
- r = is_dir(p);
+ r = is_dir(p, true);
if (r > 0)
return 0;
if (r == 0)
@@ -130,7 +135,7 @@ int mkdir_p_internal(const char *prefix, const char *path, mode_t mode, mkdir_fu
return r;
r = _mkdir(path, mode);
- if (r < 0 && (errno != EEXIST || is_dir(path) <= 0))
+ if (r < 0 && (errno != EEXIST || is_dir(path, true) <= 0))
return -errno;
return 0;