df strange behavior - BSD

This is a discussion on df strange behavior - BSD ; 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 ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: df strange behavior

  1. 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

  2. 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/

  3. 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 to Thread