Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 1 | #ifndef _SYS_STAT_H |
| 2 | #define _SYS_STAT_H |
| 3 | #ifdef __cplusplus |
| 4 | extern "C" { |
| 5 | #endif |
| 6 | |
| 7 | #define __NEED_dev_t |
| 8 | #define __NEED_ino_t |
| 9 | #define __NEED_mode_t |
| 10 | #define __NEED_nlink_t |
| 11 | #define __NEED_uid_t |
| 12 | #define __NEED_gid_t |
| 13 | #define __NEED_off_t |
| 14 | #define __NEED_time_t |
| 15 | #define __NEED_blksize_t |
| 16 | #define __NEED_blkcnt_t |
Rich Felker | 74eea62 | 2011-02-14 18:41:25 -0500 | [diff] [blame] | 17 | #define __NEED_struct_timespec |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 18 | |
| 19 | #include <bits/alltypes.h> |
| 20 | |
| 21 | #include <bits/stat.h> |
| 22 | |
Rich Felker | 74eea62 | 2011-02-14 18:41:25 -0500 | [diff] [blame] | 23 | #define st_atime st_atim.tv_sec |
| 24 | #define st_mtime st_mtim.tv_sec |
| 25 | #define st_ctime st_ctim.tv_sec |
| 26 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 27 | #define S_IFMT 0170000 |
| 28 | |
| 29 | #define S_IFDIR 0040000 |
| 30 | #define S_IFCHR 0020000 |
| 31 | #define S_IFBLK 0060000 |
| 32 | #define S_IFREG 0100000 |
| 33 | #define S_IFIFO 0010000 |
| 34 | #define S_IFLNK 0120000 |
| 35 | #define S_IFSOCK 0140000 |
| 36 | |
| 37 | #define S_TYPEISMQ(buf) 0 |
| 38 | #define S_TYPEISSEM(buf) 0 |
| 39 | #define S_TYPEISSHM(buf) 0 |
| 40 | #define S_TYPEISTMO(buf) 0 |
| 41 | |
| 42 | #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) |
| 43 | #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) |
| 44 | #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) |
| 45 | #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) |
| 46 | #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) |
| 47 | #define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) |
| 48 | #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) |
| 49 | |
Rich Felker | ac12eb9 | 2011-03-08 12:35:35 -0500 | [diff] [blame] | 50 | #ifndef S_IRUSR |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 51 | #define S_ISUID 04000 |
| 52 | #define S_ISGID 02000 |
| 53 | #define S_ISVTX 01000 |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 54 | #define S_IRUSR 0400 |
| 55 | #define S_IWUSR 0200 |
| 56 | #define S_IXUSR 0100 |
| 57 | #define S_IRWXU 0700 |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 58 | #define S_IRGRP 0040 |
| 59 | #define S_IWGRP 0020 |
| 60 | #define S_IXGRP 0010 |
| 61 | #define S_IRWXG 0070 |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 62 | #define S_IROTH 0004 |
| 63 | #define S_IWOTH 0002 |
| 64 | #define S_IXOTH 0001 |
| 65 | #define S_IRWXO 0007 |
Rich Felker | ac12eb9 | 2011-03-08 12:35:35 -0500 | [diff] [blame] | 66 | #endif |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 67 | |
Rich Felker | 4a19634 | 2011-04-10 18:32:59 -0400 | [diff] [blame] | 68 | #define UTIME_NOW 0x3fffffff |
| 69 | #define UTIME_OMIT 0x3ffffffe |
| 70 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 71 | int stat(const char *, struct stat *); |
| 72 | int fstat(int, struct stat *); |
| 73 | int lstat(const char *, struct stat *); |
| 74 | int fstatat(int, const char *, struct stat *, int); |
| 75 | int chmod(const char *, mode_t); |
| 76 | int fchmod(int, mode_t); |
| 77 | int fchmodat(int, const char *, mode_t, int); |
| 78 | mode_t umask(mode_t); |
| 79 | int mkdir(const char *, mode_t); |
| 80 | int mknod(const char *, mode_t, dev_t); |
| 81 | int mkfifo(const char *, mode_t); |
| 82 | int mkdirat(int, const char *, mode_t); |
| 83 | int mknodat(int, const char *, mode_t, dev_t); |
| 84 | int mkfifoat(int, const char *, mode_t); |
| 85 | |
Rich Felker | eda8e9d | 2011-02-27 03:48:57 -0500 | [diff] [blame] | 86 | int futimens(int, const struct timespec [2]); |
| 87 | int utimensat(int, const char *, const struct timespec [2], int); |
| 88 | |
Rich Felker | d5ca067 | 2011-02-17 23:13:46 -0500 | [diff] [blame] | 89 | #ifdef _BSD_SOURCE |
| 90 | int lchmod(const char *, mode_t); |
| 91 | #endif |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 92 | |
Rich Felker | 419ae6d | 2012-05-22 21:52:08 -0400 | [diff] [blame] | 93 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
Rich Felker | 7ecab79 | 2011-04-12 12:01:20 -0400 | [diff] [blame] | 94 | #define S_IREAD S_IRUSR |
| 95 | #define S_IWRITE S_IWUSR |
| 96 | #define S_IEXEC S_IXUSR |
| 97 | #endif |
| 98 | |
Rich Felker | 3b94dab | 2012-06-04 08:03:56 -0400 | [diff] [blame] | 99 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) |
Rich Felker | f0b85fd | 2012-05-04 00:31:25 -0400 | [diff] [blame] | 100 | #define stat64 stat |
| 101 | #define fstat64 fstat |
| 102 | #define lstat64 lstat |
| 103 | #define fstatat64 fstatat |
| 104 | #define blksize64_t blksize_t |
| 105 | #define blkcnt64_t blkcnt_t |
| 106 | #define ino64_t ino_t |
| 107 | #define off64_t off_t |
| 108 | #endif |
| 109 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 110 | #ifdef __cplusplus |
| 111 | } |
| 112 | #endif |
| 113 | #endif |
| 114 | |
| 115 | |