]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
homed: replace home-grown fs magic translation with fs_type_to_string()
authorLennart Poettering <lennart@poettering.net>
Mon, 15 Nov 2021 10:25:34 +0000 (11:25 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 15 Nov 2021 21:43:03 +0000 (22:43 +0100)
src/home/homed-home.c
src/home/homework.c

index a31e27d0511e68a5415adc232a27b9f64dc00063..2453fa31ef05a2eb8b492133583b11c02825a96a 100644 (file)
@@ -17,6 +17,7 @@
 #include "errno-util.h"
 #include "fd-util.h"
 #include "fileio.h"
+#include "filesystems.h"
 #include "fs-util.h"
 #include "home-util.h"
 #include "homed-home-bus.h"
@@ -2466,19 +2467,6 @@ int home_get_disk_status(
                         ret_access_mode);
 }
 
-static const char *fstype_magic_to_name(statfs_f_type_t magic) {
-        /* For now, let's only translate the magic values of the file systems we actually are able to manage */
-
-        if (F_TYPE_EQUAL(magic, EXT4_SUPER_MAGIC))
-                return "ext4";
-        if (F_TYPE_EQUAL(magic, XFS_SUPER_MAGIC))
-                return "xfs";
-        if (F_TYPE_EQUAL(magic, BTRFS_SUPER_MAGIC))
-                return "btrfs";
-
-        return NULL;
-}
-
 int home_augment_status(
                 Home *h,
                 UserRecordLoadFlags flags,
@@ -2518,7 +2506,7 @@ int home_augment_status(
         if (r < 0)
                 return r;
 
-        fstype = fstype_magic_to_name(magic);
+        fstype = fs_type_to_string(magic);
 
         if (disk_floor == UINT64_MAX || (disk_usage != UINT64_MAX && disk_floor < disk_usage))
                 disk_floor = disk_usage;
index 94cfd41780632adccd9c2461ae29949a745b250d..5bb759316fbc0deb395a129bb3074759ad2a9c08 100644 (file)
@@ -8,6 +8,7 @@
 #include "copy.h"
 #include "fd-util.h"
 #include "fileio.h"
+#include "filesystems.h"
 #include "fs-util.h"
 #include "home-util.h"
 #include "homework-cifs.h"
@@ -704,14 +705,7 @@ static const char *file_system_type_fd(int fd) {
                 return NULL;
         }
 
-        if (is_fs_type(&sfs, XFS_SB_MAGIC))
-                return "xfs";
-        if (is_fs_type(&sfs, EXT4_SUPER_MAGIC))
-                return "ext4";
-        if (is_fs_type(&sfs, BTRFS_SUPER_MAGIC))
-                return "btrfs";
-
-        return NULL;
+        return fs_type_to_string(sfs.f_type);
 }
 
 int home_extend_embedded_identity(UserRecord *h, UserRecord *used, HomeSetup *setup) {