Package: coreutils
Version: 5.2.1-2
Severity: wishlist
Tags: patch

I send a patch to add path exclude option to du.
I think it could be useful to more people.

MOTIVATION:

I use xdiskusage to view disk space usage.
xdiskusage uses du to calculate file and dir sizes.
When I want to make a backup of my system I use this tool to inspect where is 
my disk space going and how much it would size.
I got some big dirs that I want to exclude from reports (media files, backup 
files...) because make more diffult to view how much disk space uses the real 
data.
I could no use the --exclude option because it exclude files by basename, and 
not by path.
So I made this patch.

txemi.


-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.11-1-686
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)

Versions of packages coreutils depends on:
ii  libacl1                     2.2.29-1.0.1 Access control list shared library
ii  libc6                       2.3.2.ds1-22 GNU C Library: Shared libraries an

-- no debconf information
--- du.c.orig	2005-06-11 19:41:53.000000000 +0200
+++ du.c	2005-06-11 19:41:53.000000000 +0200
@@ -108,6 +108,7 @@
 
 /* File name patterns to exclude.  */
 static struct exclude *exclude;
+static struct exclude *exclude_path;
 
 /* Grand total size of all args, in bytes. */
 static uintmax_t tot_size = 0;
@@ -126,7 +127,8 @@
   APPARENT_SIZE_OPTION = CHAR_MAX + 1,
   EXCLUDE_OPTION,
   HUMAN_SI_OPTION,
-  MAX_DEPTH_OPTION
+  MAX_DEPTH_OPTION,
+  EXCLUDE_PATH_OPTION
 };
 
 static struct option const long_options[] =
@@ -139,6 +141,7 @@
   {"dereference", no_argument, NULL, 'L'},
   {"dereference-args", no_argument, NULL, 'D'},
   {"exclude", required_argument, 0, EXCLUDE_OPTION},
+  {"exclude-path", required_argument, 0, EXCLUDE_PATH_OPTION},
   {"exclude-from", required_argument, 0, 'X'},
   {"human-readable", no_argument, NULL, 'h'},
   {"si", no_argument, 0, HUMAN_SI_OPTION},
@@ -202,6 +205,7 @@
   -x, --one-file-system  skip directories on different filesystems\n\
   -X FILE, --exclude-from=FILE  Exclude files that match any pattern in FILE.\n\
       --exclude=PATTERN Exclude files that match PATTERN.\n\
+      --exclude-path=PATTERN Exclude file paths that match PATTERN.\n\
       --max-depth=N     print the total for a directory (or file, with --all)\n\
                           only if it is N or fewer levels below the command\n\
                           line argument;  --max-depth=0 is the same as\n\
@@ -331,7 +335,8 @@
   int skip;
 
   /* If necessary, set FTS_SKIP before returning.  */
-  skip = excluded_filename (exclude, ent->fts_name);
+  skip = excluded_filename (exclude, ent->fts_name)
+  	||excluded_filename (exclude_path, ent->fts_path);
   if (skip)
     fts_set (fts, ent, FTS_SKIP);
 
@@ -517,6 +522,7 @@
       process_file (fts, ent);
     }
 
+
   /* Ignore failure, since the only way it can do so is in failing to
      return to the original directory, and since we're about to exit,
      that doesn't matter.  */
@@ -555,6 +561,7 @@
   atexit (close_stdout);
 
   exclude = new_exclude ();
+  exclude_path = new_exclude ();
 
   human_output_opts = human_options (getenv ("DU_BLOCK_SIZE"), false,
 				     &output_block_size);
@@ -681,6 +688,10 @@
 	  add_exclude (exclude, optarg, EXCLUDE_WILDCARDS);
 	  break;
 
+	case EXCLUDE_PATH_OPTION:
+	  add_exclude (exclude_path, optarg, EXCLUDE_WILDCARDS);
+	  break;
+
 	case_GETOPT_HELP_CHAR;
 
 	case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);

Reply via email to