diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-19 09:48:00 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-19 09:48:00 +0000 |
commit | 9a356f2804f23e9ccba84af3d98bdd4685be402e (patch) | |
tree | b9fffc42ed60b0db73d246312d80896a5665d327 /file.c | |
parent | 20729e63dd81ecfaff3285d851c78e6bd63cc590 (diff) | |
download | ruby-9a356f2804f23e9ccba84af3d98bdd4685be402e.tar.gz ruby-9a356f2804f23e9ccba84af3d98bdd4685be402e.tar.xz ruby-9a356f2804f23e9ccba84af3d98bdd4685be402e.zip |
* file.c (utime_internal): fallback utimensat to utimes.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 28 |
1 files changed, 18 insertions, 10 deletions
@@ -2041,23 +2041,31 @@ rb_file_s_lchown(int argc, VALUE *argv) 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; + + 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 -static void -utime_internal(const char *path, void *arg) -{ - struct timespec *tsp = arg; - struct timeval tvbuf[2], *tvp = arg; if (tsp) { tvbuf[0].tv_sec = tsp[0].tv_sec; tvbuf[0].tv_usec = tsp[0].tv_nsec / 1000; |