Standards / Extensions | C or C++ | Dependencies |
---|---|---|
z/OS® UNIX | both |
#include <sys/statfs.h>
int w_statfs(const char *filesystem, struct w_statfs *statbuf, size_t length);
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.
Special behavior for XPG4.2: w_statfs() is replaced by w_statvfs().
If successful, w_statfs() returns the length of the data in the buffer.
⁄* CELEBW36 *⁄
#define _OPEN_SYS
#include <sys⁄statfs.h>
#include <stdio.h>
main() {
char fs[]="POSIX.ROOT.FS";
struct w_statfs buf;
if (w_statfs(fs, &buf, sizeof(buf)) == -1)
perror("w_statfs() error");
else {
printf("each block in %s is %d bytes big\n", fs,
buf.statfs_blksize);
printf("there are %d blocks in use out of a total of %d\n",
buf.statfs_used_space, buf.statfs_total_space);
printf("in bytes, that's %.0f bytes used out of a total of %.0f\n",
((double)buf.statfs_used_space * buf.statfs_blksize),
((double)buf.statfs_total_space * buf.statfs_blksize));
}
}
each block in POSIX.ROOT.FS is 4096 bytes big
there are 2089 blocks in use out of a total of 2400
in bytes, that's 8556544 bytes used out of a total of 9830400