From owner-freebsd-hackers@FreeBSD.ORG Fri Mar 2 16:39:44 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 17D38106566B for ; Fri, 2 Mar 2012 16:39:44 +0000 (UTC) (envelope-from jhellenthal@dataix.net) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id C08DF8FC08 for ; Fri, 2 Mar 2012 16:39:43 +0000 (UTC) Received: by iahk25 with SMTP id k25so3265913iah.13 for ; Fri, 02 Mar 2012 08:39:43 -0800 (PST) Received-SPF: pass (google.com: domain of jhellenthal@dataix.net designates 10.42.177.133 as permitted sender) client-ip=10.42.177.133; Authentication-Results: mr.google.com; spf=pass (google.com: domain of jhellenthal@dataix.net designates 10.42.177.133 as permitted sender) smtp.mail=jhellenthal@dataix.net; dkim=pass header.i=jhellenthal@dataix.net Received: from mr.google.com ([10.42.177.133]) by 10.42.177.133 with SMTP id bi5mr8395586icb.40.1330706383367 (num_hops = 1); Fri, 02 Mar 2012 08:39:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dataix.net; s=rsa; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to; bh=AvsIpWHhAd0vDPyTDXfVepKhZoaOED0cCDWvPGsUicg=; b=AmAGm3qDZhaHTpqeBoLpJNXdXqlX+5J2U4NY8px8eF2sHT87FaqSZ+GPKIwdutRB2W j4BjClxBzin2jn4slARFtxzR8w/FQZ4VPbFqtwYTq6pEAdy7omKMz18iwQ031q7RyG62 lw7dR8bAsYQuDhPX+WHDjuF/m9vNFv9budkeE= Received: by 10.42.177.133 with SMTP id bi5mr6902941icb.40.1330706383314; Fri, 02 Mar 2012 08:39:43 -0800 (PST) Received: from DataIX.net ([99.181.142.81]) by mx.google.com with ESMTPS id cv10sm2270713igc.13.2012.03.02.08.39.42 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 02 Mar 2012 08:39:42 -0800 (PST) Received: from DataIX.net (localhost [127.0.0.1]) by DataIX.net (8.14.5/8.14.5) with ESMTP id q22GddIr041962 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 2 Mar 2012 11:39:39 -0500 (EST) (envelope-from jhellenthal@DataIX.net) Received: (from jhellenthal@localhost) by DataIX.net (8.14.5/8.14.5/Submit) id q22Gddm0041520; Fri, 2 Mar 2012 11:39:39 -0500 (EST) (envelope-from jhellenthal@DataIX.net) Date: Fri, 2 Mar 2012 11:39:39 -0500 From: Jason Hellenthal To: Alexander Best Message-ID: <20120302163939.GA284@DataIX.net> References: <20120301233822.GA19709@freebsd.org> <20120302063659.GB31588@DataIX.net> <20120302103333.GA88008@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120302103333.GA88008@freebsd.org> X-Gm-Message-State: ALoCoQl/ausd/9j+rrSKqwy9DlAoRf1WDRdNSO0egsRoNMc2kdUVl8Dy1hgBWK56hsm+Y5am83f+ Cc: freebsd-hackers@freebsd.org Subject: Re: small change to du, so it will accepts unit suffixes for negative thresholds X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Mar 2012 16:39:44 -0000 On Fri, Mar 02, 2012 at 10:33:33AM +0000, Alexander Best wrote: > 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. > with locale being that of UTF-8 in an xterm I get the expected result from this. I would expect that locale of C would do the same. It seems that du(1) is not locale aware enough for calculating the sums and comparing them. I see 2,0k in your output where in mine it is 2.0 disbatch$ mkdir empty ; cd empty ; mkdir empty2 disbatch$ du -ht-1M 2.0k ./empty2 4.0k . disbatch$ du -t-1M 2 ./empty2 4 . disbatch$ locale LANG=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_COLLATE=C LC_TIME="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_ALL= This was done under /bin/sh 8-STABLE i386 as of the date of this message. -- ;s =;