[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
PATCH for a minimum size enhancement to du
From: |
David J Craigon |
Subject: |
PATCH for a minimum size enhancement to du |
Date: |
Mon, 21 Mar 2005 12:30:57 +0000 |
User-agent: |
Mozilla Thunderbird 0.9 (X11/20041127) |
Hi there,
One of the things I like doing with du is going through directories
when I have run out of disk space, trying to find out what is taking up
of the room. I use max-depth to try and filter the directories, but this
tends to have the problem that I either end up with a few, big
directories, which I then need to run du on again, or many small
directories which are hard to read. Wouldn't it be great if you could do
du --min-size=3G and find all directories bigger than 3G?
Patch begins....
--- coreutils/src/du.c.old 2005-03-18 17:43:15.000000000 +0000
+++ coreutils/src/du.c 2005-03-21 12:24:06.172951172 +0000
@@ -113,6 +113,11 @@
/* Grand total size of all args, in bytes. */
static uintmax_t tot_size = 0;
+/* Minimum size of sum in bytes to display */
+
+static uintmax_t min_size=0;
+
+
#define IS_DIR_TYPE(Type) \
((Type) == FTS_DP \
|| (Type) == FTS_DNR)
@@ -125,7 +130,8 @@
EXCLUDE_OPTION,
FILES0_FROM_OPTION,
HUMAN_SI_OPTION,
- MAX_DEPTH_OPTION
+ MAX_DEPTH_OPTION,
+ MIN_SIZE_OPTION
};
static struct option const long_options[] =
@@ -144,6 +150,7 @@
{"si", no_argument, NULL, HUMAN_SI_OPTION},
{"kilobytes", no_argument, NULL, 'k'}, /* long form is obsolescent */
{"max-depth", required_argument, NULL, MAX_DEPTH_OPTION},
+ {"min-size", required_argument, NULL, MIN_SIZE_OPTION},
{"null", no_argument, NULL, '0'},
{"megabytes", no_argument, NULL, 'm'}, /* obsolescent */
{"no-dereference", no_argument, NULL, 'P'},
@@ -211,6 +218,8 @@
only if it is N or fewer levels below the
command\n\
line argument; --max-depth=0 is the same as\n\
--summarize\n\
+ --min-size=SIZE allows a minimum cumulative size a
directory/file must\n\
+ be before it is displayed\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
@@ -465,8 +474,11 @@
if (!print)
return ok;
- if ((IS_DIR_TYPE (ent->fts_info) && level <= max_depth)
+ if (
+ ((IS_DIR_TYPE (ent->fts_info) && level <= max_depth)
|| ((opt_all && level <= max_depth) || level == 0))
+ && (size_to_print>min_size)
+ )
{
print_only_size (size_to_print);
fputc ('\t', stdout);
@@ -627,6 +639,10 @@
}
break;
+ case MIN_SIZE_OPTION: /* --min-size=SIZE */
+ human_output_opts = human_options (optarg, true, &min_size);
+ break;
+
case 'm': /* obsolescent: FIXME: remove in 2005. */
human_output_opts = 0;
output_block_size = 1024 * 1024;
Thanks,
David
P.S. even if you don't like the patch, I think the idea is a good one.
This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
- PATCH for a minimum size enhancement to du,
David J Craigon <=