diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/util.c | 9 | ||||
-rw-r--r-- | src/shared/util.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index 72711e133a..dda88bd2ee 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -5435,6 +5435,15 @@ int is_dir(const char* path, bool follow) { return !!S_ISDIR(st.st_mode); } +int is_device_node(const char *path) { + struct stat info; + + if (lstat(path, &info) < 0) + return -errno; + + return !!(S_ISBLK(info.st_mode) || S_ISCHR(info.st_mode)); +} + int unquote_first_word(const char **p, char **ret, UnquoteFlags flags) { _cleanup_free_ char *s = NULL; size_t allocated = 0, sz = 0; diff --git a/src/shared/util.h b/src/shared/util.h index 0c81e3dc45..22f505c0cb 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -852,6 +852,7 @@ int take_password_lock(const char *root); int is_symlink(const char *path); int is_dir(const char *path, bool follow); +int is_device_node(const char *path); typedef enum UnquoteFlags { UNQUOTE_RELAX = 1, |