From 4a5f3bbd51e8fa0b3abe6ecdfcbf353d1f944199 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 6 Feb 2012 17:26:34 +0100 Subject: [PATCH] eio: don't use futimes() on linux uclibc does not provide the syscall wrapper. Translate it into a direct utimesat syscall if available, else fail with ENOSYS. --- src/unix/eio/config_linux.h | 7 +++++-- src/unix/eio/eio.c | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/unix/eio/config_linux.h b/src/unix/eio/config_linux.h index 606301fa..e7a0d6e7 100644 --- a/src/unix/eio/config_linux.h +++ b/src/unix/eio/config_linux.h @@ -13,8 +13,8 @@ /* utimes(2) is available */ #define HAVE_UTIMES 1 -/* futimes(2) is available */ -#define HAVE_FUTIMES 1 +/* futimes(2) is available but we make the syscall directly. */ +#undef HAVE_FUTIMES /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 @@ -56,6 +56,9 @@ /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSCALL_H 1 + /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 diff --git a/src/unix/eio/eio.c b/src/unix/eio/eio.c index 58300a65..248af9e2 100644 --- a/src/unix/eio/eio.c +++ b/src/unix/eio/eio.c @@ -1039,8 +1039,15 @@ eio__utimes (const char *filename, const struct timeval times[2]) static int eio__futimes (int fd, const struct timeval tv[2]) { +#if defined(__linux) && defined(__NR_utimensat) + struct timespec ts[2]; + ts[0].tv_sec = tv[0].tv_sec, ts[0].tv_nsec = tv[0].tv_usec * 1000; + ts[1].tv_sec = tv[1].tv_sec, ts[1].tv_nsec = tv[1].tv_usec * 1000; + return syscall(__NR_utimensat, fd, NULL, ts, 0); +#else errno = ENOSYS; return -1; +#endif } #endif