/* Needed to obtain |O_PATH| */ #ifndef _GNU_SOURCE #define _GNU_SOURCE 1 #endif #include #include #include #include #include #include #include #include int main(int ac, char *av[]) { int fd; struct statfs statfsbuf; (void)memset(&statfsbuf, 0, sizeof(statfsbuf)); fd = open("/tmp", O_RDONLY|O_PATH); if (fd < 0) { perror("open() failed."); return EXIT_FAILURE; } if (fstatfs(fd, &statfsbuf) != 0) { perror("fstatfs() failed."); return EXIT_FAILURE; } (void)close(fd); (void)printf("f_blocks=%ld\n", (long)statfsbuf.f_blocks); (void)printf("f_bfree=%ld\n", (long)statfsbuf.f_bfree); (void)printf("f_bavail=%ld\n", (long)statfsbuf.f_bavail); return EXIT_SUCCESS; }