stat.c 594 B

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