small change to du, so it will accepts unit suffixes for negative thresholds

Alexander Best arundel at freebsd.org
Fri Mar 2 10:33:33 UTC 2012


On Fri Mar  2 12, Jason Hellenthal wrote:
> 
> 
> On Thu, Mar 01, 2012 at 11:38:22PM +0000, Alexander Best wrote:
> > hi there,
> > 
> > i just noticed that du will not accepts something like the following:
> > 
> > du -t-500M
> > 
> > whereas
> > 
> > du -t500M
> > 
> > will work. i've attached a patch, which makes unit suffixes in connection with
> > negative thresholds possible.
> > 
> 
> I don't get it. I just ran both instances of what you have above without
> your patch on 8-STABLE i386 and both work as intended. Are you seeing
> something I am not ?

you are right. there seems to have been a du change between 8-STABLE and HEAD,
or maybe even in expand_number().

when i run 'du -t-500M /' on HEAD i get:

du: invalid threshold: -500M
usage: du [-Aclnx] [-H | -L | -P] [-h | -k | -m ] [-a | -s | -d depth] [-B blocksize] [-I mask] [-t threshold] [file ...]

... i'll investigate some more. i also found that on 8-STABLE du isn't working
properly in all cases. try the following:

mkdir empty ; cd empty ; mkdir empty2

running 'du -t-1M' should report empty2, but it doesn't. running 'du -t-2M'
does. according to 'ls -la' an empty directory is 4096 byte. so 'du -t-4097'
should report the empty dir; however it doesn't. du seems to quite broken when
it comes to the -t option. have a look at the following:

mkdir empty3; cd empty3; du -h -t1M

reports

2,0k	.

that's completely wrong, since i instructed du to only display entries > 1 megabyte.

cheers.
alex

> 
> -- 
> ;s =;


More information about the freebsd-hackers mailing list