du -A / -B options [Re: zfs quota question]

Giorgos Keramidas keramida at ceid.upatras.gr
Tue Nov 4 18:55:12 PST 2008


On Wed, 5 Nov 2008 03:39:51 +0100, Max Laier <max at love2party.net> wrote:
>> That looks nice!  With a small fix (``how _much_ space'') I like the
>> idea a lot :)
>>
>> The patch fails to apply on a recent /head snapshot of du though:
> ...
>> Can you please refresh and repost it?
>
> Hum ... are you sure your snapshot is up to date?  I did some style(9)
> cleanup in r184654/6 that you might not have yet.  Anyways ... here is
> a diff with those revisions included.

Ah, that's it then.  I ran 'svn up' at the change right *before* the
HPS-USB commit and the latest du stuff was missing.  Thanks :)

The patch works fine here.  I only had to make a tiny change, to avoid a
core dump when the -B blocksize is invalid as an integer and it caused a
division by zero in fts:

$ ./du -B abcde
Floating point exception: 8 (core dumped)

Here's a diff of all the local changes I made:

%%%
diff -r a3da3ebb57ab usr.bin/du/du.1
--- a/usr.bin/du/du.1	Wed Nov 05 04:47:07 2008 +0200
+++ b/usr.bin/du/du.1	Wed Nov 05 04:53:28 2008 +0200
@@ -72,7 +72,7 @@
 .Fl k, m
 options or setting
 .Ev BLOCKSIZE
-and gives an estimate of how many space the examined file hierachy would
+and gives an estimate of how much space the examined file hierachy would
 require on a filesystem with the given
 .Ar blocksize .
 Unless in
@@ -160,7 +160,7 @@
 or
 .Fl h
 options are not specified, the block counts will be displayed in units of
-that size block.
+that block size.
 If
 .Ev BLOCKSIZE
 is not set, and the
diff -r a3da3ebb57ab usr.bin/du/du.c
--- a/usr.bin/du/du.c	Wed Nov 05 04:47:07 2008 +0200
+++ b/usr.bin/du/du.c	Wed Nov 05 04:53:28 2008 +0200
@@ -117,7 +117,7 @@
 		case 'B':
 			errno = 0;
 			cblocksize = atoi(optarg);
-			if (errno == ERANGE || cblocksize < 0) {
+			if (errno == ERANGE || cblocksize <= 0) {
 				warnx("invalid argument to option B: %s",
 				    optarg);
 				usage();
%%%



More information about the freebsd-hackers mailing list