From: Lennart Poettering Date: Mon, 15 Nov 2021 10:23:26 +0000 (+0100) Subject: analyze: show fs magic info in 'systemd-analyze filesystem' X-Git-Tag: v250-rc1~247^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5538ecbac8eff8941d8099d3df3c2aaf9a99e92c;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index d4c73ab86a2..4153afb1c6d 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; } }