summaryrefslogtreecommitdiff
path: root/coreutils/df.c
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 /coreutils/df.c
parenta2a9113f35741f9d01f0b5fd5d45d6387681fdb5 (diff)
downloadbusybox-d82c937a31599086e1813cb3d9cd02c5107725f2.tar.gz
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>
Diffstat (limited to 'coreutils/df.c')
-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 @@
//usage: IF_FEATURE_HUMAN_READABLE("mh")
//usage: "T"
//usage: IF_FEATURE_DF_FANCY("ai] [-B SIZE")
-//usage: "] [FILESYSTEM]..."
+//usage: "] [-t TYPE] [FILESYSTEM]..."
//usage:#define df_full_usage "\n\n"
//usage: "Print filesystem usage statistics\n"
//usage: "\n -P POSIX output format"
@@ -55,6 +55,7 @@
//usage: "\n -h Human readable (e.g. 1K 243M 2G)"
//usage: )
//usage: "\n -T Print filesystem type"
+//usage: "\n -t TYPE Print only mounts of this type"
//usage: IF_FEATURE_DF_FANCY(
//usage: "\n -a Show all filesystems"
//usage: "\n -i Inodes"
@@ -97,19 +98,19 @@ int df_main(int argc UNUSED_PARAM, char **argv)
FILE *mount_table;
struct mntent *mount_entry;
struct statvfs s;
-
enum {
- OPT_KILO = (1 << 0),
- OPT_POSIX = (1 << 1),
- OPT_FSTYPE = (1 << 2),
- OPT_ALL = (1 << 3) * ENABLE_FEATURE_DF_FANCY,
- OPT_INODE = (1 << 4) * ENABLE_FEATURE_DF_FANCY,
- OPT_BSIZE = (1 << 5) * ENABLE_FEATURE_DF_FANCY,
- OPT_HUMAN = (1 << (3 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE,
- OPT_MEGA = (1 << (4 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE,
+ OPT_KILO = (1 << 0),
+ OPT_POSIX = (1 << 1),
+ OPT_FSTYPE = (1 << 2),
+ OPT_t = (1 << 3),
+ OPT_ALL = (1 << 4) * ENABLE_FEATURE_DF_FANCY,
+ OPT_INODE = (1 << 5) * ENABLE_FEATURE_DF_FANCY,
+ OPT_BSIZE = (1 << 6) * ENABLE_FEATURE_DF_FANCY,
+ OPT_HUMAN = (1 << (4 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE,
+ OPT_MEGA = (1 << (5 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE,
};
const char *disp_units_hdr = NULL;
- char *chp;
+ char *chp, *opt_t;
init_unicode();
@@ -121,7 +122,7 @@ int df_main(int argc UNUSED_PARAM, char **argv)
df_disp_hr = 512;
opt = getopt32(argv, "^"
- "kPT"
+ "kPTt:"
IF_FEATURE_DF_FANCY("aiB:")
IF_FEATURE_HUMAN_READABLE("hm")
"\0"
@@ -130,6 +131,7 @@ int df_main(int argc UNUSED_PARAM, char **argv)
#elif ENABLE_FEATURE_HUMAN_READABLE
"k-m:m-k"
#endif
+ , &opt_t
IF_FEATURE_DF_FANCY(, &chp)
);
if (opt & OPT_MEGA)
@@ -214,6 +216,11 @@ int df_main(int argc UNUSED_PARAM, char **argv)
mount_point = mount_entry->mnt_dir;
fs_type = mount_entry->mnt_type;
+ if (opt & OPT_t) {
+ if (strcmp(fs_type, opt_t) != 0)
+ continue;
+ }
+
if (statvfs(mount_point, &s) != 0) {
bb_simple_perror_msg(mount_point);
goto set_error;