diff options
| author | Paul Eggert | 2014-10-18 23:33:40 -0700 |
|---|---|---|
| committer | Paul Eggert | 2014-10-18 23:33:40 -0700 |
| commit | 821339c944eea52105777c5f52bdc3cf477b475c (patch) | |
| tree | 373d674f6993de76acad4ac09eaf3fc457815bf1 /lib | |
| parent | 265331858f3cd63f3ab593461ca4f2931780ba5e (diff) | |
| download | emacs-821339c944eea52105777c5f52bdc3cf477b475c.tar.gz emacs-821339c944eea52105777c5f52bdc3cf477b475c.zip | |
Merge from gnulib.
This incorporates:
2014-10-18 readlinkat: port to AIX 7.1
2014-10-07 fcntl: fix error reporting by dupfd
* lib/fcntl.c, lib/readlinkat.c, lib/unistd.in.h, m4/readlinkat.m4:
* m4/unistd_h.m4: Update from gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/fcntl.c | 22 | ||||
| -rw-r--r-- | lib/gnulib.mk | 4 | ||||
| -rw-r--r-- | lib/readlinkat.c | 36 | ||||
| -rw-r--r-- | lib/unistd.in.h | 31 |
4 files changed, 74 insertions, 19 deletions
diff --git a/lib/fcntl.c b/lib/fcntl.c index 54f748606b7..1e35dd1a4f9 100644 --- a/lib/fcntl.c +++ b/lib/fcntl.c | |||
| @@ -89,8 +89,25 @@ dupfd (int oldfd, int newfd, int flags) | |||
| 89 | inherit, /* InheritHandle */ | 89 | inherit, /* InheritHandle */ |
| 90 | DUPLICATE_SAME_ACCESS)) /* Options */ | 90 | DUPLICATE_SAME_ACCESS)) /* Options */ |
| 91 | { | 91 | { |
| 92 | /* TODO: Translate GetLastError () into errno. */ | 92 | switch (GetLastError ()) |
| 93 | errno = EMFILE; | 93 | { |
| 94 | case ERROR_TOO_MANY_OPEN_FILES: | ||
| 95 | errno = EMFILE; | ||
| 96 | break; | ||
| 97 | case ERROR_INVALID_HANDLE: | ||
| 98 | case ERROR_INVALID_TARGET_HANDLE: | ||
| 99 | case ERROR_DIRECT_ACCESS_HANDLE: | ||
| 100 | errno = EBADF; | ||
| 101 | break; | ||
| 102 | case ERROR_INVALID_PARAMETER: | ||
| 103 | case ERROR_INVALID_FUNCTION: | ||
| 104 | case ERROR_INVALID_ACCESS: | ||
| 105 | errno = EINVAL; | ||
| 106 | break; | ||
| 107 | default: | ||
| 108 | errno = EACCES; | ||
| 109 | break; | ||
| 110 | } | ||
| 94 | result = -1; | 111 | result = -1; |
| 95 | break; | 112 | break; |
| 96 | } | 113 | } |
| @@ -98,7 +115,6 @@ dupfd (int oldfd, int newfd, int flags) | |||
| 98 | if (duplicated_fd < 0) | 115 | if (duplicated_fd < 0) |
| 99 | { | 116 | { |
| 100 | CloseHandle (new_handle); | 117 | CloseHandle (new_handle); |
| 101 | errno = EMFILE; | ||
| 102 | result = -1; | 118 | result = -1; |
| 103 | break; | 119 | break; |
| 104 | } | 120 | } |
diff --git a/lib/gnulib.mk b/lib/gnulib.mk index 5ba7de10d0b..6437a9d7541 100644 --- a/lib/gnulib.mk +++ b/lib/gnulib.mk | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | # the same distribution terms as the rest of that program. | 21 | # the same distribution terms as the rest of that program. |
| 22 | # | 22 | # |
| 23 | # Generated by gnulib-tool. | 23 | # Generated by gnulib-tool. |
| 24 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=stdarg --avoid=stdbool --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv update-copyright utimens vla warnings | 24 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=stdarg --avoid=stdbool --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdio strftime strtoimax strtoumax symlink sys_stat sys_time time time_r timer-time timespec-add timespec-sub unsetenv update-copyright utimens vla warnings |
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | MOSTLYCLEANFILES += core *.stackdump | 27 | MOSTLYCLEANFILES += core *.stackdump |
| @@ -1748,9 +1748,11 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H | |||
| 1748 | -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ | 1748 | -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ |
| 1749 | -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \ | 1749 | -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \ |
| 1750 | -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ | 1750 | -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ |
| 1751 | -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \ | ||
| 1751 | -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ | 1752 | -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ |
| 1752 | -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ | 1753 | -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ |
| 1753 | -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ | 1754 | -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ |
| 1755 | -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \ | ||
| 1754 | -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \ | 1756 | -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \ |
| 1755 | -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ | 1757 | -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ |
| 1756 | -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ | 1758 | -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ |
diff --git a/lib/readlinkat.c b/lib/readlinkat.c index c8a60500f18..83ea0af02e4 100644 --- a/lib/readlinkat.c +++ b/lib/readlinkat.c | |||
| @@ -20,6 +20,18 @@ | |||
| 20 | 20 | ||
| 21 | #include <unistd.h> | 21 | #include <unistd.h> |
| 22 | 22 | ||
| 23 | #if HAVE_READLINKAT | ||
| 24 | |||
| 25 | # undef readlinkat | ||
| 26 | |||
| 27 | ssize_t | ||
| 28 | rpl_readlinkat (int fd, char const *file, char *buf, size_t len) | ||
| 29 | { | ||
| 30 | return readlinkat (fd, file, buf, len); | ||
| 31 | } | ||
| 32 | |||
| 33 | #else | ||
| 34 | |||
| 23 | /* Gnulib provides a readlink stub for mingw; use it for distinction | 35 | /* Gnulib provides a readlink stub for mingw; use it for distinction |
| 24 | between EINVAL and ENOENT, rather than always failing with ENOSYS. */ | 36 | between EINVAL and ENOENT, rather than always failing with ENOSYS. */ |
| 25 | 37 | ||
| @@ -34,14 +46,16 @@ | |||
| 34 | then readlink/restore_cwd. If either the save_cwd or the restore_cwd | 46 | then readlink/restore_cwd. If either the save_cwd or the restore_cwd |
| 35 | fails, then give a diagnostic and exit nonzero. */ | 47 | fails, then give a diagnostic and exit nonzero. */ |
| 36 | 48 | ||
| 37 | #define AT_FUNC_NAME readlinkat | 49 | # define AT_FUNC_NAME readlinkat |
| 38 | #define AT_FUNC_F1 readlink | 50 | # define AT_FUNC_F1 readlink |
| 39 | #define AT_FUNC_POST_FILE_PARAM_DECLS , char *buf, size_t len | 51 | # define AT_FUNC_POST_FILE_PARAM_DECLS , char *buf, size_t len |
| 40 | #define AT_FUNC_POST_FILE_ARGS , buf, len | 52 | # define AT_FUNC_POST_FILE_ARGS , buf, len |
| 41 | #define AT_FUNC_RESULT ssize_t | 53 | # define AT_FUNC_RESULT ssize_t |
| 42 | #include "at-func.c" | 54 | # include "at-func.c" |
| 43 | #undef AT_FUNC_NAME | 55 | # undef AT_FUNC_NAME |
| 44 | #undef AT_FUNC_F1 | 56 | # undef AT_FUNC_F1 |
| 45 | #undef AT_FUNC_POST_FILE_PARAM_DECLS | 57 | # undef AT_FUNC_POST_FILE_PARAM_DECLS |
| 46 | #undef AT_FUNC_POST_FILE_ARGS | 58 | # undef AT_FUNC_POST_FILE_ARGS |
| 47 | #undef AT_FUNC_RESULT | 59 | # undef AT_FUNC_RESULT |
| 60 | |||
| 61 | #endif | ||
diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 622b2287577..bbbfd75bdd6 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h | |||
| @@ -1287,13 +1287,24 @@ _GL_WARN_ON_USE (readlink, "readlink is unportable - " | |||
| 1287 | 1287 | ||
| 1288 | 1288 | ||
| 1289 | #if @GNULIB_READLINKAT@ | 1289 | #if @GNULIB_READLINKAT@ |
| 1290 | # if !@HAVE_READLINKAT@ | 1290 | # if @REPLACE_READLINKAT@ |
| 1291 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1292 | # define readlinkat rpl_readlinkat | ||
| 1293 | # endif | ||
| 1294 | _GL_FUNCDECL_RPL (readlinkat, ssize_t, | ||
| 1295 | (int fd, char const *file, char *buf, size_t len) | ||
| 1296 | _GL_ARG_NONNULL ((2, 3))); | ||
| 1297 | _GL_CXXALIAS_RPL (readlinkat, ssize_t, | ||
| 1298 | (int fd, char const *file, char *buf, size_t len)); | ||
| 1299 | # else | ||
| 1300 | # if !@HAVE_READLINKAT@ | ||
| 1291 | _GL_FUNCDECL_SYS (readlinkat, ssize_t, | 1301 | _GL_FUNCDECL_SYS (readlinkat, ssize_t, |
| 1292 | (int fd, char const *file, char *buf, size_t len) | 1302 | (int fd, char const *file, char *buf, size_t len) |
| 1293 | _GL_ARG_NONNULL ((2, 3))); | 1303 | _GL_ARG_NONNULL ((2, 3))); |
| 1294 | # endif | 1304 | # endif |
| 1295 | _GL_CXXALIAS_SYS (readlinkat, ssize_t, | 1305 | _GL_CXXALIAS_SYS (readlinkat, ssize_t, |
| 1296 | (int fd, char const *file, char *buf, size_t len)); | 1306 | (int fd, char const *file, char *buf, size_t len)); |
| 1307 | # endif | ||
| 1297 | _GL_CXXALIASWARN (readlinkat); | 1308 | _GL_CXXALIASWARN (readlinkat); |
| 1298 | #elif defined GNULIB_POSIXCHECK | 1309 | #elif defined GNULIB_POSIXCHECK |
| 1299 | # undef readlinkat | 1310 | # undef readlinkat |
| @@ -1407,13 +1418,25 @@ _GL_WARN_ON_USE (symlink, "symlink is not portable - " | |||
| 1407 | 1418 | ||
| 1408 | 1419 | ||
| 1409 | #if @GNULIB_SYMLINKAT@ | 1420 | #if @GNULIB_SYMLINKAT@ |
| 1410 | # if !@HAVE_SYMLINKAT@ | 1421 | # if @REPLACE_SYMLINKAT@ |
| 1422 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 1423 | # undef symlinkat | ||
| 1424 | # define symlinkat rpl_symlinkat | ||
| 1425 | # endif | ||
| 1426 | _GL_FUNCDECL_RPL (symlinkat, int, | ||
| 1427 | (char const *contents, int fd, char const *file) | ||
| 1428 | _GL_ARG_NONNULL ((1, 3))); | ||
| 1429 | _GL_CXXALIAS_RPL (symlinkat, int, | ||
| 1430 | (char const *contents, int fd, char const *file)); | ||
| 1431 | # else | ||
| 1432 | # if !@HAVE_SYMLINKAT@ | ||
| 1411 | _GL_FUNCDECL_SYS (symlinkat, int, | 1433 | _GL_FUNCDECL_SYS (symlinkat, int, |
| 1412 | (char const *contents, int fd, char const *file) | 1434 | (char const *contents, int fd, char const *file) |
| 1413 | _GL_ARG_NONNULL ((1, 3))); | 1435 | _GL_ARG_NONNULL ((1, 3))); |
| 1414 | # endif | 1436 | # endif |
| 1415 | _GL_CXXALIAS_SYS (symlinkat, int, | 1437 | _GL_CXXALIAS_SYS (symlinkat, int, |
| 1416 | (char const *contents, int fd, char const *file)); | 1438 | (char const *contents, int fd, char const *file)); |
| 1439 | # endif | ||
| 1417 | _GL_CXXALIASWARN (symlinkat); | 1440 | _GL_CXXALIASWARN (symlinkat); |
| 1418 | #elif defined GNULIB_POSIXCHECK | 1441 | #elif defined GNULIB_POSIXCHECK |
| 1419 | # undef symlinkat | 1442 | # undef symlinkat |