summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/shared/mkdir.c14
-rw-r--r--src/shared/mkdir.h1
-rw-r--r--src/shared/util.c17
-rw-r--r--src/shared/util.h1
4 files changed, 15 insertions, 18 deletions
diff --git a/src/shared/mkdir.c b/src/shared/mkdir.c
index fabd9e215e..ef3f494cc8 100644
--- a/src/shared/mkdir.c
+++ b/src/shared/mkdir.c
@@ -58,20 +58,6 @@ 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, bool follow) {
- struct stat st;
-
- if (follow) {
- if (stat(path, &st) < 0)
- return -errno;
- } else {
- if (lstat(path, &st) < 0)
- return -errno;
- }
-
- return S_ISDIR(st.st_mode);
-}
-
int mkdir_parents_internal(const char *prefix, const char *path, mode_t mode, mkdir_func_t _mkdir) {
const char *p, *e;
int r;
diff --git a/src/shared/mkdir.h b/src/shared/mkdir.h
index d2794ead90..e317df300e 100644
--- a/src/shared/mkdir.h
+++ b/src/shared/mkdir.h
@@ -39,4 +39,3 @@ 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, bool is_dir);
diff --git a/src/shared/util.c b/src/shared/util.c
index 5f6249eb04..bc97c67f76 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -6933,10 +6933,21 @@ int is_symlink(const char *path) {
if (lstat(path, &info) < 0)
return -errno;
- if (S_ISLNK(info.st_mode))
- return 1;
+ return !!S_ISLNK(info.st_mode);
+}
- return 0;
+int is_dir(const char* path, bool follow) {
+ struct stat st;
+
+ if (follow) {
+ if (stat(path, &st) < 0)
+ return -errno;
+ } else {
+ if (lstat(path, &st) < 0)
+ return -errno;
+ }
+
+ return !!S_ISDIR(st.st_mode);
}
int unquote_first_word(const char **p, char **ret) {
diff --git a/src/shared/util.h b/src/shared/util.h
index 21a90a40e5..887cdc4a44 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -991,6 +991,7 @@ bool is_localhost(const char *hostname);
int take_password_lock(const char *root);
int is_symlink(const char *path);
+int is_dir(const char *path, bool follow);
int unquote_first_word(const char **p, char **ret);
int unquote_many_words(const char **p, ...) _sentinel_;