From: Eric Andersen Date: Sat, 6 Apr 2002 23:16:44 +0000 (-0000) Subject: Patch from Edward Betts to add -x switch to du.c X-Git-Tag: 0_60_3~39 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=265d229427dc35456dec37215142a3b0e06903df;p=oweals%2Fbusybox.git Patch from Edward Betts to add -x switch to du.c --- diff --git a/coreutils/du.c b/coreutils/du.c index e34a7f46f..ed9f7156a 100644 --- a/coreutils/du.c +++ b/coreutils/du.c @@ -4,6 +4,7 @@ * * Copyright (C) 1999,2000,2001 by Lineo, inc. and John Beppu * Copyright (C) 1999,2000,2001 by John Beppu + * Copyright (C) 2002 Edward Betts * * 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 @@ typedef void (Display) (long, char *); 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 @@ static long du(char *filename) 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 @@ int du_main(int argc, char **argv) print = print_normal; /* parse argv[] */ - while ((c = getopt(argc, argv, "sl" + while ((c = getopt(argc, argv, "slx" #ifdef CONFIG_FEATURE_HUMAN_READABLE "hm" #endif @@ -145,6 +152,9 @@ int du_main(int argc, char **argv) case 'l': count_hardlinks = 1; break; + case 'x': + one_file_system = 1; + break; #ifdef CONFIG_FEATURE_HUMAN_READABLE case 'h': disp_hr = 0; break; case 'm': disp_hr = MEGABYTE; break; @@ -174,7 +184,7 @@ int du_main(int argc, char **argv) return status; } -/* $Id: du.c,v 1.52 2001/12/17 15:26:25 kraai Exp $ */ +/* $Id: du.c,v 1.53 2002/04/06 23:16:44 andersen Exp $ */ /* Local Variables: c-file-style: "linux" diff --git a/include/usage.h b/include/usage.h index e7de6f53f..98a9f32cd 100644 --- a/include/usage.h +++ b/include/usage.h @@ -343,7 +343,7 @@ "$ dpkg-deb -X ./busybox_0.48-1_i386.deb /tmp\n" #define du_trivial_usage \ - "[-ls" USAGE_HUMAN_READABLE("hm") USAGE_NOT_HUMAN_READABLE("") "k] [FILE]..." + "[-lsx" USAGE_HUMAN_READABLE("hm") USAGE_NOT_HUMAN_READABLE("") "k] [FILE]..." #define du_full_usage \ "Summarizes disk space used for each FILE and/or directory.\n" \ "Disk space is printed in units of 1024 bytes.\n\n" \ @@ -353,6 +353,7 @@ USAGE_HUMAN_READABLE( \ "\n\t-h\tprint sizes in human readable format (e.g., 1K 243M 2G )\n" \ "\t-m\tprint sizes in megabytes\n" \ + "\t-x\tskip directories on different filesystems\n" \ "\t-k\tprint sizes in kilobytes(default)") USAGE_NOT_HUMAN_READABLE( \ "\n\t-k\tprint sizes in kilobytes(compatibility)") #define du_example_usage \