X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gnu%2Ffcntl.c;h=23b73e975c844d976a032d2582f482fac0f43f33;hb=d30babc23b4f25be970ada2e63a50220a3672281;hp=c272ec9c754bd1471767ba73e3390ad2e3ee673e;hpb=4aa85f09e755fc827cd5ab6225f20c83cd42245d;p=debian%2Ftar diff --git a/gnu/fcntl.c b/gnu/fcntl.c index c272ec9c..23b73e97 100644 --- a/gnu/fcntl.c +++ b/gnu/fcntl.c @@ -1,8 +1,6 @@ -/* -*- buffer-read-only: t -*- vi: set ro: */ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Provide file descriptor control. - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -91,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; } @@ -100,7 +115,6 @@ dupfd (int oldfd, int newfd, int flags) if (duplicated_fd < 0) { CloseHandle (new_handle); - errno = EMFILE; result = -1; break; }