chiark / gitweb /
nspawn: allow access to device nodes listed in --bind= and --bind-ro= switches
authorStefan Junker <code@stefanjunker.de>
Thu, 14 May 2015 20:51:05 +0000 (22:51 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 08:56:08 +0000 (09:56 +0100)
https://bugs.freedesktop.org/show_bug.cgi?id=90385

src/shared/util.c
src/shared/util.h

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;
index 4b4745a074cd43d369e7f2ffc03315eef4af7e50..4a5de6f66c84563e29063f6a00fa1efc93d09ced 100644 (file)
@@ -853,6 +853,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,