Standards / Extensions | C or C++ | Dependencies |
---|---|---|
z/OS® UNIX | both |
#define _OPEN_SOURCE 2
#include <sys/statvfs.h>
int w_statvfs(const char *filesystem, struct statvfs *buffer, size_t buflen);
If the buffer length is zero, only the return value is returned. A process can use a length of zero to detect if a file system exists or not.
If successful, w_statvfs() returns the length of the data in the buffer.
#define _OPEN_SOURCE 2
#include <sys/statvfs.h>
#include <stdio.h>
main() {
char fs[]="POSIX.ROOT.FS";
struct statvfs buf;
if (w_statvfs(fs, &buf, sizeof(buf)) == -1)
perror("w_statvfs() error");
else {
printf("each block in %s is %d bytes big\n", fs,
buf.f_bsize);
printf("there are %d blocks available out of a total of %d\n",
buf.f_bavail, buf.f_blocks);
printf("in bytes, that's %.0f bytes free out of a total of %.0f\n",
((double)buf.f_bavail * buf.f_bsize),
((double)buf.f_blocks * buf.f_bsize));
}
}
each block in POSIX.ROOT.FS is 4096 bytes big
there are 2089 blocks available out of a total of 2400
in bytes, that's 8556544 bytes free out of a total of 9830400