summaryrefslogtreecommitdiffhomepage
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-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;