aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/Config.in7
-rw-r--r--coreutils/df.c26
2 files changed, 29 insertions, 4 deletions
diff --git a/coreutils/Config.in b/coreutils/Config.in
index 3370b2a5d..d3cbc4213 100644
--- a/coreutils/Config.in
+++ b/coreutils/Config.in
@@ -135,6 +135,13 @@ config DF
df reports the amount of disk space used and available
on filesystems.
+config FEATURE_DF_INODE
+ bool "Enable -i (inode information)"
+ default n
+ depends on DF
+ help
+ This option enables support for df -i.
+
config DIRNAME
bool "dirname"
default n
diff --git a/coreutils/df.c b/coreutils/df.c
index ad6a4f370..0d7e5206f 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("/");