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