diff options
| author | Paul Eggert | 2017-11-25 22:28:31 -0800 |
|---|---|---|
| committer | Paul Eggert | 2017-11-25 22:48:09 -0800 |
| commit | 8be3aee2813f528b02bc913ca4d79e34e72b1754 (patch) | |
| tree | af1e8e35cedfe601076eade046a1a12303b93e84 /lib/fstatat.c | |
| parent | 265cee553f9d59a989d92e28865f6cc6fc02dcc9 (diff) | |
| download | emacs-8be3aee2813f528b02bc913ca4d79e34e72b1754.tar.gz emacs-8be3aee2813f528b02bc913ca4d79e34e72b1754.zip | |
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.c | 12 |
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) | |||
| 41 | above. */ | 41 | above. */ |
| 42 | #include "sys/stat.h" | 42 | #include "sys/stat.h" |
| 43 | 43 | ||
| 44 | #include "stat-time.h" | ||
| 45 | |||
| 44 | #include <errno.h> | 46 | #include <errno.h> |
| 45 | #include <fcntl.h> | 47 | #include <fcntl.h> |
| 46 | #include <string.h> | 48 | #include <string.h> |
| @@ -51,6 +53,12 @@ orig_fstatat (int fd, char const *filename, struct stat *buf, int flags) | |||
| 51 | # define LSTAT_FOLLOWS_SLASHED_SYMLINK 0 | 53 | # define LSTAT_FOLLOWS_SLASHED_SYMLINK 0 |
| 52 | # endif | 54 | # endif |
| 53 | 55 | ||
| 56 | static int | ||
| 57 | normal_fstatat (int fd, char const *file, struct stat *st, int flag) | ||
| 58 | { | ||
| 59 | return stat_time_normalize (orig_fstatat (fd, file, st, flag), st); | ||
| 60 | } | ||
| 61 | |||
| 54 | /* fstatat should always follow symbolic links that end in /, but on | 62 | /* fstatat should always follow symbolic links that end in /, but on |
| 55 | Solaris 9 it doesn't if AT_SYMLINK_NOFOLLOW is specified. | 63 | Solaris 9 it doesn't if AT_SYMLINK_NOFOLLOW is specified. |
| 56 | Likewise, trailing slash on a non-directory should be an error. | 64 | 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) | |||
| 63 | int | 71 | int |
| 64 | rpl_fstatat (int fd, char const *file, struct stat *st, int flag) | 72 | rpl_fstatat (int fd, char const *file, struct stat *st, int flag) |
| 65 | { | 73 | { |
| 66 | int result = orig_fstatat (fd, file, st, flag); | 74 | int result = normal_fstatat (fd, file, st, flag); |
| 67 | size_t len; | 75 | size_t len; |
| 68 | 76 | ||
| 69 | if (LSTAT_FOLLOWS_SLASHED_SYMLINK || result != 0) | 77 | if (LSTAT_FOLLOWS_SLASHED_SYMLINK || result != 0) |
| @@ -79,7 +87,7 @@ rpl_fstatat (int fd, char const *file, struct stat *st, int flag) | |||
| 79 | errno = ENOTDIR; | 87 | errno = ENOTDIR; |
| 80 | return -1; | 88 | return -1; |
| 81 | } | 89 | } |
| 82 | result = orig_fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW); | 90 | result = normal_fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW); |
| 83 | } | 91 | } |
| 84 | /* Fix stat behavior. */ | 92 | /* Fix stat behavior. */ |
| 85 | if (result == 0 && !S_ISDIR (st->st_mode) && file[len - 1] == '/') | 93 | if (result == 0 && !S_ISDIR (st->st_mode) && file[len - 1] == '/') |