int rpl_fstatat (int fd, char const *file, struct stat *st, int flag) { int result = orig_fstatat (fd, file, st, flag); size_t len; if (LSTAT_FOLLOWS_SLASHED_SYMLINK || result != 0) return result; len = strlen (file); if (flag & AT_SYMLINK_NOFOLLOW) { /* Fix lstat behavior. */ if (file[len - 1] != '/' || S_ISDIR (st->st_mode)) return 0; if (!S_ISLNK (st->st_mode)) { errno = ENOTDIR; return -1; } result = orig_fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW); } /* Fix stat behavior. */ if (result == 0 && !S_ISDIR (st->st_mode) && file[len - 1] == '/') { errno = ENOTDIR; return -1; } return result; }
static int normal_fstatat (int fd, char const *file, struct stat *st, int flag) { return stat_time_normalize (orig_fstatat (fd, file, st, flag), st); }