bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

utimens port to Solaris 10


From: Paul Eggert
Subject: utimens port to Solaris 10
Date: Fri, 23 Sep 2005 12:20:08 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

I installed the following into both gnulib and coreutils, to port the
utimens module to Solaris 10, which has yet another primitive for
setting file time stamps (and yet another primitive that can't do it
to full resolution! When will these guys learn?).

2005-09-23  Paul Eggert  <address@hidden>

        * lib/utimens.c (futimens): Use futimesat if available.
        Prefer it to futimes since it doesn't have the futimes bug.
        * m4/utimens.m4 (gl_UTIMENS): Check for futimesat.

Index: lib/utimens.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/utimens.c,v
retrieving revision 1.4
diff -p -u -r1.4 utimens.c
--- lib/utimens.c       14 May 2005 06:03:58 -0000      1.4
+++ lib/utimens.c       23 Sep 2005 19:14:59 -0000
@@ -25,6 +25,7 @@
 #include "utimens.h"
 
 #include <errno.h>
+#include <fcntl.h>
 
 #if HAVE_UTIME_H
 # include <utime.h>
@@ -61,7 +62,7 @@ futimens (int fd ATTRIBUTE_UNUSED,
   /* There's currently no interface to set file timestamps with
      nanosecond resolution, so do the best we can, discarding any
      fractional part of the timestamp.  */
-#if HAVE_WORKING_UTIMES
+#if HAVE_FUTIMESAT || HAVE_WORKING_UTIMES
   struct timeval timeval[2];
   struct timeval const *t;
   if (timespec)
@@ -74,7 +75,11 @@ futimens (int fd ATTRIBUTE_UNUSED,
     }
   else
     t = NULL;
-# if HAVE_FUTIMES
+
+# if HAVE_FUTIMESAT
+  return fd < 0 ? futimesat (AT_FDCWD, file, t) : futimesat (fd, NULL, t);
+# else
+#  if HAVE_FUTIMES
   if (0 <= fd)
     {
       if (futimes (fd, t) == 0)
@@ -92,8 +97,9 @@ futimens (int fd ATTRIBUTE_UNUSED,
          return -1;
        }
     }
-# endif
+#  endif
   return utimes (file, t);
+# endif
 
 #else
 
Index: m4/utimens.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/utimens.m4,v
retrieving revision 1.4
diff -p -u -r1.4 utimens.m4
--- m4/utimens.m4       21 Mar 2005 22:06:27 -0000      1.4
+++ m4/utimens.m4       23 Sep 2005 19:14:59 -0000
@@ -13,5 +13,5 @@ AC_DEFUN([gl_UTIMENS],
   AC_REQUIRE([gl_FUNC_UTIMES])
   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_UTIMBUF])
-  AC_CHECK_FUNCS_ONCE(futimes)
+  AC_CHECK_FUNCS_ONCE([futimes futimesat])
 ])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]