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

Giorgos Keramidas keramida at freebsd.org
Sat Nov 1 17:46:58 PDT 2008


On Sat, 1 Nov 2008 21:14:42 +0100, Max Laier <max at love2party.net> wrote:
> Hi,
> a thread on freebsd-stable@ [1] about problems with du(1) and
> compressed zfs filesystems got me looking for a possible solution.
> Attached is a diff for du(1) that adds two new options:
>
>  -A to display the apparent size of the file instead of the used blocks.
>  -B bsize to specify a custom blocksize.  In particular one <512byte

That's nice :)

% Index: du.1
% ===================================================================
% --- du.1	(revision 184513)
% +++ du.1	(working copy)
% @@ -60,6 +61,14 @@
%  .Pp
%  The options are as follows:
%  .Bl -tag -width indent
% +.It Fl A
% +Display the apparent size instead of the diskusage.

'disk usage' should be two words here.

% +This can be helpful to find sparse files and when operating on
% +compressed volumes.

``This can be helpful when operating on sparse files or compressed
volumes'' maybe?  The fact that a difference between plain `du' and
`du -A' output may be a nice hack to find sparse files is a cool
side-effect, but that's not really the main driving force behind the
change, right? :)

% Index: du.c
% ===================================================================
% --- du.c	(revision 184513)
% +++ du.c	(working copy)
% @@ -86,27 +86,39 @@
%  	FTS		*fts;
%  	FTSENT		*p;
%  	off_t		savednumber = 0;
% -	long		blocksize;
% +	long		blocksize = 0;

savednumber is one of the existing style bugs.  We shouldn't copy it,
but initialize `blocksize' further down, near `depth = INT_MAX' and the
rest of the initializations.

> Thoughts?

FWIW, I like the new options :)



More information about the freebsd-hackers mailing list