Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
eio: don't use futimes() on linux
Browse files Browse the repository at this point in the history
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 4a5f3bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/unix/eio/config_linux.h
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions src/unix/eio/eio.c
Expand Up @@ -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
Expand Down

0 comments on commit 4a5f3bb

Please sign in to comment.