projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add gc-arcfour and gc-arcfour-tests modules.
[gnulib.git]
/
lib
/
utimens.c
diff --git
a/lib/utimens.c
b/lib/utimens.c
index
b60ec87
..
7f88f2f
100644
(file)
--- a/
lib/utimens.c
+++ b/
lib/utimens.c
@@
-26,6
+26,7
@@
#include <errno.h>
#include <fcntl.h>
#include <errno.h>
#include <fcntl.h>
+#include <unistd.h>
#if HAVE_UTIME_H
# include <utime.h>
#if HAVE_UTIME_H
# include <utime.h>
@@
-113,11
+114,24
@@
futimens (int fd ATTRIBUTE_UNUSED,
# endif
#endif
# endif
#endif
-#if ! HAVE_FUTIMES
_
AT
+#if ! HAVE_FUTIMESAT
if (!file)
{
if (!file)
{
+# if ! (HAVE_WORKING_UTIMES && HAVE_FUTIMES)
errno = ENOSYS;
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;
}
return -1;
}