[Libsysio-commit] b_lustre: libsysio/src chdir.c dup.c fcntl.c ioctl.c lseek.c open.c read.c stat.c
Brought to you by:
lward
From: Mei <me...@us...> - 2003-12-22 02:33:52
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv5026 Modified Files: Tag: b_lustre chdir.c dup.c fcntl.c ioctl.c lseek.c open.c read.c stat.c stat64.c write.c Log Message: add back the interception of functions with __ prefix. with some hack it could work with liblustre now. Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.3.8.7 retrieving revision 1.3.8.8 diff -u -w -b -B -p -r1.3.8.7 -r1.3.8.8 --- chdir.c 16 Dec 2003 07:07:42 -0000 1.3.8.7 +++ chdir.c 22 Dec 2003 02:33:48 -0000 1.3.8.8 @@ -236,6 +236,10 @@ getcwd(char *buf, size_t size) return buf; } +#ifdef __GLIBC__ +sysio_sym_weak_alias(getcwd, __getcwd) +#endif + #ifdef PATH_MAX char * getwd(char *buf) Index: dup.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/dup.c,v retrieving revision 1.1.1.1.12.5 retrieving revision 1.1.1.1.12.6 diff -u -w -b -B -p -r1.1.1.1.12.5 -r1.1.1.1.12.6 --- dup.c 16 Dec 2003 07:07:42 -0000 1.1.1.1.12.5 +++ dup.c 22 Dec 2003 02:33:48 -0000 1.1.1.1.12.6 @@ -86,3 +86,8 @@ dup(int oldfd) return rc; } +#ifdef __GLIBC__ +#undef __dup +sysio_sym_weak_alias(dup, __dup) +#endif + Index: fcntl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v retrieving revision 1.3.2.12 retrieving revision 1.3.2.13 diff -u -w -b -B -p -r1.3.2.12 -r1.3.2.13 --- fcntl.c 16 Dec 2003 07:07:42 -0000 1.3.2.12 +++ fcntl.c 22 Dec 2003 02:33:48 -0000 1.3.2.13 @@ -136,6 +136,11 @@ out: return err; } +#ifdef __GLIBC__ +#undef __fcntl +sysio_sym_weak_alias(fcntl, __fcntl) +#endif + #if defined(BSD) || defined(REDSTORM) #undef _fcntl sysio_sym_weak_alias(fcntl, _fcntl) Index: ioctl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v retrieving revision 1.1.1.1.12.7 retrieving revision 1.1.1.1.12.8 diff -u -w -b -B -p -r1.1.1.1.12.7 -r1.1.1.1.12.8 --- ioctl.c 16 Dec 2003 07:07:42 -0000 1.1.1.1.12.7 +++ ioctl.c 22 Dec 2003 02:33:48 -0000 1.1.1.1.12.8 @@ -86,6 +86,11 @@ out: } +#ifdef __GLIBC__ +#undef __ioctl +sysio_sym_weak_alias(ioctl, __ioctl) +#endif + #if defined(BSD) || defined(REDSTORM) #undef _ioctl sysio_sym_weak_alias(ioctl, _ioctl) Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.4.2.7 retrieving revision 1.4.2.8 diff -u -w -b -B -p -r1.4.2.7 -r1.4.2.8 --- lseek.c 16 Dec 2003 07:07:42 -0000 1.4.2.7 +++ lseek.c 22 Dec 2003 02:33:48 -0000 1.4.2.8 @@ -106,6 +106,10 @@ out: #if _LARGEFILE64_SOURCE #undef lseek64 sysio_sym_weak_alias(_sysio_lseek, lseek64) +#ifdef __GLIBC__ +#undef __lseek64 +sysio_sym_weak_alias(_sysio_lseek, __lseek64) +#endif #endif #undef lseek @@ -131,6 +135,11 @@ lseek(int fd, off_t offset, int whence) SYSIO_LEAVE; return rtn; } + +#ifdef __GLIBC__ +#undef __lseek +sysio_sym_weak_alias(lseek, __lseek) +#endif #if 0 #ifdef __linux__ Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.7.2.8 retrieving revision 1.7.2.9 diff -u -w -b -B -p -r1.7.2.8 -r1.7.2.9 --- open.c 16 Dec 2003 07:07:42 -0000 1.7.2.8 +++ open.c 22 Dec 2003 02:33:48 -0000 1.7.2.9 @@ -212,8 +212,12 @@ error: } #ifdef __GLIBC__ +#undef __open +sysio_sym_weak_alias(open, __open) #undef open64 sysio_sym_weak_alias(open, open64) +#undef __open64 +sysio_sym_weak_alias(open, __open64) #endif #if defined(BSD) || defined(REDSTORM) @@ -234,6 +238,11 @@ close(int fd) return err ? -1 : 0; } +#ifdef __GLIBC__ +#undef __close +sysio_sym_weak_alias(close, __close) +#endif + #if defined(BSD) || defined(REDSTORM) #undef _close sysio_sym_weak_alias(close, _close) @@ -247,8 +256,12 @@ creat(const char *path, mode_t mode) } #ifdef __GLIBC__ +#undef __creat +sysio_sym_weak_alias(creat, __creat) #undef creat64 sysio_sym_weak_alias(creat, creat64) +#undef __creat64 +sysio_sym_weak_alias(creat, __creat64) #endif #if defined(BSD) || defined(REDSTORM) Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.2.8.11 retrieving revision 1.2.8.12 diff -u -w -b -B -p -r1.2.8.11 -r1.2.8.12 --- read.c 16 Dec 2003 07:07:42 -0000 1.2.8.11 +++ read.c 22 Dec 2003 02:33:48 -0000 1.2.8.12 @@ -252,10 +252,21 @@ read(int fd, void *buf, size_t count) ioid_t ioid; ioid = iread(fd, buf, count); - if (ioid == IOID_FAIL) + if (ioid == IOID_FAIL) { + /* XXX + * CFS hack for read/write + */ + if (errno == EBADF) + return syscall(SYS_read, fd, buf, count); return -1; + } return iowait(ioid); } + +#ifdef __GLIBC__ +#undef __read +sysio_sym_weak_alias(read, __read) +#endif #if defined(BSD) || defined(REDSTORM) #undef _read Index: stat.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/stat.c,v retrieving revision 1.3.4.5 retrieving revision 1.3.4.6 diff -u -w -b -B -p -r1.3.4.5 -r1.3.4.6 --- stat.c 16 Dec 2003 07:07:42 -0000 1.3.4.5 +++ stat.c 22 Dec 2003 02:33:48 -0000 1.3.4.6 @@ -46,6 +46,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> +#include <syscall.h> #include <sys/queue.h> #include "sysio.h" @@ -87,8 +88,8 @@ convstat(struct stat64 *st64_buf, struct } #endif -static int -__fxstat_internal(int __ver, int __fildes, struct stat *__stat_buf) +int +__fxstat(int __ver, int __fildes, struct stat *__stat_buf) { struct file *fil; int err; @@ -105,7 +106,10 @@ __fxstat_internal(int __ver, int __filde err = 0; fil = _sysio_fd_find(__fildes); if (!fil) { - err = -EBADF; + /* XXX + * CFS hack for __fxstat64/__fxstat + */ + err = syscall(SYS_fstat, __fildes, __stat_buf, 0); goto out; } #if _LARGEFILE64_SOURCE @@ -132,7 +136,7 @@ __fstat(int fd, struct stat *buf) int rc; SYSIO_ENTER; - rc = __fxstat_internal(_STAT_VER, fd, buf); + rc = __fxstat(_STAT_VER, fd, buf); SYSIO_LEAVE; return rc; Index: stat64.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/stat64.c,v retrieving revision 1.3.4.5 retrieving revision 1.3.4.6 diff -u -w -b -B -p -r1.3.4.5 -r1.3.4.6 --- stat64.c 16 Dec 2003 07:07:42 -0000 1.3.4.5 +++ stat64.c 22 Dec 2003 02:33:48 -0000 1.3.4.6 @@ -48,6 +48,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> +#include <syscall.h> #include <sys/queue.h> #include "sysio.h" @@ -62,8 +63,8 @@ #undef __xstat64 #undef __lxstat64 -static int -__fxstat64_internal(int __ver, int __fildes, struct stat64 *__stat_buf) +int +__fxstat64(int __ver, int __fildes, struct stat64 *__stat_buf) { struct file *fil; int err; @@ -76,7 +77,10 @@ __fxstat64_internal(int __ver, int __fil err = 0; fil = _sysio_fd_find(__fildes); if (!fil) { - err = -EBADF; + /* XXX + * CFS hack for __fxstat64/__fxstat + */ + err = syscall(SYS_fstat64, __fildes, __stat_buf, 0); goto out; } err = fil->f_ino->i_ops.inop_getattr(NULL, fil->f_ino, __stat_buf); @@ -94,7 +98,7 @@ fstat64(int fd, struct stat64 *buf) int rc; SYSIO_ENTER; - rc = __fxstat64_internal(_STAT_VER, fd, buf); + rc = __fxstat64(_STAT_VER, fd, buf); SYSIO_LEAVE; return rc; Index: write.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/write.c,v retrieving revision 1.2.10.11 retrieving revision 1.2.10.12 diff -u -w -b -B -p -r1.2.10.11 -r1.2.10.12 --- write.c 16 Dec 2003 07:07:42 -0000 1.2.10.11 +++ write.c 22 Dec 2003 02:33:48 -0000 1.2.10.12 @@ -201,7 +201,7 @@ iwritev(int fd, const struct iovec *iov, fil = _sysio_fd_find(fd); if (!fil) { - errno = -EBADF; + errno = EBADF; SYSIO_LEAVE; return IOID_FAIL; } @@ -251,10 +251,21 @@ write(int fd, const void *buf, size_t co ioid_t ioid; ioid = iwrite(fd, buf, count); - if (ioid == IOID_FAIL) + if (ioid == IOID_FAIL) { + /* XXX + * CFS hack for read/write + */ + if (errno == EBADF) + return syscall(SYS_write, fd, buf, count); return -1; + } return iowait(ioid); } + +#ifdef __GLIBC__ +#undef __write +sysio_sym_weak_alias(write, __write) +#endif #if defined(BSD) || defined(REDSTORM) #undef _write |