tst-statvfs.c 568 B

1234567891011121314151617181920212223242526
  1. #include <sys/statvfs.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 statvfs s;
  10. int i;
  11. for (i = 1; i < argc; i++) {
  12. if (statvfs(argv[i], &s) != 0) {
  13. fprintf(stderr, "%s: %s: statvfs failed. %s\n",
  14. *argv, argv[i], strerror(errno));
  15. exit(EXIT_FAILURE);
  16. }
  17. printf("statvfs %s:\n\tblocks=%lld\n\tblkfree=%lld\n\tbsize=%d\n",
  18. argv[i], s.f_blocks, s.f_bfree, s.f_bsize);
  19. #if 1 // def _STATFS_F_FRSIZE
  20. printf("\tfrsize=%lld\n", s.f_frsize);
  21. #endif
  22. }
  23. exit(EXIT_SUCCESS);
  24. }