svn commit: trunk/busybox/coreutils

vda at busybox.net vda at busybox.net
Thu Nov 15 09:02:13 UTC 2007


Author: vda
Date: 2007-11-15 01:02:12 -0800 (Thu, 15 Nov 2007)
New Revision: 20426

Log:
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



Modified:
   trunk/busybox/coreutils/df.c


Changeset:
Modified: trunk/busybox/coreutils/df.c
===================================================================
--- trunk/busybox/coreutils/df.c	2007-11-15 07:02:55 UTC (rev 20425)
+++ trunk/busybox/coreutils/df.c	2007-11-15 09:02:12 UTC (rev 20426)
@@ -46,18 +46,19 @@
 	const char *disp_units_hdr = "1k-blocks";
 
 	enum {
-		OPT_INODE = (ENABLE_FEATURE_HUMAN_READABLE ? (1 << 3) : (1 << 1))
+		OPT_ALL = (1 << 0),
+		OPT_INODE = (ENABLE_FEATURE_HUMAN_READABLE ? (1 << 4) : (1 << 2))
 		            * ENABLE_FEATURE_DF_INODE
 	};
 
 #if ENABLE_FEATURE_HUMAN_READABLE
 	opt_complementary = "h-km:k-hm:m-hk";
-	opt = getopt32(argv, "hmk" USE_FEATURE_DF_INODE("i"));
-	if (opt & 1) {
+	opt = getopt32(argv, "ahmk" USE_FEATURE_DF_INODE("i"));
+	if (opt & (1 << 1)) { // -h
 		df_disp_hr = 0;
 		disp_units_hdr = "     Size";
 	}
-	if (opt & 2) {
+	if (opt & (1 << 2)) { // -m
 		df_disp_hr = 1024*1024;
 		disp_units_hdr = "1M-blocks";
 	}
@@ -65,11 +66,11 @@
 		disp_units_hdr = "   Inodes";
 	}
 #else
-	opt = getopt32(argv, "k" USE_FEATURE_DF_INODE("i"));
+	opt = getopt32(argv, "ak" USE_FEATURE_DF_INODE("i"));
 #endif
 
-	printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
-			  "", disp_units_hdr);
+	printf("Filesystem           %-15sUsed Available Use%% Mounted on\n",
+			disp_units_hdr);
 
 	mount_table = NULL;
 	argv += optind;
@@ -112,7 +113,7 @@
 			goto SET_ERROR;
 		}
 
-		if ((s.f_blocks > 0) || !mount_table) {
+		if ((s.f_blocks > 0) || !mount_table || (opt & OPT_ALL)) {
 			if (opt & OPT_INODE) {
 				s.f_blocks = s.f_files;
 				s.f_bavail = s.f_bfree = s.f_ffree;
@@ -130,9 +131,13 @@
 						) / (blocks_used + s.f_bavail);
 			}
 
+#ifdef WHY_IT_SHOULD_BE_HIDDEN
 			if (strcmp(device, "rootfs") == 0) {
 				continue;
 			}
+#endif
+#ifdef WHY_WE_DO_IT_FOR_DEV_ROOT_ONLY
+/* ... and also this is the only user of find_block_device */
 			if (strcmp(device, "/dev/root") == 0) {
 				/* Adjusts device to be the real root device,
 				* or leaves device alone if it can't find it */
@@ -141,6 +146,7 @@
 					goto SET_ERROR;
 				}
 			}
+#endif
 
 			if (printf("\n%-20s" + 1, device) > 20)
 				    printf("\n%-20s", "");




More information about the busybox-cvs mailing list