[前][次][番号順一覧][スレッド一覧]

ruby-changes:2479

From: ko1@a...
Date: 19 Nov 2007 18:48:21 +0900
Subject: [ruby-changes:2479] akr - Ruby:r13970 (trunk): * file.c (utime_internal): fallback utimensat to utimes.

akr	2007-11-19 18:48:00 +0900 (Mon, 19 Nov 2007)

  New Revision: 13970

  Modified files:
    trunk/ChangeLog
    trunk/file.c

  Log:
    * file.c (utime_internal): fallback utimensat to utimes.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/file.c?r1=13970&r2=13969
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13970&r2=13969

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13969)
+++ ChangeLog	(revision 13970)
@@ -1,3 +1,7 @@
+Mon Nov 19 18:46:49 2007  Tanaka Akira  <akr@f...>
+
+	* file.c (utime_internal): fallback utimensat to utimes.
+
 Mon Nov 19 17:51:27 2007  Tanaka Akira  <akr@f...>
 
 	* configure.in: check struct timespec, clock_gettime, utimensat,
Index: file.c
===================================================================
--- file.c	(revision 13969)
+++ file.c	(revision 13970)
@@ -2041,23 +2041,31 @@
 
 struct timespec rb_time_timespec(VALUE time);
 
-#if defined(HAVE_UTIMENSAT)
+#if defined(HAVE_UTIMES)
 
 static void
 utime_internal(const char *path, void *arg)
 {
     struct timespec *tsp = arg;
-    if (utimensat(AT_FDCWD, path, tsp, 0) < 0)
-	rb_sys_fail(path);
-}
+    struct timeval tvbuf[2], *tvp = arg;
 
-#elif defined(HAVE_UTIMES)
+#ifdef HAVE_UTIMENSAT
+    static int try_utimensat = 1;
 
-static void
-utime_internal(const char *path, void *arg)
-{
-    struct timespec *tsp = arg;
-    struct timeval tvbuf[2], *tvp = arg;
+    if (try_utimensat) {
+        struct timespec *tsp = arg;
+        if (utimensat(AT_FDCWD, path, tsp, 0) < 0) {
+            if (errno == ENOSYS) {
+                try_utimensat = 0;
+                goto no_utimensat;
+            }
+            rb_sys_fail(path);
+        }
+        return;
+    }
+no_utimensat:
+#endif
+
     if (tsp) {
         tvbuf[0].tv_sec = tsp[0].tv_sec;
         tvbuf[0].tv_usec = tsp[0].tv_nsec / 1000;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]