chiark / gitweb /
fstab-generator: Do not check deviceless filesystems
[elogind.git] / src / shared / util.c
index 5cbbe8fb7d2886ffbbe36fab7cde07aba50fbe2c..2d50f73dc42ff23af2b9a71e7c246cc6d8d6b9c1 100644 (file)
@@ -1713,6 +1713,35 @@ bool fstype_is_network(const char *fstype) {
         return nulstr_contains(table, fstype);
 }
 
+bool fstype_is_deviceless(const char *fstype) {
+        static const char table[] =
+                "autofs\0"
+                "bdev\0"
+                "cgroup\0"
+                "configfs\0"
+                "cpuset\0"
+                "debugfs\0"
+                "devpts\0"
+                "devtmpfs\0"
+                "efivarfs\0"
+                "hugetlbfs\0"
+                "mqueue\0"
+                "overlayfs\0"
+                "pipefs\0"
+                "proc\0"
+                "pstore\0"
+                "ramfs\0"
+                "rootfs\0"
+                "rpc_pipefs\0"
+                "securityfs\0"
+                "sockfs\0"
+                "sysfs\0"
+                "tmpfs\0";
+
+        return !isempty(fstype) && (
+                nulstr_contains(table, fstype) || fstype_is_network(fstype));
+}
+
 int chvt(int vt) {
         _cleanup_close_ int fd;
 
@@ -7843,6 +7872,28 @@ int chattr_path(const char *p, bool b, unsigned mask) {
         return chattr_fd(fd, b, mask);
 }
 
+int change_attr_fd(int fd, unsigned value, unsigned mask) {
+        unsigned old_attr, new_attr;
+
+        assert(fd >= 0);
+
+        if (mask == 0)
+                return 0;
+
+        if (ioctl(fd, FS_IOC_GETFLAGS, &old_attr) < 0)
+                return -errno;
+
+        new_attr = (old_attr & ~mask) |(value & mask);
+
+        if (new_attr == old_attr)
+                return 0;
+
+        if (ioctl(fd, FS_IOC_SETFLAGS, &new_attr) < 0)
+                return -errno;
+
+        return 0;
+}
+
 int read_attr_fd(int fd, unsigned *ret) {
         assert(fd >= 0);