- static const char hdr_1k[] = "1k-blocks"; /* default display is kilobytes */
- const char *disp_units_hdr = hdr_1k;
-
-#ifdef CONFIG_FEATURE_HUMAN_READABLE
- bb_opt_complementaly = "h-km:k-hm:m-hk";
- opt = bb_getopt_ulflags(argc, argv, "hmk");
- if(opt & 1) {
- df_disp_hr = 0;
- disp_units_hdr = " Size";
- }
- if(opt & 2) {
- df_disp_hr = MEGABYTE;
- disp_units_hdr = "1M-blocks";
+ static const char ignored_mounts[] ALIGN1 =
+ "rootfs\0";
+
+ enum {
+ OPT_KILO = (1 << 0),
+ OPT_POSIX = (1 << 1),
+ OPT_ALL = (1 << 2) * ENABLE_FEATURE_DF_FANCY,
+ OPT_INODE = (1 << 3) * ENABLE_FEATURE_DF_FANCY,
+ OPT_BSIZE = (1 << 4) * ENABLE_FEATURE_DF_FANCY,
+ OPT_HUMAN = (1 << 5) * ENABLE_FEATURE_HUMAN_READABLE,
+ OPT_MEGA = (1 << 6) * ENABLE_FEATURE_HUMAN_READABLE,
+ };
+ const char *disp_units_hdr = NULL;
+ char *chp;
+
+#if ENABLE_FEATURE_HUMAN_READABLE && ENABLE_FEATURE_DF_FANCY
+ opt_complementary = "k-mB:m-Bk:B-km";
+#elif ENABLE_FEATURE_HUMAN_READABLE
+ opt_complementary = "k-m:m-k";
+#endif
+ opt = getopt32(argv, "kP"
+ USE_FEATURE_DF_FANCY("aiB:")
+ USE_FEATURE_HUMAN_READABLE("hm")
+ USE_FEATURE_DF_FANCY(, &chp));
+ if (opt & OPT_MEGA)
+ df_disp_hr = 1024*1024;
+
+ if (opt & OPT_BSIZE)
+ df_disp_hr = xatoul_range(chp, 1, ULONG_MAX); /* disallow 0 */
+
+ /* From the manpage of df from coreutils-6.10:
+ Disk space is shown in 1K blocks by default, unless the environment
+ variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.
+ */
+ if (getenv("POSIXLY_CORRECT")) /* TODO - a new libbb function? */
+ df_disp_hr = 512;
+
+ if (opt & OPT_HUMAN) {
+ df_disp_hr = 0;
+ disp_units_hdr = " Size";