stat.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* -*-comment-start: "//";comment-end:""-*-
  2. * GNU Mes --- Maxwell Equations of Software
  3. * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  4. *
  5. * This file is part of GNU Mes.
  6. *
  7. * GNU Mes is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * GNU Mes is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef __MES_SYS_STAT_H
  21. #define __MES_SYS_STAT_H 1lei
  22. #if SYSTEM_LIBC
  23. #undef __MES_SYS_STAT_H
  24. #include_next <sys/stat.h>
  25. #else // ! SYSTEM_LIBC
  26. #include <time.h>
  27. #include <sys/types.h>
  28. #ifndef __MES_MODE_T
  29. #define __MES_MODE_T
  30. typedef int mode_t;
  31. #endif
  32. // *INDENT-OFF*
  33. #if __i386__ || __arm__
  34. struct stat
  35. {
  36. unsigned long st_dev;
  37. unsigned long st_ino;
  38. unsigned short st_mode;
  39. unsigned short st_nlink;
  40. unsigned short st_uid;
  41. unsigned short st_gid;
  42. unsigned long st_rdev;
  43. long st_size; /* Linux: unsigned long; glibc: off_t (i.e. signed) */
  44. unsigned long st_blksize;
  45. unsigned long st_blocks;
  46. time_t st_atime; /* Linux: unsigned long; glibc: time_t */
  47. unsigned long st_atime_usec;
  48. time_t st_mtime; /* Linux: unsigned long; glibc: time_t */
  49. unsigned long st_mtime_usec;
  50. time_t st_ctime; /* Linux: unsigned long; glibc: time_t */
  51. unsigned long st_ctime_usec;
  52. unsigned long __foo0;
  53. unsigned long __foo1;
  54. };
  55. #elif __x86_64__
  56. struct stat
  57. {
  58. unsigned long st_dev;
  59. unsigned long st_ino;
  60. unsigned int st_mode;
  61. unsigned int st_nlink;
  62. unsigned int st_uid;
  63. unsigned int st_gid;
  64. unsigned long st_rdev;
  65. long st_size;
  66. unsigned long st_blksize;
  67. unsigned long st_blocks;
  68. time_t st_atime;
  69. unsigned long st_atime_usec;
  70. time_t st_mtime;
  71. unsigned long st_mtime_usec;
  72. time_t st_ctime;
  73. unsigned long st_ctime_usec;
  74. unsigned long __foo0;
  75. unsigned long __foo1;
  76. };
  77. #endif
  78. // *INDENT-ON*
  79. int chmod (char const *file_name, mode_t mode);
  80. int fstat (int filedes, struct stat *buf);
  81. int mkdir (char const *file_name, mode_t mode);
  82. int mknod (char const *file_name, mode_t mode, dev_t dev);
  83. int chown (char const *file_name, uid_t owner, gid_t group);
  84. int rmdir (char const *file_name);
  85. int stat (char const *file_name, struct stat *buf);
  86. #define S_IFIFO 0010000
  87. #define S_IFCHR 0020000
  88. #define S_IFDIR 0040000
  89. #define S_IFBLK 0060000
  90. #define S_IFREG 0100000
  91. #define S_IFLNK 0120000
  92. #define S_IFMT 0170000
  93. #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
  94. #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  95. #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  96. #define S_IRWXU 00700
  97. #define S_IXUSR 00100
  98. #define S_IWUSR 00200
  99. #define S_IRUSR 00400
  100. #define S_ISUID 04000
  101. #define S_ISGID 02000
  102. #define S_IXGRP 00010
  103. #define S_IXOTH 00001
  104. #define S_IRGRP 00040
  105. #define S_IROTH 00004
  106. #define S_IWGRP 00020
  107. #define S_IWOTH 00002
  108. #define S_IRWXG 00070
  109. #define S_IRWXO 00007
  110. #endif // ! SYSTEM_LIBC
  111. #endif // __MES_SYS_STAT_H