summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-10-23 21:36:38 +0200
committerLennart Poettering <lennart@poettering.net>2014-10-23 21:36:56 +0200
commitbe57e297acd0ae41044c99a7c41f95a8339a314c (patch)
tree9bc4a37bdc0746c3dc9e6979495bcaebe005dc53 /src/shared
parentc34255bdb217c2a1d3ac6348252437ab8be9ca46 (diff)
label: move is_dir() to util.c
Diffstat (limited to 'src/shared')
-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_;