df strange behavior

This is a discussion on df strange behavior within the BSD forums, part of the Other OS category; Hi there, Here is a copy of my terminal output: $ df -h Filesystem Size Used Avail Capacity Mounted on /dev/wd0a 78.5M 40.9M 33.7M 55% / /dev/wd0g 30.0G 19.7G 8.8G ...

Go Back   Unix Linux Forum > Unix > Other OS > BSD

FixUnix.com - Unix Linux Forums

Unix Content Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-21-2008, 09:15 AM
Default df strange behavior

Hi there,

Here is a copy of my terminal output:
$ df -h
Filesystem Size Used Avail
Capacity Mounted on
/dev/wd0a 78.5M 40.9M 33.7M
55% /
/dev/wd0g 30.0G 19.7G 8.8G
69% /home
/dev/wd0d 196M 46.0K 186M
0% /tmp
/dev/wd0e 5.9G 685M 4.9G
12% /usr
/dev/wd0f 492M 387M 80.0M
83% /var
172.16.0.50:/VOLUME1/PUB/ 1.4T 348G -1011G 25% /var/
www/doc

The number on the last line are correct except for the minus sign.
Anyone knows why?

Thanks
Reply With Quote
  #2  
Old 08-22-2008, 07:16 AM
Default Re: df strange behavior

Op Thu, 21 Aug 2008 15:15:49 +0200 schreef fnadeau :
> Hi there,
>
> Here is a copy of my terminal output:
> $ df -h
> Filesystem Size Used Avail Capacity Mounted on
> /dev/wd0a 78.5M 40.9M 33.7M 55% /
> /dev/wd0g 30.0G 19.7G 8.8G 69% /home
> /dev/wd0d 196M 46.0K 186M 0% /tmp
> /dev/wd0e 5.9G 685M 4.9G 12% /usr
> /dev/wd0f 492M 387M 80.0M 83% /var
> 172.16.0.50:/VOLUME1/PUB/ 1.4T 348G -1011G 25% /var/www/doc
>
> The number on the last line are correct except for the minus sign.
> Anyone knows why?


Look at /usr/src/bin/df/df.c:
void
prthuman(struct statfs *sfsp, unsigned long used)
{
prthumanval((long long)sfsp->f_blocks * (long long)sfsp->f_bsize);
prthumanval((long long)used * (long long)sfsp->f_bsize);
prthumanval((long long)sfsp->f_bavail * (long long)sfsp->f_bsize);
}

Now look at /usr/include/sys/mount.h:
struct statfs {
u_int32_t f_flags;
int32_t f_bsize;
u_int32_t f_iosize;
u_int32_t f_blocks;
u_int32_t f_bfree;
int32_t f_bavail;
u_int32_t f_files;
u_int32_t f_ffree;
fsid_t f_fsid;
uid_t f_owner;
u_int32_t f_syncwrites;
u_int32_t f_asyncwrites;
u_int32_t f_ctime;
u_int32_t f_spare[3];
char f_fstypename[MFSNAMELEN];
char f_mntonname[MNAMELEN];
char f_mntfromname[MNAMELEN];
union mount_info mount_info;
};

Assuming that a filesystem block on 72.16.0.50:/VOLUME1/PUB/ is 512 bytes,
then:
f_blocks ~= 0xB3333333
f_bavail ~= 0xC0D00000

Which means that f_bavail is negative. It is signed, because the system
allocates an almost-overflow zone of (CMIIW) 10%. Also, the real disk
size is probably larger than 1.4T.

So, either make bigger blocks or modify the system to use a struct statfs
with 64-bit values.

/Boudewijn


--
Gemaakt met Opera's revolutionaire e-mailprogramma:
http://www.opera.com/mail/
Reply With Quote
  #3  
Old 08-24-2008, 11:43 AM
Default Re: df strange behavior

Hi!

Boudewijn Dijkstra wrote:
>Op Thu, 21 Aug 2008 15:15:49 +0200 schreef fnadeau :
>> Here is a copy of my terminal output:
>> $ df -h
>> Filesystem Size Used Avail Capacity Mounted on
>> /dev/wd0a 78.5M 40.9M 33.7M 55% /
>> /dev/wd0g 30.0G 19.7G 8.8G 69% /home
>> /dev/wd0d 196M 46.0K 186M 0% /tmp
>> /dev/wd0e 5.9G 685M 4.9G 12% /usr
>> /dev/wd0f 492M 387M 80.0M 83% /var
>> 172.16.0.50:/VOLUME1/PUB/ 1.4T 348G -1011G 25% /var/www/doc


>Look at /usr/src/bin/df/df.c:
>void
>prthuman(struct statfs *sfsp, unsigned long used)
>{
> prthumanval((long long)sfsp->f_blocks * (long long)sfsp->f_bsize);
> prthumanval((long long)used * (long long)sfsp->f_bsize);
> prthumanval((long long)sfsp->f_bavail * (long long)sfsp->f_bsize);
>}


>Now look at /usr/include/sys/mount.h:
>struct statfs {
> u_int32_t f_flags;
> int32_t f_bsize;
> u_int32_t f_iosize;
> u_int32_t f_blocks;
> u_int32_t f_bfree;
> int32_t f_bavail;
> u_int32_t f_files;
> u_int32_t f_ffree;
> fsid_t f_fsid;
> uid_t f_owner;
> u_int32_t f_syncwrites;
> u_int32_t f_asyncwrites;
> u_int32_t f_ctime;
> u_int32_t f_spare[3];
> char f_fstypename[MFSNAMELEN];
> char f_mntonname[MNAMELEN];
> char f_mntfromname[MNAMELEN];
> union mount_info mount_info;
>};


>Assuming that a filesystem block on 72.16.0.50:/VOLUME1/PUB/ is 512 bytes,
>then:
>f_blocks ~= 0xB3333333
>f_bavail ~= 0xC0D00000


>Which means that f_bavail is negative. It is signed, because the system
>allocates an almost-overflow zone of (CMIIW) 10%. Also, the real disk
>size is probably larger than 1.4T.


>So, either make bigger blocks or modify the system to use a struct statfs
>with 64-bit values.


No need to modify the system yourself. It *has* been modified
in-between. Either wait for the upcoming release or use -current
(snapshots).

>/Boudewijn


Kind regards,

Hannah.
Reply With Quote
Reply

Thread Tools


All times are GMT -5. The time now is 02:24 AM.

In an effort to better serve ads to our visitors, cookies are used on Fixunix.com. For more information, check out our Privacy Policy.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Ad Management by RedTyger