stat.c 705 B

1234567891011121314151617181920212223242526
  1. #include <errno.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <sys/stat.h>
  5. #include <unistd.h>
  6. #include "test_helpers.h"
  7. int main(void) {
  8. printf("sizeof(struct stat): %ld\n", sizeof(struct stat));
  9. struct stat buf;
  10. int stat_status = stat("unistd/stat.c", &buf);
  11. ERROR_IF(stat, stat_status, == -1);
  12. UNEXP_IF(stat, stat_status, != 0);
  13. printf("st_size: %lu\n", buf.st_size);
  14. printf("st_blksize: %lu\n", buf.st_blksize);
  15. printf("st_dev: %lu\n", buf.st_dev);
  16. printf("st_ino: %lu\n", buf.st_ino);
  17. printf("st_mode: %o\n", buf.st_mode);
  18. printf("st_nlink: %lu\n", buf.st_nlink);
  19. printf("st_uid: %u\n", buf.st_uid);
  20. printf("st_gid: %u\n", buf.st_gid);
  21. }