Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Mar 2012 10:33:33 +0000
From:      Alexander Best <arundel@freebsd.org>
To:        Jason Hellenthal <jhellenthal@dataix.net>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: small change to du, so it will accepts unit suffixes for negative thresholds
Message-ID:  <20120302103333.GA88008@freebsd.org>
In-Reply-To: <20120302063659.GB31588@DataIX.net>
References:  <20120301233822.GA19709@freebsd.org> <20120302063659.GB31588@DataIX.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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 =;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120302103333.GA88008>