stat.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <sys/cdefs.h>
  8. #include <sys/types.h>
  9. #include <time.h>
  10. __BEGIN_DECLS
  11. #define S_IFMT 0170000
  12. #define S_IFDIR 0040000
  13. #define S_IFCHR 0020000
  14. #define S_IFBLK 0060000
  15. #define S_IFREG 0100000
  16. #define S_IFIFO 0010000
  17. #define S_IFLNK 0120000
  18. #define S_IFSOCK 0140000
  19. #define S_ISUID 04000
  20. #define S_ISGID 02000
  21. #define S_ISVTX 01000
  22. #define S_IRUSR 0400
  23. #define S_IWUSR 0200
  24. #define S_IXUSR 0100
  25. #define S_IREAD S_IRUSR
  26. #define S_IWRITE S_IWUSR
  27. #define S_IEXEC S_IXUSR
  28. #define S_IRGRP 0040
  29. #define S_IWGRP 0020
  30. #define S_IXGRP 0010
  31. #define S_IROTH 0004
  32. #define S_IWOTH 0002
  33. #define S_IXOTH 0001
  34. #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
  35. #define S_IRWXG (S_IRWXU >> 3)
  36. #define S_IRWXO (S_IRWXG >> 3)
  37. #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
  38. #define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR)
  39. #define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK)
  40. #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
  41. #define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO)
  42. #define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK)
  43. #define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK)
  44. struct stat {
  45. dev_t st_dev; /* ID of device containing file */
  46. ino_t st_ino; /* inode number */
  47. mode_t st_mode; /* protection */
  48. nlink_t st_nlink; /* number of hard links */
  49. uid_t st_uid; /* user ID of owner */
  50. gid_t st_gid; /* group ID of owner */
  51. dev_t st_rdev; /* device ID (if special file) */
  52. off_t st_size; /* total size, in bytes */
  53. blksize_t st_blksize; /* blocksize for file system I/O */
  54. blkcnt_t st_blocks; /* number of 512B blocks allocated */
  55. struct timespec st_atim; /* time of last access */
  56. struct timespec st_mtim; /* time of last modification */
  57. struct timespec st_ctim; /* time of last status change */
  58. };
  59. #define st_atime st_atim.tv_sec
  60. #define st_mtime st_mtim.tv_sec
  61. #define st_ctime st_ctim.tv_sec
  62. mode_t umask(mode_t);
  63. int chmod(const char* pathname, mode_t);
  64. int fchmod(int fd, mode_t);
  65. int mkdir(const char* pathname, mode_t);
  66. int mkfifo(const char* pathname, mode_t);
  67. int fstat(int fd, struct stat* statbuf);
  68. int lstat(const char* path, struct stat* statbuf);
  69. int stat(const char* path, struct stat* statbuf);
  70. int fstatat(int fd, const char* path, struct stat* statbuf, int flags);
  71. __END_DECLS