tst-statfs.c 593 B

123456789101112131415161718192021222324252627
  1. #include <sys/vfs.h>
  2. #include <errno.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. int
  7. main(int argc, char* argv[])
  8. {
  9. struct statfs s;
  10. int ret = 0, i;
  11. for (i = 1; i < argc; i++) {
  12. if (statfs(argv[i], &s) != 0) {
  13. fprintf(stderr, "%s: %s: statfs failed. %s\n",
  14. *argv, argv[i], strerror(errno));
  15. exit(EXIT_FAILURE);
  16. }
  17. ++ret;
  18. printf("statfs %s:\n\tblocks=%lld\n\tblkfree=%lld\n\tbsize=%d\n",
  19. argv[i], s.f_blocks, s.f_bfree, s.f_bsize);
  20. #ifdef _STATFS_F_FRSIZE
  21. printf("\tfrsize=%lld\n", s.f_frsize);
  22. #endif
  23. }
  24. exit(ret ? EXIT_SUCCESS : EXIT_FAILURE);
  25. }