summaryrefslogtreecommitdiff
path: root/lib/fstatat.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2017-11-25 22:28:31 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2017-11-25 22:48:09 -0800
commit8be3aee2813f528b02bc913ca4d79e34e72b1754 (patch)
treeaf1e8e35cedfe601076eade046a1a12303b93e84 /lib/fstatat.c
parent265cee553f9d59a989d92e28865f6cc6fc02dcc9 (diff)
downloademacs-8be3aee2813f528b02bc913ca4d79e34e72b1754.tar.gz
Merge from Gnulib
This incorporates: 2017-11-23 stat: work around Solaris bug with tv_nsec < 0 2017-11-12 maint: shorten https://lists.gnu.org/archive/html/... links * build-aux/config.sub, doc/misc/texinfo.tex, lib/allocator.h: * lib/fstatat.c, lib/intprops.h, lib/lstat.c, lib/signal.in.h: * lib/stat-time.h, lib/stdio-impl.h, lib/stdio.in.h: * lib/timespec.h, m4/alloca.m4, m4/extern-inline.m4: * m4/faccessat.m4, m4/fstatat.m4, m4/gnulib-common.m4: * m4/lstat.m4, m4/std-gnu11.m4, m4/sys_types_h.m4: * m4/vararrays.m4: Copy from Gnulib.
Diffstat (limited to 'lib/fstatat.c')
-rw-r--r--lib/fstatat.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/fstatat.c b/lib/fstatat.c
index 294861f51b1..237e68c5da7 100644
--- a/lib/fstatat.c
+++ b/lib/fstatat.c
@@ -41,6 +41,8 @@ orig_fstatat (int fd, char const *filename, struct stat *buf, int flags)
above. */
#include "sys/stat.h"
+#include "stat-time.h"
+
#include <errno.h>
#include <fcntl.h>
#include <string.h>
@@ -51,6 +53,12 @@ orig_fstatat (int fd, char const *filename, struct stat *buf, int flags)
# define LSTAT_FOLLOWS_SLASHED_SYMLINK 0
# endif
+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);
+}
+
/* fstatat should always follow symbolic links that end in /, but on
Solaris 9 it doesn't if AT_SYMLINK_NOFOLLOW is specified.
Likewise, trailing slash on a non-directory should be an error.
@@ -63,7 +71,7 @@ orig_fstatat (int fd, char const *filename, struct stat *buf, int flags)
int
rpl_fstatat (int fd, char const *file, struct stat *st, int flag)
{
- int result = orig_fstatat (fd, file, st, flag);
+ int result = normal_fstatat (fd, file, st, flag);
size_t len;
if (LSTAT_FOLLOWS_SLASHED_SYMLINK || result != 0)
@@ -79,7 +87,7 @@ rpl_fstatat (int fd, char const *file, struct stat *st, int flag)
errno = ENOTDIR;
return -1;
}
- result = orig_fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW);
+ result = normal_fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW);
}
/* Fix stat behavior. */
if (result == 0 && !S_ISDIR (st->st_mode) && file[len - 1] == '/')