stat: reduce storage for human-readable filesystem names
No binary (build failed)
—
(log yok)
| @@ -169,6 +169,42 @@ static const char *human_time(time_t t) | |
| } | |
| #if ENABLE_FEATURE_STAT_FILESYSTEM | |
| + | #define FS_TYPE_LIST \ |
| + | 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") |
| /* Return the type of the specified file system. | |
| * Some systems have statfvs.f_basetype[FSTYPSZ]. (AIX, HP-UX, and Solaris) | |
| * Others have statfs.f_fstypename[MFSNAMELEN]. (NetBSD 1.5.2) | |
| @@ -176,54 +212,22 @@ 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, |
| + | static const uint32_t fstype[] = { |
| + | FS_TYPE_LIST |
| }; | |
| - | |
| + | # undef FS_TYPE |
| + | # define FS_TYPE(type, name) name"\0" |
| + | static const char humanname[] ALIGN1 = |
| + | FS_TYPE_LIST |
| + | "UNKNOWN"; |
| + | # undef FS_TYPE |
| int i; | |
| - | for (i = 0; humantypes[i].type; ++i) |
| - | if (humantypes[i].type == f_type) |
| + | for (i = 0; i < ARRAY_SIZE(fstype); ++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 */ | |