summaryrefslogtreecommitdiff
path: root/source3/smbwrapper
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-10-04 14:02:50 +0000
committerAndrew Tridgell <tridge@samba.org>1998-10-04 14:02:50 +0000
commit3a8232644e04a4cfdcbe2061f0556b78b4045191 (patch)
treeb9c52adfd8e5f01e247aa0b4eaa2ce40467951aa /source3/smbwrapper
parent40984f6b55212c710f6a7c7b940a785b2b607985 (diff)
downloadsamba-3a8232644e04a4cfdcbe2061f0556b78b4045191.tar.gz
samba-3a8232644e04a4cfdcbe2061f0556b78b4045191.tar.bz2
samba-3a8232644e04a4cfdcbe2061f0556b78b4045191.zip
started basic support for solaris 2.5 in smbwrapper.
(This used to be commit e5c7cabae4826bde819b94a48bc4674dcd69da21)
Diffstat (limited to 'source3/smbwrapper')
-rw-r--r--source3/smbwrapper/.cvsignore2
-rw-r--r--source3/smbwrapper/realcalls.h101
-rwxr-xr-xsource3/smbwrapper/smbsh14
-rw-r--r--source3/smbwrapper/smbw_dir.c40
-rw-r--r--source3/smbwrapper/wrapped.c41
-rw-r--r--source3/smbwrapper/wrapper.h7
6 files changed, 162 insertions, 43 deletions
diff --git a/source3/smbwrapper/.cvsignore b/source3/smbwrapper/.cvsignore
index f20330ba4d..6d609cec52 100644
--- a/source3/smbwrapper/.cvsignore
+++ b/source3/smbwrapper/.cvsignore
@@ -1 +1 @@
-*.p
+*.po
diff --git a/source3/smbwrapper/realcalls.h b/source3/smbwrapper/realcalls.h
index 4678426869..74cff66d00 100644
--- a/source3/smbwrapper/realcalls.h
+++ b/source3/smbwrapper/realcalls.h
@@ -28,38 +28,107 @@
#define real_chown(fn, owner, group) (syscall(SYS_chown,(fn),(owner),(group)))
#define real_getdents(fd, dirp, count) (syscall(SYS_getdents, (fd), (dirp), (count)))
-/* if needed define SYS_getdents so that getdents gets compiled */
-
#define real_link(fn1, fn2) (syscall(SYS_link, (fn1), (fn2)))
-#define real_lstat(fn, buf ) (syscall(SYS_lstat, (fn), (buf)))
#define real_open(fn,flags,mode) (syscall(SYS_open, (fn), (flags), (mode)))
-#define real_prev_lstat(fn, buf ) (syscall(SYS_prev_lstat, (fn), (buf)))
-#define real_prev_stat(fn, buf ) (syscall(SYS_prev_stat, (fn), (buf)))
-#ifdef linux
-#define real_readdir(dir) (__readdir(dir))
+
+#ifdef HAVE__OPENDIR
+#define real_opendir(fn) (_opendir(fn))
+#elif HAVE___OPENDIR
#define real_opendir(fn) (__opendir(fn))
-#define real_telldir(dir) (__telldir(dir))
-#define real_closedir(dir) (__closedir(dir))
-#define real_seekdir(dir, ofs) (__seekdir(dir, ofs))
#else
-#define real_readdir(dirp) ((struct dirent *)syscall(SYS_readdir,(dirp)))
#define real_opendir(fn) ((DIR *)syscall(SYS_opendir,(fn)))
-/* if needed define SYS_readdir so that readdir gets compiled */
#endif
+#ifdef HAVE__READDIR
+#define real_readdir(d) (_readdir(d))
+#elif HAVE___READDIR
+#define real_readdir(d) (__readdir(d))
+#else
+#define real_readdir(d) (syscall(SYS_readdir,(d)))
+#endif
+
+#ifdef HAVE__TELLDIR
+#define real_telldir(d) (_telldir(d))
+#elif HAVE___TELLDIR
+#define real_telldir(d) (__telldir(d))
+#else
+#define real_telldir(d) (syscall(SYS_telldir,(d)))
+#endif
+
+#ifdef HAVE__CLOSEDIR
+#define real_closedir(d) (_closedir(d))
+#elif HAVE___CLOSEDIR
+#define real_closedir(d) (__closedir(d))
+#else
+#define real_closedir(d) (syscall(SYS_closedir,(d)))
+#endif
+
+#ifdef HAVE__SEEKDIR
+#define real_seekdir(d,l) (_seekdir(d,l))
+#elif HAVE___SEEKDIR
+#define real_seekdir(d) (__seekdir(d,l))
+#else
+#define real_seekdir(d,l) (syscall(SYS_seekdir,(d),(l)))
+#endif
+
+#ifdef HAVE__DUP
+#define real_dup(d) (_dup(d))
+#elif HAVE___DUP
+#define real_dup(d) (__dup(d))
+#else
+#define real_dup(d) (syscall(SYS_dup,(d)))
+#endif
+
+#ifdef HAVE__DUP2
+#define real_dup2(d1,d2) (_dup2(d1,d2))
+#elif HAVE___DUP2
+#define real_dup2(d1,d2) (__dup2(d1,d2))
+#else
+#define real_dup2(d1,d2) (syscall(SYS_dup2,(d1),(d2)))
+#endif
+
+#ifdef HAVE__GETCWD
+#define real_getcwd(b,s) (_getcwd(b,s))
+#elif HAVE___GETCWD
+#define real_getcwd(b,s) (__getcwd(b,s))
+#else
+#define real_getcwd(b,s) (syscall(SYS_getcwd,(b),(s)))
+#endif
+
+#ifdef HAVE__STAT
+#define real_stat(fn,st) (_stat(fn,st))
+#elif HAVE___STAT
+#define real_stat(fn,st) (__stat(fn,st))
+#else
+#define real_stat(fn,st) (syscall(SYS_stat,(fn),(st)))
+#endif
+
+#ifdef HAVE__LSTAT
+#define real_lstat(fn,st) (_lstat(fn,st))
+#elif HAVE___LSTAT
+#define real_lstat(fn,st) (__lstat(fn,st))
+#else
+#define real_lstat(fn,st) (syscall(SYS_lstat,(fn),(st)))
+#endif
+
+#ifdef HAVE__FSTAT
+#define real_fstat(fd,st) (_fstat(fd,st))
+#elif HAVE___FSTAT
+#define real_fstat(fd,st) (__fstat(fd,st))
+#else
+#define real_fstat(fd,st) (syscall(SYS_fstat,(fd),(st)))
+#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)))
-#define real_stat(fn, buf ) (syscall(SYS_stat, (fn), (buf)))
-#define real_fstat(fd, buf ) (syscall(SYS_fstat, (fd), (buf)))
#define real_read(fd, buf, count ) (syscall(SYS_read, (fd), (buf), (count)))
#define real_lseek(fd, offset, whence) (syscall(SYS_lseek, (fd), (offset), (whence)))
#define real_write(fd, buf, count ) (syscall(SYS_write, (fd), (buf), (count)))
#define real_close(fd) (syscall(SYS_close, (fd)))
-#define real_dup(fd) (syscall(SYS_dup, (fd)))
-#define real_dup2(fd1, fd2) (syscall(SYS_dup2, (fd1), (fd2)))
#define real_fchdir(fd) (syscall(SYS_fchdir, (fd)))
#define real_fcntl(fd,cmd,arg) (syscall(SYS_fcntl, (fd), (cmd), (arg)))
#define real_symlink(fn1, fn2) (syscall(SYS_symlink, (fn1), (fn2)))
diff --git a/source3/smbwrapper/smbsh b/source3/smbwrapper/smbsh
index c03e4f2baf..015db52d95 100755
--- a/source3/smbwrapper/smbsh
+++ b/source3/smbwrapper/smbsh
@@ -1,24 +1,28 @@
#!/bin/sh
-LIBDIR=/samba/cvs/source/smbwrapper
+LIBDIR=/home/tridge/samba/source/smbwrapper
# a simple launcher for the smbwrapper.so preloadde library
if [ x$SMBW_USER = x ]; then
echo username?
read user
- export SMBW_USER=$user
+ SMBW_USER=$user
+ export SMBW_USER
fi
# this doesn't hide the password - we need a proper launch app for that
if [ x$SMBW_PASSWORD = x ]; then
echo password?
read pass
- export SMBW_PASSWORD=$pass
+ SMBW_PASSWORD=$pass
+ export
fi
-export LD_PRELOAD=$LIBDIR/smbwrapper.so
+LD_PRELOAD=$LIBDIR/smbwrapper.so
+export LD_PRELOAD
export PWD
-export PS1='smbsh$ '
+PS1='smbsh$ '
+export PS1
bash
diff --git a/source3/smbwrapper/smbw_dir.c b/source3/smbwrapper/smbw_dir.c
index d794944b1a..5a45c11175 100644
--- a/source3/smbwrapper/smbw_dir.c
+++ b/source3/smbwrapper/smbw_dir.c
@@ -31,6 +31,9 @@ extern int DEBUGLEVEL;
extern int smbw_busy;
+#define DIRP_SIZE (sizeof(fstring) + 12)
+
+
/*****************************************************
map a fd to a smbw_dir structure
*******************************************************/
@@ -274,7 +277,7 @@ int smbw_dir_fstat(int fd, struct stat *st)
ZERO_STRUCTP(st);
- smbw_setup_stat(st, "", dir->count*sizeof(struct dirent), aDIR);
+ smbw_setup_stat(st, "", dir->count*DIRP_SIZE, aDIR);
st->st_dev = dir->srv->dev;
@@ -307,7 +310,6 @@ int smbw_dir_close(int fd)
return 0;
}
-
/*****************************************************
a wrapper for getdents()
*******************************************************/
@@ -326,24 +328,25 @@ int smbw_getdents(unsigned int fd, struct dirent *dirp, int count)
smbw_busy--;
return -1;
}
+
+ DEBUG(4,("sizeof(*dirp)=%d\n", sizeof(*dirp)));
- while (count>=sizeof(*dirp) && (dir->offset < dir->count)) {
- dirp->d_off = (dir->offset+1)*sizeof(*dirp);
- dirp->d_reclen = sizeof(*dirp);
- safe_strcpy(&dirp->d_name[0], dir->list[dir->offset].name,
- sizeof(dirp->d_name)-1);
+ while (count>=DIRP_SIZE && (dir->offset < dir->count)) {
+ dirp->d_off = (dir->offset+1)*DIRP_SIZE;
+ dirp->d_reclen = DIRP_SIZE;
+ fstrcpy(&dirp->d_name[0], dir->list[dir->offset].name);
dirp->d_ino = smbw_inode(dir->list[dir->offset].name);
dir->offset++;
count -= dirp->d_reclen;
if (dir->offset == dir->count) {
dirp->d_off = -1;
}
- dirp++;
+ dirp = (struct dirent *)(((char *)dirp) + DIRP_SIZE);
n++;
}
smbw_busy--;
- return n*sizeof(*dirp);
+ return n*DIRP_SIZE;
}
@@ -445,18 +448,18 @@ off_t smbw_dir_lseek(int fd, off_t offset, int whence)
switch (whence) {
case SEEK_SET:
- dir->offset = offset/sizeof(struct dirent);
+ dir->offset = offset/DIRP_SIZE;
break;
case SEEK_CUR:
- dir->offset += offset/sizeof(struct dirent);
+ dir->offset += offset/DIRP_SIZE;
break;
case SEEK_END:
- dir->offset = (dir->count * sizeof(struct dirent)) + offset;
- dir->offset /= sizeof(struct dirent);
+ dir->offset = (dir->count * DIRP_SIZE) + offset;
+ dir->offset /= DIRP_SIZE;
break;
}
- ret = dir->offset * sizeof(struct dirent);
+ ret = dir->offset * DIRP_SIZE;
DEBUG(4,(" -> %d\n", (int)ret));
@@ -559,7 +562,7 @@ char *smbw_getcwd(char *buf, size_t size)
smbw_init();
if (smbw_busy) {
- return __getcwd(buf, size);
+ return real_getcwd(buf, size);
}
smbw_busy++;
@@ -636,10 +639,11 @@ read one entry from a directory
struct dirent *smbw_readdir(DIR *dirp)
{
struct smbw_dir *d = (struct smbw_dir *)dirp;
- static struct dirent de;
+ static char buf[DIRP_SIZE];
+ struct dirent *de = (struct dirent *)buf;
- if (smbw_getdents(d->fd, &de, sizeof(struct dirent)) > 0)
- return &de;
+ if (smbw_getdents(d->fd, de, DIRP_SIZE) > 0)
+ return de;
return NULL;
}
diff --git a/source3/smbwrapper/wrapped.c b/source3/smbwrapper/wrapped.c
index 0ee7341e3b..885fd4d481 100644
--- a/source3/smbwrapper/wrapped.c
+++ b/source3/smbwrapper/wrapped.c
@@ -94,7 +94,7 @@ __asm__(".globl __fcntl; __fcntl = fcntl");
__asm__(".globl __getdents; __getdents = getdents");
#endif
- int getdents(unsigned int fd, struct dirent *dirp, unsigned int count)
+ int getdents(int fd, struct dirent *dirp, unsigned int count)
{
if (smbw_fd(fd)) {
return smbw_getdents(fd, dirp, count);
@@ -188,6 +188,7 @@ __asm__(".globl __write; __write = write");
}
+#ifdef LINUX
int __fxstat(int vers, int fd, struct stat *st)
{
struct kernel_stat kbuf;
@@ -249,6 +250,7 @@ __asm__(".globl __write; __write = write");
return -1;
}
}
+#endif
char *getcwd(char *buf, size_t size)
@@ -257,7 +259,7 @@ __asm__(".globl __write; __write = write");
}
-
+#ifdef LINUX
int __lxstat(int vers, const char *name, struct stat *st)
{
struct kernel_stat kbuf;
@@ -319,7 +321,7 @@ __asm__(".globl __write; __write = write");
return -1;
}
}
-
+#endif
int mkdir(const char *name, mode_t mode)
@@ -343,6 +345,7 @@ __asm__(".globl __write; __write = write");
}
+#ifdef LINUX
int __xstat(int vers, const char *name, struct stat *st)
{
struct kernel_stat kbuf;
@@ -404,10 +407,42 @@ __asm__(".globl __write; __write = write");
return -1;
}
}
+#endif
int stat(const char *name, struct stat *st)
{
+#if HAVE___XSTAT
return __xstat(_STAT_VER, name, st);
+#else
+ if (smbw_path(name)) {
+ return smbw_stat(name, st);
+ }
+ return real_stat(name, st);
+#endif
+}
+
+ int lstat(const char *name, struct stat *st)
+{
+#if HAVE___LXSTAT
+ return __lxstat(_STAT_VER, name, st);
+#else
+ if (smbw_path(name)) {
+ return smbw_stat(name, st);
+ }
+ return real_lstat(name, st);
+#endif
+}
+
+ int fstat(int fd, struct stat *st)
+{
+#if HAVE___LXSTAT
+ return __fxstat(_STAT_VER, fd, st);
+#else
+ if (smbw_fd(fd)) {
+ return smbw_fstat(fd, st);
+ }
+ return real_fstat(fd, st);
+#endif
}
diff --git a/source3/smbwrapper/wrapper.h b/source3/smbwrapper/wrapper.h
index 5339f652f8..b80a029dff 100644
--- a/source3/smbwrapper/wrapper.h
+++ b/source3/smbwrapper/wrapper.h
@@ -21,14 +21,21 @@
#include "config.h"
+#ifdef HAVE_SYSCALL_H
#include <syscall.h>
+#elif HAVE_SYS_SYSCALL_H
+#include <sys/syscall.h>
+#endif
+
#include <stdio.h>
#include <dirent.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
+#ifdef LINUX
#include "kernel_stat.h"
+#endif
#include "realcalls.h"
int smbw_dirp(DIR *dirp);