aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-03-18 11:14:52 +0000
committerDenys Vlasenko <vda.linux@googlemail.com>2019-04-12 12:00:38 +0200
commite2026381bed88e79b6f7657eef8319e60ff83041 (patch)
treebda75fff4364c0cdadf89c7168cf239f6c5ead33
parentc6c19c31c127d7d45d5e3f664eb85e7f621eb817 (diff)
downloadbusybox-e2026381bed88e79b6f7657eef8319e60ff83041.tar.gz
stat: reduce storage for human-readable filesystem names
function old new delta static.humanname - 236 +236 static.fstype - 140 +140 print_statfs 339 341 +2 static.humantypes 288 - -288 ------------------------------------------------------------------------------ (add/remove: 2/1 grow/shrink: 1/0 up/down: 378/-288) Total: 90 bytes text data bss dec hex filename 982183 485 7296 989964 f1b0c busybox_old 982152 485 7296 989933 f1aed busybox_unstripped Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/stat.c92
1 files changed, 48 insertions, 44 deletions
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 122029bda..b6ab5205b 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -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 */