chiark / gitweb /
nspawn: allow access to device nodes listed in --bind= and --bind-ro= switches
[elogind.git] / src / shared / util.c
index 9b67dd8296fde6fab7ae3b862bf7ce63fc21e015..d7a5b20946d886588e9a8541688f6bfd8cde1d6f 100644 (file)
@@ -5436,6 +5436,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;