《操作系统》的实验代码。

27 satır
1.2 KiB

12 yıl önce
  1. #ifndef __LIBS_STAT_H__
  2. #define __LIBS_STAT_H__
  3. #include <defs.h>
  4. struct stat {
  5. uint32_t st_mode; // protection mode and file type
  6. size_t st_nlinks; // number of hard links
  7. size_t st_blocks; // number of blocks file is using
  8. size_t st_size; // file size (bytes)
  9. };
  10. #define S_IFMT 070000 // mask for type of file
  11. #define S_IFREG 010000 // ordinary regular file
  12. #define S_IFDIR 020000 // directory
  13. #define S_IFLNK 030000 // symbolic link
  14. #define S_IFCHR 040000 // character device
  15. #define S_IFBLK 050000 // block device
  16. #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) // regular file
  17. #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) // directory
  18. #define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) // symlink
  19. #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) // char device
  20. #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) // block device
  21. #endif /* !__LIBS_STAT_H__ */