summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2018-07-20 09:05:38 +0200
committerFranck Bui <fbui@suse.com>2018-07-30 15:54:03 +0200
commita12e4ade1b7634f7286f53d9ce2b3a12ab17826e (patch)
tree707ba7bf179d0ce3b75e31bd4807d1998f5dd47f /src
parent62f9666ae03d3a2f0205ffa54eb4267faca43b74 (diff)
downloadsystemd-a12e4ade1b7634f7286f53d9ce2b3a12ab17826e.tar.gz
systemd-a12e4ade1b7634f7286f53d9ce2b3a12ab17826e.tar.bz2
systemd-a12e4ade1b7634f7286f53d9ce2b3a12ab17826e.zip
basic/stat-util: introduce is_dir_fd()
Diffstat (limited to 'src')
-rw-r--r--src/basic/stat-util.c11
-rw-r--r--src/basic/stat-util.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/basic/stat-util.c b/src/basic/stat-util.c
index 07154e25bb..762777e94f 100644
--- a/src/basic/stat-util.c
+++ b/src/basic/stat-util.c
@@ -45,6 +45,17 @@ int is_dir(const char* path, bool follow) {
return !!S_ISDIR(st.st_mode);
}
+int is_dir_fd(int fd) {
+ struct stat st;
+ int r;
+
+ r = fstat(fd, &st);
+ if (r < 0)
+ return -errno;
+
+ return !!S_ISDIR(st.st_mode);
+}
+
int is_device_node(const char *path) {
struct stat info;
diff --git a/src/basic/stat-util.h b/src/basic/stat-util.h
index f8014ed30b..1a725f1da0 100644
--- a/src/basic/stat-util.h
+++ b/src/basic/stat-util.h
@@ -12,6 +12,7 @@
int is_symlink(const char *path);
int is_dir(const char *path, bool follow);
+int is_dir_fd(int fd);
int is_device_node(const char *path);
int dir_is_empty(const char *path);