diff options
author | Ari Sundholm <ari@tuxera.com> | 2014-09-17 20:53:58 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-09-17 20:53:58 +0200 |
commit | d0cdacafa98ec0e73e58c2e5a8ba9dded18006df (patch) | |
tree | 7db36c063a69ac2ae283c394a36f80060d46473d /coreutils | |
parent | 9caea2448e168560de306a1496574dd58c645fea (diff) | |
download | busybox-w32-d0cdacafa98ec0e73e58c2e5a8ba9dded18006df.tar.gz busybox-w32-d0cdacafa98ec0e73e58c2e5a8ba9dded18006df.tar.bz2 busybox-w32-d0cdacafa98ec0e73e58c2e5a8ba9dded18006df.zip |
df: implement -T option
function old new delta
df_main 863 998 +135
packed_usage 29827 29861 +34
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 169/0) Total: 169 bytes
Signed-off-by: Ari Sundholm <ari@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/df.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/coreutils/df.c b/coreutils/df.c index 5e9a8670f..7a82fee83 100644 --- a/coreutils/df.c +++ b/coreutils/df.c | |||
@@ -25,6 +25,7 @@ | |||
25 | //usage:#define df_trivial_usage | 25 | //usage:#define df_trivial_usage |
26 | //usage: "[-Pk" | 26 | //usage: "[-Pk" |
27 | //usage: IF_FEATURE_HUMAN_READABLE("mh") | 27 | //usage: IF_FEATURE_HUMAN_READABLE("mh") |
28 | //usage: "T" | ||
28 | //usage: IF_FEATURE_DF_FANCY("ai] [-B SIZE") | 29 | //usage: IF_FEATURE_DF_FANCY("ai] [-B SIZE") |
29 | //usage: "] [FILESYSTEM]..." | 30 | //usage: "] [FILESYSTEM]..." |
30 | //usage:#define df_full_usage "\n\n" | 31 | //usage:#define df_full_usage "\n\n" |
@@ -35,6 +36,7 @@ | |||
35 | //usage: "\n -m 1M-byte blocks" | 36 | //usage: "\n -m 1M-byte blocks" |
36 | //usage: "\n -h Human readable (e.g. 1K 243M 2G)" | 37 | //usage: "\n -h Human readable (e.g. 1K 243M 2G)" |
37 | //usage: ) | 38 | //usage: ) |
39 | //usage: "\n -T Print filesystem type" | ||
38 | //usage: IF_FEATURE_DF_FANCY( | 40 | //usage: IF_FEATURE_DF_FANCY( |
39 | //usage: "\n -a Show all filesystems" | 41 | //usage: "\n -a Show all filesystems" |
40 | //usage: "\n -i Inodes" | 42 | //usage: "\n -i Inodes" |
@@ -88,6 +90,7 @@ int df_main(int argc UNUSED_PARAM, char **argv) | |||
88 | OPT_BSIZE = (1 << 4) * ENABLE_FEATURE_DF_FANCY, | 90 | OPT_BSIZE = (1 << 4) * ENABLE_FEATURE_DF_FANCY, |
89 | OPT_HUMAN = (1 << (2 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE, | 91 | OPT_HUMAN = (1 << (2 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE, |
90 | OPT_MEGA = (1 << (3 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE, | 92 | OPT_MEGA = (1 << (3 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE, |
93 | OPT_FSTYPE = (1 << (4 + 3*ENABLE_FEATURE_DF_FANCY)), | ||
91 | }; | 94 | }; |
92 | const char *disp_units_hdr = NULL; | 95 | const char *disp_units_hdr = NULL; |
93 | char *chp; | 96 | char *chp; |
@@ -102,6 +105,7 @@ int df_main(int argc UNUSED_PARAM, char **argv) | |||
102 | opt = getopt32(argv, "kP" | 105 | opt = getopt32(argv, "kP" |
103 | IF_FEATURE_DF_FANCY("aiB:") | 106 | IF_FEATURE_DF_FANCY("aiB:") |
104 | IF_FEATURE_HUMAN_READABLE("hm") | 107 | IF_FEATURE_HUMAN_READABLE("hm") |
108 | "T" | ||
105 | IF_FEATURE_DF_FANCY(, &chp)); | 109 | IF_FEATURE_DF_FANCY(, &chp)); |
106 | if (opt & OPT_MEGA) | 110 | if (opt & OPT_MEGA) |
107 | df_disp_hr = 1024*1024; | 111 | df_disp_hr = 1024*1024; |
@@ -134,8 +138,11 @@ int df_main(int argc UNUSED_PARAM, char **argv) | |||
134 | disp_units_hdr = xasprintf("%lu-blocks", df_disp_hr); | 138 | disp_units_hdr = xasprintf("%lu-blocks", df_disp_hr); |
135 | #endif | 139 | #endif |
136 | } | 140 | } |
137 | printf("Filesystem %-15sUsed Available %s Mounted on\n", | 141 | |
138 | disp_units_hdr, (opt & OPT_POSIX) ? "Capacity" : "Use%"); | 142 | printf("Filesystem %s%-15sUsed Available %s Mounted on\n", |
143 | (opt & OPT_FSTYPE) ? "Type " : "", | ||
144 | disp_units_hdr, | ||
145 | (opt & OPT_POSIX) ? "Capacity" : "Use%"); | ||
139 | 146 | ||
140 | mount_table = NULL; | 147 | mount_table = NULL; |
141 | argv += optind; | 148 | argv += optind; |
@@ -148,6 +155,7 @@ int df_main(int argc UNUSED_PARAM, char **argv) | |||
148 | while (1) { | 155 | while (1) { |
149 | const char *device; | 156 | const char *device; |
150 | const char *mount_point; | 157 | const char *mount_point; |
158 | const char *fs_type; | ||
151 | 159 | ||
152 | if (mount_table) { | 160 | if (mount_table) { |
153 | mount_entry = getmntent(mount_table); | 161 | mount_entry = getmntent(mount_table); |
@@ -170,6 +178,7 @@ int df_main(int argc UNUSED_PARAM, char **argv) | |||
170 | 178 | ||
171 | device = mount_entry->mnt_fsname; | 179 | device = mount_entry->mnt_fsname; |
172 | mount_point = mount_entry->mnt_dir; | 180 | mount_point = mount_entry->mnt_dir; |
181 | fs_type = mount_entry->mnt_type; | ||
173 | 182 | ||
174 | if (statfs(mount_point, &s) != 0) { | 183 | if (statfs(mount_point, &s) != 0) { |
175 | bb_simple_perror_msg(mount_point); | 184 | bb_simple_perror_msg(mount_point); |
@@ -218,10 +227,22 @@ int df_main(int argc UNUSED_PARAM, char **argv) | |||
218 | printf("%s%*s", uni_dev, 20 - (int)uni_stat.unicode_width, ""); | 227 | printf("%s%*s", uni_dev, 20 - (int)uni_stat.unicode_width, ""); |
219 | } | 228 | } |
220 | free(uni_dev); | 229 | free(uni_dev); |
230 | if (opt & OPT_FSTYPE) { | ||
231 | char *uni_type = unicode_conv_to_printable(&uni_stat, fs_type); | ||
232 | if (uni_stat.unicode_width > 10 && !(opt & OPT_POSIX)) | ||
233 | printf(" %s\n%31s", uni_type, ""); | ||
234 | else | ||
235 | printf(" %s%*s", uni_type, 10 - (int)uni_stat.unicode_width, ""); | ||
236 | free(uni_type); | ||
237 | } | ||
221 | } | 238 | } |
222 | #else | 239 | #else |
223 | if (printf("\n%-20s" + 1, device) > 20 && !(opt & OPT_POSIX)) | 240 | if (printf("\n%-20s" + 1, device) > 20 && !(opt & OPT_POSIX)) |
224 | printf("\n%-20s", ""); | 241 | printf("\n%-20s", ""); |
242 | if (opt & OPT_FSTYPE) { | ||
243 | if (printf(" %-10s", fs_type) > 11 && !(opt & OPT_POSIX)) | ||
244 | printf("\n%-30s", ""); | ||
245 | } | ||
225 | #endif | 246 | #endif |
226 | 247 | ||
227 | #if ENABLE_FEATURE_HUMAN_READABLE | 248 | #if ENABLE_FEATURE_HUMAN_READABLE |