New upstream version 1.9.0+git20190802+060058b
Andrej Shadura
4 years ago
0 | 2019-08-02: | |
1 | * (seebs) Pass flags & O_NOFOLLOW, also use that to influence | |
2 | stat types. Note. &. Not |. | |
3 | ||
4 | 2019-08-01: | |
5 | * (seebs) Pass flags|O_NOFOLLOW on when resolving paths with openat. | |
6 | ||
0 | 7 | 2019-05-15: |
1 | 8 | * (RP) Add SDPX license headers to source files. |
2 | 9 |
54 | 54 | if (flags & O_CREAT) { |
55 | 55 | save_errno = errno; |
56 | 56 | #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS |
57 | rc = real___xstat64(_STAT_VER, path, &buf); | |
57 | if (flags & O_NOFOLLOW) { | |
58 | rc = real___lxstat64(_STAT_VER, path, &buf); | |
59 | } else { | |
60 | rc = real___xstat64(_STAT_VER, path, &buf); | |
61 | } | |
58 | 62 | #else |
59 | rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, 0); | |
63 | rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, (flags & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0); | |
60 | 64 | #endif |
61 | 65 | existed = (rc != -1); |
62 | 66 | if (!existed) |
71 | 75 | if (!(flags & O_NONBLOCK) && ((flags & (O_WRONLY | O_RDONLY | O_RDWR)) != O_RDWR)) { |
72 | 76 | save_errno = errno; |
73 | 77 | #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS |
74 | rc = real___xstat64(_STAT_VER, path, &buf); | |
78 | if (flags & O_NOFOLLOW) { | |
79 | rc = real___lxstat64(_STAT_VER, path, &buf); | |
80 | } else { | |
81 | rc = real___xstat64(_STAT_VER, path, &buf); | |
82 | } | |
75 | 83 | #else |
76 | rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, 0); | |
84 | rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, (flags & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0); | |
77 | 85 | #endif |
78 | 86 | if (rc != -1 && S_ISFIFO(buf.st_mode)) { |
79 | 87 | overly_magic_nonblocking = 1; |
125 | 133 | } |
126 | 134 | #endif |
127 | 135 | #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS |
128 | stat_rc = real___xstat64(_STAT_VER, path, &buf); | |
136 | if (flags & O_NOFOLLOW) { | |
137 | stat_rc = real___lxstat64(_STAT_VER, path, &buf); | |
138 | } else { | |
139 | stat_rc = real___xstat64(_STAT_VER, path, &buf); | |
140 | } | |
129 | 141 | #else |
130 | stat_rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, 0); | |
142 | stat_rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, (flags & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0); | |
131 | 143 | #endif |
132 | 144 | |
145 | pseudo_debug(PDBGF_FILE, "openat(path %s), flags %o, stat rc %d, stat mode %o\n", | |
146 | path, flags, stat_rc, buf.st_mode); | |
133 | 147 | if (stat_rc != -1) { |
134 | 148 | buf.st_mode = PSEUDO_DB_MODE(buf.st_mode, mode); |
135 | 149 | if (!existed) { |
0 | int open(const char *path, int flags, ...{mode_t mode}); /* flags=0 */ | |
0 | int open(const char *path, int flags, ...{mode_t mode}); /* flags=flags&O_NOFOLLOW */ | |
1 | 1 | char *get_current_dir_name(void); |
2 | 2 | int __xstat(int ver, const char *path, struct stat *buf); |
3 | 3 | int __lxstat(int ver, const char *path, struct stat *buf); /* flags=AT_SYMLINK_NOFOLLOW */ |
4 | 4 | int __fxstat(int ver, int fd, struct stat *buf); |
5 | 5 | int lchown(const char *path, uid_t owner, gid_t group); /* flags=AT_SYMLINK_NOFOLLOW */ |
6 | 6 | int __fxstatat(int ver, int dirfd, const char *path, struct stat *buf, int flags); |
7 | int openat(int dirfd, const char *path, int flags, ...{mode_t mode}); /* flags=0 */ | |
8 | int __openat_2(int dirfd, const char *path, int flags); /* flags=0 */ | |
7 | int openat(int dirfd, const char *path, int flags, ...{mode_t mode}); /* flags=flags&O_NOFOLLOW */ | |
8 | int __openat_2(int dirfd, const char *path, int flags); /* flags=flags&O_NOFOLLOW */ | |
9 | 9 | int mknod(const char *path, mode_t mode, dev_t dev); /* real_func=pseudo_mknod */ |
10 | 10 | int mknodat(int dirfd, const char *path, mode_t mode, dev_t dev); /* real_func=pseudo_mknodat */ |
11 | 11 | int __xmknod(int ver, const char *path, mode_t mode, dev_t *dev); /* flags=AT_SYMLINK_NOFOLLOW */ |
14 | 14 | # just so we know the inums of symlinks |
15 | 15 | char *canonicalize_file_name(const char *filename); |
16 | 16 | int eaccess(const char *path, int mode); |
17 | int open64(const char *path, int flags, ...{mode_t mode}); /* flags=0 */ | |
18 | int openat64(int dirfd, const char *path, int flags, ...{mode_t mode}); /* flags=0 */ | |
19 | int __openat64_2(int dirfd, const char *path, int flags); /* flags=0 */ | |
17 | int open64(const char *path, int flags, ...{mode_t mode}); /* flags=flags&O_NOFOLLOW */ | |
18 | int openat64(int dirfd, const char *path, int flags, ...{mode_t mode}); /* flags=flags&O_NOFOLLOW */ | |
19 | int __openat64_2(int dirfd, const char *path, int flags); /* flags=flags&O_NOFOLLOW */ | |
20 | 20 | int creat64(const char *path, mode_t mode); |
21 | 21 | int stat(const char *path, struct stat *buf); /* real_func=pseudo_stat */ |
22 | 22 | int lstat(const char *path, struct stat *buf); /* real_func=pseudo_lstat, flags=AT_SYMLINK_NOFOLLOW */ |