diff options
author | Andrew Tridgell <tridge@samba.org> | 1998-10-05 01:42:46 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1998-10-05 01:42:46 +0000 |
commit | 0531f4640a7a0154e35af8146ed46e47c5742574 (patch) | |
tree | 19b47c913c2ba2b3a76e0a6388ba2e5bc83e8804 | |
parent | 901399b70699e4f90421c2df2df2671e000c496e (diff) | |
download | samba-0531f4640a7a0154e35af8146ed46e47c5742574.tar.gz samba-0531f4640a7a0154e35af8146ed46e47c5742574.tar.bz2 samba-0531f4640a7a0154e35af8146ed46e47c5742574.zip |
this gets smbwrapper working under Solaris 2.6. Not tested much yet.
(This used to be commit 6a1b346d98c10688f0995a6ab8fd155a77ead258)
-rw-r--r-- | source3/smbwrapper/realcalls.h | 31 | ||||
-rw-r--r-- | source3/smbwrapper/smbw_dir.c | 13 | ||||
-rw-r--r-- | source3/smbwrapper/wrapped.c | 89 | ||||
-rw-r--r-- | source3/smbwrapper/wrapper.h | 3 |
4 files changed, 129 insertions, 7 deletions
diff --git a/source3/smbwrapper/realcalls.h b/source3/smbwrapper/realcalls.h index b55ae3b551..9017db3f0a 100644 --- a/source3/smbwrapper/realcalls.h +++ b/source3/smbwrapper/realcalls.h @@ -146,6 +146,37 @@ #endif +#ifdef HAVE__STAT64 +#define real_stat64(fn,st) (_stat64(fn,st)) +#elif HAVE___STAT64 +#define real_stat64(fn,st) (__stat64(fn,st)) +#endif + +#ifdef HAVE__LSTAT64 +#define real_lstat64(fn,st) (_lstat64(fn,st)) +#elif HAVE___LSTAT64 +#define real_lstat64(fn,st) (__lstat64(fn,st)) +#endif + +#ifdef HAVE__FSTAT64 +#define real_fstat64(fd,st) (_fstat64(fd,st)) +#elif HAVE___FSTAT64 +#define real_fstat64(fd,st) (__fstat64(fd,st)) +#endif + +#ifdef HAVE__READDIR64 +#define real_readdir64(d) (_readdir64(d)) +#elif HAVE___READDIR64 +#define real_readdir64(d) (__readdir64(d)) +#endif + +#ifdef HAVE__LLSEEK +#define real_llseek(fd,ofs,whence) (_llseek(fd,ofs,whence)) +#elif HAVE___LLSEEK +#define real_llseek(fd,ofs,whence) (__llseek(fd,ofs,whence)) +#endif + + #define real_readlink(fn,buf,len) (syscall(SYS_readlink, (fn), (buf), (len))) #define real_rename(fn1, fn2) (syscall(SYS_rename, (fn1), (fn2))) #define real_symlink(fn1, fn2) (syscall(SYS_symlink, (fn1), (fn2))) diff --git a/source3/smbwrapper/smbw_dir.c b/source3/smbwrapper/smbw_dir.c index 913fc9662e..bd8c91682e 100644 --- a/source3/smbwrapper/smbw_dir.c +++ b/source3/smbwrapper/smbw_dir.c @@ -31,9 +31,6 @@ extern int DEBUGLEVEL; extern int smbw_busy; -#define DIRP_SIZE (sizeof(fstring) + 12) - - /***************************************************** map a fd to a smbw_dir structure *******************************************************/ @@ -641,11 +638,13 @@ read one entry from a directory struct dirent *smbw_readdir(DIR *dirp) { struct smbw_dir *d = (struct smbw_dir *)dirp; - static char buf[DIRP_SIZE]; - struct dirent *de = (struct dirent *)buf; + static union { + char buf[DIRP_SIZE]; + struct dirent de; + } dbuf; - if (smbw_getdents(d->fd, de, DIRP_SIZE) > 0) - return de; + if (smbw_getdents(d->fd, &dbuf.de, DIRP_SIZE) > 0) + return &dbuf.de; return NULL; } diff --git a/source3/smbwrapper/wrapped.c b/source3/smbwrapper/wrapped.c index 50f78ce005..422f3abbf5 100644 --- a/source3/smbwrapper/wrapped.c +++ b/source3/smbwrapper/wrapped.c @@ -537,6 +537,7 @@ __asm__(".globl _write; _write = write"); DIR *opendir(const char *name) { + DIR *ret; if (smbw_path(name)) { return smbw_opendir(name); } @@ -628,3 +629,91 @@ __asm__(".globl _write; _write = write"); return open(path, O_WRONLY|O_CREAT|O_TRUNC, mode); } #endif + +#ifdef HAVE_STAT64 +static void stat64_convert(struct stat *st, struct stat64 *st64) +{ + st64->st_size = st->st_size; + st64->st_mode = st->st_mode; + st64->st_ino = st->st_ino; + st64->st_dev = st->st_dev; + st64->st_rdev = st->st_rdev; + st64->st_nlink = st->st_nlink; + st64->st_uid = st->st_uid; + st64->st_gid = st->st_gid; + st64->st_atime = st->st_atime; + st64->st_mtime = st->st_mtime; + st64->st_ctime = st->st_ctime; + st64->st_blksize = st->st_blksize; + st64->st_blocks = st->st_blocks; +} + + int stat64(const char *name, struct stat64 *st64) +{ + if (smbw_path(name)) { + struct stat st; + int ret = stat(name, &st); + stat64_convert(&st, st64); + return ret; + } + return real_stat64(name, st64); +} + + int fstat64(int fd, struct stat64 *st64) +{ + if (smbw_fd(fd)) { + struct stat st; + int ret = fstat(fd, &st); + stat64_convert(&st, st64); + return ret; + } + return real_fstat64(fd, st64); +} + + int lstat64(const char *name, struct stat64 *st64) +{ + if (smbw_path(name)) { + struct stat st; + int ret = lstat(name, &st); + stat64_convert(&st, st64); + return ret; + } + return real_lstat64(name, st64); +} +#endif + +#ifdef HAVE_LLSEEK + offset_t llseek(int fd, offset_t ofs, int whence) +{ + if (smbw_fd(fd)) { + return lseek(fd, ofs, whence); + } + return real_llseek(fd, ofs, whence); +} +#endif + +#ifdef HAVE_READDIR64 +static void dirent64_convert(struct dirent *d, struct dirent64 *d64) +{ + d64->d_ino = d->d_ino; + d64->d_off = d->d_off; + d64->d_reclen = d->d_reclen; + strcpy(d64->d_name, d->d_name); +} + + struct dirent64 *readdir64(DIR *dir) +{ + if (smbw_dirp(dir)) { + struct dirent *d; + static union { + char buf[DIRP_SIZE]; + struct dirent64 d64; + } dbuf; + d = readdir(dir); + if (!d) return NULL; + dirent64_convert(d, &dbuf.d64); + return &dbuf.d64; + } + return real_readdir64(dir); +} +#endif diff --git a/source3/smbwrapper/wrapper.h b/source3/smbwrapper/wrapper.h index 3eccdcac1e..839f51c6ed 100644 --- a/source3/smbwrapper/wrapper.h +++ b/source3/smbwrapper/wrapper.h @@ -37,6 +37,9 @@ #endif #endif +/* yuck! */ +#define DIRP_SIZE (256 + 32) + #include <stdio.h> #include <dirent.h> #include <errno.h> |