tst-statfs.c 693 B

12345678910111213141516171819202122232425262728293031
  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. #elif defined __mips__
  23. printf("\tfrsize=mips, unsupported?\n");
  24. #else
  25. # error no _STATFS_F_FRSIZE
  26. #endif
  27. }
  28. exit(ret ? EXIT_SUCCESS : EXIT_FAILURE);
  29. }