diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbwrapper/realcalls.c | 37 | ||||
-rw-r--r-- | source3/smbwrapper/realcalls.h | 9 | ||||
-rw-r--r-- | source3/smbwrapper/smbw.c | 27 | ||||
-rw-r--r-- | source3/smbwrapper/wrapped.c | 40 | ||||
-rw-r--r-- | source3/smbwrapper/wrapper.h | 1 |
5 files changed, 102 insertions, 12 deletions
diff --git a/source3/smbwrapper/realcalls.c b/source3/smbwrapper/realcalls.c new file mode 100644 index 0000000000..4eb3d5e087 --- /dev/null +++ b/source3/smbwrapper/realcalls.c @@ -0,0 +1,37 @@ +/* + Unix SMB/Netbios implementation. + Version 2.0 + SMB wrapper functions for calls that syscall() can't do + Copyright (C) Andrew Tridgell 1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "wrapper.h" + +#ifdef REPLACE_UTIME +int real_utime(const char *name, struct utimbuf *buf) +{ + struct timeval tv[2]; + + tv[0].tv_sec = buf->actime; + tv[0].tv_usec = 0; + tv[1].tv_sec = buf->modtime; + tv[1].tv_usec = 0; + + return real_utimes(name, &tv[0]); +} +#endif diff --git a/source3/smbwrapper/realcalls.h b/source3/smbwrapper/realcalls.h index 1d65499ae3..ada2591101 100644 --- a/source3/smbwrapper/realcalls.h +++ b/source3/smbwrapper/realcalls.h @@ -74,8 +74,6 @@ #define real_telldir(d) (syscall(SYS_telldir,(d))) #elif HAVE___TELLDIR #define real_telldir(d) (__telldir(d)) -#else -#define NO_TELLDIR_WRAPPER #endif #ifdef HAVE__DUP @@ -216,5 +214,10 @@ #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_utime(fn, buf) (syscall(SYS_utime, (fn), (buf))) #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 diff --git a/source3/smbwrapper/smbw.c b/source3/smbwrapper/smbw.c index 9734215305..e7d0106034 100644 --- a/source3/smbwrapper/smbw.c +++ b/source3/smbwrapper/smbw.c @@ -913,11 +913,10 @@ int smbw_rename(const char *oldname, const char *newname) /***************************************************** -a wrapper for utime() +a wrapper for utime and utimes *******************************************************/ -int smbw_utime(const char *fname, void *buf) +static int smbw_settime(const char *fname, time_t t) { - struct utimbuf *tbuf = (struct utimbuf *)buf; struct smbw_server *srv; fstring server, share; pstring path; @@ -947,8 +946,7 @@ int smbw_utime(const char *fname, void *buf) goto failed; } - if (!cli_setatr(&srv->cli, path, mode, - tbuf?tbuf->modtime:time(NULL))) { + if (!cli_setatr(&srv->cli, path, mode, t)) { errno = smbw_errno(&srv->cli); goto failed; } @@ -962,6 +960,25 @@ int smbw_utime(const char *fname, void *buf) } /***************************************************** +a wrapper for utime +*******************************************************/ +int smbw_utime(const char *fname, void *buf) +{ + struct utimbuf *tbuf = (struct utimbuf *)buf; + return smbw_settime(fname, tbuf?tbuf->modtime:time(NULL)); +} + +/***************************************************** +a wrapper for utime +*******************************************************/ +int smbw_utimes(const char *fname, void *buf) +{ + struct timeval *tbuf = (struct timeval *)buf; + return smbw_settime(fname, tbuf?tbuf->tv_sec:time(NULL)); +} + + +/***************************************************** a wrapper for chown() *******************************************************/ int smbw_chown(const char *fname, uid_t owner, gid_t group) diff --git a/source3/smbwrapper/wrapped.c b/source3/smbwrapper/wrapped.c index 81f8162290..7902371ec6 100644 --- a/source3/smbwrapper/wrapped.c +++ b/source3/smbwrapper/wrapped.c @@ -22,8 +22,15 @@ #include "wrapper.h" - int open(const char *name, int flags, mode_t mode) + int open(const char *name, int flags, ...) { + va_list ap; + mode_t mode; + + va_start(ap, flags); + mode = va_arg(ap, mode_t); + va_end(ap); + if (smbw_path(name)) { return smbw_open(name, flags, mode); } @@ -174,8 +181,14 @@ #endif - 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); + if (smbw_fd(fd)) { return smbw_fcntl(fd, cmd, arg); } @@ -575,6 +588,7 @@ } +#ifdef HAVE_UTIME int utime(const char *name,void *tvp) { if (smbw_path(name)) { @@ -583,6 +597,18 @@ return real_utime(name, tvp); } +#endif + +#ifdef HAVE_UTIMES + int utimes(const char *name,void *tvp) +{ + if (smbw_path(name)) { + return smbw_utimes(name, tvp); + } + + return real_utimes(name, tvp); +} +#endif int readlink(char *path, char *buf, size_t bufsize) { @@ -657,6 +683,7 @@ return real_dup2(oldfd, newfd); } +#ifdef real_opendir DIR *opendir(const char *name) { DIR *ret; @@ -666,7 +693,9 @@ return real_opendir(name); } +#endif +#ifdef real_readdir struct dirent *readdir(DIR *dir) { if (smbw_dirp(dir)) { @@ -675,7 +704,9 @@ return real_readdir(dir); } +#endif +#ifdef real_closedir int closedir(DIR *dir) { if (smbw_dirp(dir)) { @@ -684,8 +715,9 @@ return real_closedir(dir); } +#endif -#ifndef NO_TELLDIR_WRAPPER +#ifdef real_telldir off_t telldir(DIR *dir) { if (smbw_dirp(dir)) { @@ -696,7 +728,7 @@ } #endif -#ifndef NO_SEEKDIR_WRAPPER +#ifdef real_seekdir void seekdir(DIR *dir, off_t offset) { if (smbw_dirp(dir)) { diff --git a/source3/smbwrapper/wrapper.h b/source3/smbwrapper/wrapper.h index 839f51c6ed..89ad3954e7 100644 --- a/source3/smbwrapper/wrapper.h +++ b/source3/smbwrapper/wrapper.h @@ -43,6 +43,7 @@ #include <stdio.h> #include <dirent.h> #include <errno.h> +#include <stdarg.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/time.h> |