summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2012-11-02 15:05:31 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-03-17 01:55:47 -0400
commit6cf487afad4ef4706b5d6d9ba5df24cac68e687a (patch)
tree0a4e37b9a937db6bc2ca81785105599dd625df30
parentd18d46ecea80a7f07415edb9264af6a254fd70bb (diff)
shared: export is_dir
-rw-r--r--src/shared/mkdir.c2
-rw-r--r--src/shared/mkdir.h1
-rw-r--r--src/tmpfiles/tmpfiles.c13
3 files changed, 8 insertions, 8 deletions
diff --git a/src/shared/mkdir.c b/src/shared/mkdir.c
index b35551eb02..ba083d6d67 100644
--- a/src/shared/mkdir.c
+++ b/src/shared/mkdir.c
@@ -58,7 +58,7 @@ int mkdir_safe(const char *path, mode_t mode, uid_t uid, gid_t gid) {
return mkdir_safe_internal(path, mode, uid, gid, mkdir);
}
-static int is_dir(const char* path) {
+int is_dir(const char* path) {
struct stat st;
if (stat(path, &st) < 0)
diff --git a/src/shared/mkdir.h b/src/shared/mkdir.h
index eb73902fc2..f1bf4c0a68 100644
--- a/src/shared/mkdir.h
+++ b/src/shared/mkdir.h
@@ -41,3 +41,4 @@ typedef int (*mkdir_func_t)(const char *pathname, mode_t mode);
int mkdir_safe_internal(const char *path, mode_t mode, uid_t uid, gid_t gid, mkdir_func_t _mkdir);
int mkdir_parents_internal(const char *prefix, const char *path, mode_t mode, mkdir_func_t _mkdir);
int mkdir_p_internal(const char *prefix, const char *path, mode_t mode, mkdir_func_t _mkdir);
+int is_dir(const char *path);
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 52f80379e3..74a01271e9 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -542,7 +542,7 @@ static int recursive_relabel_children(Item *i, const char *path) {
for (;;) {
struct dirent *de;
- bool is_dir;
+ bool dir;
int r;
_cleanup_free_ char *entry_path = NULL;
@@ -567,18 +567,17 @@ static int recursive_relabel_children(Item *i, const char *path) {
}
if (de->d_type == DT_UNKNOWN) {
- struct stat st;
-
- if (lstat(entry_path, &st) < 0) {
+ r = is_dir(entry_path);
+ if (r < 0) {
if (ret == 0 && errno != ENOENT)
ret = -errno;
continue;
}
- is_dir = S_ISDIR(st.st_mode);
+ dir = r;
} else
- is_dir = de->d_type == DT_DIR;
+ dir = de->d_type == DT_DIR;
r = item_set_perms(i, entry_path);
if (r < 0) {
@@ -587,7 +586,7 @@ static int recursive_relabel_children(Item *i, const char *path) {
continue;
}
- if (is_dir) {
+ if (dir) {
r = recursive_relabel_children(i, entry_path);
if (r < 0 && ret == 0)
ret = r;