diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-15 09:02:12 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-15 09:02:12 +0000 |
| commit | 6d38dc3af42480fa103d35bdd97611dcf22f4904 (patch) | |
| tree | 2d5fcea25c5d6b1e4664959c1d99a4264fefbe30 /coreutils | |
| parent | f430cdbf2e7cfd284443addd98c93fbb7017d8e5 (diff) | |
| download | busybox-w32-6d38dc3af42480fa103d35bdd97611dcf22f4904.tar.gz busybox-w32-6d38dc3af42480fa103d35bdd97611dcf22f4904.tar.bz2 busybox-w32-6d38dc3af42480fa103d35bdd97611dcf22f4904.zip | |
df: add -a
df: don't special case rootfs and /dev/root
function old new delta
df_main 746 684 -62
find_block_device 111 - -111
find_block_device_in_dir 243 - -243
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-416) Total: -416 bytes
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/df.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/coreutils/df.c b/coreutils/df.c index 0d7e5206f..9cb328aa3 100644 --- a/coreutils/df.c +++ b/coreutils/df.c | |||
| @@ -46,18 +46,19 @@ int df_main(int argc, char **argv) | |||
| 46 | const char *disp_units_hdr = "1k-blocks"; | 46 | const char *disp_units_hdr = "1k-blocks"; |
| 47 | 47 | ||
| 48 | enum { | 48 | enum { |
| 49 | OPT_INODE = (ENABLE_FEATURE_HUMAN_READABLE ? (1 << 3) : (1 << 1)) | 49 | OPT_ALL = (1 << 0), |
| 50 | OPT_INODE = (ENABLE_FEATURE_HUMAN_READABLE ? (1 << 4) : (1 << 2)) | ||
| 50 | * ENABLE_FEATURE_DF_INODE | 51 | * ENABLE_FEATURE_DF_INODE |
| 51 | }; | 52 | }; |
| 52 | 53 | ||
| 53 | #if ENABLE_FEATURE_HUMAN_READABLE | 54 | #if ENABLE_FEATURE_HUMAN_READABLE |
| 54 | opt_complementary = "h-km:k-hm:m-hk"; | 55 | opt_complementary = "h-km:k-hm:m-hk"; |
| 55 | opt = getopt32(argv, "hmk" USE_FEATURE_DF_INODE("i")); | 56 | opt = getopt32(argv, "ahmk" USE_FEATURE_DF_INODE("i")); |
| 56 | if (opt & 1) { | 57 | if (opt & (1 << 1)) { // -h |
| 57 | df_disp_hr = 0; | 58 | df_disp_hr = 0; |
| 58 | disp_units_hdr = " Size"; | 59 | disp_units_hdr = " Size"; |
| 59 | } | 60 | } |
| 60 | if (opt & 2) { | 61 | if (opt & (1 << 2)) { // -m |
| 61 | df_disp_hr = 1024*1024; | 62 | df_disp_hr = 1024*1024; |
| 62 | disp_units_hdr = "1M-blocks"; | 63 | disp_units_hdr = "1M-blocks"; |
| 63 | } | 64 | } |
| @@ -65,11 +66,11 @@ int df_main(int argc, char **argv) | |||
| 65 | disp_units_hdr = " Inodes"; | 66 | disp_units_hdr = " Inodes"; |
| 66 | } | 67 | } |
| 67 | #else | 68 | #else |
| 68 | opt = getopt32(argv, "k" USE_FEATURE_DF_INODE("i")); | 69 | opt = getopt32(argv, "ak" USE_FEATURE_DF_INODE("i")); |
| 69 | #endif | 70 | #endif |
| 70 | 71 | ||
| 71 | printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n", | 72 | printf("Filesystem %-15sUsed Available Use%% Mounted on\n", |
| 72 | "", disp_units_hdr); | 73 | disp_units_hdr); |
| 73 | 74 | ||
| 74 | mount_table = NULL; | 75 | mount_table = NULL; |
| 75 | argv += optind; | 76 | argv += optind; |
| @@ -112,7 +113,7 @@ int df_main(int argc, char **argv) | |||
| 112 | goto SET_ERROR; | 113 | goto SET_ERROR; |
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | if ((s.f_blocks > 0) || !mount_table) { | 116 | if ((s.f_blocks > 0) || !mount_table || (opt & OPT_ALL)) { |
| 116 | if (opt & OPT_INODE) { | 117 | if (opt & OPT_INODE) { |
| 117 | s.f_blocks = s.f_files; | 118 | s.f_blocks = s.f_files; |
| 118 | s.f_bavail = s.f_bfree = s.f_ffree; | 119 | s.f_bavail = s.f_bfree = s.f_ffree; |
| @@ -130,9 +131,13 @@ int df_main(int argc, char **argv) | |||
| 130 | ) / (blocks_used + s.f_bavail); | 131 | ) / (blocks_used + s.f_bavail); |
| 131 | } | 132 | } |
| 132 | 133 | ||
| 134 | #ifdef WHY_IT_SHOULD_BE_HIDDEN | ||
| 133 | if (strcmp(device, "rootfs") == 0) { | 135 | if (strcmp(device, "rootfs") == 0) { |
| 134 | continue; | 136 | continue; |
| 135 | } | 137 | } |
| 138 | #endif | ||
| 139 | #ifdef WHY_WE_DO_IT_FOR_DEV_ROOT_ONLY | ||
| 140 | /* ... and also this is the only user of find_block_device */ | ||
| 136 | if (strcmp(device, "/dev/root") == 0) { | 141 | if (strcmp(device, "/dev/root") == 0) { |
| 137 | /* Adjusts device to be the real root device, | 142 | /* Adjusts device to be the real root device, |
| 138 | * or leaves device alone if it can't find it */ | 143 | * or leaves device alone if it can't find it */ |
| @@ -141,6 +146,7 @@ int df_main(int argc, char **argv) | |||
| 141 | goto SET_ERROR; | 146 | goto SET_ERROR; |
| 142 | } | 147 | } |
| 143 | } | 148 | } |
| 149 | #endif | ||
| 144 | 150 | ||
| 145 | if (printf("\n%-20s" + 1, device) > 20) | 151 | if (printf("\n%-20s" + 1, device) > 20) |
| 146 | printf("\n%-20s", ""); | 152 | printf("\n%-20s", ""); |
