X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Futimens.c;h=7f88f2fa960cd63d14d7283ebfcd7546759d4457;hb=c4f00b7d32160f83e4fb811c6584e8f4e48dfa2e;hp=b60ec879a3a158c6820c42789bb43582e85ad926;hpb=52bcc4fca9336df9167ed2f5d0aeaeaf874302c2;p=gnulib.git diff --git a/lib/utimens.c b/lib/utimens.c index b60ec879a..7f88f2fa9 100644 --- a/lib/utimens.c +++ b/lib/utimens.c @@ -26,6 +26,7 @@ #include #include +#include #if HAVE_UTIME_H # include @@ -113,11 +114,24 @@ futimens (int fd ATTRIBUTE_UNUSED, # endif #endif -#if ! HAVE_FUTIMES_AT +#if ! HAVE_FUTIMESAT if (!file) { +# if ! (HAVE_WORKING_UTIMES && HAVE_FUTIMES) errno = ENOSYS; +# endif + + /* Prefer EBADF to ENOSYS if both error numbers apply. */ + if (errno == ENOSYS) + { + int fd2 = dup (fd); + int dup_errno = errno; + if (0 <= fd2) + close (fd2); + errno = (fd2 < 0 && dup_errno == EBADF ? EBADF : ENOSYS); + } + return -1; }