tech-misc archive

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

du -m is off




To: tech-misc%netbsd.org@localhost

Subject: du -m is off

From: "Jeremy C. Reed" <reed%reedmedia.net@localhost>

Date: Sat, 22 Mar 2008 10:00:00 -0500 (CDT)


I noticed that a file of 10485760 bytes would be listed as 11MB by du -m. 
The -h "humanize" is correct and lists as 10MB.

du.c uses:

                (void)printf("%lld\t%s\n",
                    (long long)howmany(blocks, (int64_t)blocksize),

This works better for me:

printf("%ld\n", (long)((int64_t)blocks / blocksize));

But that doesn't help for files less than a megabyte which will then be 
displayed as a zero.

As another example, a file of 3372684 bytes is 3.21644MB. du -m would 
round up to 4. While my printf above prints "3".

I am not sure what correct behaviour should be.

Either way, the du man page should document about this as it is 
misleading.



Follow-Ups:

Re: du -m is off
From: Greg A. Woods; Planix, Inc.




Prev by Date: Re: DEBUG work for fortune?

Next by Date: Re: du -m is off

Previous by Thread: DEBUG work for fortune?

Next by Thread: Re: du -m is off

Indexes:

reverse Date

reverse Thread

Old Index



Home | Main Index | Thread Index | Old Index