summaryrefslogtreecommitdiff
path: root/src/basic/dirent-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-10-07 22:23:35 +0200
committerLennart Poettering <lennart@poettering.net>2021-10-07 23:13:03 +0200
commitba24ef86e7e3a8b9b3b03108c097142e503e1fd6 (patch)
treefc1b232d7b9df498947cede9f5c9742b232715c3 /src/basic/dirent-util.c
parentd888ef68d11de94c975d3418d600a11e516efdc6 (diff)
downloadsystemd-ba24ef86e7e3a8b9b3b03108c097142e503e1fd6.tar.gz
dirent-util: get rid of stat_mode_to_dirent_type()
Apparently glibc already has a helper for this. (Not in the man pages for Linux, but FreeBSD does document these cryptic helpers, and its exported by glibc. That should be good enough for us.)
Diffstat (limited to 'src/basic/dirent-util.c')
-rw-r--r--src/basic/dirent-util.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/src/basic/dirent-util.c b/src/basic/dirent-util.c
index a70871b33d..366cc077f3 100644
--- a/src/basic/dirent-util.c
+++ b/src/basic/dirent-util.c
@@ -7,18 +7,6 @@
#include "path-util.h"
#include "string-util.h"
-int stat_mode_to_dirent_type(mode_t mode) {
- return
- S_ISREG(mode) ? DT_REG :
- S_ISDIR(mode) ? DT_DIR :
- S_ISLNK(mode) ? DT_LNK :
- S_ISFIFO(mode) ? DT_FIFO :
- S_ISSOCK(mode) ? DT_SOCK :
- S_ISCHR(mode) ? DT_CHR :
- S_ISBLK(mode) ? DT_BLK :
- DT_UNKNOWN;
-}
-
static int dirent_ensure_type(DIR *d, struct dirent *de) {
struct stat st;
@@ -36,7 +24,7 @@ static int dirent_ensure_type(DIR *d, struct dirent *de) {
if (fstatat(dirfd(d), de->d_name, &st, AT_SYMLINK_NOFOLLOW) < 0)
return -errno;
- de->d_type = stat_mode_to_dirent_type(st.st_mode);
+ de->d_type = IFTODT(st.st_mode);
return 0;
}