Act like fstat (DIRFD, FILENAME, ST, FLAGS), except when following symbolic links on Solaris-like systems, treat any character-special device like /dev/fd/0 as if it were the file it is open on. */
| 184 | symbolic links on Solaris-like systems, treat any character-special |
| 185 | device like /dev/fd/0 as if it were the file it is open on. */ |
| 186 | static int |
| 187 | follow_fstatat (int dirfd, char const *filename, struct stat *st, int flags) |
| 188 | { |
| 189 | int result = fstatat (dirfd, filename, st, flags); |
| 190 | |
| 191 | if (DEV_FD_MIGHT_BE_CHR && result == 0 && !(flags & AT_SYMLINK_NOFOLLOW) |
| 192 | && S_ISCHR (st->st_mode)) |
| 193 | { |
| 194 | static dev_t stdin_rdev; |
| 195 | static signed char stdin_rdev_status; |
| 196 | if (stdin_rdev_status == 0) |
| 197 | { |
| 198 | struct stat stdin_st; |
| 199 | if (stat ("/dev/stdin", &stdin_st) == 0 && S_ISCHR (stdin_st.st_mode) |
| 200 | && minor (stdin_st.st_rdev) == STDIN_FILENO) |
| 201 | { |
| 202 | stdin_rdev = stdin_st.st_rdev; |
| 203 | stdin_rdev_status = 1; |
| 204 | } |
| 205 | else |
| 206 | stdin_rdev_status = -1; |
| 207 | } |
| 208 | if (0 < stdin_rdev_status && major (stdin_rdev) == major (st->st_rdev)) |
| 209 | result = fstat (minor (st->st_rdev), st); |
| 210 | } |
| 211 | |
| 212 | return result; |
| 213 | } |
| 214 | |
| 215 | /* Whether an errno value ERR, set by FICLONE or copy_file_range, |
| 216 | indicates that the copying operation has terminally failed, even |