aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-11-15 07:02:55 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-11-15 07:02:55 +0000
commitf430cdbf2e7cfd284443addd98c93fbb7017d8e5 (patch)
tree9187e3703a17aeb35bfb93a9c3cfafc0385f1c64
parent1fe4e9e573c2c6f5338890cc3d1de6d2b7384600 (diff)
downloadbusybox-w32-f430cdbf2e7cfd284443addd98c93fbb7017d8e5.tar.gz
busybox-w32-f430cdbf2e7cfd284443addd98c93fbb7017d8e5.tar.bz2
busybox-w32-f430cdbf2e7cfd284443addd98c93fbb7017d8e5.zip
df: add -i (conditional on CONFIG)
uasge: trim a bit
-rw-r--r--coreutils/Config.in7
-rw-r--r--coreutils/df.c26
-rw-r--r--include/usage.h74
3 files changed, 71 insertions, 36 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
138config 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
138config DIRNAME 145config 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("/");
diff --git a/include/usage.h b/include/usage.h
index e609cbc18..953645ba0 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -99,7 +99,7 @@
99 "The ash shell (command interpreter)" 99 "The ash shell (command interpreter)"
100 100
101#define awk_trivial_usage \ 101#define awk_trivial_usage \
102 "[OPTION]... [program-text] [FILE ...]" 102 "[OPTION]... [program-text] [FILE...]"
103#define awk_full_usage \ 103#define awk_full_usage \
104 "Options:\n" \ 104 "Options:\n" \
105 " -v var=val Set variable\n" \ 105 " -v var=val Set variable\n" \
@@ -548,7 +548,7 @@
548 "Wed Apr 12 18:52:41 MDT 2000\n" 548 "Wed Apr 12 18:52:41 MDT 2000\n"
549 549
550#define dc_trivial_usage \ 550#define dc_trivial_usage \
551 "expression ..." 551 "expression..."
552#define dc_full_usage \ 552#define dc_full_usage \
553 "This is a Tiny RPN calculator that understands the\n" \ 553 "This is a Tiny RPN calculator that understands the\n" \
554 "following operations: +, add, -, sub, *, mul, /, div, %, mod, " \ 554 "following operations: +, add, -, sub, *, mul, /, div, %, mod, " \
@@ -617,7 +617,7 @@
617 617
618#define devfsd_trivial_usage \ 618#define devfsd_trivial_usage \
619 "mntpnt [-v]" \ 619 "mntpnt [-v]" \
620 USE_DEVFSD_FG_NP("[-fg][-np]" ) 620 USE_DEVFSD_FG_NP("[-fg][-np]")
621#define devfsd_full_usage \ 621#define devfsd_full_usage \
622 "Manage devfs permissions and old device name symlinks" \ 622 "Manage devfs permissions and old device name symlinks" \
623 "\n\nOptions:" \ 623 "\n\nOptions:" \
@@ -630,18 +630,28 @@
630 "\n and processing synthetic REGISTER events," \ 630 "\n and processing synthetic REGISTER events," \
631 "\n do not poll for events") 631 "\n do not poll for events")
632 632
633/* -k is accepted but ignored for !HUMAN_READABLE,
634 * but we won't mention this (unimportant) */
635#if ENABLE_FEATURE_HUMAN_READABLE || ENABLE_FEATURE_DF_INODE
636#define DF_HAS_OPTIONS(x) x
637#else
638#define DF_HAS_OPTIONS(x)
639#endif
633#define df_trivial_usage \ 640#define df_trivial_usage \
634 "[-" USE_FEATURE_HUMAN_READABLE("hm") "k] [FILESYSTEM ...]" 641 DF_HAS_OPTIONS("[-") \
642 USE_FEATURE_HUMAN_READABLE("hmk") USE_FEATURE_DF_INODE("i") \
643 DF_HAS_OPTIONS("] ") "[FILESYSTEM...]"
635#define df_full_usage \ 644#define df_full_usage \
636 "Print the filesystem space used and space available" \ 645 "Print filesystem usage statistics" \
646 DF_HAS_OPTIONS("\n\nOptions:") \
637 USE_FEATURE_HUMAN_READABLE( \ 647 USE_FEATURE_HUMAN_READABLE( \
638 "\n\nOptions control size display:" \
639 "\n -h Human readable (e.g. 1K 243M 2G)" \ 648 "\n -h Human readable (e.g. 1K 243M 2G)" \
640 "\n -m 1024*1024 blocks" \ 649 "\n -m 1024*1024 blocks" \
641 "\n -k 1024 blocks") \ 650 "\n -k 1024 blocks" \
642 SKIP_FEATURE_HUMAN_READABLE( \ 651 ) \
643 "\n\nOptions:" \ 652 USE_FEATURE_DF_INODE( \
644 "\n -k Ignored") 653 "\n -i Inodes" \
654 )
645#define df_example_usage \ 655#define df_example_usage \
646 "$ df\n" \ 656 "$ df\n" \
647 "Filesystem 1k-blocks Used Available Use% Mounted on\n" \ 657 "Filesystem 1k-blocks Used Available Use% Mounted on\n" \
@@ -828,7 +838,7 @@
828 " -L file Set badblocks list" 838 " -L file Set badblocks list"
829 839
830#define echo_trivial_usage \ 840#define echo_trivial_usage \
831 USE_FEATURE_FANCY_ECHO("[-neE] ") "[ARG ...]" 841 USE_FEATURE_FANCY_ECHO("[-neE] ") "[ARG...]"
832#define echo_full_usage \ 842#define echo_full_usage \
833 "Print the specified ARGs to stdout" \ 843 "Print the specified ARGs to stdout" \
834 USE_FEATURE_FANCY_ECHO( \ 844 USE_FEATURE_FANCY_ECHO( \
@@ -1075,7 +1085,7 @@
1075 "$ freeramdisk /dev/ram2\n" 1085 "$ freeramdisk /dev/ram2\n"
1076 1086
1077#define fsck_trivial_usage \ 1087#define fsck_trivial_usage \
1078 "[-ANPRTV] [-C fd] [-t fstype] [fs-options] [filesys ...]" 1088 "[-ANPRTV] [-C fd] [-t fstype] [fs-options] [filesys...]"
1079#define fsck_full_usage \ 1089#define fsck_full_usage \
1080 "Check and repair filesystems" \ 1090 "Check and repair filesystems" \
1081 "\n\nOptions:\n" \ 1091 "\n\nOptions:\n" \
@@ -1825,7 +1835,7 @@
1825 " -u Unicode (utf-8)" 1835 " -u Unicode (utf-8)"
1826 1836
1827#define kill_trivial_usage \ 1837#define kill_trivial_usage \
1828 "[-l] [-signal] process-id [process-id ...]" 1838 "[-l] [-signal] process-id [process-id...]"
1829#define kill_full_usage \ 1839#define kill_full_usage \
1830 "Send a signal (default is TERM) to the specified process(es)" \ 1840 "Send a signal (default is TERM) to the specified process(es)" \
1831 "\n\nOptions:\n" \ 1841 "\n\nOptions:\n" \
@@ -1841,7 +1851,7 @@
1841 "$ kill 252\n" 1851 "$ kill 252\n"
1842 1852
1843#define killall_trivial_usage \ 1853#define killall_trivial_usage \
1844 "[-l] [-q] [-signal] process-name [process-name ...]" 1854 "[-l] [-q] [-signal] process-name [process-name...]"
1845#define killall_full_usage \ 1855#define killall_full_usage \
1846 "Send a signal (default is TERM) to the specified process(es)" \ 1856 "Send a signal (default is TERM) to the specified process(es)" \
1847 "\n\nOptions:\n" \ 1857 "\n\nOptions:\n" \
@@ -1887,7 +1897,7 @@
1887 " reached" 1897 " reached"
1888 1898
1889#define setarch_trivial_usage \ 1899#define setarch_trivial_usage \
1890 "personality program [args ...]" 1900 "personality program [args...]"
1891#define setarch_full_usage \ 1901#define setarch_full_usage \
1892 "Personality may be:\n" \ 1902 "Personality may be:\n" \
1893 " linux32 Set 32bit uname emulation\n" \ 1903 " linux32 Set 32bit uname emulation\n" \
@@ -1940,7 +1950,7 @@
1940 "$ logger \"hello\"\n" 1950 "$ logger \"hello\"\n"
1941 1951
1942#define login_trivial_usage \ 1952#define login_trivial_usage \
1943 "[OPTION]... [username] [ENV=VAR ...]" 1953 "[OPTION]... [username] [ENV=VAR...]"
1944#define login_full_usage \ 1954#define login_full_usage \
1945 "Begin a new session on the system" \ 1955 "Begin a new session on the system" \
1946 "\n\nOptions:\n" \ 1956 "\n\nOptions:\n" \
@@ -2297,7 +2307,7 @@
2297 "-rw------- 1 andersen andersen 0 Apr 25 17:10 /tmp/temp.mWiLjM\n" 2307 "-rw------- 1 andersen andersen 0 Apr 25 17:10 /tmp/temp.mWiLjM\n"
2298 2308
2299#define modprobe_trivial_usage \ 2309#define modprobe_trivial_usage \
2300 "[-knqrsv] MODULE [symbol=value ...]" 2310 "[-knqrsv] MODULE [symbol=value...]"
2301#define modprobe_full_usage \ 2311#define modprobe_full_usage \
2302 "Options:\n" \ 2312 "Options:\n" \
2303 " -k Make module autoclean-able\n" \ 2313 " -k Make module autoclean-able\n" \
@@ -2331,7 +2341,7 @@
2331" the module and the alias.\n" \ 2341" the module and the alias.\n" \
2332" A module can be aliased more than once.\n" \ 2342" A module can be aliased more than once.\n" \
2333"\n" \ 2343"\n" \
2334" options <mod_name|alias_name> <symbol=value ...>\n" \ 2344" options <mod_name|alias_name> <symbol=value...>\n" \
2335" When loading module mod_name (or the module aliased by alias_name), pass\n" \ 2345" When loading module mod_name (or the module aliased by alias_name), pass\n" \
2336" the \"symbol=value\" pairs as option to that module.\n" \ 2346" the \"symbol=value\" pairs as option to that module.\n" \
2337"\n" \ 2347"\n" \
@@ -2367,7 +2377,7 @@
2367 " from the command line\n" 2377 " from the command line\n"
2368 2378
2369#define more_trivial_usage \ 2379#define more_trivial_usage \
2370 "[FILE ...]" 2380 "[FILE...]"
2371#define more_full_usage \ 2381#define more_full_usage \
2372 "View FILE or standard input one screenful at a time" 2382 "View FILE or standard input one screenful at a time"
2373#define more_example_usage \ 2383#define more_example_usage \
@@ -2560,7 +2570,7 @@
2560 ) 2570 )
2561 2571
2562#define nice_trivial_usage \ 2572#define nice_trivial_usage \
2563 "[-n ADJUST] [COMMAND [ARG] ...]" 2573 "[-n ADJUST] [COMMAND [ARG]...]"
2564#define nice_full_usage \ 2574#define nice_full_usage \
2565 "Run a program with modified scheduling priority" \ 2575 "Run a program with modified scheduling priority" \
2566 "\n\nOptions:\n" \ 2576 "\n\nOptions:\n" \
@@ -2678,7 +2688,7 @@
2678#endif 2688#endif
2679 2689
2680#define pidof_trivial_usage \ 2690#define pidof_trivial_usage \
2681 "process-name [OPTION] [process-name ...]" 2691 "process-name [OPTION] [process-name...]"
2682 2692
2683#define pidof_full_usage \ 2693#define pidof_full_usage \
2684 "List the PIDs of all processes with names that match the\n" \ 2694 "List the PIDs of all processes with names that match the\n" \
@@ -2895,7 +2905,7 @@
2895 " -n Disable byte order auto-detection" 2905 " -n Disable byte order auto-detection"
2896 2906
2897#define realpath_trivial_usage \ 2907#define realpath_trivial_usage \
2898 "pathname ..." 2908 "pathname..."
2899#define realpath_full_usage \ 2909#define realpath_full_usage \
2900 "Return the absolute pathnames of given argument" 2910 "Return the absolute pathnames of given argument"
2901 2911
@@ -2909,7 +2919,7 @@
2909 " -f Force reboot (don't go through init)" 2919 " -f Force reboot (don't go through init)"
2910 2920
2911#define renice_trivial_usage \ 2921#define renice_trivial_usage \
2912 "{{-n INCREMENT} | PRIORITY} [[-p | -g | -u] ID ...]" 2922 "{{-n INCREMENT} | PRIORITY} [[-p | -g | -u] ID...]"
2913#define renice_full_usage \ 2923#define renice_full_usage \
2914 "Change priority of running processes" \ 2924 "Change priority of running processes" \
2915 "\n\nOptions:\n" \ 2925 "\n\nOptions:\n" \
@@ -3141,7 +3151,7 @@ USE_FEATURE_RUN_PARTS_FANCY("\n -l Prints names of all matching files even when
3141 "\n -W Display warnings about entries that had no matching files" 3151 "\n -W Display warnings about entries that had no matching files"
3142 3152
3143#define setkeycodes_trivial_usage \ 3153#define setkeycodes_trivial_usage \
3144 "SCANCODE KEYCODE ..." 3154 "SCANCODE KEYCODE..."
3145#define setkeycodes_full_usage \ 3155#define setkeycodes_full_usage \
3146 "Set entries into the kernel's scancode-to-keycode map,\n" \ 3156 "Set entries into the kernel's scancode-to-keycode map,\n" \
3147 "allowing unusual keyboards to generate usable keycodes.\n\n" \ 3157 "allowing unusual keyboards to generate usable keycodes.\n\n" \
@@ -3162,7 +3172,7 @@ USE_FEATURE_RUN_PARTS_FANCY("\n -l Prints names of all matching files even when
3162 "Change boolean setting" 3172 "Change boolean setting"
3163 3173
3164#define setsid_trivial_usage \ 3174#define setsid_trivial_usage \
3165 "program [arg ...]" 3175 "program [arg...]"
3166#define setsid_full_usage \ 3176#define setsid_full_usage \
3167 "Run any program in a new session by calling setsid() before\n" \ 3177 "Run any program in a new session by calling setsid() before\n" \
3168 "exec'ing the rest of its arguments. See setsid(2) for details." 3178 "exec'ing the rest of its arguments. See setsid(2) for details."
@@ -3390,7 +3400,7 @@ USE_FEATURE_RUN_PARTS_FANCY("\n -l Prints names of all matching files even when
3390 ) 3400 )
3391 3401
3392#define strings_trivial_usage \ 3402#define strings_trivial_usage \
3393 "[-afo] [-n length] [file ...]" 3403 "[-afo] [-n length] [file...]"
3394#define strings_full_usage \ 3404#define strings_full_usage \
3395 "Display printable strings in a binary file" \ 3405 "Display printable strings in a binary file" \
3396 "\n\nOptions:" \ 3406 "\n\nOptions:" \
@@ -3495,8 +3505,8 @@ USE_FEATURE_RUN_PARTS_FANCY("\n -l Prints names of all matching files even when
3495 " -a Display all values\n" \ 3505 " -a Display all values\n" \
3496 " -A Display all values in table form" 3506 " -A Display all values in table form"
3497#define sysctl_example_usage \ 3507#define sysctl_example_usage \
3498 "sysctl [-n] variable ...\n" \ 3508 "sysctl [-n] variable...\n" \
3499 "sysctl [-n] -w variable=value ...\n" \ 3509 "sysctl [-n] -w variable=value...\n" \
3500 "sysctl [-n] -a\n" \ 3510 "sysctl [-n] -a\n" \
3501 "sysctl [-n] -p file (default /etc/sysctl.conf)\n" \ 3511 "sysctl [-n] -p file (default /etc/sysctl.conf)\n" \
3502 "sysctl [-n] -A\n" 3512 "sysctl [-n] -A\n"
@@ -3553,7 +3563,7 @@ USE_FEATURE_RUN_PARTS_FANCY("\n -l Prints names of all matching files even when
3553 USE_FEATURE_TAR_BZIP2("j") USE_FEATURE_TAR_LZMA("a") \ 3563 USE_FEATURE_TAR_BZIP2("j") USE_FEATURE_TAR_LZMA("a") \
3554 USE_FEATURE_TAR_COMPRESS("Z") "xtvO] " \ 3564 USE_FEATURE_TAR_COMPRESS("Z") "xtvO] " \
3555 USE_FEATURE_TAR_FROM("[-X FILE] ") \ 3565 USE_FEATURE_TAR_FROM("[-X FILE] ") \
3556 "[-f TARFILE] [-C DIR] [FILE(s)] ..." 3566 "[-f TARFILE] [-C DIR] [FILE(s)]..."
3557#define tar_full_usage \ 3567#define tar_full_usage \
3558 "Create, extract, or list files from a tar file" \ 3568 "Create, extract, or list files from a tar file" \
3559 "\n\nOptions:\n" \ 3569 "\n\nOptions:\n" \
@@ -3737,7 +3747,7 @@ USE_FEATURE_RUN_PARTS_FANCY("\n -l Prints names of all matching files even when
3737 "and show the status for however many processes will fit on the screen." 3747 "and show the status for however many processes will fit on the screen."
3738 3748
3739#define touch_trivial_usage \ 3749#define touch_trivial_usage \
3740 "[-c] FILE [FILE ...]" 3750 "[-c] FILE [FILE...]"
3741#define touch_full_usage \ 3751#define touch_full_usage \
3742 "Update the last-modified date on the given FILE[s]" \ 3752 "Update the last-modified date on the given FILE[s]" \
3743 "\n\nOptions:\n" \ 3753 "\n\nOptions:\n" \
@@ -4011,7 +4021,7 @@ USE_FEATURE_RUN_PARTS_FANCY("\n -l Prints names of all matching files even when
4011 "$\n" 4021 "$\n"
4012 4022
4013#define vconfig_trivial_usage \ 4023#define vconfig_trivial_usage \
4014 "COMMAND [OPTIONS] ..." 4024 "COMMAND [OPTIONS]..."
4015#define vconfig_full_usage \ 4025#define vconfig_full_usage \
4016 "Create and remove virtual ethernet devices" \ 4026 "Create and remove virtual ethernet devices" \
4017 "\n\nOptions:\n" \ 4027 "\n\nOptions:\n" \
@@ -4094,7 +4104,7 @@ USE_FEATURE_RUN_PARTS_FANCY("\n -l Prints names of all matching files even when
4094 " -Y Use proxy ('on' or 'off')" 4104 " -Y Use proxy ('on' or 'off')"
4095 4105
4096#define which_trivial_usage \ 4106#define which_trivial_usage \
4097 "[COMMAND ...]" 4107 "[COMMAND...]"
4098#define which_full_usage \ 4108#define which_full_usage \
4099 "Locate a COMMAND" 4109 "Locate a COMMAND"
4100#define which_example_usage \ 4110#define which_example_usage \