[BusyBox] [patch] added -x switch to du.c

Edward Betts edward at debian.org
Fri Mar 22 05:55:04 UTC 2002


--- fileutils/du.c.was	Thu Mar 21 01:26:38 2002
+++ fileutils/du.c	Thu Mar 21 01:32:35 2002
@@ -4,6 +4,7 @@
  *
  * Copyright (C) 1999,2000,2001 by Lineo, inc. and John Beppu
  * Copyright (C) 1999,2000,2001 by John Beppu <beppu at codepoet.org>
+ * Copyright (C) 2002  Edward Betts <edward at debian.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -40,6 +41,8 @@
 
 static int du_depth = 0;
 static int count_hardlinks = 0;
+static int one_file_system = 0;
+static dev_t dir_dev = 0;
 
 static Display *print;
 
@@ -69,6 +72,10 @@
 		perror_msg("%s", filename);
 		return 0;
 	}
+	if (du_depth == 0)
+		dir_dev = statbuf.st_dev;
+	else if (one_file_system && dir_dev != statbuf.st_dev)
+		return 0;
 
 	du_depth++;
 	sum = (statbuf.st_blocks >> 1);
@@ -133,7 +140,7 @@
 	print = print_normal;
 
 	/* parse argv[] */
-	while ((c = getopt(argc, argv, "sl"
+	while ((c = getopt(argc, argv, "slx"
 #ifdef CONFIG_FEATURE_HUMAN_READABLE
 "hm"
 #endif
@@ -144,6 +151,9 @@
 					break;
 			case 'l':
 					count_hardlinks = 1;
+					break;
+			case 'x':
+					one_file_system = 1;
 					break;
 #ifdef CONFIG_FEATURE_HUMAN_READABLE
 			case 'h': disp_hr = 0;        break;

-- 
The enemy's gate is down
http://people.debian.org/~edward/



More information about the busybox mailing list