Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

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.
  • Loading branch information
bnoordhuis committed Feb 6, 2012
1 parent e53302f commit 4a5f3bbd51e8fa0b3abe6ecdfcbf353d1f944199
Showing with 12 additions and 2 deletions.
  1. +5 −2 src/unix/eio/config_linux.h
  2. +7 −0 src/unix/eio/eio.c
@@ -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 <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
@@ -56,6 +56,9 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1

/* Define to 1 if you have the <sys/syscall.h> header file. */
#define HAVE_SYS_SYSCALL_H 1

/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

@@ -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

0 comments on commit 4a5f3bb

Please sign in to comment.
You can’t perform that action at this time.