]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect: split list of discard-supporting fs out into mount-util.c
authorLennart Poettering <lennart@poettering.net>
Fri, 29 Sep 2017 12:23:17 +0000 (14:23 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 29 Sep 2017 12:36:29 +0000 (14:36 +0200)
Let's manage the list of file systems that do a specific thing at one
place, following similar naming.

No functional changes.

src/basic/mount-util.c
src/basic/mount-util.h
src/shared/dissect-image.c

index 843d266a2f5604bd48defd03e087f4f1c0197121..9069280721330ab1f2af07c9f99b9bf5838a0a51 100644 (file)
@@ -591,6 +591,18 @@ bool fstype_is_ro(const char *fstype) {
         return nulstr_contains(table, fstype);
 }
 
+bool fstype_can_discard(const char *fstype) {
+
+        static const char table[] =
+                "btrfs\0"
+                "ext4\0"
+                "vfat\0"
+                "xfs\0"
+                ;
+
+        return nulstr_contains(table, fstype);
+}
+
 int repeat_unmount(const char *path, int flags) {
         bool done = false;
 
index 3ec0e7d1f83fa708903657b5d57a90dcdae97a59..1e066d88867e004dc57a2c31df9ba72ee5eda9e8 100644 (file)
@@ -46,6 +46,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, endmntent);
 bool fstype_is_network(const char *fstype);
 bool fstype_is_api_vfs(const char *fstype);
 bool fstype_is_ro(const char *fsype);
+bool fstype_can_discard(const char *fstype);
 
 union file_handle_union {
         struct file_handle handle;
index b02b2897d3e71faf455a3068cad7927bfafcb7b8..243a46f2e3c7d4bbbe3cbcfc116db4c43d5b4485 100644 (file)
@@ -684,7 +684,7 @@ static int mount_partition(
                 p = where;
 
         /* If requested, turn on discard support. */
-        if (STR_IN_SET(fstype, "btrfs", "ext4", "vfat", "xfs") &&
+        if (fstype_can_discard(fstype) &&
             ((flags & DISSECT_IMAGE_DISCARD) ||
              ((flags & DISSECT_IMAGE_DISCARD_ON_LOOP) && is_loop_device(m->node))))
                 options = "discard";