diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2014-10-18 23:33:40 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2014-10-18 23:33:40 -0700 |
commit | 821339c944eea52105777c5f52bdc3cf477b475c (patch) | |
tree | 373d674f6993de76acad4ac09eaf3fc457815bf1 /lib/fcntl.c | |
parent | 265331858f3cd63f3ab593461ca4f2931780ba5e (diff) | |
download | emacs-821339c944eea52105777c5f52bdc3cf477b475c.tar.gz |
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/fcntl.c')
-rw-r--r-- | lib/fcntl.c | 22 |
1 files changed, 19 insertions, 3 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) inherit, /* InheritHandle */ DUPLICATE_SAME_ACCESS)) /* Options */ { - /* TODO: Translate GetLastError () into errno. */ - errno = EMFILE; + switch (GetLastError ()) + { + case ERROR_TOO_MANY_OPEN_FILES: + errno = EMFILE; + break; + case ERROR_INVALID_HANDLE: + case ERROR_INVALID_TARGET_HANDLE: + case ERROR_DIRECT_ACCESS_HANDLE: + errno = EBADF; + break; + case ERROR_INVALID_PARAMETER: + case ERROR_INVALID_FUNCTION: + case ERROR_INVALID_ACCESS: + errno = EINVAL; + break; + default: + errno = EACCES; + break; + } result = -1; break; } @@ -98,7 +115,6 @@ dupfd (int oldfd, int newfd, int flags) if (duplicated_fd < 0) { CloseHandle (new_handle); - errno = EMFILE; result = -1; break; } |