bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Support in du for showing both apparent and on-disk size and


From: Luca Barbieri
Subject: Re: [PATCH] Support in du for showing both apparent and on-disk size and the ratio between them
Date: Thu, 22 Feb 2007 20:52:03 +0100

On Thu, 2007-02-22 at 17:54 +0000, James Youngman wrote:
> On 1/31/07, Luca Barbieri <address@hidden> wrote:
> > This patch allows to display simultaneously both the disk usage and
> > apparent size and also allows to display the "completeness" (or
> > "nonsparsity") of file, which is the ratio of the disk usage to the
> > apparent size.
> 
> For what it's worth, findutils-4.3 in CVS implements a similar feature:
> 
> static double
> file_sparseness(const struct stat *p)
> {
>   if (0 == p->st_size)
>     {
>       if (0 == p->st_blocks)
>         return 1.0;
>       else
>         return p->st_blocks < 0 ? -HUGE_VAL : HUGE_VAL;
>     }
>   else
>     {
>       double blklen = file_blocksize(p) * (double)p->st_blocks;
>       return blklen / p->st_size;
>     }
> }
> 
> 
> > For instance, this is useful when dealing with software that download
> > files by creating sparse files and filling them: the "completeness" then
> > is approximately the progress of the download.
> 
> Personally, I don't like the name "completeness" very much; it
> communicates nothing much to me.
> 
> James.

The algorithm in my patch should be the same, even though I think it
doesn't check for division by zero and negative st_blocks: feel free to
add those checks.

As for the name, "sparseness" seems wrong or would require reversing the
ratio (a user would expect a file with maximum "sparseness" to be as
sparse as possible and thus not take up any disk space, which is not the
case with file_sparseness() or my patch).

Perhaps "density" could be the proper name since "dense" is the opposite
of "sparse", even though "density" is not customarily used when dealing
with files.

Other options could be "disk/device/space/block usage ratio" or
"fullness".

Regards,
Luca Barbieri






reply via email to

[Prev in Thread] Current Thread [Next in Thread]