aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-06-20 15:03:21 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-06-20 15:03:21 +0200
commitd82c937a31599086e1813cb3d9cd02c5107725f2 (patch)
tree03029d49dd01cef710c88e9e2d40397dbe0fa8e6
parenta2a9113f35741f9d01f0b5fd5d45d6387681fdb5 (diff)
downloadbusybox-w32-d82c937a31599086e1813cb3d9cd02c5107725f2.tar.gz
busybox-w32-d82c937a31599086e1813cb3d9cd02c5107725f2.tar.bz2
busybox-w32-d82c937a31599086e1813cb3d9cd02c5107725f2.zip
df: support -t TYPE
function old new delta packed_usage 33656 33716 +60 df_main 1029 1065 +36 .rodata 103395 103397 +2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 98/0) Total: 98 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/df.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/coreutils/df.c b/coreutils/df.c
index a659353c0..e8d4bc8f2 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -45,7 +45,7 @@
45//usage: IF_FEATURE_HUMAN_READABLE("mh") 45//usage: IF_FEATURE_HUMAN_READABLE("mh")
46//usage: "T" 46//usage: "T"
47//usage: IF_FEATURE_DF_FANCY("ai] [-B SIZE") 47//usage: IF_FEATURE_DF_FANCY("ai] [-B SIZE")
48//usage: "] [FILESYSTEM]..." 48//usage: "] [-t TYPE] [FILESYSTEM]..."
49//usage:#define df_full_usage "\n\n" 49//usage:#define df_full_usage "\n\n"
50//usage: "Print filesystem usage statistics\n" 50//usage: "Print filesystem usage statistics\n"
51//usage: "\n -P POSIX output format" 51//usage: "\n -P POSIX output format"
@@ -55,6 +55,7 @@
55//usage: "\n -h Human readable (e.g. 1K 243M 2G)" 55//usage: "\n -h Human readable (e.g. 1K 243M 2G)"
56//usage: ) 56//usage: )
57//usage: "\n -T Print filesystem type" 57//usage: "\n -T Print filesystem type"
58//usage: "\n -t TYPE Print only mounts of this type"
58//usage: IF_FEATURE_DF_FANCY( 59//usage: IF_FEATURE_DF_FANCY(
59//usage: "\n -a Show all filesystems" 60//usage: "\n -a Show all filesystems"
60//usage: "\n -i Inodes" 61//usage: "\n -i Inodes"
@@ -97,19 +98,19 @@ int df_main(int argc UNUSED_PARAM, char **argv)
97 FILE *mount_table; 98 FILE *mount_table;
98 struct mntent *mount_entry; 99 struct mntent *mount_entry;
99 struct statvfs s; 100 struct statvfs s;
100
101 enum { 101 enum {
102 OPT_KILO = (1 << 0), 102 OPT_KILO = (1 << 0),
103 OPT_POSIX = (1 << 1), 103 OPT_POSIX = (1 << 1),
104 OPT_FSTYPE = (1 << 2), 104 OPT_FSTYPE = (1 << 2),
105 OPT_ALL = (1 << 3) * ENABLE_FEATURE_DF_FANCY, 105 OPT_t = (1 << 3),
106 OPT_INODE = (1 << 4) * ENABLE_FEATURE_DF_FANCY, 106 OPT_ALL = (1 << 4) * ENABLE_FEATURE_DF_FANCY,
107 OPT_BSIZE = (1 << 5) * ENABLE_FEATURE_DF_FANCY, 107 OPT_INODE = (1 << 5) * ENABLE_FEATURE_DF_FANCY,
108 OPT_HUMAN = (1 << (3 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE, 108 OPT_BSIZE = (1 << 6) * ENABLE_FEATURE_DF_FANCY,
109 OPT_MEGA = (1 << (4 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE, 109 OPT_HUMAN = (1 << (4 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE,
110 OPT_MEGA = (1 << (5 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE,
110 }; 111 };
111 const char *disp_units_hdr = NULL; 112 const char *disp_units_hdr = NULL;
112 char *chp; 113 char *chp, *opt_t;
113 114
114 init_unicode(); 115 init_unicode();
115 116
@@ -121,7 +122,7 @@ int df_main(int argc UNUSED_PARAM, char **argv)
121 df_disp_hr = 512; 122 df_disp_hr = 512;
122 123
123 opt = getopt32(argv, "^" 124 opt = getopt32(argv, "^"
124 "kPT" 125 "kPTt:"
125 IF_FEATURE_DF_FANCY("aiB:") 126 IF_FEATURE_DF_FANCY("aiB:")
126 IF_FEATURE_HUMAN_READABLE("hm") 127 IF_FEATURE_HUMAN_READABLE("hm")
127 "\0" 128 "\0"
@@ -130,6 +131,7 @@ int df_main(int argc UNUSED_PARAM, char **argv)
130#elif ENABLE_FEATURE_HUMAN_READABLE 131#elif ENABLE_FEATURE_HUMAN_READABLE
131 "k-m:m-k" 132 "k-m:m-k"
132#endif 133#endif
134 , &opt_t
133 IF_FEATURE_DF_FANCY(, &chp) 135 IF_FEATURE_DF_FANCY(, &chp)
134 ); 136 );
135 if (opt & OPT_MEGA) 137 if (opt & OPT_MEGA)
@@ -214,6 +216,11 @@ int df_main(int argc UNUSED_PARAM, char **argv)
214 mount_point = mount_entry->mnt_dir; 216 mount_point = mount_entry->mnt_dir;
215 fs_type = mount_entry->mnt_type; 217 fs_type = mount_entry->mnt_type;
216 218
219 if (opt & OPT_t) {
220 if (strcmp(fs_type, opt_t) != 0)
221 continue;
222 }
223
217 if (statvfs(mount_point, &s) != 0) { 224 if (statvfs(mount_point, &s) != 0) {
218 bb_simple_perror_msg(mount_point); 225 bb_simple_perror_msg(mount_point);
219 goto set_error; 226 goto set_error;