Bruce Shaw wrote:

if (statvfs("/dev/dsk/c0t0d0s7",&vfs) == -1)

The first arg to statvfs is a directory or file, not a device.

printf("size = %d, blocks = %d free = %d\n",
>                    vfs.f_frsize, vfs.f_blocks, vfs.f_bfree, mt[n]);

gcc should complain about %d They should be %ld

This works for me:

==========================================================
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/statvfs.h>
char *mt[] = { "/", "/home", "/opt", "/usr", "/usr/OV", "/usr/src",
    "/usr/src/gnu", "/usr/src/misc", "/var", "/var/cdtemp", "/vmdisks",
    "/tmp", "/old", "/d", "/c", "/e", NULL
};
int main(int argc, char *argv[])
{
    int n;
    struct statvfs vfs;

    for (n = 0; mt[n]; n++) {
        if (statvfs(mt[n], &vfs) == -1)
            printf("partition lookup  failed%s\n", mt[n]);
        else {
            printf("size = %5ld, blocks = %7ld free = %7ld %s\n",
                   vfs.f_frsize, vfs.f_blocks, vfs.f_bfree, mt[n]);
        }                       /*end if */
    }                           /* end for */
    return 0;
}                               /* end vfs.c */
==========================================================

size =  1024, blocks =  508020 free =  191144 /
size =  4096, blocks =  714596 free =  286144 /home
size =  4096, blocks =  500932 free =  226343 /opt
size =  4096, blocks =  878968 free =  118357 /usr
size =  4096, blocks =  258022 free =  101117 /usr/OV
size =  4096, blocks =  476735 free =  350052 /usr/src
size =  4096, blocks =  516052 free =   35234 /usr/src/gnu
size =  4096, blocks =  516052 free =   35985 /usr/src/misc
size =  4096, blocks =  249958 free =  173429 /var
size =  4096, blocks =  516052 free =  279473 /var/cdtemp
size =  4096, blocks = 1332460 free =  281919 /vmdisks
size =  4096, blocks =  761796 free =  252723 /tmp
size =  4096, blocks = 2031782 free =  141666 /old
size =  4096, blocks =  654640 free =   69039 /d
size =  4096, blocks =  526128 free =   66424 /c
size = 32768, blocks =   32877 free =   22850 /e


-- There's no point in being grown up if you can't be childish sometimes. -- Dr. Who


------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ Net-snmp-coders mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to