text data bss dec hex filename 930028 4199 1888 936115 e48b3 busybox_old 929753 4199 1888 935840 e47a0 busybox_unstripped
Signed-off-by: Ron Yorston <[email protected]> --- coreutils/fstype.h | 39 +++++++++++++++++++++++++++++++ coreutils/stat.c | 57 ++++++++++------------------------------------ 2 files changed, 51 insertions(+), 45 deletions(-) create mode 100644 coreutils/fstype.h diff --git a/coreutils/fstype.h b/coreutils/fstype.h new file mode 100644 index 000000000..f53c852bd --- /dev/null +++ b/coreutils/fstype.h @@ -0,0 +1,39 @@ +/* + * Mapping between filesystem type and human-readable name used + * by 'stat -f' (FEATURE_STAT_FILESYSTEM). + */ +FS_TYPE(0xADFF, "affs") +FS_TYPE(0x1Cd1, "devpts") +FS_TYPE(0x137D, "ext") +FS_TYPE(0xEF51, "ext2") +FS_TYPE(0xEF53, "ext2/ext3") +FS_TYPE(0x3153464a, "jfs") +FS_TYPE(0x58465342, "xfs") +FS_TYPE(0xF995E849, "hpfs") +FS_TYPE(0x9660, "isofs") +FS_TYPE(0x4000, "isofs") +FS_TYPE(0x4004, "isofs") +FS_TYPE(0x137F, "minix") +FS_TYPE(0x138F, "minix (30 char.)") +FS_TYPE(0x2468, "minix v2") +FS_TYPE(0x2478, "minix v2 (30 char.)") +FS_TYPE(0x4d44, "msdos") +FS_TYPE(0x4006, "fat") +FS_TYPE(0x564c, "novell") +FS_TYPE(0x6969, "nfs") +FS_TYPE(0x9fa0, "proc") +FS_TYPE(0x517B, "smb") +FS_TYPE(0x012FF7B4, "xenix") +FS_TYPE(0x012FF7B5, "sysv4") +FS_TYPE(0x012FF7B6, "sysv2") +FS_TYPE(0x012FF7B7, "coh") +FS_TYPE(0x00011954, "ufs") +FS_TYPE(0x012FD16D, "xia") +FS_TYPE(0x5346544e, "ntfs") +FS_TYPE(0x1021994, "tmpfs") +FS_TYPE(0x52654973, "reiserfs") +FS_TYPE(0x28cd3d45, "cramfs") +FS_TYPE(0x7275, "romfs") +FS_TYPE(0x858458f6, "ramfs") +FS_TYPE(0x73717368, "squashfs") +FS_TYPE(0x62656572, "sysfs") diff --git a/coreutils/stat.c b/coreutils/stat.c index 122029bda..02174d690 100644 --- a/coreutils/stat.c +++ b/coreutils/stat.c @@ -176,54 +176,21 @@ static const char *human_time(time_t t) */ static const char *human_fstype(uint32_t f_type) { - static const struct types { - uint32_t type; - const char *const fs; - } humantypes[] = { - { 0xADFF, "affs" }, - { 0x1Cd1, "devpts" }, - { 0x137D, "ext" }, - { 0xEF51, "ext2" }, - { 0xEF53, "ext2/ext3" }, - { 0x3153464a, "jfs" }, - { 0x58465342, "xfs" }, - { 0xF995E849, "hpfs" }, - { 0x9660, "isofs" }, - { 0x4000, "isofs" }, - { 0x4004, "isofs" }, - { 0x137F, "minix" }, - { 0x138F, "minix (30 char.)" }, - { 0x2468, "minix v2" }, - { 0x2478, "minix v2 (30 char.)" }, - { 0x4d44, "msdos" }, - { 0x4006, "fat" }, - { 0x564c, "novell" }, - { 0x6969, "nfs" }, - { 0x9fa0, "proc" }, - { 0x517B, "smb" }, - { 0x012FF7B4, "xenix" }, - { 0x012FF7B5, "sysv4" }, - { 0x012FF7B6, "sysv2" }, - { 0x012FF7B7, "coh" }, - { 0x00011954, "ufs" }, - { 0x012FD16D, "xia" }, - { 0x5346544e, "ntfs" }, - { 0x1021994, "tmpfs" }, - { 0x52654973, "reiserfs" }, - { 0x28cd3d45, "cramfs" }, - { 0x7275, "romfs" }, - { 0x858458f6, "ramfs" }, - { 0x73717368, "squashfs" }, - { 0x62656572, "sysfs" }, - { 0, "UNKNOWN" } - }; - +# define FS_TYPE(type, name) type, + uint32_t fstype[] = { +# include "fstype.h" + 0 }; +# undef FS_TYPE +# define FS_TYPE(type, name) name"\0" + static const char humanname[] ALIGN1 = +# include "fstype.h" + "UNKNOWN"; int i; - for (i = 0; humantypes[i].type; ++i) - if (humantypes[i].type == f_type) + for (i = 0; fstype[i]; ++i) + if (fstype[i] == f_type) break; - return humantypes[i].fs; + return nth_string(humanname, i); } /* "man statfs" says that statfsbuf->f_fsid is a mess */ -- 2.20.1 _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
