diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-15 07:02:55 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-15 07:02:55 +0000 |
commit | f430cdbf2e7cfd284443addd98c93fbb7017d8e5 (patch) | |
tree | 9187e3703a17aeb35bfb93a9c3cfafc0385f1c64 /coreutils | |
parent | 1fe4e9e573c2c6f5338890cc3d1de6d2b7384600 (diff) | |
download | busybox-w32-f430cdbf2e7cfd284443addd98c93fbb7017d8e5.tar.gz busybox-w32-f430cdbf2e7cfd284443addd98c93fbb7017d8e5.tar.bz2 busybox-w32-f430cdbf2e7cfd284443addd98c93fbb7017d8e5.zip |
df: add -i (conditional on CONFIG)
uasge: trim a bit
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/Config.in | 7 | ||||
-rw-r--r-- | coreutils/df.c | 26 |
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 | |||
135 | df reports the amount of disk space used and available | 135 | df reports the amount of disk space used and available |
136 | on filesystems. | 136 | on filesystems. |
137 | 137 | ||
138 | config FEATURE_DF_INODE | ||
139 | bool "Enable -i (inode information)" | ||
140 | default n | ||
141 | depends on DF | ||
142 | help | ||
143 | This option enables support for df -i. | ||
144 | |||
138 | config DIRNAME | 145 | config DIRNAME |
139 | bool "dirname" | 146 | bool "dirname" |
140 | default n | 147 | 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) | |||
45 | /* default display is kilobytes */ | 45 | /* default display is kilobytes */ |
46 | const char *disp_units_hdr = "1k-blocks"; | 46 | const char *disp_units_hdr = "1k-blocks"; |
47 | 47 | ||
48 | enum { | ||
49 | OPT_INODE = (ENABLE_FEATURE_HUMAN_READABLE ? (1 << 3) : (1 << 1)) | ||
50 | * ENABLE_FEATURE_DF_INODE | ||
51 | }; | ||
52 | |||
48 | #if ENABLE_FEATURE_HUMAN_READABLE | 53 | #if ENABLE_FEATURE_HUMAN_READABLE |
49 | opt_complementary = "h-km:k-hm:m-hk"; | 54 | opt_complementary = "h-km:k-hm:m-hk"; |
50 | opt = getopt32(argv, "hmk"); | 55 | opt = getopt32(argv, "hmk" USE_FEATURE_DF_INODE("i")); |
51 | if (opt & 1) { | 56 | if (opt & 1) { |
52 | df_disp_hr = 0; | 57 | df_disp_hr = 0; |
53 | disp_units_hdr = " Size"; | 58 | disp_units_hdr = " Size"; |
@@ -56,8 +61,11 @@ int df_main(int argc, char **argv) | |||
56 | df_disp_hr = 1024*1024; | 61 | df_disp_hr = 1024*1024; |
57 | disp_units_hdr = "1M-blocks"; | 62 | disp_units_hdr = "1M-blocks"; |
58 | } | 63 | } |
64 | if (opt & OPT_INODE) { | ||
65 | disp_units_hdr = " Inodes"; | ||
66 | } | ||
59 | #else | 67 | #else |
60 | opt = getopt32(argv, "k"); | 68 | opt = getopt32(argv, "k" USE_FEATURE_DF_INODE("i")); |
61 | #endif | 69 | #endif |
62 | 70 | ||
63 | printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n", | 71 | printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n", |
@@ -104,7 +112,16 @@ int df_main(int argc, char **argv) | |||
104 | goto SET_ERROR; | 112 | goto SET_ERROR; |
105 | } | 113 | } |
106 | 114 | ||
107 | if ((s.f_blocks > 0) || !mount_table){ | 115 | if ((s.f_blocks > 0) || !mount_table) { |
116 | if (opt & OPT_INODE) { | ||
117 | s.f_blocks = s.f_files; | ||
118 | s.f_bavail = s.f_bfree = s.f_ffree; | ||
119 | s.f_bsize = 1; | ||
120 | #if ENABLE_FEATURE_HUMAN_READABLE | ||
121 | if (df_disp_hr) | ||
122 | df_disp_hr = 1; | ||
123 | #endif | ||
124 | } | ||
108 | blocks_used = s.f_blocks - s.f_bfree; | 125 | blocks_used = s.f_blocks - s.f_bfree; |
109 | blocks_percent_used = 0; | 126 | blocks_percent_used = 0; |
110 | if (blocks_used + s.f_bavail) { | 127 | if (blocks_used + s.f_bavail) { |
@@ -115,7 +132,8 @@ int df_main(int argc, char **argv) | |||
115 | 132 | ||
116 | if (strcmp(device, "rootfs") == 0) { | 133 | if (strcmp(device, "rootfs") == 0) { |
117 | continue; | 134 | continue; |
118 | } else if (strcmp(device, "/dev/root") == 0) { | 135 | } |
136 | if (strcmp(device, "/dev/root") == 0) { | ||
119 | /* Adjusts device to be the real root device, | 137 | /* Adjusts device to be the real root device, |
120 | * or leaves device alone if it can't find it */ | 138 | * or leaves device alone if it can't find it */ |
121 | device = find_block_device("/"); | 139 | device = find_block_device("/"); |