summaryrefslogtreecommitdiff
path: root/coreutils/df.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-11-15 07:02:55 +0000
committerDenis Vlasenko2007-11-15 07:02:55 +0000
commitf430cdbf2e7cfd284443addd98c93fbb7017d8e5 (patch)
tree9187e3703a17aeb35bfb93a9c3cfafc0385f1c64 /coreutils/df.c
parent1fe4e9e573c2c6f5338890cc3d1de6d2b7384600 (diff)
downloadbusybox-f430cdbf2e7cfd284443addd98c93fbb7017d8e5.zip
busybox-f430cdbf2e7cfd284443addd98c93fbb7017d8e5.tar.gz
df: add -i (conditional on CONFIG)
uasge: trim a bit
Diffstat (limited to 'coreutils/df.c')
-rw-r--r--coreutils/df.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/coreutils/df.c b/coreutils/df.c
index ad6a4f3..0d7e520 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -45,9 +45,14 @@ int df_main(int argc, char **argv)
/* default display is kilobytes */
const char *disp_units_hdr = "1k-blocks";
+ enum {
+ OPT_INODE = (ENABLE_FEATURE_HUMAN_READABLE ? (1 << 3) : (1 << 1))
+ * ENABLE_FEATURE_DF_INODE
+ };
+
#if ENABLE_FEATURE_HUMAN_READABLE
opt_complementary = "h-km:k-hm:m-hk";
- opt = getopt32(argv, "hmk");
+ opt = getopt32(argv, "hmk" USE_FEATURE_DF_INODE("i"));
if (opt & 1) {
df_disp_hr = 0;
disp_units_hdr = " Size";
@@ -56,8 +61,11 @@ int df_main(int argc, char **argv)
df_disp_hr = 1024*1024;
disp_units_hdr = "1M-blocks";
}
+ if (opt & OPT_INODE) {
+ disp_units_hdr = " Inodes";
+ }
#else
- opt = getopt32(argv, "k");
+ opt = getopt32(argv, "k" USE_FEATURE_DF_INODE("i"));
#endif
printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
@@ -104,7 +112,16 @@ int df_main(int argc, char **argv)
goto SET_ERROR;
}
- if ((s.f_blocks > 0) || !mount_table){
+ if ((s.f_blocks > 0) || !mount_table) {
+ if (opt & OPT_INODE) {
+ s.f_blocks = s.f_files;
+ s.f_bavail = s.f_bfree = s.f_ffree;
+ s.f_bsize = 1;
+#if ENABLE_FEATURE_HUMAN_READABLE
+ if (df_disp_hr)
+ df_disp_hr = 1;
+#endif
+ }
blocks_used = s.f_blocks - s.f_bfree;
blocks_percent_used = 0;
if (blocks_used + s.f_bavail) {
@@ -115,7 +132,8 @@ int df_main(int argc, char **argv)
if (strcmp(device, "rootfs") == 0) {
continue;
- } else if (strcmp(device, "/dev/root") == 0) {
+ }
+ if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
device = find_block_device("/");