changeset 15657:befccd4a7d52

utimens: remove dependency on dup2 * lib/utimens.c (fdutimens): Don't invoke dup2; it's not needed to work around the Linux kernel bug. * modules/utimens (Depends-on): Remove dup2.
author Paul Eggert <eggert@cs.ucla.edu>
date Sun, 18 Sep 2011 20:57:48 -0700
parents 54ccb1d64384
children 07e1173e4fc9
files ChangeLog lib/utimens.c modules/utimens
diffstat 3 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-09-18  Paul Eggert  <eggert@cs.ucla.edu>
+
+	utimens: remove dependency on dup2
+	* lib/utimens.c (fdutimens): Don't invoke dup2; it's not needed
+	to work around the Linux kernel bug.
+	* modules/utimens (Depends-on): Remove dup2.
+
 2011-09-18  Bruno Haible  <bruno@clisp.org>
 
 	inet_ntop, inet_pton: Look for it also in libresolv.
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -180,18 +180,13 @@
   if (adjustment_needed < 0)
     return -1;
 
-  /* Require that at least one of FD or FILE are valid.  Works around
+  /* Require that at least one of FD or FILE are potentially valid, to avoid
      a Linux bug where futimens (AT_FDCWD, NULL) changes "." rather
      than failing.  */
-  if (!file)
+  if (fd < 0 && !file)
     {
-      if (fd < 0)
-        {
-          errno = EBADF;
-          return -1;
-        }
-      if (dup2 (fd, fd) != fd)
-        return -1;
+      errno = EBADF;
+      return -1;
     }
 
   /* Some Linux-based NFS clients are buggy, and mishandle time stamps
--- a/modules/utimens
+++ b/modules/utimens
@@ -9,7 +9,6 @@
 m4/utimes.m4
 
 Depends-on:
-dup2
 errno
 lstat
 gettime