Skip to content

Commit 7c604e8

Browse files
committed
homed: replace home-grown fs magic translation with fs_type_to_string()
1 parent 66d3932 commit 7c604e8

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

src/home/homed-home.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "errno-util.h"
1818
#include "fd-util.h"
1919
#include "fileio.h"
20+
#include "filesystems.h"
2021
#include "fs-util.h"
2122
#include "home-util.h"
2223
#include "homed-home-bus.h"
@@ -2466,19 +2467,6 @@ int home_get_disk_status(
24662467
ret_access_mode);
24672468
}
24682469

2469-
static const char *fstype_magic_to_name(statfs_f_type_t magic) {
2470-
/* For now, let's only translate the magic values of the file systems we actually are able to manage */
2471-
2472-
if (F_TYPE_EQUAL(magic, EXT4_SUPER_MAGIC))
2473-
return "ext4";
2474-
if (F_TYPE_EQUAL(magic, XFS_SUPER_MAGIC))
2475-
return "xfs";
2476-
if (F_TYPE_EQUAL(magic, BTRFS_SUPER_MAGIC))
2477-
return "btrfs";
2478-
2479-
return NULL;
2480-
}
2481-
24822470
int home_augment_status(
24832471
Home *h,
24842472
UserRecordLoadFlags flags,
@@ -2518,7 +2506,7 @@ int home_augment_status(
25182506
if (r < 0)
25192507
return r;
25202508

2521-
fstype = fstype_magic_to_name(magic);
2509+
fstype = fs_type_to_string(magic);
25222510

25232511
if (disk_floor == UINT64_MAX || (disk_usage != UINT64_MAX && disk_floor < disk_usage))
25242512
disk_floor = disk_usage;

src/home/homework.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "copy.h"
99
#include "fd-util.h"
1010
#include "fileio.h"
11+
#include "filesystems.h"
1112
#include "fs-util.h"
1213
#include "home-util.h"
1314
#include "homework-cifs.h"
@@ -704,14 +705,7 @@ static const char *file_system_type_fd(int fd) {
704705
return NULL;
705706
}
706707

707-
if (is_fs_type(&sfs, XFS_SB_MAGIC))
708-
return "xfs";
709-
if (is_fs_type(&sfs, EXT4_SUPER_MAGIC))
710-
return "ext4";
711-
if (is_fs_type(&sfs, BTRFS_SUPER_MAGIC))
712-
return "btrfs";
713-
714-
return NULL;
708+
return fs_type_to_string(sfs.f_type);
715709
}
716710

717711
int home_extend_embedded_identity(UserRecord *h, UserRecord *used, HomeSetup *setup) {

0 commit comments

Comments
 (0)