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-w32-e2026381bed88e79b6f7657eef8319e60ff83041.tar.gz
busybox-w32-e2026381bed88e79b6f7657eef8319e60ff83041.tar.bz2
busybox-w32-e2026381bed88e79b6f7657eef8319e60ff83041.zip
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)
169} 169}
170 170
171#if ENABLE_FEATURE_STAT_FILESYSTEM 171#if ENABLE_FEATURE_STAT_FILESYSTEM
172#define FS_TYPE_LIST \
173FS_TYPE(0xADFF, "affs") \
174FS_TYPE(0x1CD1, "devpts") \
175FS_TYPE(0x137D, "ext") \
176FS_TYPE(0xEF51, "ext2") \
177FS_TYPE(0xEF53, "ext2/ext3") \
178FS_TYPE(0x3153464a, "jfs") \
179FS_TYPE(0x58465342, "xfs") \
180FS_TYPE(0xF995E849, "hpfs") \
181FS_TYPE(0x9660, "isofs") \
182FS_TYPE(0x4000, "isofs") \
183FS_TYPE(0x4004, "isofs") \
184FS_TYPE(0x137F, "minix") \
185FS_TYPE(0x138F, "minix (30 char.)") \
186FS_TYPE(0x2468, "minix v2") \
187FS_TYPE(0x2478, "minix v2 (30 char.)") \
188FS_TYPE(0x4d44, "msdos") \
189FS_TYPE(0x4006, "fat") \
190FS_TYPE(0x564c, "novell") \
191FS_TYPE(0x6969, "nfs") \
192FS_TYPE(0x9fa0, "proc") \
193FS_TYPE(0x517B, "smb") \
194FS_TYPE(0x012FF7B4, "xenix") \
195FS_TYPE(0x012FF7B5, "sysv4") \
196FS_TYPE(0x012FF7B6, "sysv2") \
197FS_TYPE(0x012FF7B7, "coh") \
198FS_TYPE(0x00011954, "ufs") \
199FS_TYPE(0x012FD16D, "xia") \
200FS_TYPE(0x5346544e, "ntfs") \
201FS_TYPE(0x1021994, "tmpfs") \
202FS_TYPE(0x52654973, "reiserfs") \
203FS_TYPE(0x28cd3d45, "cramfs") \
204FS_TYPE(0x7275, "romfs") \
205FS_TYPE(0x858458f6, "ramfs") \
206FS_TYPE(0x73717368, "squashfs") \
207FS_TYPE(0x62656572, "sysfs")
172/* Return the type of the specified file system. 208/* Return the type of the specified file system.
173 * Some systems have statfvs.f_basetype[FSTYPSZ]. (AIX, HP-UX, and Solaris) 209 * Some systems have statfvs.f_basetype[FSTYPSZ]. (AIX, HP-UX, and Solaris)
174 * Others have statfs.f_fstypename[MFSNAMELEN]. (NetBSD 1.5.2) 210 * Others have statfs.f_fstypename[MFSNAMELEN]. (NetBSD 1.5.2)
@@ -176,54 +212,22 @@ static const char *human_time(time_t t)
176 */ 212 */
177static const char *human_fstype(uint32_t f_type) 213static const char *human_fstype(uint32_t f_type)
178{ 214{
179 static const struct types { 215# define FS_TYPE(type, name) type,
180 uint32_t type; 216 static const uint32_t fstype[] = {
181 const char *const fs; 217 FS_TYPE_LIST
182 } humantypes[] = {
183 { 0xADFF, "affs" },
184 { 0x1Cd1, "devpts" },
185 { 0x137D, "ext" },
186 { 0xEF51, "ext2" },
187 { 0xEF53, "ext2/ext3" },
188 { 0x3153464a, "jfs" },
189 { 0x58465342, "xfs" },
190 { 0xF995E849, "hpfs" },
191 { 0x9660, "isofs" },
192 { 0x4000, "isofs" },
193 { 0x4004, "isofs" },
194 { 0x137F, "minix" },
195 { 0x138F, "minix (30 char.)" },
196 { 0x2468, "minix v2" },
197 { 0x2478, "minix v2 (30 char.)" },
198 { 0x4d44, "msdos" },
199 { 0x4006, "fat" },
200 { 0x564c, "novell" },
201 { 0x6969, "nfs" },
202 { 0x9fa0, "proc" },
203 { 0x517B, "smb" },
204 { 0x012FF7B4, "xenix" },
205 { 0x012FF7B5, "sysv4" },
206 { 0x012FF7B6, "sysv2" },
207 { 0x012FF7B7, "coh" },
208 { 0x00011954, "ufs" },
209 { 0x012FD16D, "xia" },
210 { 0x5346544e, "ntfs" },
211 { 0x1021994, "tmpfs" },
212 { 0x52654973, "reiserfs" },
213 { 0x28cd3d45, "cramfs" },
214 { 0x7275, "romfs" },
215 { 0x858458f6, "ramfs" },
216 { 0x73717368, "squashfs" },
217 { 0x62656572, "sysfs" },
218 { 0, "UNKNOWN" }
219 }; 218 };
220 219# undef FS_TYPE
220# define FS_TYPE(type, name) name"\0"
221 static const char humanname[] ALIGN1 =
222 FS_TYPE_LIST
223 "UNKNOWN";
224# undef FS_TYPE
221 int i; 225 int i;
222 226
223 for (i = 0; humantypes[i].type; ++i) 227 for (i = 0; i < ARRAY_SIZE(fstype); ++i)
224 if (humantypes[i].type == f_type) 228 if (fstype[i] == f_type)
225 break; 229 break;
226 return humantypes[i].fs; 230 return nth_string(humanname, i);
227} 231}
228 232
229/* "man statfs" says that statfsbuf->f_fsid is a mess */ 233/* "man statfs" says that statfsbuf->f_fsid is a mess */