diff --git a/src/unix/eio/config_sunos.h b/src/unix/eio/config_sunos.h index 01d049c3e6..546926fcb5 100644 --- a/src/unix/eio/config_sunos.h +++ b/src/unix/eio/config_sunos.h @@ -11,7 +11,7 @@ #define HAVE_UTIMES 1 /* futimes(2) is available */ -/* #undef HAVE_FUTIMES */ +#define HAVE_FUTIMES 1 /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 diff --git a/src/unix/eio/eio.c b/src/unix/eio/eio.c index a005db5d3b..2374006110 100644 --- a/src/unix/eio/eio.c +++ b/src/unix/eio/eio.c @@ -108,6 +108,10 @@ static void eio_destroy (eio_req *req); #define EIO_ENOSYS() EIO_ERRNO (ENOSYS, -1) +#ifdef __sun +# define futimes(fd, times) futimesat (fd, NULL, times) +#endif + #ifdef _WIN32 #include diff --git a/src/unix/fs.c b/src/unix/fs.c index 76de94dea9..86da281cf5 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -496,7 +496,7 @@ int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, } -#if defined(HAVE_FUTIMES) +#if HAVE_FUTIMES static int _futime(const uv_file file, double atime, double mtime) { struct timeval tv[2]; @@ -507,14 +507,18 @@ static int _futime(const uv_file file, double atime, double mtime) { tv[1].tv_sec = mtime; tv[1].tv_usec = (unsigned long)(mtime * 1000000) % 1000000; +#ifdef __sun + return futimesat(file, NULL, tv); +#else return futimes(file, tv); +#endif } #endif int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime, double mtime, uv_fs_cb cb) { -#if defined(HAVE_FUTIMES) +#if HAVE_FUTIMES const char* path = NULL; uv_fs_req_init(loop, req, UV_FS_FUTIME, path, cb); diff --git a/src/unix/internal.h b/src/unix/internal.h index 7200e33df3..e6ae9b75d8 100644 --- a/src/unix/internal.h +++ b/src/unix/internal.h @@ -49,11 +49,7 @@ #endif /* __linux__ */ -#ifdef __APPLE__ -# define HAVE_FUTIMES 1 -#endif - -#ifdef __FreeBSD__ +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun) # define HAVE_FUTIMES 1 #endif