tst-statvfs.c 598 B

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