From 61d8534d7cd274d521ee211ac927096a465a0551 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 5 Oct 1998 08:54:55 +0000 Subject: handle systems that are missing either SYS_utime or SYS_utimes (This used to be commit 4379f0fe48a40e1ff6b343bbcff542efbda1f4f8) --- source3/smbwrapper/realcalls.c | 12 ++++++++++++ source3/smbwrapper/realcalls.h | 7 ++++++- source3/smbwrapper/wrapped.c | 40 +++++++++++++++++++++++++++++++++------- source3/smbwrapper/wrapper.h | 2 -- 4 files changed, 51 insertions(+), 10 deletions(-) diff --git a/source3/smbwrapper/realcalls.c b/source3/smbwrapper/realcalls.c index 4eb3d5e087..a453aff3ea 100644 --- a/source3/smbwrapper/realcalls.c +++ b/source3/smbwrapper/realcalls.c @@ -35,3 +35,15 @@ int real_utime(const char *name, struct utimbuf *buf) return real_utimes(name, &tv[0]); } #endif + +#ifdef REPLACE_UTIMES +int real_utimes(const char *name, struct timeval tv[2]) +{ + struct utimbuf buf; + + buf.actime = tv[0].tv_sec; + buf.modtime = tv[1].tv_sec; + + return real_utime(name, &buf); +} +#endif diff --git a/source3/smbwrapper/realcalls.h b/source3/smbwrapper/realcalls.h index ada2591101..cf23aec5b2 100644 --- a/source3/smbwrapper/realcalls.h +++ b/source3/smbwrapper/realcalls.h @@ -214,10 +214,15 @@ #define real_unlink(fn) (syscall(SYS_unlink, (fn))) #define real_rmdir(fn) (syscall(SYS_rmdir, (fn))) #define real_mkdir(fn, mode) (syscall(SYS_mkdir, (fn), (mode))) -#define real_utimes(fn, buf) (syscall(SYS_utimes, (fn), (buf))) #ifdef SYS_utime #define real_utime(fn, buf) (syscall(SYS_utime, (fn), (buf))) #else #define REPLACE_UTIME 1 #endif + +#ifdef SYS_utimes +#define real_utimes(fn, buf) (syscall(SYS_utimes, (fn), (buf))) +#else +#define REPLACE_UTIMES 1 +#endif diff --git a/source3/smbwrapper/wrapped.c b/source3/smbwrapper/wrapped.c index 7902371ec6..65550b19cc 100644 --- a/source3/smbwrapper/wrapped.c +++ b/source3/smbwrapper/wrapped.c @@ -39,14 +39,28 @@ } #ifdef HAVE__OPEN - int _open(const char *name, int flags, mode_t mode) + int _open(const char *name, int flags, ...) { - return open(name, flags, mode); + va_list ap; + mode_t mode; + + va_start(ap, flags); + mode = va_arg(ap, mode_t); + va_end(ap); + + return open(name, flags, mode); } #elif HAVE___OPEN - int __open(const char *name, int flags, mode_t mode) + int __open(const char *name, int flags, ...) { - return open(name, flags, mode); + va_list ap; + mode_t mode; + + va_start(ap, flags); + mode = va_arg(ap, mode_t); + va_end(ap); + + return open(name, flags, mode); } #endif @@ -198,13 +212,25 @@ #ifdef HAVE___FCNTL - int __fcntl(int fd, int cmd, long arg) + int __fcntl(int fd, int cmd, ...) { + va_list ap; + long arg; + va_start(ap, cmd); + arg = va_arg(ap, long); + va_end(ap); + return fcntl(fd, cmd, arg); } #elif HAVE__FCNTL - int _fcntl(int fd, int cmd, long arg) + int _fcntl(int fd, int cmd, ...) { + va_list ap; + long arg; + va_start(ap, cmd); + arg = va_arg(ap, long); + va_end(ap); + return fcntl(fd, cmd, arg); } #endif @@ -600,7 +626,7 @@ #endif #ifdef HAVE_UTIMES - int utimes(const char *name,void *tvp) + int utimes(const char *name,struct timeval tvp[2]) { if (smbw_path(name)) { return smbw_utimes(name, tvp); diff --git a/source3/smbwrapper/wrapper.h b/source3/smbwrapper/wrapper.h index 89ad3954e7..25694bd78c 100644 --- a/source3/smbwrapper/wrapper.h +++ b/source3/smbwrapper/wrapper.h @@ -31,11 +31,9 @@ #include #endif -#ifndef LINUX #ifdef HAVE_SYS_FCNTL_H #include #endif -#endif /* yuck! */ #define DIRP_SIZE (256 + 32) -- cgit