From 73e7576e3bbeb7f72623548712f0a4df95a686df Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 12 Nov 2021 23:08:25 +0100 Subject: [PATCH 01/18] filesystems: add two new filesystem groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. @anonymous → for file systems that aren't real file systems but simply the backing for sockets, pipes and other "anonymous" fds. 2. @security → for the various MAC security file systems. --- src/basic/filesystems.c | 16 ++++++++++++++++ src/basic/filesystems.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/src/basic/filesystems.c b/src/basic/filesystems.c index 9fccea2018..9f3acfb6b9 100644 --- a/src/basic/filesystems.c +++ b/src/basic/filesystems.c @@ -51,6 +51,14 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = { "proc\0" "sysfs\0" }, + [FILESYSTEM_SET_ANONYMOUS] = { + .name = "@anonymous", + .help = "Anonymous inodes", + .value = + "anon_inodefs\0" + "pipefs\0" + "sockfs\0" + }, [FILESYSTEM_SET_AUXILIARY_API] = { .name = "@auxiliary-api", .help = "Auxiliary filesystem API", @@ -104,6 +112,14 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = { "pstore\0" "tracefs\0" }, + [FILESYSTEM_SET_SECURITY] = { + .name = "@security", + .help = "Security/MAC API VFS", + .value = + "apparmorfs\0" + "selinuxfs\0" + "smackfs\0" + }, [FILESYSTEM_SET_TEMPORARY] = { .name = "@temporary", .help = "Temporary filesystems", diff --git a/src/basic/filesystems.h b/src/basic/filesystems.h index a0964476af..c7f4ea4f1b 100644 --- a/src/basic/filesystems.h +++ b/src/basic/filesystems.h @@ -10,11 +10,13 @@ typedef enum FilesystemGroups { /* Please leave BASIC_API first and KNOWN last, but sort the rest alphabetically */ FILESYSTEM_SET_BASIC_API, + FILESYSTEM_SET_ANONYMOUS, FILESYSTEM_SET_AUXILIARY_API, FILESYSTEM_SET_COMMON_BLOCK, FILESYSTEM_SET_HISTORICAL_BLOCK, FILESYSTEM_SET_NETWORK, FILESYSTEM_SET_PRIVILEGED_API, + FILESYSTEM_SET_SECURITY, FILESYSTEM_SET_TEMPORARY, FILESYSTEM_SET_KNOWN, _FILESYSTEM_SET_MAX, From 2867cb392a4578ff8cd2f81feacd9783228f1496 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 12 Nov 2021 23:09:45 +0100 Subject: [PATCH 02/18] filesystems: slightly update common block device groups --- src/basic/filesystems.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/basic/filesystems.c b/src/basic/filesystems.c index 9f3acfb6b9..2d7fd5d886 100644 --- a/src/basic/filesystems.c +++ b/src/basic/filesystems.c @@ -74,7 +74,12 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = { .help = "Common block device filesystems", .value = "btrfs\0" + "erofs\0" + "exfat\0" "ext4\0" + "iso9660\0" + "squashfs\0" + "udf\0" "vfat\0" "xfs\0" }, From 333a2ad649c3417f070986835ecbf5777ca85fa5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 12 Nov 2021 23:27:59 +0100 Subject: [PATCH 03/18] filesystems: add ceph to network file systems group --- src/basic/filesystems.c | 1 + src/basic/mountpoint-util.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/filesystems.c b/src/basic/filesystems.c index 2d7fd5d886..f33d2c458e 100644 --- a/src/basic/filesystems.c +++ b/src/basic/filesystems.c @@ -97,6 +97,7 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = { .value = "afs\0" "cifs\0" + "ceph\0" "gfs\0" "gfs2\0" "ncpfs\0" diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c index 803f36da8d..9dbe34ba4d 100644 --- a/src/basic/mountpoint-util.c +++ b/src/basic/mountpoint-util.c @@ -373,7 +373,6 @@ bool fstype_is_network(const char *fstype) { /* Filesystems not present in the internal database */ return STR_IN_SET(fstype, - "ceph", "davfs", "glusterfs", "lustre", From 9c8214d559dd175a311f5b644e42c44cc3fe1d64 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 12 Nov 2021 23:31:03 +0100 Subject: [PATCH 04/18] filesystems: add binfmt_misc to auxiliary API VFS group --- src/basic/filesystems.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/basic/filesystems.c b/src/basic/filesystems.c index f33d2c458e..3474fbe775 100644 --- a/src/basic/filesystems.c +++ b/src/basic/filesystems.c @@ -63,6 +63,7 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = { .name = "@auxiliary-api", .help = "Auxiliary filesystem API", .value = + "binfmt_misc\0" "configfs\0" "efivarfs\0" "fusectl\0" From 5feeb2584fb05174842004b8742177cc487cb187 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 12 Nov 2021 23:30:59 +0100 Subject: [PATCH 05/18] filesystems: add group for "application" file system This group shall cover file systems whose job is to make stuff that isn't actually storing anything in itself, and isn't just an API file system, but allows exposing stuff with special semantics in the VFS. --- src/basic/filesystems.c | 8 ++++++++ src/basic/filesystems.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/basic/filesystems.c b/src/basic/filesystems.c index 3474fbe775..d2c70f54cb 100644 --- a/src/basic/filesystems.c +++ b/src/basic/filesystems.c @@ -59,6 +59,14 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = { "pipefs\0" "sockfs\0" }, + [FILESYSTEM_SET_APPLICATION] = { + .name = "@application", + .help = "Application virtual filesystems", + .value = + "autofs\0" + "fuse\0" + "overlay\0" + }, [FILESYSTEM_SET_AUXILIARY_API] = { .name = "@auxiliary-api", .help = "Auxiliary filesystem API", diff --git a/src/basic/filesystems.h b/src/basic/filesystems.h index c7f4ea4f1b..48f6c01187 100644 --- a/src/basic/filesystems.h +++ b/src/basic/filesystems.h @@ -11,6 +11,7 @@ typedef enum FilesystemGroups { /* Please leave BASIC_API first and KNOWN last, but sort the rest alphabetically */ FILESYSTEM_SET_BASIC_API, FILESYSTEM_SET_ANONYMOUS, + FILESYSTEM_SET_APPLICATION, FILESYSTEM_SET_AUXILIARY_API, FILESYSTEM_SET_COMMON_BLOCK, FILESYSTEM_SET_HISTORICAL_BLOCK, From 3818d6a3a5a9bb5e23db12121066de848c95ad79 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 12 Nov 2021 23:30:38 +0100 Subject: [PATCH 06/18] mountpoint-util: sort list of read-only fs again --- src/basic/mountpoint-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c index 9dbe34ba4d..c813a4f56f 100644 --- a/src/basic/mountpoint-util.c +++ b/src/basic/mountpoint-util.c @@ -411,8 +411,8 @@ bool fstype_is_ro(const char *fstype) { /* All Linux file systems that are necessarily read-only */ return STR_IN_SET(fstype, "DM_verity_hash", - "iso9660", "erofs", + "iso9660", "squashfs"); } From 6d439321e8e1f45c8263a29b0f10dddae537169b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Nov 2021 11:22:43 +0100 Subject: [PATCH 07/18] filesystems: add internal APIs to convert fs magic to name We previously had tooling for the opposite direction, let's complete the work. --- src/basic/filesystems.c | 12 +++- src/basic/filesystems.h | 1 + src/basic/generate-filesystem-list.py | 3 + src/basic/generate-filesystem-switch-case.py | 63 ++++++++++++++++++++ src/basic/meson.build | 16 ++++- 5 files changed, 91 insertions(+), 4 deletions(-) create mode 100755 src/basic/generate-filesystem-switch-case.py diff --git a/src/basic/filesystems.c b/src/basic/filesystems.c index d2c70f54cb..628a7dfa91 100644 --- a/src/basic/filesystems.c +++ b/src/basic/filesystems.c @@ -1,6 +1,17 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "filesystems-gperf.h" +#include "stat-util.h" + +const char *fs_type_to_string(statfs_f_type_t magic) { + + switch (magic) { +#include "filesystem-switch-case.h" + } + + return NULL; +} + int fs_type_from_string(const char *name, const statfs_f_type_t **ret) { const struct FilesystemMagic *fs_magic; @@ -13,7 +24,6 @@ int fs_type_from_string(const char *name, const statfs_f_type_t **ret) { return -EINVAL; *ret = fs_magic->magic; - return 0; } diff --git a/src/basic/filesystems.h b/src/basic/filesystems.h index 48f6c01187..6d07a97ba7 100644 --- a/src/basic/filesystems.h +++ b/src/basic/filesystems.h @@ -34,6 +34,7 @@ extern const FilesystemSet filesystem_sets[]; const FilesystemSet *filesystem_set_find(const char *name); +const char *fs_type_to_string(statfs_f_type_t magic); int fs_type_from_string(const char *name, const statfs_f_type_t **ret); int fs_in_group(const struct statfs *s, enum FilesystemGroups fs_group); diff --git a/src/basic/generate-filesystem-list.py b/src/basic/generate-filesystem-list.py index 8271b3fbeb..52b74f1763 100755 --- a/src/basic/generate-filesystem-list.py +++ b/src/basic/generate-filesystem-list.py @@ -6,6 +6,9 @@ import sys keywords_section = False for line in open(sys.argv[1]): + if line[0] == '#': + continue + if keywords_section: print('"{}\\0"'.format(line.split(',')[0].strip())) elif line.startswith('%%'): diff --git a/src/basic/generate-filesystem-switch-case.py b/src/basic/generate-filesystem-switch-case.py new file mode 100755 index 0000000000..73b1d65657 --- /dev/null +++ b/src/basic/generate-filesystem-switch-case.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1-or-later + +import sys + + +def filter_fsname(name): + # File system magics are sometimes not unique, because file systems got new + # revisions or got renamed. Let's prefer newer over older here, and thus + # ignore the old names. Specifically: + # + # → cgroupfs took over the magic of cpuset + # → devtmpfs is not a file system of its own, but just a "named superblock" of tmpfs + # → ext4 is the newest revision of ext2 + ext3 + # → fuseblk is closely related to fuse, so close that they share a single magic, but the latter is more common + # → gfs2 is the newest revision of gfs + # → vfat is the newest revision of msdos + # → ncpfs (not ncp) was the last name of the netware `file_system_type` name before it was removed in 2018 + # → nfs4 is the newest revision of nfs + # → orangefs is the new name of pvfs2 + # → smb3 is an alias for cifs + + return name in ( + "cpuset", + "devtmpfs", + "ext2", + "ext3", + "fuseblk", + "gfs", + "msdos", + "ncp", + "nfs", + "pvfs2", + "smb3", + ) + + +gperf_file = sys.argv[1] +keywords_section = False + +for line in open(gperf_file): + if line[0] == "#": + continue + + if keywords_section: + name, ids = line.split(",", 1) + + name = name.strip() + if filter_fsname(name): + continue + + ids = ids.strip() + assert ids[0] == "{" + assert ids[-1] == "}" + ids = ids[1:-1] + + for id in ids.split(","): + print(f"case (statfs_f_type_t) {id.strip()}:") + + print(f' return "{name}";') + + if line.startswith("%%"): + keywords_section = True diff --git a/src/basic/meson.build b/src/basic/meson.build index 042ab86d5e..f0d5a1d2ea 100644 --- a/src/basic/meson.build +++ b/src/basic/meson.build @@ -383,8 +383,8 @@ filesystem_includes = ['linux/magic.h', check_filesystems = find_program('check-filesystems.sh') r = run_command([check_filesystems, cpp, 'filesystems-gperf.gperf'] + filesystem_includes) if r.returncode() != 0 - error('found unknown filesystem(s) defined in kernel headers:\n\n' + r.stdout()) - r.stdout() + error('found unknown filesystem(s) defined in kernel headers:\n\n' + r.stdout()) + r.stdout() endif filesystems_gperf_h = custom_target( @@ -403,7 +403,17 @@ filesystem_list_h = custom_target( '@INPUT@'], capture : true) -basic_sources += [filesystem_list_h, filesystems_gperf_h] +generate_filesystem_switch_case_h = find_program('generate-filesystem-switch-case.py') +fname = 'filesystem-switch-case.h' +filesystem_switch_case_h = custom_target( + fname, + input : 'filesystems-gperf.gperf', + output : 'filesystem-switch-case.h', + command : [generate_filesystem_switch_case_h, + '@INPUT@'], + capture : true) + +basic_sources += [filesystem_list_h, filesystem_switch_case_h, filesystems_gperf_h] libbasic = static_library( 'basic', From 5538ecbac8eff8941d8099d3df3c2aaf9a99e92c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Nov 2021 11:23:26 +0100 Subject: [PATCH 08/18] analyze: show fs magic info in 'systemd-analyze filesystem' Let's show this information, since its quite useful. Moreover it allows us to highlight file system aliases. --- src/analyze/analyze.c | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index d4c73ab86a..4153afb1c6 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -1850,8 +1850,9 @@ static void filesystem_set_remove(Set *s, const FilesystemSet *set) { } } -static void dump_filesystem(const FilesystemSet *set) { +static void dump_filesystem_set(const FilesystemSet *set) { const char *filesystem; + int r; if (!set) return; @@ -1863,8 +1864,38 @@ static void dump_filesystem(const FilesystemSet *set) { ansi_normal(), set->help); - NULSTR_FOREACH(filesystem, set->value) - printf(" %s%s%s\n", filesystem[0] == '@' ? ansi_underline() : "", filesystem, ansi_normal()); + NULSTR_FOREACH(filesystem, set->value) { + const statfs_f_type_t *magic; + + if (filesystem[0] == '@') { + printf(" %s%s%s\n", ansi_underline(), filesystem, ansi_normal()); + continue; + } + + r = fs_type_from_string(filesystem, &magic); + assert_se(r >= 0); + + printf(" %s", filesystem); + + for (size_t i = 0; magic[i] != 0; i++) { + const char *primary; + if (i == 0) + printf(" %s(magic: ", ansi_grey()); + else + printf(", "); + + printf("0x%llx", (unsigned long long) magic[i]); + + primary = fs_type_to_string(magic[i]); + if (primary && !streq(primary, filesystem)) + printf("[%s]", primary); + + if (magic[i+1] == 0) + printf(")%s", ansi_normal()); + } + + printf("\n"); + } } static int dump_filesystems(int argc, char *argv[], void *userdata) { @@ -1892,7 +1923,7 @@ static int dump_filesystems(int argc, char *argv[], void *userdata) { if (!first) puts(""); - dump_filesystem(set); + dump_filesystem_set(set); filesystem_set_remove(kernel, set); if (i != FILESYSTEM_SET_KNOWN) filesystem_set_remove(known, set); @@ -1956,7 +1987,7 @@ static int dump_filesystems(int argc, char *argv[], void *userdata) { "Filesystem set \"%s\" not found.", *name); } - dump_filesystem(set); + dump_filesystem_set(set); first = false; } } From 66d39325d7f9a3ee3717e6afcd74ef34bc769008 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Nov 2021 11:24:14 +0100 Subject: [PATCH 09/18] filesystems: add three more file system types devtmpfs and cpuset are not actual filesystems of their own. cpuset used to be but is now an alias for cgroupsfs. devtmpfs is the same as tmpfs as its just a "named superblock", i.e. a specific instance of tmpfs, but not a file system of its own. --- src/basic/filesystems-gperf.gperf | 3 +++ src/basic/missing_magic.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/basic/filesystems-gperf.gperf b/src/basic/filesystems-gperf.gperf index f31c9de192..fe302b7ebf 100644 --- a/src/basic/filesystems-gperf.gperf +++ b/src/basic/filesystems-gperf.gperf @@ -34,6 +34,7 @@ binfmt_misc, {BINFMTFS_MAGIC} bpf, {BPF_FS_MAGIC} btrfs, {BTRFS_SUPER_MAGIC} btrfs_test_fs, {BTRFS_TEST_MAGIC} +cpuset, {CGROUP_SUPER_MAGIC} ceph, {CEPH_SUPER_MAGIC} cgroup2, {CGROUP2_SUPER_MAGIC} cgroup, {CGROUP_SUPER_MAGIC} @@ -45,6 +46,7 @@ dax, {DAXFS_MAGIC} debugfs, {DEBUGFS_MAGIC} devmem, {DEVMEM_MAGIC} devpts, {DEVPTS_SUPER_MAGIC} +devtmpfs, {TMPFS_MAGIC} dmabuf, {DMA_BUF_MAGIC} ecryptfs, {ECRYPTFS_SUPER_MAGIC} efivarfs, {EFIVARFS_MAGIC} @@ -88,6 +90,7 @@ qnx6, {QNX6_SUPER_MAGIC} ramfs, {RAMFS_MAGIC} resctrl, {RDTGROUP_SUPER_MAGIC} reiserfs, {REISERFS_SUPER_MAGIC} +rpc_pipefs, {RPC_PIPEFS_SUPER_MAGIC} secretmem, {SECRETMEM_MAGIC} securityfs, {SECURITYFS_MAGIC} selinuxfs, {SELINUX_MAGIC} diff --git a/src/basic/missing_magic.h b/src/basic/missing_magic.h index 1f50e565a2..7b586971ae 100644 --- a/src/basic/missing_magic.h +++ b/src/basic/missing_magic.h @@ -172,3 +172,8 @@ #ifndef EXFAT_SUPER_MAGIC #define EXFAT_SUPER_MAGIC 0x2011BAB0UL #endif + +/* Not exposed yet, internally actually called RPCAUTH_GSSMAGIC. Defined in net/sunrpc/rpc_pipe.c */ +#ifndef RPC_PIPEFS_SUPER_MAGIC +#define RPC_PIPEFS_SUPER_MAGIC 0x67596969 +#endif From 7c604e89aad47c8eacd7fa523b8a13703d7ce251 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Nov 2021 11:25:34 +0100 Subject: [PATCH 10/18] 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 a31e27d051..2453fa31ef 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 94cfd41780..5bb759316f 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) { From e0f89b065696c45933dba09c553521ef27da9e08 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Nov 2021 14:05:31 +0100 Subject: [PATCH 11/18] analyze: don't list filesystems among ungrouped that are aliases There are a bunch of filesystems that actually are just aliases for other filesystems. So far we listed them as "ungrouped", suggesting they should be added to some file system group. But that's not really something needed, since they are after all not file systems in their own right, but aliases only (and usually legacy at that). hence, let's hide them from display (but debug log about them) --- src/analyze/analyze.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index 4153afb1c6..3801cf0ead 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -1944,8 +1944,29 @@ static int dump_filesystems(int argc, char *argv[], void *userdata) { strv_sort(l); - STRV_FOREACH(filesystem, l) + STRV_FOREACH(filesystem, l) { + const statfs_f_type_t *magic; + bool is_primary = false; + + assert(fs_type_from_string(*filesystem, &magic) >= 0); + + for (size_t i = 0; magic[i] != 0; i++) { + const char *primary; + + primary = fs_type_to_string(magic[i]); + assert(primary); + + if (streq(primary, *filesystem)) + is_primary = true; + } + + if (!is_primary) { + log_debug("Skipping ungrouped file system '%s', because it's an alias for another one.", *filesystem); + continue; + } + printf("# %s\n", *filesystem); + } } if (k < 0) { From 2b69f6e591ae0b55a8d8c51d57e0e0856bed9f58 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Nov 2021 14:09:09 +0100 Subject: [PATCH 12/18] devtmpfs is a primary API fs --- src/basic/filesystems.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/basic/filesystems.c b/src/basic/filesystems.c index 628a7dfa91..f8c0deb77c 100644 --- a/src/basic/filesystems.c +++ b/src/basic/filesystems.c @@ -57,6 +57,7 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = { "cgroup\0" "cgroup2\0" "devpts\0" + "devtmpfs\0" "mqueue\0" "proc\0" "sysfs\0" From 7e8fd6108988234ec1cc627a831513bf0cf5a65b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Nov 2021 14:10:04 +0100 Subject: [PATCH 13/18] filesystems: list orangefs as network fs it's the new name or pvfs2, hence we might as well list it, given we list that already. --- src/basic/filesystems.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/basic/filesystems.c b/src/basic/filesystems.c index f8c0deb77c..6e28d64b47 100644 --- a/src/basic/filesystems.c +++ b/src/basic/filesystems.c @@ -116,15 +116,16 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = { .help = "Well-known network filesystems", .value = "afs\0" - "cifs\0" "ceph\0" + "cifs\0" "gfs\0" "gfs2\0" - "ncpfs\0" "ncp\0" + "ncpfs\0" "nfs\0" "nfs4\0" "ocfs2\0" + "orangefs\0" "pvfs2\0" "smb3\0" "smbfs\0" From d7c2f8817a59116e1e3cfef54ae4485df7b37527 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Nov 2021 14:10:50 +0100 Subject: [PATCH 14/18] filesystems: list rpc_pipefs as auxiliary kernel API VFS --- src/basic/filesystems.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/basic/filesystems.c b/src/basic/filesystems.c index 6e28d64b47..c3fe6497be 100644 --- a/src/basic/filesystems.c +++ b/src/basic/filesystems.c @@ -87,6 +87,7 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = { "efivarfs\0" "fusectl\0" "hugetlbfs\0" + "rpc_pipefs\0" "securityfs\0" }, [FILESYSTEM_SET_COMMON_BLOCK] = { From 0ed6103c19233a0234bc789b0d9ec4b938bb5a49 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Nov 2021 14:15:40 +0100 Subject: [PATCH 15/18] filesystems: fix magic of "smb3" fs smb3 is an alias for modern CIFS, not the old SMB fs (see kmod alias list, i.e. modinfo fs-smb3). (the old smbfs has long been removed from the kernel actually, it's dead and obsolete) --- src/basic/filesystems-gperf.gperf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/filesystems-gperf.gperf b/src/basic/filesystems-gperf.gperf index fe302b7ebf..3c9465e0ae 100644 --- a/src/basic/filesystems-gperf.gperf +++ b/src/basic/filesystems-gperf.gperf @@ -96,7 +96,7 @@ securityfs, {SECURITYFS_MAGIC} selinuxfs, {SELINUX_MAGIC} shiftfs, {SHIFTFS_MAGIC} smackfs, {SMACK_MAGIC} -smb3, {SMB_SUPER_MAGIC} +smb3, {CIFS_MAGIC_NUMBER} smbfs, {SMB_SUPER_MAGIC} sockfs, {SOCKFS_MAGIC} squashfs, {SQUASHFS_MAGIC} From ad4e99fe9a1722acfb3fc4b4c5d9f93f0651300e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Nov 2021 14:14:54 +0100 Subject: [PATCH 16/18] filesystems: add comments to gperf file anomalies Some file systems have non-unique names or non-unique magics. Let's add some comments explaining that. --- src/basic/filesystems-gperf.gperf | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/basic/filesystems-gperf.gperf b/src/basic/filesystems-gperf.gperf index 3c9465e0ae..0c0c609f80 100644 --- a/src/basic/filesystems-gperf.gperf +++ b/src/basic/filesystems-gperf.gperf @@ -34,9 +34,11 @@ binfmt_misc, {BINFMTFS_MAGIC} bpf, {BPF_FS_MAGIC} btrfs, {BTRFS_SUPER_MAGIC} btrfs_test_fs, {BTRFS_TEST_MAGIC} +# cpuset's magic got reassigned to cgroupfs cpuset, {CGROUP_SUPER_MAGIC} ceph, {CEPH_SUPER_MAGIC} cgroup2, {CGROUP2_SUPER_MAGIC} +# note that the cgroupfs magic got reassigned from cpuset cgroup, {CGROUP_SUPER_MAGIC} cifs, {CIFS_MAGIC_NUMBER} coda, {CODA_SUPER_MAGIC} @@ -46,20 +48,24 @@ dax, {DAXFS_MAGIC} debugfs, {DEBUGFS_MAGIC} devmem, {DEVMEM_MAGIC} devpts, {DEVPTS_SUPER_MAGIC} +# devtmpfs is just a special instance of tmpfs, hence it reports its magic devtmpfs, {TMPFS_MAGIC} dmabuf, {DMA_BUF_MAGIC} ecryptfs, {ECRYPTFS_SUPER_MAGIC} efivarfs, {EFIVARFS_MAGIC} efs, {EFS_SUPER_MAGIC} erofs, {EROFS_SUPER_MAGIC_V1} +# ext2 + ext3 + ext4 use the same magic ext2, {EXT2_SUPER_MAGIC} ext3, {EXT3_SUPER_MAGIC} ext4, {EXT4_SUPER_MAGIC} exfat, {EXFAT_SUPER_MAGIC} f2fs, {F2FS_SUPER_MAGIC} +# fuseblk is so closely related to fuse that it shares the same magic fuseblk, {FUSE_SUPER_MAGIC} fuse, {FUSE_SUPER_MAGIC} fusectl, {FUSE_CTL_SUPER_MAGIC} +# gfs is an old version of gfs2 and reuses the magic gfs, {GFS2_MAGIC} gfs2, {GFS2_MAGIC} hostfs, {HOSTFS_SUPER_MAGIC} @@ -69,9 +75,12 @@ iso9660, {ISOFS_SUPER_MAGIC} jffs2, {JFFS2_SUPER_MAGIC} minix, {MINIX_SUPER_MAGIC, MINIX_SUPER_MAGIC2, MINIX2_SUPER_MAGIC, MINIX2_SUPER_MAGIC2, MINIX3_SUPER_MAGIC} mqueue, {MQUEUE_MAGIC} +# msdos is an older legacy version of vfat, shares the magic msdos, {MSDOS_SUPER_MAGIC} +# ncp/ncpfs have been removed from the kernel, but ncpfs was the offical name ncp, {NCP_SUPER_MAGIC} ncpfs, {NCP_SUPER_MAGIC} +# nfs is the old version of nfs4, and they share the same magic nfs, {NFS_SUPER_MAGIC} nfs4, {NFS_SUPER_MAGIC} nilfs2, {NILFS_SUPER_MAGIC} @@ -84,6 +93,7 @@ pipefs, {PIPEFS_MAGIC} ppc-cmm, {PPC_CMM_MAGIC} proc, {PROC_SUPER_MAGIC} pstore, {PSTOREFS_MAGIC} +# pvfs2 is the old version of orangefs pvfs2, {ORANGEFS_DEVREQ_MAGIC} qnx4, {QNX4_SUPER_MAGIC} qnx6, {QNX6_SUPER_MAGIC} @@ -96,16 +106,20 @@ securityfs, {SECURITYFS_MAGIC} selinuxfs, {SELINUX_MAGIC} shiftfs, {SHIFTFS_MAGIC} smackfs, {SMACK_MAGIC} +# smb3 is an alias for cifs smb3, {CIFS_MAGIC_NUMBER} +# smbfs was removed from the kernel in 2010, the magic remains smbfs, {SMB_SUPER_MAGIC} sockfs, {SOCKFS_MAGIC} squashfs, {SQUASHFS_MAGIC} sysfs, {SYSFS_MAGIC} +# note that devtmpfs shares the same magic with tmpfs, given it is just a special named instance of it. tmpfs, {TMPFS_MAGIC} tracefs, {TRACEFS_MAGIC} udf, {UDF_SUPER_MAGIC} usbdevfs, {USBDEVICE_SUPER_MAGIC} vboxsf, {VBOXSF_SUPER_MAGIC} +# note that msdos shares the same magic (and is the older version) vfat, {MSDOS_SUPER_MAGIC} v9fs, {V9FS_MAGIC} xenfs, {XENFS_SUPER_MAGIC} From 05715f12a8be1123c9c8ee2096b9a1c0a38907b3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Nov 2021 22:53:25 +0100 Subject: [PATCH 17/18] filesystems: add ntfs/ntfs3 magic and add it current version to group As suggested: https://github.com/systemd/systemd/pull/21373#discussion_r749523677 --- src/basic/filesystems-gperf.gperf | 2 ++ src/basic/filesystems.c | 1 + src/basic/missing_magic.h | 10 ++++++++++ 3 files changed, 13 insertions(+) diff --git a/src/basic/filesystems-gperf.gperf b/src/basic/filesystems-gperf.gperf index 0c0c609f80..7dd660addf 100644 --- a/src/basic/filesystems-gperf.gperf +++ b/src/basic/filesystems-gperf.gperf @@ -85,6 +85,8 @@ nfs, {NFS_SUPER_MAGIC} nfs4, {NFS_SUPER_MAGIC} nilfs2, {NILFS_SUPER_MAGIC} nsfs, {NSFS_MAGIC} +ntfs, {NTFS_SB_MAGIC} +ntfs3, {NTFS3_SUPER_MAGIC} ocfs2, {OCFS2_SUPER_MAGIC} openpromfs, {OPENPROM_SUPER_MAGIC} orangefs, {ORANGEFS_DEVREQ_MAGIC} diff --git a/src/basic/filesystems.c b/src/basic/filesystems.c index c3fe6497be..b9cc622107 100644 --- a/src/basic/filesystems.c +++ b/src/basic/filesystems.c @@ -99,6 +99,7 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = { "exfat\0" "ext4\0" "iso9660\0" + "ntfs3\0" "squashfs\0" "udf\0" "vfat\0" diff --git a/src/basic/missing_magic.h b/src/basic/missing_magic.h index 7b586971ae..7d9320bb6d 100644 --- a/src/basic/missing_magic.h +++ b/src/basic/missing_magic.h @@ -177,3 +177,13 @@ #ifndef RPC_PIPEFS_SUPER_MAGIC #define RPC_PIPEFS_SUPER_MAGIC 0x67596969 #endif + +/* Not exposed yet, defined at fs/ntfs/ntfs.h */ +#ifndef NTFS_SB_MAGIC +#define NTFS_SB_MAGIC 0x5346544e +#endif + +/* Not exposed yet, encoded literally in fs/ntfs3/super.c. */ +#ifndef NTFS3_SUPER_MAGIC +#define NTFS3_SUPER_MAGIC 0x7366746e +#endif From ad004abe9d9f71fc74db26ad29ea8ab6a84599ee Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Nov 2021 22:54:15 +0100 Subject: [PATCH 18/18] filesystems: apparently f2fs is als reasonably common As suggested: https://github.com/systemd/systemd/pull/21373#discussion_r749523677 --- src/basic/filesystems.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/basic/filesystems.c b/src/basic/filesystems.c index b9cc622107..0f71f8e07c 100644 --- a/src/basic/filesystems.c +++ b/src/basic/filesystems.c @@ -98,6 +98,7 @@ const FilesystemSet filesystem_sets[_FILESYSTEM_SET_MAX] = { "erofs\0" "exfat\0" "ext4\0" + "f2fs\0" "iso9660\0" "ntfs3\0" "squashfs\0"