Like fstatat, but cache on POSIX-compatible systems. */
| 56 | |
| 57 | /* Like fstatat, but cache on POSIX-compatible systems. */ |
| 58 | static int |
| 59 | cache_fstatat (int fd, char const *file, struct stat *st, int flag) |
| 60 | { |
| 61 | #if HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC |
| 62 | /* If ST->st_atim.tv_nsec is -1, the status has not been gotten yet. |
| 63 | If less than -1, fstatat failed with errno == ST->st_ino. |
| 64 | Otherwise, the status has already been gotten, so return 0. */ |
| 65 | if (0 <= st->st_atim.tv_nsec) |
| 66 | return 0; |
| 67 | if (st->st_atim.tv_nsec == -1) |
| 68 | { |
| 69 | if (fstatat (fd, file, st, flag) == 0) |
| 70 | return 0; |
| 71 | st->st_atim.tv_nsec = -2; |
| 72 | st->st_ino = errno; |
| 73 | } |
| 74 | errno = st->st_ino; |
| 75 | return -1; |
| 76 | #else |
| 77 | return fstatat (fd, file, st, flag); |
| 78 | #endif |
| 79 | } |
| 80 | |
| 81 | /* Initialize a fstatat cache *ST. Return ST for convenience. */ |
| 82 | static inline struct stat * |
no outgoing calls
no test coverage detected