From 7c604e89aad47c8eacd7fa523b8a13703d7ce251 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Nov 2021 11:25:34 +0100 Subject: [PATCH] homed: replace home-grown fs magic translation with fs_type_to_string() --- src/home/homed-home.c | 16 ++-------------- src/home/homework.c | 10 ++-------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/home/homed-home.c b/src/home/homed-home.c index a31e27d0511..2453fa31ef0 100644 --- a/src/home/homed-home.c +++ b/src/home/homed-home.c @@ -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; diff --git a/src/home/homework.c b/src/home/homework.c index 94cfd417806..5bb759316fb 100644 --- a/src/home/homework.c +++ b/src/home/homework.c @@ -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) { -- 2.47.3