libsysio-commit Mailing List for libsysio (Page 42)
Brought to you by:
lward
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(25) |
May
(28) |
Jun
(25) |
Jul
(30) |
Aug
(60) |
Sep
(52) |
Oct
(100) |
Nov
(15) |
Dec
(34) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(89) |
Feb
(48) |
Mar
(22) |
Apr
(59) |
May
(16) |
Jun
(15) |
Jul
(50) |
Aug
(26) |
Sep
(40) |
Oct
(27) |
Nov
(12) |
Dec
|
2005 |
Jan
(24) |
Feb
(11) |
Mar
|
Apr
|
May
(3) |
Jun
(6) |
Jul
|
Aug
(14) |
Sep
(21) |
Oct
(10) |
Nov
|
Dec
|
2006 |
Jan
(8) |
Feb
(5) |
Mar
(2) |
Apr
(6) |
May
(11) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2007 |
Jan
(3) |
Feb
(5) |
Mar
(20) |
Apr
(41) |
May
(21) |
Jun
(3) |
Jul
(5) |
Aug
(12) |
Sep
(21) |
Oct
(5) |
Nov
(16) |
Dec
|
2008 |
Jan
|
Feb
(2) |
Mar
(4) |
Apr
(23) |
May
|
Jun
(22) |
Jul
(13) |
Aug
|
Sep
|
Oct
(9) |
Nov
(3) |
Dec
(13) |
2009 |
Jan
(14) |
Feb
(10) |
Mar
(2) |
Apr
(11) |
May
(7) |
Jun
(1) |
Jul
(1) |
Aug
(36) |
Sep
(12) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Ruth K. <rk...@us...> - 2003-10-06 21:14:28
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv17203 Modified Files: Tag: cplant chdir.c fcntl.c ioctl.c lseek.c open.c read.c write.c Log Message: replace fn defs with symbol aliases Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -u -w -b -B -p -r1.4.2.1 -r1.4.2.2 --- chdir.c 26 Aug 2003 17:21:39 -0000 1.4.2.1 +++ chdir.c 6 Oct 2003 21:14:21 -0000 1.4.2.2 @@ -77,6 +77,8 @@ #include "mount.h" #include "file.h" +#include "sysio-symbols.h" + struct pnode *_sysio_cwd = NULL; int @@ -181,12 +183,8 @@ getcwd(char *buf, size_t size) return buf; } -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -char * -__getcwd(char *buf, size_t size) -{ - return getcwd(buf, size); -} +#ifdef __GLIBC__ +sysio_sym_weak_alias(getcwd, __getcwd) #endif #ifdef PATH_MAX Index: fcntl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -w -b -B -p -r1.4 -r1.4.2.1 --- fcntl.c 14 Aug 2003 18:39:33 -0000 1.4 +++ fcntl.c 6 Oct 2003 21:14:22 -0000 1.4.2.1 @@ -51,6 +51,8 @@ #include "inode.h" #include "file.h" +#include "sysio-symbols.h" + int fcntl(int fd, int cmd, ...) { @@ -96,17 +98,7 @@ out: return err; } -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -int -__fcntl(int fd, int cmd, ...) -{ - int rc; - va_list ap; - - va_start(ap, cmd); - rc = fcntl(fd, cmd, ap); - va_end(ap); - - return rc; -} +#ifdef __GLIBC__ +#undef __fcntl +sysio_sym_weak_alias(fcntl, __fcntl) #endif Index: ioctl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -w -b -B -p -r1.2 -r1.2.2.1 --- ioctl.c 14 Aug 2003 18:39:33 -0000 1.2 +++ ioctl.c 6 Oct 2003 21:14:22 -0000 1.2.2.1 @@ -50,6 +50,8 @@ #include "inode.h" #include "file.h" +#include "sysio-symbols.h" + int ioctl(int fd, unsigned long request, ...) { @@ -77,17 +79,7 @@ out: } -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -int -__ioctl(int fd, unsigned long request, ...) -{ - va_list ap; - int rc; - - va_start(ap, request); - rc = ioctl(fd, request, ap); - va_end(ap); - - return rc; -} +#ifdef __GLIBC__ +#undef __ioctl +sysio_sym_weak_alias(ioctl, __ioctl) #endif Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -w -b -B -p -r1.6 -r1.6.2.1 --- lseek.c 14 Aug 2003 18:39:33 -0000 1.6 +++ lseek.c 6 Oct 2003 21:14:22 -0000 1.6.2.1 @@ -103,7 +103,14 @@ out: return fil->f_pos = off; } +#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 @@ -114,30 +121,7 @@ lseek(int fd, off_t offset, int whence) return (off_t )_sysio_lseek(fd, offset, whence); } -#if defined(__GLIBC__) && defined(ALPHA_LINUX) - -off_t -__lseek(int fd, off_t offset, int whence) -{ - return lseek(fd, offset, whence); -} - -loff_t -__lseek64( int fd, loff_t offset, int whence) -{ - return lseek( fd, offset, whence ); -} - -loff_t -__llseek( int fd, loff_t offset, int whence) -{ - return __lseek64(fd, offset, whence); -} - -loff_t -__llseek64( int fd, loff_t offset, int whence) -{ - return __lseek64(fd, offset, whence); -} - +#ifdef __GLIBC__ +#undef __lseek +sysio_sym_weak_alias(lseek, __lseek) #endif Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -w -b -B -p -r1.8 -r1.8.2.1 --- open.c 14 Aug 2003 18:39:33 -0000 1.8 +++ open.c 6 Oct 2003 21:14:22 -0000 1.8.2.1 @@ -49,7 +49,6 @@ #include <sys/stat.h> #include <fcntl.h> #include <sys/queue.h> -#include <features.h> #include "sysio.h" #include "inode.h" @@ -57,12 +56,7 @@ #include "fs.h" #include "mount.h" -#ifdef __GLIBC__ -#undef open -#undef __open -#undef open64 -#undef __open64 -#endif +#include "sysio-symbols.h" /* * Open file support. @@ -206,6 +200,15 @@ error: return -1; } +#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 + int close(int fd) { @@ -217,6 +220,11 @@ close(int fd) return err ? -1 : 0; } +#ifdef __GLIBC__ +#undef __close +sysio_sym_weak_alias(close, __close) +#endif + int creat(const char *path, mode_t mode) { @@ -224,6 +232,15 @@ creat(const char *path, mode_t mode) return open(path, O_CREAT|O_WRONLY|O_TRUNC, 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 + mode_t umask(mode_t mask) { @@ -233,49 +250,3 @@ umask(mode_t mask) _sysio_umask = mask & 0777; return omask; } - -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -int -open64(const char *fname, int flags, ...) -{ - va_list ap; - mode_t mode; - - va_start(ap, flags); - mode = va_arg(ap, mode_t); - va_end(ap); - - return open(fname, flags, mode); -} - -int -__open64(const char *fname, int flags, ...) -{ - va_list ap; - mode_t mode; - - va_start(ap, flags); - mode = va_arg(ap, mode_t); - va_end(ap); - - return open(fname, flags, mode); -} -int -__open(const char *fname, int flags, ...) -{ - va_list ap; - mode_t mode; - - va_start(ap, flags); - mode = va_arg(ap, mode_t); - va_end(ap); - - return open(fname, flags, mode); -} - -int -__close(int fd) { - - return close(fd); -} -#endif Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -w -b -B -p -r1.3 -r1.3.2.1 --- read.c 14 Aug 2003 18:39:33 -0000 1.3 +++ read.c 6 Oct 2003 21:14:22 -0000 1.3.2.1 @@ -53,6 +53,8 @@ #include "file.h" #include "inode.h" +#include "sysio-symbols.h" + /* * Schedule asynchronous read of iovec at some file extent. */ @@ -210,6 +212,16 @@ read(int fd, void *buf, size_t count) return iowait(ioid); } +#ifdef __GLIBC__ +#undef __read +sysio_sym_weak_alias(read, __read) +#endif + +#if _LARGEFILE64_SOURCE +#undef read64 +sysio_sym_weak_alias(read, read64) +#endif + #ifdef notdef int read_list(int fd, @@ -222,13 +234,5 @@ read_list(int fd, { errno = ENOSYS; return -1; -} -#endif - -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -ssize_t -__read(int fd, void *buf, size_t count) -{ - return read(fd, buf, count); } #endif Index: write.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/write.c,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -w -b -B -p -r1.3 -r1.3.2.1 --- write.c 14 Aug 2003 18:39:33 -0000 1.3 +++ write.c 6 Oct 2003 21:14:22 -0000 1.3.2.1 @@ -55,6 +55,8 @@ #include "fs.h" #include "mount.h" +#include "sysio-symbols.h" + /* * Schedule asynchronous write of iovec at some file extent. */ @@ -216,6 +218,16 @@ write(int fd, const void *buf, size_t co return iowait(ioid); } +#ifdef __GLIBC__ +#undef __write +sysio_sym_weak_alias(write, __write) +#endif + +#if _LARGEFILE64_SOURCE +#undef write64 +sysio_sym_weak_alias(write, write64) +#endif + #ifdef notdef int write_list(int fd, @@ -230,18 +242,3 @@ write_list(int fd, return -1; } #endif - -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -ssize_t -__write(int fd, const void *buf, size_t count) -{ - return write(fd, buf, count); -} - -ssize_t -__writev(int fd, const struct iovec *iov, int count) -{ - return writev(fd, iov, count); -} -#endif - |
From: Lee W. <lw...@us...> - 2003-09-30 00:06:33
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv22549/drivers/native Modified Files: Tag: RedStorm fs_native.c Log Message: -Fix prototype for getdirentries for Red Storm -Remove entry point for llseek in the core. That was goofy. Linux defines it as a syscall but there is no entry in libc. -Move __USE_LARGEFILE64 to _LARGEFILE64_SOURCE; We only want the xxx64() routines if asked explicitly. -Fix driver/native/fs_native.c _LARGEFILE64_SOURCE defines. The symbol is always defined. The test should be whether it is true/false not just defined. -Fix driver/native/fs_native.c to use SYS_lseek if SYS__llseek is not present. The 64-bit machines don't seem to use that interface. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11.4.8 retrieving revision 1.11.4.9 diff -u -w -b -B -p -r1.11.4.8 -r1.11.4.9 --- fs_native.c 27 Sep 2003 20:20:40 -0000 1.11.4.8 +++ fs_native.c 29 Sep 2003 14:57:01 -0000 1.11.4.9 @@ -841,7 +841,7 @@ out: static int native_pos(int fd, -#ifdef _LARGEFILE64_SOURCE +#if _LARGEFILE64_SOURCE loff_t *offset #else _SYSIO_OFF_T *offset @@ -852,7 +852,7 @@ native_pos(int fd, assert(fd >= 0); assert(*offset >= 0); -#ifdef _LARGEFILE64_SOURCE +#if _LARGEFILE64_SOURCE && defined(SYS__llseek) { int err; err = @@ -887,7 +887,7 @@ native_getdirentries(struct inode *ino, { struct native_inode *nino = I2NI(ino); int err; -#ifdef _LARGEFILE64_SOURCE +#if _LARGEFILE64_SOURCE loff_t result; #else _SYSIO_OFF_T result; @@ -1141,7 +1141,7 @@ doio(ssize_t (*f)(int, const struct iove { struct native_inode *nino = I2NI(ino); struct ioctx *ioctx; -#ifdef _LARGEFILE64_SOURCE +#if _LARGEFILE64_SOURCE loff_t result; #else _SYSIO_OFF_T result; |
From: Lee W. <lw...@us...> - 2003-09-30 00:02:53
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv22549/src Modified Files: Tag: RedStorm getdirentries.c lseek.c read.c stat64.c truncate.c write.c Log Message: -Fix prototype for getdirentries for Red Storm -Remove entry point for llseek in the core. That was goofy. Linux defines it as a syscall but there is no entry in libc. -Move __USE_LARGEFILE64 to _LARGEFILE64_SOURCE; We only want the xxx64() routines if asked explicitly. -Fix driver/native/fs_native.c _LARGEFILE64_SOURCE defines. The symbol is always defined. The test should be whether it is true/false not just defined. -Fix driver/native/fs_native.c to use SYS_lseek if SYS__llseek is not present. The 64-bit machines don't seem to use that interface. Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.1.10.3 retrieving revision 1.1.10.4 diff -u -w -b -B -p -r1.1.10.3 -r1.1.10.4 --- getdirentries.c 27 Sep 2003 23:01:23 -0000 1.1.10.3 +++ getdirentries.c 29 Sep 2003 14:57:01 -0000 1.1.10.4 @@ -46,7 +46,7 @@ _getdirentries64(int fd, return cc; } -#if __USE_LARGEFILE64 +#if _LARGEFILE64_SOURCE #undef getdirentries64 sysio_sym_strong_alias(_getdirentries64, getdirentries64) #endif Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.4.4.3 retrieving revision 1.4.4.4 diff -u -w -b -B -p -r1.4.4.3 -r1.4.4.4 --- lseek.c 27 Sep 2003 23:01:23 -0000 1.4.4.3 +++ lseek.c 29 Sep 2003 14:57:01 -0000 1.4.4.4 @@ -103,7 +103,7 @@ out: return fil->f_pos = off; } -#if __USE_LARGEFILE64 +#if _LARGEFILE64_SOURCE #undef lseek64 sysio_sym_weak_alias(_sysio_lseek, lseek64) #ifdef __GLIBC__ @@ -136,6 +136,7 @@ lseek(int fd, off_t offset, int whence) sysio_sym_weak_alias(lseek, __lseek) #endif +#if 0 #ifdef __linux__ #undef llseek int @@ -155,4 +156,5 @@ llseek(unsigned int fd __IS_UNUSED, #undef __llseek sysio_sym_weak_alias(llseek, __llseek) +#endif #endif Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.2.10.2 retrieving revision 1.2.10.3 diff -u -w -b -B -p -r1.2.10.2 -r1.2.10.3 --- read.c 27 Sep 2003 23:01:23 -0000 1.2.10.2 +++ read.c 29 Sep 2003 14:57:01 -0000 1.2.10.3 @@ -156,7 +156,7 @@ _pread(int fd, void *buf, size_t count, return iowait(ioid); } -#if __USE_LARGEFILE64 +#if _LARGEFILE64_SOURCE #undef pread64 sysio_sym_weak_alias(_pread, pread64) @@ -233,7 +233,7 @@ read(int fd, void *buf, size_t count) sysio_sym_weak_alias(read, __read) #endif -#if __USE_LARGEFILE +#if _LARGEFILE64_SOURCE #undef read64 sysio_sym_weak_alias(read, read64) #endif Index: stat64.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/stat64.c,v retrieving revision 1.3.6.2 retrieving revision 1.3.6.3 diff -u -w -b -B -p -r1.3.6.2 -r1.3.6.3 --- stat64.c 27 Sep 2003 23:01:24 -0000 1.3.6.2 +++ stat64.c 29 Sep 2003 14:57:01 -0000 1.3.6.3 @@ -166,4 +166,4 @@ lstat64(const char *filename, struct sta return __lxstat64(_STAT_VER, filename, buf); } -#endif /* !__USE_LARGEFILE64 */ +#endif /* !_LARGEFILE64_SOURCE */ Index: truncate.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/truncate.c,v retrieving revision 1.3.6.1 retrieving revision 1.3.6.2 diff -u -w -b -B -p -r1.3.6.1 -r1.3.6.2 --- truncate.c 27 Sep 2003 23:01:24 -0000 1.3.6.1 +++ truncate.c 29 Sep 2003 14:57:01 -0000 1.3.6.2 @@ -97,7 +97,7 @@ out: return err; } -#if __USE_LARGEFILE64 +#if _LARGEFILE64_SOURCE #undef truncate64 sysio_sym_weak_alias(_truncate, truncate64) @@ -134,7 +134,7 @@ out: return err; } -#if __USE_LARGEFILE64 +#if _LARGEFILE64_SOURCE #undef ftruncate64 sysio_sym_weak_alias(_ftruncate, ftruncate64) Index: write.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/write.c,v retrieving revision 1.2.12.2 retrieving revision 1.2.12.3 diff -u -w -b -B -p -r1.2.12.2 -r1.2.12.3 --- write.c 27 Sep 2003 23:01:24 -0000 1.2.12.2 +++ write.c 29 Sep 2003 14:57:01 -0000 1.2.12.3 @@ -156,7 +156,7 @@ _pwrite(int fd, const void *buf, size_t return iowait(ioid); } -#if __USE_LARGEFILE64 +#if _LARGEFILE64_SOURCE #undef pwrite64 sysio_sym_weak_alias(_pwrite, pwrite64) @@ -233,7 +233,7 @@ write(int fd, const void *buf, size_t co sysio_sym_weak_alias(write, __write) #endif -#if __USE_LARGEFILE +#if _LARGEFILE64_SOURCE #undef write64 sysio_sym_weak_alias(write, write64) #endif |
From: Lee W. <lw...@us...> - 2003-09-29 23:02:18
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1:/tmp/cvs-serv22549/include Modified Files: Tag: RedStorm sysio.h Log Message: -Fix prototype for getdirentries for Red Storm -Remove entry point for llseek in the core. That was goofy. Linux defines it as a syscall but there is no entry in libc. -Move __USE_LARGEFILE64 to _LARGEFILE64_SOURCE; We only want the xxx64() routines if asked explicitly. -Fix driver/native/fs_native.c _LARGEFILE64_SOURCE defines. The symbol is always defined. The test should be whether it is true/false not just defined. -Fix driver/native/fs_native.c to use SYS_lseek if SYS__llseek is not present. The 64-bit machines don't seem to use that interface. Index: sysio.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio.h,v retrieving revision 1.7.6.4 retrieving revision 1.7.6.5 diff -u -w -b -B -p -r1.7.6.4 -r1.7.6.5 --- sysio.h 27 Sep 2003 23:01:23 -0000 1.7.6.4 +++ sysio.h 29 Sep 2003 14:57:01 -0000 1.7.6.5 @@ -164,7 +164,7 @@ extern off64_t lseek64(int fd, off64_t o #endif extern int lstat(const char *path, struct stat *buf); #if defined(BSD) || defined(REDSTORM) -extern ssize_t getdirentries(int fd, char *buf, int nbytes , long *basep); +extern int getdirentries(int fd, char *buf, int nbytes , long *basep); #else extern ssize_t getdirentries(int fd, char *buf, size_t nbytes, off_t *basep); #if __USE_LARGEFILE64 |
From: Lee W. <lw...@us...> - 2003-09-27 23:37:59
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv11329/src Modified Files: Tag: RedStorm chdir.c fcntl.c getdirentries.c ioctl.c lseek.c open.c read.c stat64.c truncate.c write.c Log Message: Incorporating the head dragged in a whole bunch of symbols. Mostly, improperly defined. They were functions instead of aliases :-( Fixed that... Along the way, base everything around __USE_LARGEFILE64 from the glibc headers when trying to get the xxxx64() entry-points. If this isn't being compiled under glibc then __USE_LARGEFILE64 is defined to be 0. Which means that the internal offset, stat, statvfs, etc types all become the defaults from the system and everything is considered to be "natural". This is a very intrusive change. Everybody should retest. Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.3.10.2 retrieving revision 1.3.10.3 diff -u -w -b -B -p -r1.3.10.2 -r1.3.10.3 --- chdir.c 27 Sep 2003 20:20:40 -0000 1.3.10.2 +++ chdir.c 27 Sep 2003 23:01:23 -0000 1.3.10.3 @@ -78,6 +78,8 @@ #include "mount.h" #include "file.h" +#include "sysio-symbols.h" + struct pnode *_sysio_cwd = NULL; /* @@ -221,12 +223,8 @@ getcwd(char *buf, size_t size) return buf; } -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -char * -__getcwd(char *buf, size_t size) -{ - return getcwd(buf, size); -} +#ifdef __GLIBC__ +sysio_sym_weak_alias(getcwd, __getcwd) #endif #ifdef PATH_MAX Index: fcntl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v retrieving revision 1.3.4.1 retrieving revision 1.3.4.2 diff -u -w -b -B -p -r1.3.4.1 -r1.3.4.2 --- fcntl.c 26 Sep 2003 21:28:34 -0000 1.3.4.1 +++ fcntl.c 27 Sep 2003 23:01:23 -0000 1.3.4.2 @@ -51,6 +51,8 @@ #include "inode.h" #include "file.h" +#include "sysio-symbols.h" + int fcntl(int fd, int cmd, ...) { @@ -96,17 +98,7 @@ out: return err; } -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -int -__fcntl(int fd, int cmd, ...) -{ - int rc; - va_list ap; - - va_start(ap, cmd); - rc = fcntl(fd, cmd, ap); - va_end(ap); - - return rc; -} +#ifdef __GLIBC__ +#undef __fcntl +sysio_sym_weak_alias(fcntl, __fcntl) #endif Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.1.10.2 retrieving revision 1.1.10.3 diff -u -w -b -B -p -r1.1.10.2 -r1.1.10.3 --- getdirentries.c 19 May 2003 14:05:34 -0000 1.1.10.2 +++ getdirentries.c 27 Sep 2003 23:01:23 -0000 1.1.10.3 @@ -18,8 +18,8 @@ #define __restrict #endif -ssize_t -getdirentries64(int fd, +static ssize_t +_getdirentries64(int fd, char *buf, size_t nbytes, _SYSIO_OFF_T * __restrict basep) @@ -46,6 +46,13 @@ getdirentries64(int fd, return cc; } +#if __USE_LARGEFILE64 +#undef getdirentries64 +sysio_sym_strong_alias(_getdirentries64, getdirentries64) +#endif + +#undef getdirentries + #ifndef DIRENT64_IS_NATURAL #ifndef EOVERFLOW @@ -127,7 +134,7 @@ getdirentries(int fd, dp = (struct dirent *)buf; ibase = *basep; - cc = getdirentries64(fd, ibuf, inbytes, &ibase); + cc = _getdirentries64(fd, ibuf, inbytes, &ibase); if (cc < 0) { cc = -errno; goto out; @@ -212,6 +219,5 @@ out: #undef _dbaselen } #else /* !defined(DIRENT64_IS_NATURAL) */ -sysio_sym_strong_alias(getdirentries64, getdirentries) +sysio_sym_strong_alias(_getdirentries64, getdirentries) #endif - Index: ioctl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v retrieving revision 1.1.1.1.14.1 retrieving revision 1.1.1.1.14.2 diff -u -w -b -B -p -r1.1.1.1.14.1 -r1.1.1.1.14.2 --- ioctl.c 26 Sep 2003 21:28:34 -0000 1.1.1.1.14.1 +++ ioctl.c 27 Sep 2003 23:01:23 -0000 1.1.1.1.14.2 @@ -50,6 +50,8 @@ #include "inode.h" #include "file.h" +#include "sysio-symbols.h" + int ioctl(int fd, unsigned long request, ...) { @@ -77,17 +79,7 @@ out: } -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -int -__ioctl(int fd, unsigned long request, ...) -{ - va_list ap; - int rc; - - va_start(ap, request); - rc = ioctl(fd, request, ap); - va_end(ap); - - return rc; -} +#ifdef __GLIBC__ +#undef __ioctl +sysio_sym_weak_alias(ioctl, __ioctl) #endif Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.4.4.2 retrieving revision 1.4.4.3 diff -u -w -b -B -p -r1.4.4.2 -r1.4.4.3 --- lseek.c 26 Sep 2003 21:28:34 -0000 1.4.4.2 +++ lseek.c 27 Sep 2003 23:01:23 -0000 1.4.4.3 @@ -103,41 +103,56 @@ out: return fil->f_pos = off; } +#if __USE_LARGEFILE64 +#undef lseek64 sysio_sym_weak_alias(_sysio_lseek, lseek64) +#ifdef __GLIBC__ +#undef __lseek64 +sysio_sym_weak_alias(_sysio_lseek, __lseek64) +#endif +#endif #undef lseek extern off_t lseek(int fd, off_t offset, int whence) { + _SYSIO_OFF_T off; + off_t rtn; - return (off_t )_sysio_lseek(fd, offset, whence); + off = _sysio_lseek(fd, offset, whence); + if (off < 0) + return -1; + rtn = (off_t )off; + if ((_SYSIO_OFF_T )rtn != off) { + errno = EINVAL; + return -1; } - -#if defined(__GLIBC__) && defined(ALPHA_LINUX) - -off_t -__lseek(int fd, off_t offset, int whence) -{ - return lseek(fd, offset, whence); -} - -loff_t -__lseek64( int fd, loff_t offset, int whence) -{ - return lseek( fd, offset, whence ); + return rtn; } -loff_t -__llseek( int fd, loff_t offset, int whence) +#ifdef __GLIBC__ +#undef __lseek +sysio_sym_weak_alias(lseek, __lseek) +#endif + +#ifdef __linux__ +#undef llseek +int +llseek(unsigned int fd __IS_UNUSED, + unsigned long offset_high __IS_UNUSED, + unsigned long offset_low __IS_UNUSED, + loff_t *result __IS_UNUSED, + unsigned int whence __IS_UNUSED) { - return __lseek64(fd, offset, whence); -} -loff_t -__llseek64( int fd, loff_t offset, int whence) -{ - return __lseek64(fd, offset, whence); + /* + * Something is very wrong if this was called. + */ + errno = ENOTSUP; + return -1; } +#undef __llseek +sysio_sym_weak_alias(llseek, __llseek) #endif Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.7.4.3 retrieving revision 1.7.4.4 diff -u -w -b -B -p -r1.7.4.3 -r1.7.4.4 --- open.c 26 Sep 2003 22:14:53 -0000 1.7.4.3 +++ open.c 27 Sep 2003 23:01:23 -0000 1.7.4.4 @@ -49,9 +49,6 @@ #include <sys/stat.h> #include <fcntl.h> #include <sys/queue.h> -#ifdef ALPHA_LINUX -#include <features.h> -#endif #include "sysio.h" #include "inode.h" @@ -59,12 +56,7 @@ #include "fs.h" #include "mount.h" -#ifdef __GLIBC__ -#undef open -#undef __open -#undef open64 -#undef __open64 -#endif +#include "sysio-symbols.h" /* * Open file support. @@ -126,6 +118,8 @@ _sysio_open(struct pnode *pno, int flags return err; } +#undef open + int open(const char *path, int flags, ...) { @@ -213,6 +207,15 @@ error: return -1; } +#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 + int close(int fd) { @@ -224,6 +227,11 @@ close(int fd) return err ? -1 : 0; } +#ifdef __GLIBC__ +#undef __close +sysio_sym_weak_alias(close, __close) +#endif + int creat(const char *path, mode_t mode) { @@ -231,6 +239,15 @@ creat(const char *path, mode_t mode) return open(path, O_CREAT|O_WRONLY|O_TRUNC, 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 + mode_t umask(mode_t mask) { @@ -240,49 +257,3 @@ umask(mode_t mask) _sysio_umask = mask & 0777; return omask; } - -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -int -open64(const char *fname, int flags, ...) -{ - va_list ap; - mode_t mode; - - va_start(ap, flags); - mode = va_arg(ap, mode_t); - va_end(ap); - - return open(fname, flags, mode); -} - -int -__open64(const char *fname, int flags, ...) -{ - va_list ap; - mode_t mode; - - va_start(ap, flags); - mode = va_arg(ap, mode_t); - va_end(ap); - - return open(fname, flags, mode); -} -int -__open(const char *fname, int flags, ...) -{ - va_list ap; - mode_t mode; - - va_start(ap, flags); - mode = va_arg(ap, mode_t); - va_end(ap); - - return open(fname, flags, mode); -} - -int -__close(int fd) { - - return close(fd); -} -#endif Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.2.10.1 retrieving revision 1.2.10.2 diff -u -w -b -B -p -r1.2.10.1 -r1.2.10.2 --- read.c 26 Sep 2003 21:28:34 -0000 1.2.10.1 +++ read.c 27 Sep 2003 23:01:23 -0000 1.2.10.2 @@ -53,13 +53,15 @@ #include "file.h" #include "inode.h" +#include "sysio-symbols.h" + /* * Schedule asynchronous read of iovec at some file extent. */ static struct ioctx * do_ixreadv(struct file *fil, const struct iovec *iov, size_t count, - off_t offset, + _SYSIO_OFF_T offset, void (*fcompletio)(struct ioctx *)) { struct inode *ino; @@ -96,7 +98,7 @@ do_ixreadv(struct file *fil, * API interface to accomplish asynch read into iovec from given file offset. */ ioid_t -ipreadv(int fd, const struct iovec *iov, size_t count, off_t offset) +ipreadv(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset) { struct file *fil; struct ioctx *ioctxp; @@ -115,7 +117,7 @@ ipreadv(int fd, const struct iovec *iov, * API interface to accomplish asynch read into buf from given file offset. */ ioid_t -ipread(int fd, void *buf, size_t count, off_t offset) +ipread(int fd, void *buf, size_t count, _SYSIO_OFF_T offset) { struct iovec iov[1]; @@ -130,7 +132,7 @@ ipread(int fd, void *buf, size_t count, * API interface to accomplish read into iovec from given file offset. */ ssize_t -preadv(int fd, const struct iovec *iov, size_t count, off_t offset) +preadv(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset) { ioid_t ioid; @@ -143,8 +145,8 @@ preadv(int fd, const struct iovec *iov, /* * API interface to accomplish read into buf from given file offset. */ -ssize_t -pread(int fd, void *buf, size_t count, off_t offset) +static ssize_t +_pread(int fd, void *buf, size_t count, _SYSIO_OFF_T offset) { ioid_t ioid; @@ -154,6 +156,21 @@ pread(int fd, void *buf, size_t count, o return iowait(ioid); } +#if __USE_LARGEFILE64 +#undef pread64 +sysio_sym_weak_alias(_pread, pread64) + +ssize_t +pread(int fd, void *buf, size_t count, off_t offset) +{ + + return _pread(fd, buf, count, offset); +} +#else +#undef pread +sysio_sym_weak_alias(_pread, pread) +#endif + /* * API interface to accomplish asynch read into iovec from current file offset. */ @@ -211,6 +228,16 @@ read(int fd, void *buf, size_t count) return iowait(ioid); } +#ifdef __GLIBC__ +#undef __read +sysio_sym_weak_alias(read, __read) +#endif + +#if __USE_LARGEFILE +#undef read64 +sysio_sym_weak_alias(read, read64) +#endif + #ifdef notdef int read_list(int fd, @@ -223,13 +250,5 @@ read_list(int fd, { errno = ENOSYS; return -1; -} -#endif - -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -ssize_t -__read(int fd, void *buf, size_t count) -{ - return read(fd, buf, count); } #endif Index: stat64.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/stat64.c,v retrieving revision 1.3.6.1 retrieving revision 1.3.6.2 diff -u -w -b -B -p -r1.3.6.1 -r1.3.6.2 --- stat64.c 12 May 2003 11:48:45 -0000 1.3.6.1 +++ stat64.c 27 Sep 2003 23:01:24 -0000 1.3.6.2 @@ -166,4 +166,4 @@ lstat64(const char *filename, struct sta return __lxstat64(_STAT_VER, filename, buf); } -#endif /* defined(_LARGEFILE64_SOURCE) */ +#endif /* !__USE_LARGEFILE64 */ Index: truncate.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/truncate.c,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -u -w -b -B -p -r1.3 -r1.3.6.1 --- truncate.c 24 Mar 2003 22:09:07 -0000 1.3 +++ truncate.c 27 Sep 2003 23:01:24 -0000 1.3.6.1 @@ -53,11 +53,13 @@ #include "inode.h" #include "file.h" +#include "sysio-symbols.h" + /* * Truncate file, given path (alias) or index node. */ static int -do_truncate(struct pnode *pno, struct inode *ino, off_t length) +do_truncate(struct pnode *pno, struct inode *ino, _SYSIO_OFF_T length) { struct intnl_stat stbuf; unsigned mask; @@ -75,8 +77,8 @@ do_truncate(struct pnode *pno, struct in return _sysio_setattr(pno, ino, mask, &stbuf); } -int -truncate(const char *path, off_t length) +static int +_truncate(const char *path, _SYSIO_OFF_T length) { int err; struct pnode *pno; @@ -95,8 +97,24 @@ out: return err; } +#if __USE_LARGEFILE64 +#undef truncate64 +sysio_sym_weak_alias(_truncate, truncate64) + +#undef truncate int -ftruncate(int fd, off_t length) +truncate(const char *path, off_t length) +{ + + return _truncate(path, length); +} +#else +#undef truncate +sysio_sym_weak_alias(_truncate, truncate) +#endif + +static int +_ftruncate(int fd, _SYSIO_OFF_T length) { int err; struct file *fil; @@ -115,3 +133,19 @@ out: } return err; } + +#if __USE_LARGEFILE64 +#undef ftruncate64 +sysio_sym_weak_alias(_ftruncate, ftruncate64) + +#undef ftruncate +int +ftruncate(int fd, off_t length) +{ + + return _ftruncate(fd, length); +} +#else +#undef ftruncate +sysio_sym_weak_alias(_ftruncate, ftruncate) +#endif Index: write.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/write.c,v retrieving revision 1.2.12.1 retrieving revision 1.2.12.2 diff -u -w -b -B -p -r1.2.12.1 -r1.2.12.2 --- write.c 26 Sep 2003 21:28:34 -0000 1.2.12.1 +++ write.c 27 Sep 2003 23:01:24 -0000 1.2.12.2 @@ -52,8 +52,8 @@ #include "sysio.h" #include "file.h" #include "inode.h" -#include "fs.h" -#include "mount.h" + +#include "sysio-symbols.h" /* * Schedule asynchronous write of iovec at some file extent. @@ -61,7 +61,7 @@ static struct ioctx * do_ixwritev(struct file *fil, const struct iovec *iov, size_t count, - off_t offset, + _SYSIO_OFF_T offset, void (*fcompletio)(struct ioctx *)) { struct inode *ino; @@ -69,7 +69,7 @@ do_ixwritev(struct file *fil, struct io_arguments ioarguments; struct ioctx *ioctx; - if (!(fil->f_flags & (O_WRONLY|O_RDWR))) { + if (fil->f_flags & O_RDONLY) { errno = EBADF; return IOID_FAIL; } @@ -79,11 +79,7 @@ do_ixwritev(struct file *fil, /* * Huh? It's dead. */ - errno = -EBADF; - return NULL; - } - if (IS_RDONLY(NULL, ino)) { - errno = -EROFS; + errno = EBADF; return NULL; } IOARG_INIT(&ioarguments, @@ -99,10 +95,10 @@ do_ixwritev(struct file *fil, } /* - * API interface to accomplish asynch write from iovec at given file offset. + * API interface to accomplish asynch write into iovec from given file offset. */ ioid_t -ipwritev(int fd, const struct iovec *iov, size_t count, off_t offset) +ipwritev(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset) { struct file *fil; struct ioctx *ioctxp; @@ -118,10 +114,10 @@ ipwritev(int fd, const struct iovec *iov } /* - * API interface to accomplish asynch write from buf from given file offset. + * API interface to accomplish asynch write into buf from given file offset. */ ioid_t -ipwrite(int fd, const void *buf, size_t count, off_t offset) +ipwrite(int fd, const void *buf, size_t count, _SYSIO_OFF_T offset) { struct iovec iov[1]; @@ -133,10 +129,10 @@ ipwrite(int fd, const void *buf, size_t } /* - * API interface to accomplish write from iovec at given file offset. + * API interface to accomplish write into iovec from given file offset. */ ssize_t -pwritev(int fd, const struct iovec *iov, size_t count, off_t offset) +pwritev(int fd, const struct iovec *iov, size_t count, _SYSIO_OFF_T offset) { ioid_t ioid; @@ -147,10 +143,10 @@ pwritev(int fd, const struct iovec *iov, } /* - * API interface to accomplish write from buf from given file offset. + * API interface to accomplish write into buf from given file offset. */ -ssize_t -pwrite(int fd, const void *buf, size_t count, off_t offset) +static ssize_t +_pwrite(int fd, const void *buf, size_t count, _SYSIO_OFF_T offset) { ioid_t ioid; @@ -160,8 +156,23 @@ pwrite(int fd, const void *buf, size_t c return iowait(ioid); } +#if __USE_LARGEFILE64 +#undef pwrite64 +sysio_sym_weak_alias(_pwrite, pwrite64) + +ssize_t +pwrite(int fd, const void *buf, size_t count, off_t offset) +{ + + return _pwrite(fd, buf, count, offset); +} +#else +#undef pwrite +sysio_sym_weak_alias(_pwrite, pwrite) +#endif + /* - * API interface to accomplish asynch write from iovec at current file offset. + * API interface to accomplish asynch write into iovec from current file offset. */ ioid_t iwritev(int fd, const struct iovec *iov, int count) @@ -182,7 +193,7 @@ iwritev(int fd, const struct iovec *iov, } /* - * API interface to accomplish asynch write from buf at current file offset. + * API interface to accomplish asynch write into buf from current file offset. */ ioid_t iwrite(int fd, const void *buf, size_t count) @@ -217,6 +228,16 @@ write(int fd, const void *buf, size_t co return iowait(ioid); } +#ifdef __GLIBC__ +#undef __write +sysio_sym_weak_alias(write, __write) +#endif + +#if __USE_LARGEFILE +#undef write64 +sysio_sym_weak_alias(write, write64) +#endif + #ifdef notdef int write_list(int fd, @@ -231,18 +252,3 @@ write_list(int fd, return -1; } #endif - -#if defined(__GLIBC__) && defined(ALPHA_LINUX) -ssize_t -__write(int fd, const void *buf, size_t count) -{ - return write(fd, buf, count); -} - -ssize_t -__writev(int fd, const struct iovec *iov, int count) -{ - return writev(fd, iov, count); -} -#endif - |
From: Lee W. <lw...@us...> - 2003-09-27 23:37:57
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1:/tmp/cvs-serv11329/include Modified Files: Tag: RedStorm sysio.h Log Message: Incorporating the head dragged in a whole bunch of symbols. Mostly, improperly defined. They were functions instead of aliases :-( Fixed that... Along the way, base everything around __USE_LARGEFILE64 from the glibc headers when trying to get the xxxx64() entry-points. If this isn't being compiled under glibc then __USE_LARGEFILE64 is defined to be 0. Which means that the internal offset, stat, statvfs, etc types all become the defaults from the system and everything is considered to be "natural". This is a very intrusive change. Everybody should retest. Index: sysio.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio.h,v retrieving revision 1.7.6.3 retrieving revision 1.7.6.4 diff -u -w -b -B -p -r1.7.6.3 -r1.7.6.4 --- sysio.h 27 Sep 2003 20:20:40 -0000 1.7.6.3 +++ sysio.h 27 Sep 2003 23:01:23 -0000 1.7.6.4 @@ -79,10 +79,17 @@ typedef void *ioid_t; #define MAX_SYMLINK 250 #endif +#ifndef __USE_LARGEFILE64 +/* + * Not glibc. Define this ourselves. + */ +#define __USE_LARGEFILE64 0 +#endif + /* * Define internal file-offset type. */ -#ifdef _LARGEFILE64_SOURCE +#if __USE_LARGEFILE64 #define _SYSIO_OFF_T off64_t #else #define _SYSIO_OFF_T off_t @@ -92,7 +99,7 @@ typedef void *ioid_t; * Internally, all directory entries are carried in the 64-bit capable * structure. */ -#ifdef _LARGEFILE64_SOURCE +#if __USE_LARGEFILE64 #define intnl_dirent dirent64 #else #define intnl_dirent dirent @@ -103,7 +110,7 @@ struct dirent; * Internally, all file status is carried in the 64-bit capable * structure. */ -#ifdef _LARGEFILE64_SOURCE +#if __USE_LARGEFILE64 #define intnl_stat stat64 #else #define intnl_stat stat @@ -111,7 +118,7 @@ struct dirent; struct stat; #ifdef _HAVE_STATVFS -#ifdef _LARGEFILE64_SOURCE +#if __USE_LARGEFILE64 #define intnl_statvfs statvfs64 #else #define intnl_statvfs statvfs @@ -123,6 +130,8 @@ struct iovec; struct utimbuf; +struct stat64; + struct pnode; extern struct pnode *_sysio_cwd; @@ -149,24 +158,53 @@ extern int dup2(int oldfd, int newfd); extern int fcntl(int fd, int cmd, ...); extern int fstat(int fd, struct stat *buf); extern int fsync(int fd); -extern int ftruncate(int fd, off_t length); extern char *getcwd(char *buf, size_t size); -extern off_t lseek(int fd, off_t offset, int whence); +#if __USE_LARGEFILE64 +extern off64_t lseek64(int fd, off64_t offset, int whence); +#endif extern int lstat(const char *path, struct stat *buf); #if defined(BSD) || defined(REDSTORM) extern ssize_t getdirentries(int fd, char *buf, int nbytes , long *basep); #else extern ssize_t getdirentries(int fd, char *buf, size_t nbytes , off_t *basep); +#if __USE_LARGEFILE64 +extern ssize_t getdirentries64(int fd, + char *buf, + size_t nbytes, + off64_t *basep); +#endif #endif extern int mkdir(const char *path, mode_t mode); extern int open(const char *path, int flag, ...); +#if __USE_LARGEFILE64 +extern int open64(const char *path, int flag, ...); +#endif extern int creat(const char *path, mode_t mode); +#if __USE_LARGEFILE64 +extern int creat64(const char *path, mode_t mode); +#endif extern int stat(const char *path, struct stat *buf); +#if __USE_LARGEFILE64 +extern int stat64(const char *path, struct stat64 *buf); +#endif #ifdef _HAVE_STATVFS extern int statvfs(const char *path, struct statvfs *buf); +#if __USE_LARGEFILE64 +extern int statvfs64(const char *path, struct statvfs64 *buf); +#endif extern int fstatvfs(int fd, struct statvfs *buf); +#if __USE_LARGEFILE64 +extern int fstatvfs64(int fd, struct statvfs64 *buf); +#endif #endif extern int truncate(const char *path, off_t length); +#if __USE_LARGEFILE64 +extern int truncate64(const char *path, off64_t length); +#endif +extern int ftruncate(int fd, off_t length); +#if __USE_LARGEFILE64 +extern int ftruncate64(int fd, off64_t length); +#endif extern int rmdir(const char *path); extern int symlink(const char *path1, const char *path2); extern int link(const char *oldpath, const char *newpath); @@ -179,25 +217,38 @@ extern int iodone(ioid_t ioid); extern ssize_t iowait(ioid_t ioid); extern int iodone(ioid_t ioid); extern ioid_t ipreadv(int fd, const struct iovec *iov, size_t count, - off_t offset); -extern ioid_t ipread(int fd, void *buf, size_t count, off_t offset); + _SYSIO_OFF_T offset); +extern ioid_t ipread(int fd, void *buf, size_t count, _SYSIO_OFF_T offset); extern ssize_t preadv(int fd, const struct iovec *iov, size_t count, - off_t offset); + _SYSIO_OFF_T offset); extern ssize_t pread(int fd, void *buf, size_t count, off_t offset); +#if __USE_LARGEFILE64 +extern ssize_t pread64(int fd, void *buf, size_t count, off64_t offset); +#endif extern ioid_t ireadv(int fd, const struct iovec *iov, int count); extern ioid_t iread(int fd, void *buf, size_t count); extern ssize_t readv(int fd, const struct iovec *iov, int count); extern ssize_t read(int fd, void *buf, size_t count); +#if __USE_LARGEFILE64 +extern ssize_t read64(int fd, void *buf, size_t count); +#endif extern ioid_t ipwritev(int fd, const struct iovec *iov, size_t count, - off_t offset); -extern ioid_t ipwrite(int fd, const void *buf, size_t count, off_t offset); + _SYSIO_OFF_T offset); +extern ioid_t ipwrite(int fd, const void *buf, size_t count, + _SYSIO_OFF_T offset); extern ssize_t pwritev(int fd, const struct iovec *iov, size_t count, - off_t offset); + _SYSIO_OFF_T offset); extern ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset); +#if __USE_LARGEFILE64 +extern ssize_t pwrite64(int fd, const void *buf, size_t count, off64_t offset); +#endif extern ioid_t iwritev(int fd, const struct iovec *iov, int count); extern ioid_t iwrite(int fd, const void *buf, size_t count); extern ssize_t writev(int fd, const struct iovec *iov, int count); extern ssize_t write(int fd, const void *buf, size_t count); +#if __USE_LARGEFILE64 +extern ssize_t write64(int fd, const void *buf, size_t count); +#endif extern int mknod(const char *path, mode_t mode, dev_t dev); extern int utime(const char *path, const struct utimbuf *buf); extern int mount(const char *source, const char *target, |
From: Lee W. <lw...@us...> - 2003-09-27 20:23:10
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1:/tmp/cvs-serv6348/include Modified Files: dev.h inode.h sysio.h Log Message: - Better checking during chdir(). - Added _sysio_p_chdir() to call change working directory with a pnode. - test_path.c doesn't follow symlinks anymore. - sysio_stubs.c defined a bunch of disk ioctl's inappropriately. Removed. - Added fchmod(), fchown(), rename(), link(), utime(). Index: dev.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/dev.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- dev.h 24 Mar 2003 22:09:04 -0000 1.2 +++ dev.h 27 Sep 2003 19:42:02 -0000 1.3 @@ -70,71 +70,75 @@ extern const struct inode_ops _sysio_nod (int (*)(struct pnode *, \ struct inode **, \ struct intent *, \ - const char *))_sysio_dev_e_notdir + const char *))_sysio_dev_illop #define _sysio_nodev_inop_getattr \ (int (*)(struct pnode *, \ struct inode *, \ - struct intnl_stat *))_sysio_dev_e_badf + struct intnl_stat *))_sysio_dev_illop #define _sysio_nodev_inop_setattr \ (int (*)(struct pnode *, \ struct inode *, \ unsigned , \ - struct intnl_stat *))_sysio_dev_e_badf + struct intnl_stat *))_sysio_dev_illop #define _sysio_nodev_getdirentries \ (ssize_t (*)(struct inode *, \ char *, \ size_t , \ - off64_t *))_sysio_dev_e_notdir + off64_t *))_sysio_dev_illop #define _sysio_nodev_inop_mkdir \ (int (*)(struct pnode *, \ - mode_t))_sysio_dev_e_notdir + mode_t))_sysio_dev_illop #define _sysio_nodev_inop_rmdir \ - (int (*)(struct pnode *))_sysio_dev_e_notdir + (int (*)(struct pnode *))_sysio_dev_illop #define _sysio_nodev_inop_symlink \ (int (*)(struct pnode *, \ - const char *))_sysio_dev_e_notdir + const char *))_sysio_dev_illop #define _sysio_nodev_inop_readlink \ (int (*)(struct pnode *, \ char *, \ - size_t))_sysio_dev_e_inval + size_t))_sysio_dev_illop #define _sysio_nodev_inop_open \ (int (*)(struct pnode *, \ int, \ - mode_t))_sysio_dev_e_nxio + mode_t))_sysio_dev_illop #define _sysio_nodev_inop_close \ - (int (*)(struct inode *))_sysio_dev_e_badf + (int (*)(struct inode *))_sysio_dev_illop +#define _sysio_nodev_inop_link \ + (int (*)(struct pnode *, struct pnode *))_sysio_dev_illop #define _sysio_nodev_inop_unlink \ - (int (*)(struct pnode *))_sysio_dev_e_notdir + (int (*)(struct pnode *))_sysio_dev_illop +#define _sysio_nodev_inop_rename \ + (int (*)(struct pnode *, struct pnode *))_sysio_dev_illop #define _sysio_nodev_inop_ipreadv \ (int (*)(struct inode *, \ struct io_arguments *, \ - struct ioctx **))_sysio_dev_e_inval + struct ioctx **))_sysio_dev_illop #define _sysio_nodev_inop_ipwritev \ (int (*)(struct inode *, \ struct io_arguments *, \ - struct ioctx **))_sysio_dev_e_inval + struct ioctx **))_sysio_dev_illop #define _sysio_nodev_inop_iodone \ - (int (*)(struct ioctx *))_sysio_dev_e_illop + (int (*)(struct ioctx *))_sysio_dev_illop #define _sysio_nodev_inop_fcntl \ (int (*)(struct inode *, \ int, \ - va_list))_sysio_dev_e_inval + va_list))_sysio_dev_illop #define _sysio_nodev_inop_sync \ - (int (*)(struct inode *))_sysio_dev_e_inval + (int (*)(struct inode *))_sysio_dev_illop #define _sysio_nodev_inop_datasync \ - (int (*)(struct inode *))_sysio_dev_e_inval + (int (*)(struct inode *))_sysio_dev_illop #define _sysio_nodev_inop_ioctl \ (int (*)(struct inode *, \ unsigned long int, \ - va_list))_sysio_dev_e_notty + va_list))_sysio_dev_illop #define _sysio_nodev_inop_mknod \ (int (*)(struct pnode *, \ mode_t, \ - dev_t))_sysio_dev_e_notdir + dev_t))_sysio_dev_illop #define _sysio_nodev_inop_statvfs \ (int (*)(struct pnode *, \ struct inode *, \ - struct intnl_statvfs *))_sysio_dev_e_inval + struct intnl_statvfs *))_sysio_dev_illop #define _sysio_nodev_inop_gone \ (void (*)(struct inode *ino))_sysio_dev_noop @@ -144,10 +148,5 @@ extern struct inode_ops *_sysio_dev_look extern int _sysio_char_dev_register(int major, const char *name, struct inode_ops *ops); -extern int _sysio_dev_e_notdir(void); -extern int _sysio_dev_e_badf(void); -extern int _sysio_dev_e_inval(void); -extern int _sysio_dev_e_nxio(void); -extern int _sysio_dev_e_illop(void); -extern int _sysio_dev_e_notty(void); +extern int _sysio_dev_illop(void); extern void _sysio_dev_noop(void); Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- inode.h 21 Aug 2003 19:48:37 -0000 1.8 +++ inode.h 27 Sep 2003 19:42:02 -0000 1.9 @@ -94,7 +94,9 @@ struct inode_ops { int (*inop_readlink)(struct pnode *pno, char *buf, size_t bufsiz); int (*inop_open)(struct pnode *pno, int flags, mode_t mode); int (*inop_close)(struct inode *ino); + int (*inop_link)(struct pnode *old, struct pnode *new); int (*inop_unlink)(struct pnode *pno); + int (*inop_rename)(struct pnode *old, struct pnode *new); int (*inop_ipreadv)(struct inode *ino, struct io_arguments *ioargs, struct ioctx **ioctxp); @@ -441,6 +443,7 @@ extern int _sysio_namei(struct pnode *pn unsigned flags, struct intent *intnt, struct pnode **pnop); +extern int _sysio_p_chdir(struct pnode *pno); extern int _sysio_ioctx_init(void); extern struct ioctx *_sysio_ioctx_new(struct inode *ino, struct io_arguments *ioargs); Index: sysio.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- sysio.h 29 Jul 2003 19:53:33 -0000 1.8 +++ sysio.h 27 Sep 2003 19:42:02 -0000 1.9 @@ -110,6 +110,8 @@ struct stat; struct statvfs; struct iovec; +struct utimbuf; + struct pnode; extern struct pnode *_sysio_cwd; @@ -127,7 +129,9 @@ extern void _sysio_shutdown(void); extern int access(const char *path, int amode); extern int chdir(const char *path); extern int chmod(const char *path, mode_t mode); +extern int fchmod(int fd, mode_t mode); extern int chown(const char *path, uid_t owner, gid_t group); +extern int fchown(int fd, uid_t owner, gid_t group); extern int close(int d); extern int dup(int oldfd); extern int dup2(int oldfd, int newfd); @@ -148,7 +152,9 @@ extern int truncate(const char *path, of extern int fstatvfs(int fd, struct statvfs *buf); extern int rmdir(const char *path); extern int symlink(const char *path1, const char *path2); +extern int link(const char *oldpath, const char *newpath); extern int unlink(const char *path); +extern int rename(const char *oldpath, const char *newpath); extern int fdatasync(int fd); extern int ioctl(int fd, unsigned long request, ...); extern mode_t umask(mode_t mask); @@ -176,6 +182,7 @@ extern ioid_t iwrite(int fd, const void extern ssize_t writev(int fd, const struct iovec *iov, int count); extern ssize_t write(int fd, const void *buf, size_t count); extern int mknod(const char *path, mode_t mode, dev_t dev); +extern int utime(const char *path, const struct utimbuf *buf); extern int mount(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, |
From: Lee W. <lw...@us...> - 2003-09-27 20:20:55
|
Update of /cvsroot/libsysio/libsysio/drivers/incore In directory sc8-pr-cvs1:/tmp/cvs-serv15049/drivers/incore Modified Files: Tag: RedStorm fs_incore.c Log Message: Updated with recent changes in HEAD branch. Index: fs_incore.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/incore/fs_incore.c,v retrieving revision 1.4.4.3 retrieving revision 1.4.4.4 diff -u -w -b -B -p -r1.4.4.3 -r1.4.4.4 --- fs_incore.c 26 Sep 2003 21:28:33 -0000 1.4.4.3 +++ fs_incore.c 27 Sep 2003 20:20:40 -0000 1.4.4.4 @@ -139,7 +139,9 @@ static int _sysio_incore_dirop_mkdir(str static int _sysio_incore_dirop_rmdir(struct pnode *pno); static int _sysio_incore_inop_open(struct pnode *pno, int flags, mode_t mode); static int _sysio_incore_inop_close(struct inode *ino); +static int _sysio_incore_dirop_link(struct pnode *old, struct pnode *new); static int _sysio_incore_dirop_unlink(struct pnode *pno); +static int _sysio_incore_dirop_rename(struct pnode *old, struct pnode *new); static int _sysio_incore_filop_ipreadv(struct inode *ino, struct io_arguments *ioargs, struct ioctx **ioctxp); @@ -160,7 +162,6 @@ static int _sysio_incore_inop_statvfs(st #endif static void _sysio_incore_inop_gone(struct inode *ino); static int _sysio_incore_e_isdir(void); -static int _sysio_incore_e_notdir(void); static int _sysio_incore_e_inval(void); static int _sysio_incore_e_nosys(void); static void _sysio_incore_illop(void); @@ -197,7 +198,9 @@ static struct inode_ops _sysio_incore_di _sysio_incore_dirop_readlink, _sysio_incore_inop_open, _sysio_incore_inop_close, + _sysio_incore_dirop_link, _sysio_incore_dirop_unlink, + _sysio_incore_dirop_rename, _sysio_incore_dirop_ipreadv, _sysio_incore_dirop_ipwritev, _sysio_incore_dirop_iodone, @@ -216,24 +219,28 @@ static struct inode_ops _sysio_incore_di (int (*)(struct pnode *, \ struct inode **, \ struct intent *, \ - const char *))_sysio_incore_e_notdir + const char *))_sysio_incore_illop #define _sysio_incore_filop_getdirentries \ (ssize_t (*)(struct inode *, \ char *, \ size_t, \ - _SYSIO_OFF_T *))_sysio_incore_e_notdir + _SYSIO_OFF_T *))_sysio_incore_illop #define _sysio_incore_filop_mkdir \ - (int (*)(struct pnode *, mode_t))_sysio_incore_e_notdir + (int (*)(struct pnode *, mode_t))_sysio_incore_illop #define _sysio_incore_filop_rmdir \ - (int (*)(struct pnode *))_sysio_incore_e_notdir + (int (*)(struct pnode *))_sysio_incore_illop #define _sysio_incore_filop_symlink \ (int (*)(struct pnode *, const char *))_sysio_incore_illop #define _sysio_incore_symlinkop_readlink \ (int (*)(struct pnode *, char *, size_t))_sysio_incore_illop +#define _sysio_incore_filop_link \ + (int (*)(struct pnode *old, struct pnode *new))_sysio_incore_illop #define _sysio_incore_filop_unlink \ - (int (*)(struct pnode *pno))_sysio_incore_e_notdir + (int (*)(struct pnode *pno))_sysio_incore_illop +#define _sysio_incore_filop_rename \ + (int (*)(struct pnode *old, struct pnode *new))_sysio_incore_illop #define _sysio_incore_filop_mknod \ - (int (*)(struct pnode *pno, mode_t, dev_t))_sysio_incore_e_notdir + (int (*)(struct pnode *pno, mode_t, dev_t))_sysio_incore_illop static struct inode_ops _sysio_incore_file_ops = { _sysio_incore_filop_lookup, @@ -246,7 +253,9 @@ static struct inode_ops _sysio_incore_fi _sysio_incore_symlinkop_readlink, _sysio_incore_inop_open, _sysio_incore_inop_close, + _sysio_incore_filop_link, _sysio_incore_filop_unlink, + _sysio_incore_filop_rename, _sysio_incore_filop_ipreadv, _sysio_incore_filop_ipwritev, _sysio_incore_filop_iodone, @@ -272,7 +281,9 @@ static struct inode_ops _sysio_incore_de _sysio_incore_symlinkop_readlink, _sysio_nodev_inop_open, _sysio_nodev_inop_close, + _sysio_incore_filop_link, _sysio_incore_filop_unlink, + _sysio_incore_filop_rename, _sysio_nodev_inop_ipreadv, _sysio_nodev_inop_ipwritev, _sysio_nodev_inop_iodone, @@ -319,7 +330,7 @@ struct lookup_data { */ #define INCORE_D_RECLEN(namlen) \ (((size_t )&((struct intnl_dirent *)0)->d_name + \ - (namlen) + sizeof(void *)) & \ + (namlen) + 1 + sizeof(void *)) & \ ~(sizeof(void *) - 1)) /* @@ -369,17 +380,20 @@ _sysio_incore_init() #ifdef _DIRENT_HAVE_D_NAMLEN de->d_namlen = 1; #endif + /* + * Move to entry for `..' + */ de = (void *)de + off; de->d_reclen = INCORE_D_RECLEN(2); +#ifdef _DIRENT_HAVE_D_NAMLEN + de->d_namlen = 2; +#endif #ifdef _DIRENT_HAVE_D_OFF de->d_off = #endif off += de->d_reclen; de->d_type = INCORE_D_TYPEOF(S_IFDIR); de->d_name[0] = de->d_name[1] = '.'; -#ifdef _DIRENT_HAVE_D_NAMLEN - de->d_namlen = 2; -#endif return _sysio_fssw_register("incore", &incore_fssw_ops); } @@ -764,8 +778,7 @@ incore_directory_match(struct intnl_dire #ifdef _DIRENT_HAVE_D_NAMLEN ld->name->len == de->d_namlen && #endif - strncmp(de->d_name, ld->name->name, ld->name->len) == 0 - ) + strncmp(de->d_name, ld->name->name, ld->name->len) == 0) return de; ld->de = de; return NULL; @@ -1220,6 +1233,12 @@ incore_unlink_entry(struct incore_inode lookup_data.de->d_off = off; #endif + /* + * Adjust link count. + */ + assert(icino->ici_st.st_nlink > 2); + icino->ici_st.st_nlink--; + return 0; } @@ -1251,6 +1270,12 @@ _sysio_incore_dirop_rmdir(struct pnode * return err; I_RELE(ino); + /* + * Adjust link count. + */ + assert(icino->ici_st.st_nlink > 2); + icino->ici_st.st_nlink--; + return 0; } @@ -1348,6 +1373,94 @@ _sysio_incore_inop_close(struct inode *i } static int +_sysio_incore_dirop_link(struct pnode *old, struct pnode *new) +{ + struct incore_inode *icino = I2IC(old->p_base->pb_ino); + int err; + + assert(!new->p_base->pb_ino); + assert(!S_ISDIR(old->p_base->pb_ino->i_mode)); + + /* + * Can bump the link count? + */ + if (!(icino->ici_st.st_nlink + 1)) + return -EMLINK; + /* + * Insert into parent. + */ + err = + incore_directory_insert(I2IC(new->p_parent->p_base->pb_ino), + &new->p_base->pb_name, + icino->ici_st.st_ino, + INCORE_D_TYPEOF(icino->ici_st.st_mode)); + if (err) + return err; + /* + * Bump the link count. + */ + icino->ici_st.st_nlink++; + + return 0; +} + +static int +_sysio_incore_dirop_rename(struct pnode *old, struct pnode *new) +{ + int err; + struct incore_inode *icino = I2IC(old->p_base->pb_ino); + + if (new->p_base->pb_ino) { + /* + * Have to kill off the target first. + */ + if (S_ISDIR(I2IC(new->p_base->pb_ino)->ici_st.st_mode) && + I2IC(new->p_base->pb_ino)->ici_st.st_nlink > 2) + return -ENOTEMPTY; + err = + incore_unlink_entry(I2IC(new->p_parent->p_base->pb_ino), + &new->p_base->pb_name); + if (err) + return err; + I_RELE(new->p_base->pb_ino); + _sysio_i_gone(new->p_base->pb_ino); + new->p_base->pb_ino = NULL; + } + + /* + * Insert into new parent. + */ + err = + incore_directory_insert(I2IC(new->p_parent->p_base->pb_ino), + &new->p_base->pb_name, + icino->ici_st.st_ino, + INCORE_D_TYPEOF(icino->ici_st.st_mode)); + if (err) + abort(); + /* + * Remove from the old parent. + */ + err = + incore_unlink_entry(I2IC(old->p_parent->p_base->pb_ino), + &old->p_base->pb_name); + if (err) + abort(); + + if (S_ISDIR(icino->ici_st.st_mode)) { + struct intnl_dirent *de; + + /* + * We moved a directory. The entry for `..' must be corrected. + */ + de = icino->ici_data; + de++; + assert(strcmp(de->d_name, "..") == 0); + de->d_ino = I2IC(new->p_parent->p_base->pb_ino)->ici_st.st_ino; + } + return 0; +} + +static int _sysio_incore_dirop_unlink(struct pnode *pno) { struct inode *ino = pno->p_base->pb_ino; @@ -1357,7 +1470,6 @@ _sysio_incore_dirop_unlink(struct pnode if (S_ISDIR(icino->ici_st.st_mode)) return -EISDIR; - pno->p_base->pb_ino = NULL; err = incore_unlink_entry(I2IC(pno->p_parent->p_base->pb_ino), &pno->p_base->pb_name); @@ -1579,7 +1691,8 @@ _sysio_incore_inop_statvfs(struct pnode */ buf->f_bsize = fs->fs_bsize; buf->f_frsize = buf->f_bsize; - buf->f_blocks = (0xffffffffffffffff - 1) / buf->f_bsize; + buf->f_blocks = ~0; + buf->f_blocks /= buf->f_bsize; buf->f_bfree = buf->f_blocks - 1; buf->f_bavail = buf->f_bfree; buf->f_files = buf->f_blocks; @@ -1606,13 +1719,6 @@ _sysio_incore_e_isdir(void) { return -EISDIR; -} - -static int -_sysio_incore_e_notdir(void) -{ - - return -ENOTDIR; } static int |
From: Lee W. <lw...@us...> - 2003-09-27 20:20:55
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv15049/drivers/native Modified Files: Tag: RedStorm fs_native.c Log Message: Updated with recent changes in HEAD branch. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11.4.7 retrieving revision 1.11.4.8 diff -u -w -b -B -p -r1.11.4.7 -r1.11.4.8 --- fs_native.c 26 Sep 2003 21:28:34 -0000 1.11.4.7 +++ fs_native.c 27 Sep 2003 20:20:40 -0000 1.11.4.8 @@ -136,12 +136,12 @@ do { #endif #if defined(USE_NATIVE_STAT) -#define __SYS_STAT SYS_stat +#define __SYS_STAT SYS_lstat #define __SYS_FSTAT SYS_fstat #define __SYS_TRUNCATE SYS_truncate #define __SYS_FTRUNCATE SYS_ftruncate #else -#define __SYS_STAT SYS_stat64 +#define __SYS_STAT SYS_lstat64 #define __SYS_FSTAT SYS_fstat64 #define __SYS_TRUNCATE SYS_truncate64 #define __SYS_FTRUNCATE SYS_ftruncate64 @@ -206,7 +206,9 @@ static int native_inop_symlink(struct pn static int native_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz); static int native_inop_open(struct pnode *pno, int flags, mode_t mode); static int native_inop_close(struct inode *ino); +static int native_inop_link(struct pnode *old, struct pnode *new); static int native_inop_unlink(struct pnode *pno); +static int native_inop_rename(struct pnode *old, struct pnode *new); static int native_inop_ipreadv(struct inode *ino, struct io_arguments *ioargs, struct ioctx **ioctxp); @@ -239,7 +241,9 @@ static struct inode_ops native_i_ops = { native_inop_readlink, native_inop_open, native_inop_close, + native_inop_link, native_inop_unlink, + native_inop_rename, native_inop_ipreadv, native_inop_ipwritev, native_inop_iodone, @@ -1070,6 +1074,32 @@ native_inop_close(struct inode *ino) } static int +native_inop_link(struct pnode *old, struct pnode *new) +{ + int err; + char *opath, *npath; + + err = 0; + + opath = _sysio_pb_path(old->p_base, '/'); + npath = _sysio_pb_path(new->p_base, '/'); + if (!(opath && npath)) { + err = -ENOMEM; + goto out; + } + + err = syscall(SYS_link, opath, npath); + +out: + if (opath) + free(opath); + if (npath) + free(npath); + + return err; +} + +static int native_inop_unlink(struct pnode *pno) { char *path; @@ -1185,6 +1215,30 @@ _readv(int fd, const struct iovec *vecto { return syscall(SYS_readv, fd, vector, count); +} + +static int +native_inop_rename(struct pnode *old, struct pnode *new) +{ + int err; + char *opath, *npath; + + opath = _sysio_pb_path(old->p_base, '/'); + npath = _sysio_pb_path(new->p_base, '/'); + if (!(opath && npath)) { + err = -ENOMEM; + goto out; + } + + err = syscall(SYS_rename, opath, npath); + +out: + if (opath) + free(opath); + if (npath) + free(npath); + + return err; } static int |
From: Lee W. <lw...@us...> - 2003-09-27 20:20:55
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv15049/tests Modified Files: Tag: RedStorm Makefile.am test_path.c Log Message: Updated with recent changes in HEAD branch. Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.8.6.4 retrieving revision 1.8.6.5 diff -u -w -b -B -p -r1.8.6.4 -r1.8.6.5 --- Makefile.am 26 Sep 2003 22:15:40 -0000 1.8.6.4 +++ Makefile.am 27 Sep 2003 20:20:41 -0000 1.8.6.5 @@ -46,13 +46,20 @@ DRIVERS=$(NATIVE_DRIVER_NAME) $(INCORE_D CMNSRC=drv_init_all.c drv_data.c BUILT_SOURCES=drv_data.c +check_PROGRAMS=test_driver +if TEST_ALPHA_ARG +TESTS_ENVIRONMENT=IS_ALPHA=yes +else +TESTS_ENVIRONMENT=IS_ALPHA=no +endif +TESTS=test_all.pl CFL=$(AM_CFLAGS) $(AM_CPPFLAGS) \ $(NATIVE_DRIVER_CFLAGS) $(INCORE_DRIVER_CFLAGS) \ $(STDFD_DEV_CFLAGS) $(YOD_DRIVER_CFLAGS) LIBS=$(NATIVE_DRIVER_LIB) $(INCORE_DRIVER_LIB) \ - $(STDFD_DEV_LIB) \ + $(STDFD_DEV_LIB) $(YOD_DRIVER_LIB) \ $(top_builddir)/src/libsysio.a test_copy_SOURCES=test_copy.c $(CMNSRC) Index: test_path.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_path.c,v retrieving revision 1.3.10.2 retrieving revision 1.3.10.3 diff -u -w -b -B -p -r1.3.10.2 -r1.3.10.3 --- test_path.c 26 Sep 2003 21:28:34 -0000 1.3.10.2 +++ test_path.c 27 Sep 2003 20:20:41 -0000 1.3.10.3 @@ -191,7 +191,7 @@ statit(const char *path) /* * Get file attrs. */ - err = stat(path, &stbuf); + err = lstat(path, &stbuf); if (err) { perror(path); return -1; |
From: Lee W. <lw...@us...> - 2003-09-27 20:20:55
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs1:/tmp/cvs-serv15049 Modified Files: Tag: RedStorm configure.in Log Message: Updated with recent changes in HEAD branch. Index: configure.in =================================================================== RCS file: /cvsroot/libsysio/libsysio/configure.in,v retrieving revision 1.5.6.5 retrieving revision 1.5.6.6 diff -u -w -b -B -p -r1.5.6.5 -r1.5.6.6 --- configure.in 26 Sep 2003 21:28:33 -0000 1.5.6.5 +++ configure.in 27 Sep 2003 20:20:40 -0000 1.5.6.6 @@ -3,7 +3,7 @@ AC_INIT(libsysio, 0.1) AC_CANONICAL_HOST case "$host_os" in - linux-gnu) + linux*) ;; *) AC_MSG_WARN('***' ${host_os}: Unsupported OS target) @@ -25,8 +25,8 @@ AC_ARG_WITH(native_driver, yes) ;; no) ;; *) AC_MSG_ERROR(bad value ${withval} for --with-native-driver) ;; - esac], - [with_native_driver=yes]) + esac;], + [with_native_driver=yes;]) AM_CONDITIONAL(WITH_NATIVE_DRIVER, test x$with_native_driver = xyes) AC_ARG_WITH(incore-driver, @@ -211,8 +211,10 @@ else _syscallnum=SYS_fdatasync fi AC_TRY_COMPILE([ -#include <syscall.h>], [ -syscall($_syscallnum, 0);], +#include <syscall.h> +extern int syscall();], +[int fd = 0; +syscall(SYS_fdatasync, fd);], syscall_fdatasync_exists=yes, syscall_fdatasync_exists=no) AC_MSG_RESULT($syscall_fdatasync_exists) |
From: Lee W. <lw...@us...> - 2003-09-27 20:20:55
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv15049/src Modified Files: Tag: RedStorm Makefile.am chdir.c chmod.c chown.c dev.c rmdir.c unlink.c Added Files: Tag: RedStorm link.c rename.c utime.c Log Message: Updated with recent changes in HEAD branch. --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2003 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1110 * * le...@sa... */ #include <string.h> #include <errno.h> #include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/queue.h> #include "sysio.h" #include "mount.h" #include "inode.h" int link(const char *oldpath, const char *newpath) { struct intent intent; int err; struct pnode *old, *new; INTENT_INIT(&intent, 0, NULL, NULL); err = _sysio_namei(_sysio_cwd, oldpath, 0, &intent, &old); if (err) goto out; if (S_ISDIR(old->p_base->pb_ino->i_mode)) { err = -EPERM; goto error2; } INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &new); if (err && !new) goto error2; if (!err || (err && err != -ENOENT)) { err = -EEXIST; goto error1; } if (old->p_mount->mnt_root != new->p_mount->mnt_root) { err = -EXDEV; goto error1; } err = old->p_base->pb_ino->i_ops.inop_link(old, new); if (err) goto error1; /* * The new path-base node must point to the inode referenced by * the old. As well, we need to record the new reference of the inode. */ new->p_base->pb_ino = old->p_base->pb_ino; I_REF(new->p_base->pb_ino); error1: P_RELE(new); error2: P_RELE(old); if (err) { errno = -err; err = -1; } out: return err; } --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2003 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1110 * * le...@sa... */ #include <stdlib.h> #include <string.h> #include <errno.h> #include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/queue.h> #include "sysio.h" #include "mount.h" #include "inode.h" int rename(const char *oldpath, const char *newpath) { struct intent intent; int err; struct pnode *old, *new; struct pnode_base *nxtpb, *pb; struct intnl_stat ostbuf, nstbuf; /* * Resolve oldpath to a path node. */ INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = _sysio_namei(_sysio_cwd, oldpath, 0, &intent, &old); if (err) goto out; /* * Resolve newpath to a path node. */ INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &new); if (err && !new) goto error2; if (old->p_mount->mnt_root != new->p_mount->mnt_root) { /* * Oops. They're trying to move it across mounts. */ err = -EXDEV; goto error1; } /* * Make sure the old pnode can't be found in the ancestor chain * for the new. If it can, they are trying to move into a subdirectory * of the old. */ nxtpb = new->p_base; do { pb = nxtpb; nxtpb = pb->pb_parent; if (pb == old->p_base) { err = -EINVAL; goto error1; } } while (pb != nxtpb); while (new->p_base->pb_ino) { /* * Existing entry. We're replacing the new. Make sure that's * ok. */ err = old->p_base->pb_ino->i_ops.inop_getattr(old, NULL, &ostbuf); if (err) goto error1; err = new->p_base->pb_ino->i_ops.inop_getattr(new, NULL, &nstbuf); if (err) { if (err != ENOENT) goto error1; /* * Rats! It disappeared beneath us. */ (void )_sysio_p_validate(new, NULL, NULL); continue; } if (S_ISDIR(ostbuf.st_mode)) { if (!S_ISDIR(nstbuf.st_mode)) { err = -ENOTDIR; goto error1; } if (nstbuf.st_nlink > 2) { err = -ENOTEMPTY; goto error1; } } else if (S_ISDIR(nstbuf.st_mode)) { err = -EEXIST; goto error1; } } /* * It's not impossible to clean up the altered name space after * a rename. However, it is onerous and I don't want to do it right * now. If it becomes an issue, we can do it later. For now, I've * elected to use the semantic that says, basically, the entire * sub-tree must be unreferenced. */ if (_sysio_p_prune(new) != 1) { err = -EBUSY; goto error1; } err = old->p_base->pb_ino->i_ops.inop_rename(old, new); if (err) goto error1; error1: P_RELE(new); error2: P_RELE(old); if (err) { errno = -err; err = -1; goto out; } _sysio_p_gone(old); /* kill it! */ out: return err; } --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2003 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1110 * * le...@sa... */ #include <string.h> #include <errno.h> #include <time.h> #include <assert.h> #include <sys/types.h> #include <utime.h> #include <sys/stat.h> #include <unistd.h> #include <sys/queue.h> #include "sysio.h" #include "inode.h" #include "file.h" int utime(const char *path, const struct utimbuf *buf) { struct intent intent; int err; struct pnode *pno; struct utimbuf _utbuffer; struct intnl_stat stbuf; INTENT_INIT(&intent, INT_SETATTR, NULL, NULL); err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno); if (err) goto out; if (!buf) { _utbuffer.actime = _utbuffer.modtime = time(NULL); buf = &_utbuffer; } (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); stbuf.st_atime = buf->actime; stbuf.st_mtime = buf->modtime; err = _sysio_setattr(pno, pno->p_base->pb_ino, SETATTR_ATIME | SETATTR_MTIME, &stbuf); P_RELE(pno); out: if (err) { errno = -err; err = -1; } return err; } Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/Makefile.am,v retrieving revision 1.5.6.4 retrieving revision 1.5.6.5 diff -u -w -b -B -p -r1.5.6.4 -r1.5.6.5 --- Makefile.am 26 Sep 2003 21:28:34 -0000 1.5.6.4 +++ Makefile.am 27 Sep 2003 20:20:40 -0000 1.5.6.5 @@ -2,8 +2,9 @@ lib_LIBRARIES = libsysio.a libsysio_a_SOURCES = chdir.c chmod.c chown.c dev.c dup.c fcntl.c file.c fs.c \ fsync.c getdirentries.c init.c inode.c ioctl.c ioctx.c iowait.c \ - lseek.c mkdir.c mknod.c mount.c namei.c open.c read.c rmdir.c stat.c \ - stat64.c statvfs.c symlink.c truncate.c unlink.c write.c access.c + link.c lseek.c mkdir.c mknod.c mount.c namei.c open.c read.c rename.c \ + rmdir.c stat.c stat64.c statvfs.c symlink.c truncate.c unlink.c \ + utime.c write.c access.c include $(top_srcdir)/Rules.make Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.3.10.1 retrieving revision 1.3.10.2 diff -u -w -b -B -p -r1.3.10.1 -r1.3.10.2 --- chdir.c 26 Sep 2003 21:28:34 -0000 1.3.10.1 +++ chdir.c 27 Sep 2003 20:20:40 -0000 1.3.10.2 @@ -64,12 +64,13 @@ */ #include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> #include <unistd.h> #include <string.h> #include <limits.h> #include <errno.h> #include <assert.h> -#include <sys/types.h> #include <sys/queue.h> #include "sysio.h" @@ -79,6 +80,49 @@ struct pnode *_sysio_cwd = NULL; +/* + * Change to directory specified by the given pnode. + */ +int +_sysio_p_chdir(struct pnode *pno) +{ + int err; + struct intnl_stat stbuf; + + /* + * Revalidate + */ + err = _sysio_p_validate(pno, NULL, NULL); + if (err) + return err; + if (!pno->p_base->pb_ino) + return -ENOTDIR; + /* + * Stat the node and ensure it's a directory. + */ + err = + pno->p_base->pb_ino->i_ops.inop_getattr(pno, + NULL, + &stbuf); + if (err) + return err; + if (!S_ISDIR(stbuf.st_mode)) + return -ENOTDIR; + + /* + * Release old if set. + */ + if (_sysio_cwd) + P_RELE(_sysio_cwd); + + /* + * Finally, change to the new. + */ + _sysio_cwd = pno; + + return 0; +} + int chdir(const char *path) { @@ -91,11 +135,7 @@ chdir(const char *path) return -1; } - if (_sysio_cwd) - P_RELE(_sysio_cwd); - - _sysio_cwd = pno; - return 0; + return _sysio_p_chdir(pno); } /* Index: chmod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chmod.c,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -u -w -b -B -p -r1.3 -r1.3.6.1 --- chmod.c 24 Mar 2003 22:09:06 -0000 1.3 +++ chmod.c 27 Sep 2003 20:20:40 -0000 1.3.6.1 @@ -51,6 +51,21 @@ #include "sysio.h" #include "inode.h" +#include "file.h" + +static int +do_chmod(struct pnode *pno, struct inode *ino, mode_t mode) +{ + int err; + struct intnl_stat stbuf; + unsigned mask; + + (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); + stbuf.st_mode = mode & 0777; + mask = SETATTR_MODE; + err = _sysio_setattr(pno, ino, mask, &stbuf); + return err; +} int chmod(const char *path, mode_t mode) @@ -58,18 +73,35 @@ chmod(const char *path, mode_t mode) struct intent intent; int err; struct pnode *pno; - struct intnl_stat stbuf; - unsigned mask; INTENT_INIT(&intent, INT_SETATTR, NULL, NULL); err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno); if (err) goto out; - (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); - stbuf.st_mode = mode & 0777; - mask = SETATTR_MODE; - err = _sysio_setattr(pno, pno->p_base->pb_ino, mask, &stbuf); + err = do_chmod(pno, pno->p_base->pb_ino, mode); P_RELE(pno); +out: + if (err) { + errno = -err; + err = -1; + } + return err; +} + +int +fchmod(int fd, mode_t mode) +{ + int err; + struct file *fil; + + err = 0; + fil = _sysio_fd_find(fd); + if (!fil) { + err = -EBADF; + goto out; + } + + err = do_chmod(NULL, fil->f_ino, mode); out: if (err) { errno = -err; Index: chown.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chown.c,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -u -w -b -B -p -r1.3 -r1.3.6.1 --- chown.c 24 Mar 2003 22:09:06 -0000 1.3 +++ chown.c 27 Sep 2003 20:20:40 -0000 1.3.6.1 @@ -51,18 +51,15 @@ #include "sysio.h" #include "inode.h" +#include "file.h" -int -chown(const char *path, uid_t owner, gid_t group) +static int +_do_chown(struct pnode *pno, struct inode *ino, uid_t owner, gid_t group) { int err; - struct pnode *pno; struct intnl_stat stbuf; unsigned mask; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); mask = 0; if (owner != (uid_t )-1) { @@ -73,11 +70,44 @@ chown(const char *path, uid_t owner, gid stbuf.st_gid = group; mask |= SETATTR_GID; } - if (!mask) - goto done; - err = _sysio_setattr(pno, pno->p_base->pb_ino, mask, &stbuf); -done: + err = _sysio_setattr(pno, ino, mask, &stbuf); + return err; +} + +int +chown(const char *path, uid_t owner, gid_t group) +{ + int err; + struct pnode *pno; + + err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); + if (err) + goto out; + + err = _do_chown(pno, pno->p_base->pb_ino, owner, group); P_RELE(pno); +out: + if (err) { + errno = -err; + err = -1; + } + return err; +} + +int +fchown(int fd, uid_t owner, gid_t group) +{ + int err; + struct file *fil; + + err = 0; + fil = _sysio_fd_find(fd); + if (!fil) { + err = -EBADF; + goto out; + } + + err = _do_chown(NULL, fil->f_ino, owner, group); out: if (err) { errno = -err; Index: dev.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/dev.c,v retrieving revision 1.2.6.1 retrieving revision 1.2.6.2 diff -u -w -b -B -p -r1.2.6.1 -r1.2.6.2 --- dev.c 12 May 2003 11:48:45 -0000 1.2.6.1 +++ dev.c 27 Sep 2003 20:20:40 -0000 1.2.6.2 @@ -63,7 +63,9 @@ const struct inode_ops _sysio_nodev_ops _sysio_nodev_inop_readlink, _sysio_nodev_inop_open, _sysio_nodev_inop_close, + _sysio_nodev_inop_link, _sysio_nodev_inop_unlink, + _sysio_nodev_inop_rename, _sysio_nodev_inop_ipreadv, _sysio_nodev_inop_ipwritev, _sysio_nodev_inop_iodone, @@ -169,45 +171,10 @@ _sysio_dev_lookup(mode_t mode, dev_t dev } int -_sysio_dev_e_notdir() -{ - - return -ENOTDIR; -} - -int -_sysio_dev_e_badf() -{ - - return -EBADF; -} - -int -_sysio_dev_e_inval() -{ - - return -EINVAL; -} - -int -_sysio_dev_e_nxio() -{ - - return -ENXIO; -} - -int -_sysio_dev_e_illop() +_sysio_dev_illop() { abort(); -} - -int -_sysio_dev_e_notty() -{ - - return -ENOTTY; } void Index: rmdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rmdir.c,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -u -w -b -B -p -r1.3 -r1.3.6.1 --- rmdir.c 24 Mar 2003 22:09:06 -0000 1.3 +++ rmdir.c 27 Sep 2003 20:20:41 -0000 1.3.6.1 @@ -68,6 +68,13 @@ rmdir(const char *path) goto error; } err = pno->p_base->pb_ino->i_ops.inop_rmdir(pno); + if (err) + goto error; + /* + * Invalide the path-base node. The inode reference was dropped + * by the driver. + */ + pno->p_base->pb_ino = NULL; error: P_RELE(pno); out: Index: unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/unlink.c,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -u -w -b -B -p -r1.3 -r1.3.6.1 --- unlink.c 24 Mar 2003 22:09:07 -0000 1.3 +++ unlink.c 27 Sep 2003 20:20:41 -0000 1.3.6.1 @@ -68,6 +68,13 @@ unlink(const char *path) goto error; } err = (*pno->p_base->pb_ino->i_ops.inop_unlink)(pno); + if (err) + goto error; + /* + * Invalidate the path-base node. The inode reference was + * dropped by the driver. + */ + pno->p_base->pb_ino = NULL; error: P_RELE(pno); out: |
From: Lee W. <lw...@us...> - 2003-09-27 20:20:55
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1:/tmp/cvs-serv15049/include Modified Files: Tag: RedStorm dev.h inode.h sysio.h Log Message: Updated with recent changes in HEAD branch. Index: dev.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/dev.h,v retrieving revision 1.2.6.1 retrieving revision 1.2.6.2 diff -u -w -b -B -p -r1.2.6.1 -r1.2.6.2 --- dev.h 12 May 2003 11:48:45 -0000 1.2.6.1 +++ dev.h 27 Sep 2003 20:20:40 -0000 1.2.6.2 @@ -70,72 +70,76 @@ extern const struct inode_ops _sysio_nod (int (*)(struct pnode *, \ struct inode **, \ struct intent *, \ - const char *))_sysio_dev_e_notdir + const char *))_sysio_dev_illop #define _sysio_nodev_inop_getattr \ (int (*)(struct pnode *, \ struct inode *, \ - struct intnl_stat *))_sysio_dev_e_badf + struct intnl_stat *))_sysio_dev_illop #define _sysio_nodev_inop_setattr \ (int (*)(struct pnode *, \ struct inode *, \ unsigned , \ - struct intnl_stat *))_sysio_dev_e_badf + struct intnl_stat *))_sysio_dev_illop #define _sysio_nodev_getdirentries \ (ssize_t (*)(struct inode *, \ char *, \ size_t , \ - _SYSIO_OFF_T *))_sysio_dev_e_notdir + _SYSIO_OFF_T *))_sysio_dev_illop #define _sysio_nodev_inop_mkdir \ (int (*)(struct pnode *, \ - mode_t))_sysio_dev_e_notdir + mode_t))_sysio_dev_illop #define _sysio_nodev_inop_rmdir \ - (int (*)(struct pnode *))_sysio_dev_e_notdir + (int (*)(struct pnode *))_sysio_dev_illop #define _sysio_nodev_inop_symlink \ (int (*)(struct pnode *, \ - const char *))_sysio_dev_e_notdir + const char *))_sysio_dev_illop #define _sysio_nodev_inop_readlink \ (int (*)(struct pnode *, \ char *, \ - size_t))_sysio_dev_e_inval + size_t))_sysio_dev_illop #define _sysio_nodev_inop_open \ (int (*)(struct pnode *, \ int, \ - mode_t))_sysio_dev_e_nxio + mode_t))_sysio_dev_illop #define _sysio_nodev_inop_close \ - (int (*)(struct inode *))_sysio_dev_e_badf + (int (*)(struct inode *))_sysio_dev_illop +#define _sysio_nodev_inop_link \ + (int (*)(struct pnode *, struct pnode *))_sysio_dev_illop #define _sysio_nodev_inop_unlink \ - (int (*)(struct pnode *))_sysio_dev_e_notdir + (int (*)(struct pnode *))_sysio_dev_illop +#define _sysio_nodev_inop_rename \ + (int (*)(struct pnode *, struct pnode *))_sysio_dev_illop #define _sysio_nodev_inop_ipreadv \ (int (*)(struct inode *, \ struct io_arguments *, \ - struct ioctx **))_sysio_dev_e_inval + struct ioctx **))_sysio_dev_illop #define _sysio_nodev_inop_ipwritev \ (int (*)(struct inode *, \ struct io_arguments *, \ - struct ioctx **))_sysio_dev_e_inval + struct ioctx **))_sysio_dev_illop #define _sysio_nodev_inop_iodone \ - (int (*)(struct ioctx *))_sysio_dev_e_illop + (int (*)(struct ioctx *))_sysio_dev_illop #define _sysio_nodev_inop_fcntl \ (int (*)(struct inode *, \ int, \ - va_list))_sysio_dev_e_inval + va_list))_sysio_dev_illop #define _sysio_nodev_inop_sync \ - (int (*)(struct inode *))_sysio_dev_e_inval + (int (*)(struct inode *))_sysio_dev_illop #define _sysio_nodev_inop_datasync \ - (int (*)(struct inode *))_sysio_dev_e_inval + (int (*)(struct inode *))_sysio_dev_illop #define _sysio_nodev_inop_ioctl \ (int (*)(struct inode *, \ unsigned long int, \ - va_list))_sysio_dev_e_notty + va_list))_sysio_dev_illop #define _sysio_nodev_inop_mknod \ (int (*)(struct pnode *, \ mode_t, \ - dev_t))_sysio_dev_e_notdir + dev_t))_sysio_dev_illop #ifdef _HAVE_STATVFS #define _sysio_nodev_inop_statvfs \ (int (*)(struct pnode *, \ struct inode *, \ - struct intnl_statvfs *))_sysio_dev_e_inval + struct intnl_statvfs *))_sysio_dev_illop #endif #define _sysio_nodev_inop_gone \ (void (*)(struct inode *ino))_sysio_dev_noop @@ -146,10 +150,5 @@ extern struct inode_ops *_sysio_dev_look extern int _sysio_char_dev_register(int major, const char *name, struct inode_ops *ops); -extern int _sysio_dev_e_notdir(void); -extern int _sysio_dev_e_badf(void); -extern int _sysio_dev_e_inval(void); -extern int _sysio_dev_e_nxio(void); -extern int _sysio_dev_e_illop(void); -extern int _sysio_dev_e_notty(void); +extern int _sysio_dev_illop(void); extern void _sysio_dev_noop(void); Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.6.4.3 retrieving revision 1.6.4.4 diff -u -w -b -B -p -r1.6.4.3 -r1.6.4.4 --- inode.h 26 Sep 2003 21:28:34 -0000 1.6.4.3 +++ inode.h 27 Sep 2003 20:20:40 -0000 1.6.4.4 @@ -96,7 +96,9 @@ struct inode_ops { int (*inop_readlink)(struct pnode *pno, char *buf, size_t bufsiz); int (*inop_open)(struct pnode *pno, int flags, mode_t mode); int (*inop_close)(struct inode *ino); + int (*inop_link)(struct pnode *old, struct pnode *new); int (*inop_unlink)(struct pnode *pno); + int (*inop_rename)(struct pnode *old, struct pnode *new); int (*inop_ipreadv)(struct inode *ino, struct io_arguments *ioargs, struct ioctx **ioctxp); @@ -445,6 +447,7 @@ extern int _sysio_namei(struct pnode *pn unsigned flags, struct intent *intnt, struct pnode **pnop); +extern int _sysio_p_chdir(struct pnode *pno); extern int _sysio_ioctx_init(void); extern struct ioctx *_sysio_ioctx_new(struct inode *ino, struct io_arguments *ioargs); Index: sysio.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio.h,v retrieving revision 1.7.6.2 retrieving revision 1.7.6.3 diff -u -w -b -B -p -r1.7.6.2 -r1.7.6.3 --- sysio.h 29 Jul 2003 20:17:22 -0000 1.7.6.2 +++ sysio.h 27 Sep 2003 20:20:40 -0000 1.7.6.3 @@ -121,6 +121,8 @@ struct statvfs; #endif struct iovec; +struct utimbuf; + struct pnode; extern struct pnode *_sysio_cwd; @@ -138,7 +140,9 @@ extern void _sysio_shutdown(void); extern int access(const char *path, int amode); extern int chdir(const char *path); extern int chmod(const char *path, mode_t mode); +extern int fchmod(int fd, mode_t mode); extern int chown(const char *path, uid_t owner, gid_t group); +extern int fchown(int fd, uid_t owner, gid_t group); extern int close(int d); extern int dup(int oldfd); extern int dup2(int oldfd, int newfd); @@ -165,7 +169,9 @@ extern int fstatvfs(int fd, struct statv extern int truncate(const char *path, off_t length); extern int rmdir(const char *path); extern int symlink(const char *path1, const char *path2); +extern int link(const char *oldpath, const char *newpath); extern int unlink(const char *path); +extern int rename(const char *oldpath, const char *newpath); extern int fdatasync(int fd); extern int ioctl(int fd, unsigned long request, ...); extern mode_t umask(mode_t mask); @@ -193,6 +199,7 @@ extern ioid_t iwrite(int fd, const void extern ssize_t writev(int fd, const struct iovec *iov, int count); extern ssize_t write(int fd, const void *buf, size_t count); extern int mknod(const char *path, mode_t mode, dev_t dev); +extern int utime(const char *path, const struct utimbuf *buf); extern int mount(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, |
From: Lee W. <lw...@us...> - 2003-09-27 20:19:13
|
Update of /cvsroot/libsysio/libsysio/drivers/incore In directory sc8-pr-cvs1:/tmp/cvs-serv6348/drivers/incore Modified Files: fs_incore.c Log Message: - Better checking during chdir(). - Added _sysio_p_chdir() to call change working directory with a pnode. - test_path.c doesn't follow symlinks anymore. - sysio_stubs.c defined a bunch of disk ioctl's inappropriately. Removed. - Added fchmod(), fchown(), rename(), link(), utime(). Index: fs_incore.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/incore/fs_incore.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- fs_incore.c 31 Jul 2003 22:21:36 -0000 1.5 +++ fs_incore.c 27 Sep 2003 19:42:01 -0000 1.6 @@ -137,7 +137,9 @@ static int _sysio_incore_dirop_mkdir(str static int _sysio_incore_dirop_rmdir(struct pnode *pno); static int _sysio_incore_inop_open(struct pnode *pno, int flags, mode_t mode); static int _sysio_incore_inop_close(struct inode *ino); +static int _sysio_incore_dirop_link(struct pnode *old, struct pnode *new); static int _sysio_incore_dirop_unlink(struct pnode *pno); +static int _sysio_incore_dirop_rename(struct pnode *old, struct pnode *new); static int _sysio_incore_filop_ipreadv(struct inode *ino, struct io_arguments *ioargs, struct ioctx **ioctxp); @@ -156,7 +158,6 @@ static int _sysio_incore_inop_statvfs(st struct intnl_statvfs *buf); static void _sysio_incore_inop_gone(struct inode *ino); static int _sysio_incore_e_isdir(void); -static int _sysio_incore_e_notdir(void); static int _sysio_incore_e_inval(void); static int _sysio_incore_e_nosys(void); static void _sysio_incore_illop(void); @@ -193,7 +194,9 @@ static struct inode_ops _sysio_incore_di _sysio_incore_dirop_readlink, _sysio_incore_inop_open, _sysio_incore_inop_close, + _sysio_incore_dirop_link, _sysio_incore_dirop_unlink, + _sysio_incore_dirop_rename, _sysio_incore_dirop_ipreadv, _sysio_incore_dirop_ipwritev, _sysio_incore_dirop_iodone, @@ -210,24 +213,28 @@ static struct inode_ops _sysio_incore_di (int (*)(struct pnode *, \ struct inode **, \ struct intent *, \ - const char *))_sysio_incore_e_notdir + const char *))_sysio_incore_illop #define _sysio_incore_filop_getdirentries \ (ssize_t (*)(struct inode *, \ char *, \ size_t, \ - off64_t *))_sysio_incore_e_notdir + off64_t *))_sysio_incore_illop #define _sysio_incore_filop_mkdir \ - (int (*)(struct pnode *, mode_t))_sysio_incore_e_notdir + (int (*)(struct pnode *, mode_t))_sysio_incore_illop #define _sysio_incore_filop_rmdir \ - (int (*)(struct pnode *))_sysio_incore_e_notdir + (int (*)(struct pnode *))_sysio_incore_illop #define _sysio_incore_filop_symlink \ (int (*)(struct pnode *, const char *))_sysio_incore_illop #define _sysio_incore_symlinkop_readlink \ (int (*)(struct pnode *, char *, size_t))_sysio_incore_illop +#define _sysio_incore_filop_link \ + (int (*)(struct pnode *old, struct pnode *new))_sysio_incore_illop #define _sysio_incore_filop_unlink \ - (int (*)(struct pnode *pno))_sysio_incore_e_notdir + (int (*)(struct pnode *pno))_sysio_incore_illop +#define _sysio_incore_filop_rename \ + (int (*)(struct pnode *old, struct pnode *new))_sysio_incore_illop #define _sysio_incore_filop_mknod \ - (int (*)(struct pnode *pno, mode_t, dev_t))_sysio_incore_e_notdir + (int (*)(struct pnode *pno, mode_t, dev_t))_sysio_incore_illop static struct inode_ops _sysio_incore_file_ops = { _sysio_incore_filop_lookup, @@ -240,7 +247,9 @@ static struct inode_ops _sysio_incore_fi _sysio_incore_symlinkop_readlink, _sysio_incore_inop_open, _sysio_incore_inop_close, + _sysio_incore_filop_link, _sysio_incore_filop_unlink, + _sysio_incore_filop_rename, _sysio_incore_filop_ipreadv, _sysio_incore_filop_ipwritev, _sysio_incore_filop_iodone, @@ -264,7 +273,9 @@ static struct inode_ops _sysio_incore_de _sysio_incore_symlinkop_readlink, _sysio_nodev_inop_open, _sysio_nodev_inop_close, + _sysio_incore_filop_link, _sysio_incore_filop_unlink, + _sysio_incore_filop_rename, _sysio_nodev_inop_ipreadv, _sysio_nodev_inop_ipwritev, _sysio_nodev_inop_iodone, @@ -309,7 +320,7 @@ struct lookup_data { */ #define INCORE_D_RECLEN(namlen) \ (((size_t )&((struct intnl_dirent *)0)->d_name + \ - (namlen) + sizeof(void *)) & \ + (namlen) + 1 + sizeof(void *)) & \ ~(sizeof(void *) - 1)) /* @@ -353,11 +364,13 @@ _sysio_incore_init() de->d_off = off = de->d_reclen = INCORE_D_RECLEN(1); de->d_type = INCORE_D_TYPEOF(S_IFDIR); de->d_name[0] = '.'; + de->d_name[1] = ' '; de = (void *)de + de->d_off; de->d_reclen = INCORE_D_RECLEN(2); de->d_off = off += de->d_reclen; de->d_type = INCORE_D_TYPEOF(S_IFDIR); de->d_name[0] = de->d_name[1] = '.'; + de->d_name[2] = ' '; return _sysio_fssw_register("incore", &incore_fssw_ops); } @@ -719,7 +732,8 @@ incore_directory_match(struct intnl_dire struct lookup_data *ld) { - if (strncmp(de->d_name, ld->name->name, ld->name->len) == 0) + if (strlen(de->d_name) == ld->name->len && + strncmp(de->d_name, ld->name->name, ld->name->len) == 0) return de; ld->de = de; return NULL; @@ -1006,6 +1020,7 @@ incore_directory_insert(struct incore_in de->d_reclen = reclen; de->d_type = type; (void )memcpy(de->d_name, name->name, name->len); + de->d_name[name->len] = '\0'; /* * Update attributes to reflect the new entry. @@ -1114,6 +1129,12 @@ incore_unlink_entry(struct incore_inode lookup_data.de->d_off = de->d_off; /* unlink */ (void )memset(de, 0, de->d_reclen); /* clear */ + /* + * Adjust link count. + */ + assert(icino->ici_st.st_nlink > 2); + icino->ici_st.st_nlink--; + return 0; } @@ -1145,6 +1166,12 @@ _sysio_incore_dirop_rmdir(struct pnode * return err; I_RELE(ino); + /* + * Adjust link count. + */ + assert(icino->ici_st.st_nlink > 2); + icino->ici_st.st_nlink--; + return 0; } @@ -1242,6 +1269,94 @@ _sysio_incore_inop_close(struct inode *i } static int +_sysio_incore_dirop_link(struct pnode *old, struct pnode *new) +{ + struct incore_inode *icino = I2IC(old->p_base->pb_ino); + int err; + + assert(!new->p_base->pb_ino); + assert(!S_ISDIR(old->p_base->pb_ino->i_mode)); + + /* + * Can bump the link count? + */ + if (!(icino->ici_st.st_nlink + 1)) + return -EMLINK; + /* + * Insert into parent. + */ + err = + incore_directory_insert(I2IC(new->p_parent->p_base->pb_ino), + &new->p_base->pb_name, + icino->ici_st.st_ino, + INCORE_D_TYPEOF(icino->ici_st.st_mode)); + if (err) + return err; + /* + * Bump the link count. + */ + icino->ici_st.st_nlink++; + + return 0; +} + +static int +_sysio_incore_dirop_rename(struct pnode *old, struct pnode *new) +{ + int err; + struct incore_inode *icino = I2IC(old->p_base->pb_ino); + + if (new->p_base->pb_ino) { + /* + * Have to kill off the target first. + */ + if (S_ISDIR(I2IC(new->p_base->pb_ino)->ici_st.st_mode) && + I2IC(new->p_base->pb_ino)->ici_st.st_nlink > 2) + return -ENOTEMPTY; + err = + incore_unlink_entry(I2IC(new->p_parent->p_base->pb_ino), + &new->p_base->pb_name); + if (err) + return err; + I_RELE(new->p_base->pb_ino); + _sysio_i_gone(new->p_base->pb_ino); + new->p_base->pb_ino = NULL; + } + + /* + * Insert into new parent. + */ + err = + incore_directory_insert(I2IC(new->p_parent->p_base->pb_ino), + &new->p_base->pb_name, + icino->ici_st.st_ino, + INCORE_D_TYPEOF(icino->ici_st.st_mode)); + if (err) + abort(); + /* + * Remove from the old parent. + */ + err = + incore_unlink_entry(I2IC(old->p_parent->p_base->pb_ino), + &old->p_base->pb_name); + if (err) + abort(); + + if (S_ISDIR(icino->ici_st.st_mode)) { + struct intnl_dirent *de; + + /* + * We moved a directory. The entry for `..' must be corrected. + */ + de = icino->ici_data; + de++; + assert(strcmp(de->d_name, "..") == 0); + de->d_ino = I2IC(new->p_parent->p_base->pb_ino)->ici_st.st_ino; + } + return 0; +} + +static int _sysio_incore_dirop_unlink(struct pnode *pno) { struct inode *ino = pno->p_base->pb_ino; @@ -1251,7 +1366,6 @@ _sysio_incore_dirop_unlink(struct pnode if (S_ISDIR(icino->ici_st.st_mode)) return -EISDIR; - pno->p_base->pb_ino = NULL; err = incore_unlink_entry(I2IC(pno->p_parent->p_base->pb_ino), &pno->p_base->pb_name); @@ -1472,7 +1586,8 @@ _sysio_incore_inop_statvfs(struct pnode */ buf->f_bsize = fs->fs_bsize; buf->f_frsize = buf->f_bsize; - buf->f_blocks = (0xffffffffffffffff - 1) / buf->f_bsize; + buf->f_blocks = ~0; + buf->f_blocks /= buf->f_bsize; buf->f_bfree = buf->f_blocks - 1; buf->f_bavail = buf->f_bfree; buf->f_files = buf->f_blocks; @@ -1498,13 +1613,6 @@ _sysio_incore_e_isdir(void) { return -EISDIR; -} - -static int -_sysio_incore_e_notdir(void) -{ - - return -ENOTDIR; } static int |
From: Lee W. <lw...@us...> - 2003-09-27 20:19:13
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv6348/drivers/native Modified Files: fs_native.c Log Message: - Better checking during chdir(). - Added _sysio_p_chdir() to call change working directory with a pnode. - test_path.c doesn't follow symlinks anymore. - sysio_stubs.c defined a bunch of disk ioctl's inappropriately. Removed. - Added fchmod(), fchown(), rename(), link(), utime(). Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -b -B -p -r1.16 -r1.17 --- fs_native.c 14 Aug 2003 18:39:33 -0000 1.16 +++ fs_native.c 27 Sep 2003 19:42:02 -0000 1.17 @@ -132,12 +132,12 @@ do { #endif #if defined(USE_NATIVE_STAT) -#define __SYS_STAT SYS_stat +#define __SYS_STAT SYS_lstat #define __SYS_FSTAT SYS_fstat #define __SYS_TRUNCATE SYS_truncate #define __SYS_FTRUNCATE SYS_ftruncate #else -#define __SYS_STAT SYS_stat64 +#define __SYS_STAT SYS_lstat64 #define __SYS_FSTAT SYS_fstat64 #define __SYS_TRUNCATE SYS_truncate64 #define __SYS_FTRUNCATE SYS_ftruncate64 @@ -202,7 +202,9 @@ static int native_inop_symlink(struct pn static int native_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz); static int native_inop_open(struct pnode *pno, int flags, mode_t mode); static int native_inop_close(struct inode *ino); +static int native_inop_link(struct pnode *old, struct pnode *new); static int native_inop_unlink(struct pnode *pno); +static int native_inop_rename(struct pnode *old, struct pnode *new); static int native_inop_ipreadv(struct inode *ino, struct io_arguments *ioargs, struct ioctx **ioctxp); @@ -233,7 +235,9 @@ static struct inode_ops native_i_ops = { native_inop_readlink, native_inop_open, native_inop_close, + native_inop_link, native_inop_unlink, + native_inop_rename, native_inop_ipreadv, native_inop_ipwritev, native_inop_iodone, @@ -1014,6 +1018,32 @@ native_inop_close(struct inode *ino) } static int +native_inop_link(struct pnode *old, struct pnode *new) +{ + int err; + char *opath, *npath; + + err = 0; + + opath = _sysio_pb_path(old->p_base, '/'); + npath = _sysio_pb_path(new->p_base, '/'); + if (!(opath && npath)) { + err = -ENOMEM; + goto out; + } + + err = syscall(SYS_link, opath, npath); + +out: + if (opath) + free(opath); + if (npath) + free(npath); + + return err; +} + +static int native_inop_unlink(struct pnode *pno) { char *path; @@ -1118,6 +1148,30 @@ _readv(int fd, const struct iovec *vecto { return syscall(SYS_readv, fd, vector, count); +} + +static int +native_inop_rename(struct pnode *old, struct pnode *new) +{ + int err; + char *opath, *npath; + + opath = _sysio_pb_path(old->p_base, '/'); + npath = _sysio_pb_path(new->p_base, '/'); + if (!(opath && npath)) { + err = -ENOMEM; + goto out; + } + + err = syscall(SYS_rename, opath, npath); + +out: + if (opath) + free(opath); + if (npath) + free(npath); + + return err; } static int |
From: Lee W. <lw...@us...> - 2003-09-27 20:07:13
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv6348/src Modified Files: Makefile.am chdir.c chmod.c chown.c dev.c rmdir.c unlink.c Added Files: link.c rename.c utime.c Log Message: - Better checking during chdir(). - Added _sysio_p_chdir() to call change working directory with a pnode. - test_path.c doesn't follow symlinks anymore. - sysio_stubs.c defined a bunch of disk ioctl's inappropriately. Removed. - Added fchmod(), fchown(), rename(), link(), utime(). --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2003 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1110 * * le...@sa... */ #include <string.h> #include <errno.h> #include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/queue.h> #include "sysio.h" #include "mount.h" #include "inode.h" int link(const char *oldpath, const char *newpath) { struct intent intent; int err; struct pnode *old, *new; INTENT_INIT(&intent, 0, NULL, NULL); err = _sysio_namei(_sysio_cwd, oldpath, 0, &intent, &old); if (err) goto out; if (S_ISDIR(old->p_base->pb_ino->i_mode)) { err = -EPERM; goto error2; } INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &new); if (err && !new) goto error2; if (!err || (err && err != -ENOENT)) { err = -EEXIST; goto error1; } if (old->p_mount->mnt_root != new->p_mount->mnt_root) { err = -EXDEV; goto error1; } err = old->p_base->pb_ino->i_ops.inop_link(old, new); if (err) goto error1; /* * The new path-base node must point to the inode referenced by * the old. As well, we need to record the new reference of the inode. */ new->p_base->pb_ino = old->p_base->pb_ino; I_REF(new->p_base->pb_ino); error1: P_RELE(new); error2: P_RELE(old); if (err) { errno = -err; err = -1; } out: return err; } --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2003 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1110 * * le...@sa... */ #include <stdlib.h> #include <string.h> #include <errno.h> #include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/queue.h> #include "sysio.h" #include "mount.h" #include "inode.h" int rename(const char *oldpath, const char *newpath) { struct intent intent; int err; struct pnode *old, *new; struct pnode_base *nxtpb, *pb; struct intnl_stat ostbuf, nstbuf; /* * Resolve oldpath to a path node. */ INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = _sysio_namei(_sysio_cwd, oldpath, 0, &intent, &old); if (err) goto out; /* * Resolve newpath to a path node. */ INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &new); if (err && !new) goto error2; if (old->p_mount->mnt_root != new->p_mount->mnt_root) { /* * Oops. They're trying to move it across mounts. */ err = -EXDEV; goto error1; } /* * Make sure the old pnode can't be found in the ancestor chain * for the new. If it can, they are trying to move into a subdirectory * of the old. */ nxtpb = new->p_base; do { pb = nxtpb; nxtpb = pb->pb_parent; if (pb == old->p_base) { err = -EINVAL; goto error1; } } while (pb != nxtpb); while (new->p_base->pb_ino) { /* * Existing entry. We're replacing the new. Make sure that's * ok. */ err = old->p_base->pb_ino->i_ops.inop_getattr(old, NULL, &ostbuf); if (err) goto error1; err = new->p_base->pb_ino->i_ops.inop_getattr(new, NULL, &nstbuf); if (err) { if (err != ENOENT) goto error1; /* * Rats! It disappeared beneath us. */ (void )_sysio_p_validate(new, NULL, NULL); continue; } if (S_ISDIR(ostbuf.st_mode)) { if (!S_ISDIR(nstbuf.st_mode)) { err = -ENOTDIR; goto error1; } if (nstbuf.st_nlink > 2) { err = -ENOTEMPTY; goto error1; } } else if (S_ISDIR(nstbuf.st_mode)) { err = -EEXIST; goto error1; } } /* * It's not impossible to clean up the altered name space after * a rename. However, it is onerous and I don't want to do it right * now. If it becomes an issue, we can do it later. For now, I've * elected to use the semantic that says, basically, the entire * sub-tree must be unreferenced. */ if (_sysio_p_prune(new) != 1) { err = -EBUSY; goto error1; } err = old->p_base->pb_ino->i_ops.inop_rename(old, new); if (err) goto error1; error1: P_RELE(new); error2: P_RELE(old); if (err) { errno = -err; err = -1; goto out; } _sysio_p_gone(old); /* kill it! */ out: return err; } --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2003 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1110 * * le...@sa... */ #include <string.h> #include <errno.h> #include <time.h> #include <assert.h> #include <sys/types.h> #include <utime.h> #include <sys/stat.h> #include <unistd.h> #include <sys/queue.h> #include "sysio.h" #include "inode.h" #include "file.h" int utime(const char *path, const struct utimbuf *buf) { struct intent intent; int err; struct pnode *pno; struct utimbuf _utbuffer; struct intnl_stat stbuf; INTENT_INIT(&intent, INT_SETATTR, NULL, NULL); err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno); if (err) goto out; if (!buf) { _utbuffer.actime = _utbuffer.modtime = time(NULL); buf = &_utbuffer; } (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); stbuf.st_atime = buf->actime; stbuf.st_mtime = buf->modtime; err = _sysio_setattr(pno, pno->p_base->pb_ino, SETATTR_ATIME | SETATTR_MTIME, &stbuf); P_RELE(pno); out: if (err) { errno = -err; err = -1; } return err; } Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/Makefile.am,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- Makefile.am 14 Aug 2003 18:39:33 -0000 1.7 +++ Makefile.am 27 Sep 2003 19:42:02 -0000 1.8 @@ -2,8 +2,9 @@ lib_LIBRARIES = libsysio.a libsysio_a_SOURCES = chdir.c chmod.c chown.c dev.c dup.c fcntl.c file.c fs.c \ fsync.c getdirentries.c init.c inode.c ioctl.c ioctx.c iowait.c \ - lseek.c mkdir.c mknod.c mount.c namei.c open.c read.c rmdir.c stat.c \ - stat64.c statvfs.c symlink.c truncate.c unlink.c write.c access.c + link.c lseek.c mkdir.c mknod.c mount.c namei.c open.c read.c rename.c \ + rmdir.c stat.c stat64.c statvfs.c symlink.c truncate.c unlink.c \ + utime.c write.c access.c include $(top_srcdir)/Rules.make Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- chdir.c 26 Aug 2003 15:53:59 -0000 1.5 +++ chdir.c 27 Sep 2003 19:42:02 -0000 1.6 @@ -64,12 +64,13 @@ */ #include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> #include <unistd.h> #include <string.h> #include <limits.h> #include <errno.h> #include <assert.h> -#include <sys/types.h> #include <sys/queue.h> #include "sysio.h" @@ -79,6 +80,49 @@ struct pnode *_sysio_cwd = NULL; +/* + * Change to directory specified by the given pnode. + */ +int +_sysio_p_chdir(struct pnode *pno) +{ + int err; + struct intnl_stat stbuf; + + /* + * Revalidate + */ + err = _sysio_p_validate(pno, NULL, NULL); + if (err) + return err; + if (!pno->p_base->pb_ino) + return -ENOTDIR; + /* + * Stat the node and ensure it's a directory. + */ + err = + pno->p_base->pb_ino->i_ops.inop_getattr(pno, + NULL, + &stbuf); + if (err) + return err; + if (!S_ISDIR(stbuf.st_mode)) + return -ENOTDIR; + + /* + * Release old if set. + */ + if (_sysio_cwd) + P_RELE(_sysio_cwd); + + /* + * Finally, change to the new. + */ + _sysio_cwd = pno; + + return 0; +} + int chdir(const char *path) { @@ -91,11 +135,7 @@ chdir(const char *path) return -1; } - if (_sysio_cwd) - P_RELE(_sysio_cwd); - - _sysio_cwd = pno; - return 0; + return _sysio_p_chdir(pno); } /* Index: chmod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chmod.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- chmod.c 24 Mar 2003 22:09:06 -0000 1.3 +++ chmod.c 27 Sep 2003 19:42:02 -0000 1.4 @@ -51,6 +51,21 @@ #include "sysio.h" #include "inode.h" +#include "file.h" + +static int +do_chmod(struct pnode *pno, struct inode *ino, mode_t mode) +{ + int err; + struct intnl_stat stbuf; + unsigned mask; + + (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); + stbuf.st_mode = mode & 0777; + mask = SETATTR_MODE; + err = _sysio_setattr(pno, ino, mask, &stbuf); + return err; +} int chmod(const char *path, mode_t mode) @@ -58,18 +73,35 @@ chmod(const char *path, mode_t mode) struct intent intent; int err; struct pnode *pno; - struct intnl_stat stbuf; - unsigned mask; INTENT_INIT(&intent, INT_SETATTR, NULL, NULL); err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno); if (err) goto out; - (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); - stbuf.st_mode = mode & 0777; - mask = SETATTR_MODE; - err = _sysio_setattr(pno, pno->p_base->pb_ino, mask, &stbuf); + err = do_chmod(pno, pno->p_base->pb_ino, mode); P_RELE(pno); +out: + if (err) { + errno = -err; + err = -1; + } + return err; +} + +int +fchmod(int fd, mode_t mode) +{ + int err; + struct file *fil; + + err = 0; + fil = _sysio_fd_find(fd); + if (!fil) { + err = -EBADF; + goto out; + } + + err = do_chmod(NULL, fil->f_ino, mode); out: if (err) { errno = -err; Index: chown.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chown.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- chown.c 24 Mar 2003 22:09:06 -0000 1.3 +++ chown.c 27 Sep 2003 19:42:02 -0000 1.4 @@ -51,18 +51,15 @@ #include "sysio.h" #include "inode.h" +#include "file.h" -int -chown(const char *path, uid_t owner, gid_t group) +static int +_do_chown(struct pnode *pno, struct inode *ino, uid_t owner, gid_t group) { int err; - struct pnode *pno; struct intnl_stat stbuf; unsigned mask; - err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); - if (err) - goto out; (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); mask = 0; if (owner != (uid_t )-1) { @@ -73,11 +70,44 @@ chown(const char *path, uid_t owner, gid stbuf.st_gid = group; mask |= SETATTR_GID; } - if (!mask) - goto done; - err = _sysio_setattr(pno, pno->p_base->pb_ino, mask, &stbuf); -done: + err = _sysio_setattr(pno, ino, mask, &stbuf); + return err; +} + +int +chown(const char *path, uid_t owner, gid_t group) +{ + int err; + struct pnode *pno; + + err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); + if (err) + goto out; + + err = _do_chown(pno, pno->p_base->pb_ino, owner, group); P_RELE(pno); +out: + if (err) { + errno = -err; + err = -1; + } + return err; +} + +int +fchown(int fd, uid_t owner, gid_t group) +{ + int err; + struct file *fil; + + err = 0; + fil = _sysio_fd_find(fd); + if (!fil) { + err = -EBADF; + goto out; + } + + err = _do_chown(NULL, fil->f_ino, owner, group); out: if (err) { errno = -err; Index: dev.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/dev.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- dev.c 24 Mar 2003 22:09:06 -0000 1.2 +++ dev.c 27 Sep 2003 19:42:03 -0000 1.3 @@ -63,7 +63,9 @@ const struct inode_ops _sysio_nodev_ops _sysio_nodev_inop_readlink, _sysio_nodev_inop_open, _sysio_nodev_inop_close, + _sysio_nodev_inop_link, _sysio_nodev_inop_unlink, + _sysio_nodev_inop_rename, _sysio_nodev_inop_ipreadv, _sysio_nodev_inop_ipwritev, _sysio_nodev_inop_iodone, @@ -167,45 +169,10 @@ _sysio_dev_lookup(mode_t mode, dev_t dev } int -_sysio_dev_e_notdir() -{ - - return -ENOTDIR; -} - -int -_sysio_dev_e_badf() -{ - - return -EBADF; -} - -int -_sysio_dev_e_inval() -{ - - return -EINVAL; -} - -int -_sysio_dev_e_nxio() -{ - - return -ENXIO; -} - -int -_sysio_dev_e_illop() +_sysio_dev_illop() { abort(); -} - -int -_sysio_dev_e_notty() -{ - - return -ENOTTY; } void Index: rmdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rmdir.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- rmdir.c 24 Mar 2003 22:09:06 -0000 1.3 +++ rmdir.c 27 Sep 2003 19:42:03 -0000 1.4 @@ -68,6 +68,13 @@ rmdir(const char *path) goto error; } err = pno->p_base->pb_ino->i_ops.inop_rmdir(pno); + if (err) + goto error; + /* + * Invalide the path-base node. The inode reference was dropped + * by the driver. + */ + pno->p_base->pb_ino = NULL; error: P_RELE(pno); out: Index: unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/unlink.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- unlink.c 24 Mar 2003 22:09:07 -0000 1.3 +++ unlink.c 27 Sep 2003 19:42:03 -0000 1.4 @@ -68,6 +68,13 @@ unlink(const char *path) goto error; } err = (*pno->p_base->pb_ino->i_ops.inop_unlink)(pno); + if (err) + goto error; + /* + * Invalidate the path-base node. The inode reference was + * dropped by the driver. + */ + pno->p_base->pb_ino = NULL; error: P_RELE(pno); out: |
From: Lee W. <lw...@us...> - 2003-09-27 20:07:10
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv6348/tests Modified Files: sysio_stubs.c test_path.c Log Message: - Better checking during chdir(). - Added _sysio_p_chdir() to call change working directory with a pnode. - test_path.c doesn't follow symlinks anymore. - sysio_stubs.c defined a bunch of disk ioctl's inappropriately. Removed. - Added fchmod(), fchown(), rename(), link(), utime(). Index: sysio_stubs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/sysio_stubs.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- sysio_stubs.c 14 Aug 2003 21:16:33 -0000 1.2 +++ sysio_stubs.c 27 Sep 2003 19:42:03 -0000 1.3 @@ -1245,6 +1245,7 @@ int do_symlink(int argc, char **argv) struct cmd_map ioctl_cmds[] = { +#if 0 { "BLKROSET", BLKROSET, 3 }, { "BLKROGET", BLKROGET, 3 }, { "BLKRRPART", BLKRRPART, 3 }, @@ -1260,6 +1261,7 @@ struct cmd_map ioctl_cmds[] = { { "BLKBSZSET", BLKBSZSET, 3 }, { "FIBMAP", FIBMAP, 3 }, { "FIGETBSZ", FIGETBSZ, 3}, +#endif { NULL, -1, 0 } }; Index: test_path.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_path.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -b -B -p -r1.4 -r1.5 --- test_path.c 14 Aug 2003 18:39:33 -0000 1.4 +++ test_path.c 27 Sep 2003 19:42:03 -0000 1.5 @@ -187,7 +187,7 @@ statit(const char *path) /* * Get file attrs. */ - err = stat(path, &stbuf); + err = lstat(path, &stbuf); if (err) { perror(path); return -1; |
From: Ruth K. <rk...@us...> - 2003-09-26 23:34:25
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv20600 Modified Files: Tag: RedStorm Makefile.am Log Message: fix automake errors Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.8.6.3 retrieving revision 1.8.6.4 diff -u -w -b -B -p -r1.8.6.3 -r1.8.6.4 --- Makefile.am 26 Sep 2003 21:28:34 -0000 1.8.6.3 +++ Makefile.am 26 Sep 2003 22:15:40 -0000 1.8.6.4 @@ -46,20 +46,13 @@ DRIVERS=$(NATIVE_DRIVER_NAME) $(INCORE_D CMNSRC=drv_init_all.c drv_data.c BUILT_SOURCES=drv_data.c -check_PROGRAMS=test_driver -if TEST_ALPHA_ARG -TESTS_ENVIRONMENT=IS_ALPHA=yes -else -TESTS_ENVIRONMENT=IS_ALPHA=no -endif -TESTS=test_all.pl CFL=$(AM_CFLAGS) $(AM_CPPFLAGS) \ $(NATIVE_DRIVER_CFLAGS) $(INCORE_DRIVER_CFLAGS) \ $(STDFD_DEV_CFLAGS) $(YOD_DRIVER_CFLAGS) LIBS=$(NATIVE_DRIVER_LIB) $(INCORE_DRIVER_LIB) \ - $(STDFD_DEV_LIB) $(YOD_DRIVER_LIB) \ + $(STDFD_DEV_LIB) \ $(top_builddir)/src/libsysio.a test_copy_SOURCES=test_copy.c $(CMNSRC) |
From: Ruth K. <rk...@us...> - 2003-09-26 22:17:29
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv20404 Modified Files: Tag: RedStorm open.c Log Message: ifdef on features.h Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.7.4.2 retrieving revision 1.7.4.3 diff -u -w -b -B -p -r1.7.4.2 -r1.7.4.3 --- open.c 26 Sep 2003 21:28:34 -0000 1.7.4.2 +++ open.c 26 Sep 2003 22:14:53 -0000 1.7.4.3 @@ -49,7 +49,9 @@ #include <sys/stat.h> #include <fcntl.h> #include <sys/queue.h> +#ifdef ALPHA_LINUX #include <features.h> +#endif #include "sysio.h" #include "inode.h" |
From: Lee W. <lw...@us...> - 2003-09-26 21:28:55
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv12723/tests Modified Files: Tag: RedStorm Makefile.am test_copy.c test_getcwd.c test_list.c test_mounts.c test_path.c test_stats.c test_stdfd.c Added Files: Tag: RedStorm README help.c helper.pm populator.pl sysio_stubs.c sysio_tests.c test_all.pl test_copy.pl test_driver.c test_driver.h test_getcwd.pl test_list.pl test_path.pl test_stats.pl test_stdfd.pl verifier.pl Log Message: Merged with current head. --- NEW FILE --- To run the tests, just do a "make check" in the tests subdirectory. On the CPlant alpha systems, 3 of the 7 tests in test_all.pl are excluded due to known problems (problems as of the date of writing this; they may have since been fixed). You can also manually run the individual tests or ./test_all.pl. If you are running on CPlant, you need to run test_all.pl with a -alpha argument. Either "make check" or test_all.pl will run the 7 basic functionality tests (explained below) and report the total number of passes and failures. number of passes and failures. -----------------------SCRIPTS--------------------------------- There are a total of 8 scripts: test_copy.pl, test_list.pl, test_getcwd.pl, test_stats.pl, test_stdfd.pl, test_path.pl, populator.pl, and verifier.pl. All but the last two scripts are ran with the test_all.pl script. Here is an explanation of the scripts. All scripts take an optional "-alpha" arg for running the scripts in an alpha/cplant environment. The alpha arg makes certain assumptions about the running of the environment; for example, it does not initilization and it starts off the test driver with yod. test_copy.pl <src> <dest> : This copies a file from src to dest. : It runs a system cmp to verify that : the two files are equivalent test_list.pl [-p] <dir> : This comes in two forms. test_list.pl [-p] <fstype:mdir> <dir> : In the first form, it will : parse through the getdirentries : result in order to generate a : a listing. If the -p option is : given, it will print out the : listing. In the second form, it : mounts mdir into dir and then does : the listing test_getcwd.pl <dir> : Tests getcwd by verifying that setting the current : working directory to dir and then calling getcwd : returns dir test_stats.pl <file> : Verifies that the set of stat calls (stat, fstat, : fstatvfs, statvfs) return the same set of stats for file : and that the calls return the same items as Perl's stat : call (which would use a native library and not libsysio) test_stdfd.pl <file> : Verified that stdin, stdout, and stderr can be opened and : either written to or read from test_path.pl <path1> <path2> ... : Print each path listed and its type. : If no paths are given, paths are read : from stdin until a "quit" is given populator.pl [-seed seed] : Create a file and populate with random numbers. [-file filename] : Will use the given seed for the random number [-bytes bytes] : generator if it is given, otherwise it uses the : the current time as a seed. The seed used is : returned. If no filename is given, the file : will be named randfile.seed.procnum, where seed : is the seed used and procnum is the process number : of the script. If no bytes are given, 1024 bytes : are written. All write commands use libsysio verifier.pl <-seed seed> <-file fname> : Verifies that all bytes in the file fname : (which was created with populator) match the : random numbers which would have been used with : the populator, using the given seed. -----------------------------TEST DRIVER--------------------------------- There are 6 basic commands for the test driver, CALL, PRINT, ALLOC, FREE, HELP, and exit (EXIT, quit, or QUIT will also work). CALL is the main command for running libsysio calls. The format will depend on the particular libsysio command being ran. Basically, the format is CALL cmd args. The available commands used with CALL are (in no particular order): fstat iwrite read chdir fstatvfs iwritev readv chmod fsync list rmdir chown ftruncate lseek sizeof close getcwd lstat stat cmpstr getdirentries mkdir statvfs creat init mknod symlink debug ioctl mount truncate dup iodone open umask dup2 iowait umount endian ipread printline unlink ipreadv pread write fcntl ipwrite preadv writev fdatasync ipwritev pwritev fill iread pwrite ireadv The specifics of the commands are explained later. The return value from a command can be saved and referenced later by using a syntax similar to $foo = x. Commands can be combined, such as: CALL fstat ( $fd = CALL open foo ) ( $buf = ALLOC 128 ), with some cautionary notes. First, everything needs to be seperated by a space. File names with spaces in them need to be quoted, as in: $fd = CALL open "file with spaces" O_RDONLY Second, any value that is used needs to be identified with an identifier. In other words, the command: $buf = ALLOC ( CALL sizeof stat ) will not work, but the command $buf = ALLOC ( $size = CALL sizeof stat ) will. All commands return a 4 digit status code. The codes are: 0000 : Success. This does NOT necessarily mean that the libsysio : command returned success, only that there were no errors : in issuing the command to libsysio. To get the result of : the libsysio command, use PRINT $$ . PRINT $errno will return : the last error code. 0x001 : Invalid arguments given to command 0x002 : Invalid command issued 0x004 : Invalid variable identifier given ALLOC takes a size argument and an optional alignment argument. FREE takes the variable to free as an argument. HELP without any arguments displays the list of commands. HELP <cmd> will give information on the specific command PRINT take several forms. To just print out a variable, type PRINT $var-name. If the variable is an integer, it will return the integer. If it is a string, it will print out the string. If it is a buffer, it will print out the buffer as a series of hex digits. Note for most buffers, the test driver will not know what it contains--just because it should contain a string does not mean that the driver will know that. The other form of PRINT is: PRINT $var_name <offset> <length> <type> which will print out length units of the given type starting at the given offset. The length is the total length in bytes, so for an integer, a length of 4 would only print out one integer. The length argument is ignored for strings. Allowable types are INT SHORT CHAR and LONG. For most of the CALL commands, their format is similar to the related sysio call. The ones that do not have a corresponding sysio call are listed below: init: This MUST be called prior to any sysio calls. It initilizes : libsysio printline: If debugging is turned on, this will print a line number : with any debug lines fill <val> <type> <size> <offset> <buf>: Fills buffer buf with size : bytes of val starting at : buf+offset. The type of val : can be UINT. STR, or PTR and : is given by the type arg list <dir>: Lists contents of dir. If no dir is given, uses cwd debug <num>: Sets debug level to num sizeof <obj>: Gives the size of the obj. Valid objs are char, int, : long, flock, stat, and statvfs endian: returns 0 if the machine is little endian, one otherwise cmpstr <buf1> <buf2>: Issues a strcmp call on the two buffers to : see if they are the same. Returns 0 for a : match --- NEW FILE --- #include <stdio.h> #include "test_driver.h" void do_help() { int i, d, count = 0; fprintf(outfp, "libsysio test harness\n"); fprintf(outfp, "To get help on a specific command, use HELP <cmd>\n"); fprintf(outfp, "To exit, type exit or quit\n"); fprintf(outfp, "\nTo save the result from a function, use \"$res = CALL command\"\n"); fprintf(outfp, "To later use that res, do \"comm $res\"\n"); fprintf(outfp, "\n\nAvailable commands are (always preceded by CALL):\n\n"); /* Get total number of commands */ while (cmd_list[count].cmd) count++; d = count/4; if (count % 4) d++; for (i=0; i < d; i++) { if ( (i+d) < count ) { if ( (i + 2*d) < count) { if ( (i+3*d) < count) fprintf(outfp, "%-15s %-15s %-15s %-15s\n", cmd_list[i].cmd, cmd_list[i+d].cmd, cmd_list[i+2*d].cmd, cmd_list[i+3*d].cmd); else fprintf(outfp, "%-15s %-15s %-15s\n", cmd_list[i].cmd, cmd_list[i+d].cmd, cmd_list[i+2*d].cmd); } else fprintf(outfp, "%-15s %-15s\n", cmd_list[i].cmd, cmd_list[i+d].cmd); } else fprintf(outfp, "%-15s\n", cmd_list[i].cmd); } fprintf(outfp, "\n"); } void usage_setdebug() { fprintf(outfp, "setdebug [level]: Set debugging level to level\n"); } void usage_clear() { fprintf(outfp, "clear buf: zero out the buffer\n"); } void usage_printline() { fprintf(outfp, "printline [0|1]: Turn off (0) or on (1) the printing of line number\n"); fprintf(outfp, " : and file name with debug output\n"); } void usage_endian() { fprintf(outfp, "endian: returns 1 for bigendian machines and 0 for little endian machines\n"); } void usage_sizeof() { fprintf(outfp, "sizeof [type]: returns the size of the data type. Currently \n"); fprintf(outfp, " : supported types are char, int, long, flock, stat and \n"); fprintf(outfp, " : statvfs\n"); } void usage_get_buffer() { fprintf(outfp, "alloc [size] <align>: allocates a buffer of size bytes aligned to align\n"); fprintf(outfp, " : align is optional. If not there, buffer will be aligned on\n"); fprintf(outfp, " : a one-byte boundary. returns an index into an array that \n"); fprintf(outfp, " : holds the buffer\n"); } void usage_free_buffer() { fprintf(outfp, "free [bufidx]: frees buffer at bufidx. Returns 0 on success, -1 on failure\n"); } void usage_do_fillbuff() { fprintf(outfp, "fill [val] [type] [size] [offset] [buf] : Fills the buffer buf with size \n"); fprintf(outfp, " : bytes of val starting at buf+offset\n"); fprintf(outfp, " : The type of val is specified by type,\n"); fprintf(outfp, " : which can be UINT, STR, or PTR\n"); } void usage_do_printbuf() { fprintf(outfp, "printbuf [buf] : print out contents of the buffer stored in buf\n"); fprintf(outfp, " : Always returns 0\n"); } void usage_cmpbufs() { fprintf(outfp, "cmpstr [buf1] [buf2]: Compare the contents of buf1 with buf2 by issuing a \n"); fprintf(outfp, " strcmp call. Returns 0 if the buffers match\n"); } void usage_init() { fprintf(outfp, "init <driver> <path> <flags>: Without any arguments, initilizes libsysio\n"); fprintf(outfp, " : to default values for root directory and\n"); fprintf(outfp, " : current directory. Accepts optional\n"); fprintf(outfp, " : arguments for the root driver, the mount\n"); fprintf(outfp, " : path, and the mount flags. Must be called\n"); fprintf(outfp, " : before any other libsysio calls. Returns\n"); fprintf(outfp," : 0 on success, -1 on failure\n"); } void usage_list() { fprintf(outfp, "list <dir>: lists contents of dir. If dir is ommitted, will list contents\n"); fprintf(outfp, " : of the current working directory\n"); fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); } void usage_chdir() { fprintf(outfp, "chdir [dir]: change the current working directory to dir\n"); fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); } void usage_chmod() { fprintf(outfp, "chmod [newmode] [file]: change mode of file to newmode. newmode can be \n"); fprintf(outfp, " : specifed symbolically (eg, a+x), numerically \n"); fprintf(outfp, " : (eg, 0777), or using system defines \n"); fprintf(outfp, " : (eg S_IRUSR|S_IWUSR|S_IRGRP)\n"); fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); } void usage_chown() { fprintf(outfp, "chown [newown[:newgrp]] [file]: change the owner of file to newown, the group\n"); fprintf(outfp, " : of file to newgrp, or both\n"); fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); } void usage_open() { fprintf(outfp, "open [file] [flags] <mode>: open file with given flags. The mode is optional\n"); fprintf(outfp, " : can use defines for open, (eg, open foo O_RDONLY)\n"); fprintf(outfp, " : If flags are 0, file will be opened with O_RDWR\n"); fprintf(outfp, " : Returns the file descriptor for the opened file\n"); } void usage_close() { fprintf(outfp, "close [file]: closes the file. Returns 0 on success, -1 on failure\n"); } void usage_mount() { fprintf(outfp, "mount [fstype:source] [target]: mount source (which has fstype as its file\n"); fprintf(outfp, " : system type) onto target.\n"); fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); } void usage_dup() { fprintf(outfp, "dup [oldfd]: Duplicate oldfd. Returns the duplicated file descriptor\n"); fprintf(outfp, " : Returns -1 on failure\n"); } void usage_dup2() { fprintf(outfp, "dup2 [oldfd] [newfd]: Make newfd be a copy of oldfd. Returns newfd on \n"); fprintf(outfp, " : success and -1 on failure\n"); } void usage_fcntl() { fprintf(outfp, "fcntl [fd] [cmd] <args> : execute fcntl cmd on file with file descriptor fd\n"); fprintf(outfp, " : using (optional) args. Accepted (but not \n"); fprintf(outfp, " : necesarily working) commands are F_DUPFD, \n"); fprintf(outfp, " : F_GETFD, F_GETFL, F_GETOWN, F_SETFD, F_SETFL,\n"); fprintf(outfp, " : F_SETOWN, F_SETLK, F_SETLKW, and F_GETLK. \n"); } void usage_fstat() { fprintf(outfp, "fstat [fd] [buf]: Get the stat structure for file descriptor fd and place it\n"); fprintf(outfp, " : in buf. Returns 0 on success, -1 on failure\n"); } void usage_fsync() { fprintf(outfp, "fsync [fd]: ensure all parts of file with file descriptor fd are output to\n"); fprintf(outfp, " : stable storage. Returns 0 on success, -1 on failure\n"); } void usage_fdatasync() { fprintf(outfp, "fdatasync [fd]: ensure all parts of file with file descriptor fd except the \n"); fprintf(outfp, " : metadata are output to stable storage. Returns 0 on \n"); fprintf(outfp, " : success, -1 on failure\n"); } void usage_ftruncate() { fprintf(outfp, "ftruncate [fd] [len]: truncate file with file descriptor fd to have be \n"); fprintf(outfp, " : len bytes in length. Returns 0 on success, -1 on \n"); fprintf(outfp, " : failure\n"); } void usage_getcwd() { fprintf(outfp, "getcwd [buf] [size]: get the current working directory and store it in buf\n"); fprintf(outfp, " : buf is size bytes in length. If buf is too short, an \n"); fprintf(outfp, " : error of ERANGE is returned. Returns 0 on success, -1\n"); fprintf(outfp, " : on failure\n"); } void usage_lseek() { fprintf(outfp, "lseek [fd] [offset] [whence]: Sets the offset of the file descriptor fd to\n"); fprintf(outfp, " : either offset if whence is SEEK_SET or offset\n"); fprintf(outfp, " : plus the current location if whence is SEEK_CUR\n"); fprintf(outfp, " : or offset plus the size of the file if whence\n"); fprintf(outfp, " : is SEEK_END. Returns 0 on success and -1 on \n"); fprintf(outfp, " : failure\n"); } void usage_lstat() { fprintf(outfp, "lstat [filename] [buf]: Get the stat structure for filename and return it in\n"); fprintf(outfp, " : buf. Returns 0 on success and -1 on failure\n"); } void usage_getdirentries() { fprintf(outfp, "getdirentries [fd] [buf] [nbytes] [basep]: Read dir entries from directory\n"); fprintf(outfp, " : with file descriptor fd into buf\n"); fprintf(outfp, " : At most nbytes are read. Reading\n"); fprintf(outfp, " : starts at basep, and basep is set\n"); fprintf(outfp, " : to new pos. Returns the number of \n"); fprintf(outfp, " : bytes read on success or 0 on\n"); fprintf(outfp, " : failure\n"); fprintf(outfp, "Note that basep does not have to be pre-allocated. Executing cmd: \n"); fprintf(outfp, "\"getdirentries $fd $buf 4096 $basep\", where $fd is the result of an open\n"); fprintf(outfp, "and $buf is the result of an alloc (but $basep is totally new) will work\n"); fprintf(outfp, "After the execution of the command, $basep holds the new offset and can be\n"); fprintf(outfp, "used again for any further getdirentries calls\n"); } void usage_mkdir() { fprintf(outfp, "mkdir [newdir] [mode]: make a new directory, newdir, with the permissions \n"); fprintf(outfp, " : specified in mode. Permissions can be symbolic \n"); fprintf(outfp, " : (eg, a+x), numeric (eg, 0777), or can use defines\n"); fprintf(outfp, " : (eg S_IRUSR|S_IWUSR|S_IRGRP). Returns 0 on success \n"); fprintf(outfp, " : -1 on failure.\n"); } void usage_creat() { fprintf(outfp, "creat [newfile] [mode]: create a new file, newfile, with the permissions \n"); fprintf(outfp, " : specified in mode. Permissions can be symbolic \n"); fprintf(outfp, " : (eg, a+x), numeric (eg, 0777), or can use defines\n"); fprintf(outfp, " : (eg S_IRUSR|S_IWUSR|S_IRGRP). Returns 0 on success \n"); fprintf(outfp, " : -1 on failure.\n"); } void usage_stat() { fprintf(outfp, "stat [filename] [buf]: Get the stat structure for filename and return it in\n"); fprintf(outfp, " : buf. Returns 0 on success and -1 on failure\n"); } void usage_statvfs() { fprintf(outfp, "statvfs [filename] [buf]: Get the statvfs structure for filename and return\n"); fprintf(outfp, " : it in buf. Returns 0 on success and -1 on failure\n"); } void usage_fstatvfs() { fprintf(outfp, "fstatvfs [fd] [buf]: Get the stat structure for file with file descriptor fd\n"); fprintf(outfp, " : and return it in buf. Returns 0 on success and -1 on\n"); fprintf(outfp, " : failure\n"); } void usage_truncate() { fprintf(outfp, "truncate [fname] [len]: truncate file with name fname to be exactly \n"); fprintf(outfp, " : len bytes in length. Returns 0 on success, -1 on \n"); fprintf(outfp, " : failure\n"); } void usage_rmdir() { fprintf(outfp, "rmdir [dirname]: Remove directory at dirname. Returns 0 on success, -1 on\n"); fprintf(outfp, " : failure.\n"); } void usage_symlink() { fprintf(outfp, "symlink [path1] [path2]: Make a symbolic link from path1 to path2. Returns\n"); fprintf(outfp, " : 0 on success, -1 on failure\n"); } void usage_unlink() { fprintf(outfp, "unlink [path]: Unlink path. If path is the last name to a file, the file is \n"); fprintf(outfp, " : is removed. If it was a symbolic link, the link is removed. \n"); fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); } void usage_ioctl() { fprintf(outfp, "ioctl [fd] [cmd] <args> : Issue the ioctl command cmd on the file with file\n"); fprintf(outfp, " : descriptor fd. Any arguments are placed in args\n"); fprintf(outfp, " : At the moment, the only commands understand are the \n"); fprintf(outfp, " : ioctl commands found in /usr/include/linux/fs.h\n"); } void usage_umask() { fprintf(outfp, "ioctl [mask] : Sets the umask used by open to set initial file permissions on\n"); fprintf(outfp, " : a newly created file. Returnds the previous value of the mask\n"); } void usage_iodone() { fprintf(outfp, "iodone [ioid] : Poll for completion of the asynchronous request identifed by\n"); fprintf(outfp, " : ioid. Returns 1 if request finished\n"); } void usage_iowait() { fprintf(outfp, "iowait [ioid] : Wait for completion of the asynchronous request identifed by\n"); fprintf(outfp, " : ioid. Returns result of asynchronous request \n"); } void usage_ipreadv() { fprintf(outfp, "ipreadv [fd] [buf] [count] [off]: Reads data asynchrously to file descriptor fd \n"); fprintf(outfp, " : starting at offset off. Data comes from \n"); fprintf(outfp, " : buffer described by buf, which is a pointer to\n"); fprintf(outfp, " : an iovec strucutre. Number of buffers is \n"); fprintf(outfp, " : specified by count. Returns an iod_t on \n"); fprintf(outfp, " : success and -1 on failure\n"); } void usage_ipread() { fprintf(outfp, "ipread [fd] [buf] [count] [off]: Read asynchrously up to count bytes from file\n"); fprintf(outfp, " : with file descriptor fd starting at offset off\n"); fprintf(outfp, " : Read into buffer pointed at by buf. Returns\n"); fprintf(outfp, " : an iod_t on success and -1 on failure\n"); } void usage_preadv() { fprintf(outfp, "preadv [fd] [buf] [count] [off]: Reads data from file descriptor fd starting at\n"); fprintf(outfp, " : offset off. Data goes into buffer described\n"); fprintf(outfp, " : by buf, which is a pointer to an iovec \n"); fprintf(outfp, " : structure. Number of buffers is specified by\n"); fprintf(outfp, " : count. Returns the number of bytes read\n"); } void usage_pread() { fprintf(outfp, "preadv [fd] [buf] [count] [off]: Reads count bytes of data from file descriptor\n"); fprintf(outfp, " : fd starting at offset off. Data goes into buf.\n"); fprintf(outfp, " : Returns number of bytes read or -1 on failure\n"); } void usage_ireadv() { fprintf(outfp, "ireadv [fd] [buf] [count] : Reads data asynchrously to file descriptor fd \n"); fprintf(outfp, " : Data comes from buffer described by buf, which is \n"); fprintf(outfp, " : an pointer to an iovec structure. Number of\n"); fprintf(outfp, " : buffers is specified by count. Returns an iod_t\n"); fprintf(outfp, " : on success and -1 on failure\n"); } void usage_iread() { fprintf(outfp, "iread [fd] [buf] [count]: Read asynchrously up to count bytes from file with\n"); fprintf(outfp, " : file descriptor fd into buffer pointed at by buf\n"); fprintf(outfp, " : Returns an iod_t on success and -1 on failure\n"); } void usage_readv() { fprintf(outfp, "readv [fd] [buf] [count] : Reads data from file descriptor fd. Data comes from\n"); fprintf(outfp, " : the buffer described by buf, which is a pointer to an\n"); fprintf(outfp, " : an iovec structure. Number of buffers is specified\n"); fprintf(outfp, " : by count. Returns the number of bytes read on \n"); fprintf(outfp, " : on success and -1 on failure\n"); } void usage_read() { fprintf(outfp, "read [fd] [buf] [count]: Read up to count bytes from file with file \n"); fprintf(outfp, " : descriptor fd into buffer pointed at by buf\n"); fprintf(outfp, " : Returns number of bytes read on success or 0 on \n"); fprintf(outfp, " : on failure\n"); } void usage_ipwritev() { fprintf(outfp, "ipwritev [fd] [buf] [count] [off]: writes data asynchronously to file with file\n"); fprintf(outfp, " : descriptor fd starting at offset off. Data \n"); fprintf(outfp, " : comes from buffers described by buf, which\n"); fprintf(outfp, " : is a pointer to an iovec structure. Number \n"); fprintf(outfp, " : of buffers is specified by count. Returns\n"); fprintf(outfp, " : an iod_t on success and -1 on failure\n"); } void usage_ipwrite() { fprintf(outfp, "ipwrite [fd] [buf] [count] [off]: writes count bytes of data asynchronously to\n"); fprintf(outfp, " : file with file descriptor fd starting at \n"); fprintf(outfp, " : offset off. Data comes from buf. Returns an\n"); fprintf(outfp, " : iod_t on success and -1 on failure\n"); } void usage_pwritev() { fprintf(outfp, "pwritev [fd] [buf] [count] [off]: writes data to file with file descriptor fd\n"); fprintf(outfp, " : starting at offset off. Data comes from \n"); fprintf(outfp, " : buffers described by buf, which is a pointer\n"); fprintf(outfp, " : to an iovec structure. Number of buffers is\n"); fprintf(outfp, " : by count. Returns number of bytes read on \n"); fprintf(outfp, " : success and -1 on failure\n"); } void usage_pwrite() { fprintf(outfp, "pwrite [fd] [buf] [count] [off]: writes count bytes of data to file with file \n"); fprintf(outfp, " : descriptor fd starting at offset off. Data\n"); fprintf(outfp, " : Data comes from buf. Returns number of bytes\n"); fprintf(outfp, " : written on success and -1 on failure\n"); } void usage_iwritev() { fprintf(outfp, "iwritev [fd] [buf] [count] : writes data asynchronously to file with file\n"); fprintf(outfp, " : descriptor fd. Data comes from buffers described\n"); fprintf(outfp, " : by buf, which is a pointer to an iovec structure.\n"); fprintf(outfp, " : Number of buffers is specified by count. Returns\n"); fprintf(outfp, " : an iod_t on success and -1 on failure\n"); } void usage_iwrite() { fprintf(outfp, "iwrite [fd] [buf] [count] : writes count bytes of data asynchronously to\n"); fprintf(outfp, " : file with file descriptor fd. Data comes from buf.\n"); fprintf(outfp, " : Returns an iod_t on success and -1 on failure.\n"); } void usage_writev() { fprintf(outfp, "writev [fd] [buf] [count]: writes data to file descriptor fd. Data comes from\n"); fprintf(outfp, " : buffers described by buf, which is a pointer to a \n"); fprintf(outfp, " : iovec strucutre. Number of buffers is specified by \n"); fprintf(outfp, " : count \n"); } void usage_write() { fprintf(outfp, "write [fd] [buf] [count] : writes count bytes of data to file with file \n"); fprintf(outfp, " : descriptor fd. Data comes from buf. Returns number\n"); fprintf(outfp, " : of bytes written on success and -1 on failure.\n"); } void usage_mknod() { fprintf(outfp, "mknod [path] [mode] [dev] : creates a filesystem node named path with \n"); fprintf(outfp, " : specified mode using device special file dev\n"); fprintf(outfp, " : Returns 0 on sucess and -1 on failure\n"); } void usage_umount() { fprintf(outfp, "umount [path] : Umount file at path. Returns 0 on success and -1 on failure\n"); } void usage_exit() { } --- NEW FILE --- #!/usr/bin/perl -w # # Provides a set of helper routines for use in the Perl # test scripts # package helper; use strict; use Fcntl ':mode'; BEGIN{} # Print out a given error message, close the command file # and exit sub print_and_exit { my ($cmdfh, $outfh, $exit_num, $exit_str) = @_; print STDOUT "$exit_str"; # Clean up my $cmdstr = 'FREE $buf'; $cmdstr = $cmdstr."\n"; print $cmdfh $cmdstr; my $res = <$outfh>; chop($res); if ($res ne "0000 ") { print STDOUT "ERROR! Failed to free buf (code $res)\n"; } print $cmdfh "exit\n"; close $outfh; # Give test_driver time to finish sleep 0.000001; exit $exit_num; } # Output the given command and make sure that the exit # code for the command was valid sub send_cmd { my ($cmdfh, $outfh, $cmd, $cmdstr) = @_; print $cmdfh $cmdstr; my $res = <$outfh>; chop($res); if ($res ne "0000 ") { print_and_exit($cmdfh, $outfh, 1, "ERROR! Command $cmd failed with code $res\n"); } } # Check the return value from the last libsysio call sub verify_cmd { my ($cmdfh, $outfh, $cmd) = @_; # Verify the system call's output my $cmdstr = 'PRINT $$'; $cmdstr .= "\n"; send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); my $res = <$outfh>; chop($res); if ($res eq "0xffffffff") { # Get the errno $cmdstr = 'PRINT $errno'; $cmdstr .= "\n"; send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); my $err = <$outfh>; chop($err); print_and_exit($cmdfh, $outfh, 1, "ERROR! $cmd returned $err\n"); } return $res; } # Compares two numbers. Output error message and exit if # they differ sub cmp_nums { my ($cmdfh, $outfh, $ionum, $pnum, $desc) = @_; my $str; if (!defined($ionum)) { print_and_exit($cmdfh, $outfh, 1, "ERROR! ionum for $desc undefined"); } elsif (!defined($pnum)) { print_and_exit($cmdfh, $outfh, 1, "ERROR! pnum for $desc undefined"); } if ($ionum != $pnum) { my $str = sprintf("ERROR! Sysio's number %x does not match Perl's (%x)\n", $ionum, $pnum); $str = sprintf("%s Numbers were %s\n", $str, $desc); print_and_exit($cmdfh, $outfh, 1, $str); } } sub get_type { my $mode = $_[0]; my $t = '?'; if (S_ISDIR($mode)) { $t = 'd'; } elsif (S_ISCHR($mode)) { $t = 'c'; } elsif (S_ISBLK($mode)) { $t = 'b'; } elsif (S_ISREG($mode)) { $t = 'f'; } elsif (S_ISFIFO($mode)) { $t = 'p'; } elsif (S_ISLNK($mode)) { $t = 'S'; } elsif (S_ISSOCK($mode)) { $t = 's'; } return $t; } END{} 1; --- NEW FILE --- #!/usr/bin/perl -w use IPC::Open2; use strict; use helper; sub usage { print "Usage: ./populator.pl <-seed seed> :\n"; print " <-file filename> :\n"; print " <-bytes bytes> : Create a file, filename, that\n"; print " : is bytes long and populate with\n"; print " : random numbers using the given\n"; print " : seed. Will use defaults if args\n"; print " : not given\n"; exit(-1); } sub get_buf { my $MAX_SIZE = 2147483648; my $str; my $num; my $len = 0; while ($len < 512) { $num = rand $MAX_SIZE; my $tmpstr = sprintf("%d", $num); $str .= $tmpstr; $len += length $tmpstr; } return ($len, $str); } sub write_file { my ($cmdfh, $outfh, $filename, $bytes) = @_; # Allocate the read buffer my $cmd = '$buf = ALLOC 1024'."\n"; helper::send_cmd($cmdfh, $outfh, "alloc", $cmd); # Open (create) the new file $cmd = '$fd = CALL open '."$filename O_RDWR|O_CREAT S_IRWXU\n"; helper::send_cmd($cmdfh, $outfh, "open", $cmd); # Verify the system call's output helper::verify_cmd($cmdfh, $outfh, "open"); my $left_bytes = $bytes; while ($left_bytes > 0) { # Get a buffer filled with random numbers # Buffer will be no less than 512 bytes my ($len, $buf) = get_buf; if ($len > $left_bytes) { $len = $left_bytes; } # Need to fill $buf with the buffer $cmd = "CALL fill $buf STR $len 0 ".'$buf'."\n"; helper::send_cmd($cmdfh, $outfh, "fill", $cmd); # Write out $len bytes to $filename $cmd = 'CALL write $fd $buf '."$len\n"; helper::send_cmd($cmdfh, $outfh, "write", $cmd); my $written_bytes = helper::verify_cmd($cmdfh, $outfh, "write"); $written_bytes = oct($written_bytes); if ($written_bytes != $len) { helper::print_and_exit($cmdfh, $outfh, 1, "ERROR! Meant to print out $len but only printed $written_bytes\n"); } $left_bytes -= $len; } } sub populate_file { my ($filename, $bytes, $is_alpha) = @_; eval { if ($is_alpha == 0) { open2(\*OUTFILE, \*CMDFILE, "./test_driver --np"); } else { open2(\*OUTFILE, \*CMDFILE, "yod -batch -quiet -sz 1 ./test_driver --np"); } }; if ($@) { if ($@ =~ /^open2/) { warn "open2 failed: $!\n$@\n"; return; } die; } my $outfh = \*OUTFILE; my $cmdfh = \*CMDFILE; if ($is_alpha == 0) { helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); } # Now write the file write_file($cmdfh, $outfh, $filename, $bytes); # Close the file my $cmd = 'CALL close $fd'."\n"; helper::send_cmd($cmdfh, $outfh, "close", $cmd); helper::verify_cmd($cmdfh, $outfh, "close"); # All done helper::print_and_exit($cmdfh, $outfh, 0, "File $filename successfully created\n"); } my $is_alpha = 0; my $seed = time; my $filename = "randfile.$seed.$$"; my $bytes = 1024; for (my $i = 0; $i < @ARGV; $i++) { if ($ARGV[$i] eq "-file") { $i++; $filename = $ARGV[$i]; } elsif ($ARGV[$i] eq "-seed") { $i++; $seed = $ARGV[$i]; } elsif ($ARGV[$i] eq "-alpha") { $is_alpha = 1; } elsif ($ARGV[$i] eq "-bytes") { $i++; $bytes = $ARGV[$i]; } } # seed the randome number generator srand $seed; populate_file($filename, $bytes, $is_alpha); exit $seed; --- NEW FILE --- #define _BSD_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <sys/uio.h> #include <linux/fs.h> #include <sys/stat.h> #include <sys/statvfs.h> #include "test_driver.h" #include "sysio.h" /* * ################################################ * # Function stubs # [...2189 lines suppressed...] int do_umount(int argc, char **argv) { int err; if (argc != 1) { DBG(2, fprintf(outfp, "Invalid number (%d) of args for umount\n", argc)); return INVALID_ARGS; } err = umount(argv[0]); if (err) my_perror("umount"); my_errno = errno; last_ret_val = err; last_type = SINT; return SUCCESS; } --- NEW FILE --- #define _BSD_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <getopt.h> #include <errno.h> #include <ctype.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/statvfs.h> #include <fcntl.h> #include <sys/queue.h> #include <dirent.h> #include <pwd.h> #include <grp.h> #include "sysio.h" #include "mount.h" #include "test.h" #include "test_driver.h" /* * ################################################### * # Test functions # * # These functions are used to test libsysio. # * # Eventually, there should be one of these for # * # every function document in sysio.h # * ################################################### */ int initilize_sysio(char *root_driver, char *root_path, int mntflgs) { int err; char *wd; /* * Init sysio lib. */ _sysio_init(); /* * Init native file system driver and request mount of specified * source directory. */ err = drv_init_all(); if (err) { my_errno = err; my_perror("drv_init_all"); last_ret_val = errno; return SUCCESS; } err = _sysio_mount_root(root_path, root_driver, mntflgs, NULL); if (err) { my_errno = errno; my_perror("_sysio_mount_root"); perror("_sysio_mount_root"); last_ret_val = err; return SUCCESS; } /* * Attempt to set the cwd by getting it out of the * user's environment. If that does not work, set * it to / */ wd = getenv("PWD"); if (wd == NULL) { wd = malloc(5); strcpy(wd, "/"); } if (chdir(wd) != 0) { my_perror(wd); my_errno = errno; last_ret_val = errno; return SUCCESS; } DBG(3, sprintf(output, "Your current working directory is %s\n", wd)); last_ret_val = 0; return SUCCESS; } int sysio_list(char *path) { int fd; size_t n; struct dirent *buf, *dp; __off_t base; ssize_t cc; int numfiles = 0; fd = open(path, O_RDONLY); if (fd < 0) { my_errno = errno; last_ret_val = fd; my_perror(path); return SUCCESS; } n = 16 * 1024; buf = malloc(n); if (!buf) { my_perror(path); cc = -1; goto out; } base = 0; DBG(5, sprintf(output, "About to call getdirentries\n")); while ((cc = getdirentries(fd, (char *)buf, n, &base)) > 0) { dp = buf; while (cc > 0) { DBG(4, fprintf(outfp, "\t%s: ino %#08x off %#08x type %#08x\n", dp->d_name, (unsigned int)dp->d_ino, (unsigned int)dp->d_off, (int )dp->d_type)); sprintf(output, "%s\n", dp->d_name); cc -= dp->d_reclen; dp = (void *)dp + dp->d_reclen; numfiles++; } printf("Out of inner loop\n"); if (!base) break; } out: if (cc < 0) { DBG(2, sprintf(output, "cc barfed\n")); my_perror(path); } free(buf); { int oerrno = errno; if (close(fd) != 0) { DBG(2,sprintf(output, "close barfed\n")); my_perror(path); if (cc < 0) errno = oerrno; else cc = -1; } } last_ret_val = numfiles; my_errno = errno; return SUCCESS; } int sysio_mount(char *from, char *to) { int err; char *s; char *buf; char *cp; char *fstype, *source, *opts, *target; err = 0; /* * Copy everything to a buffer we can modify. */ s = buf = malloc(strlen(from) + 1); if (!buf) { my_perror(from); last_ret_val = -1; my_errno = errno; return SUCCESS; } (void )strcpy(s, from); /* * Eat leading white. */ while (*s && *s == ' ' && *s == '\t') s++; /* * Get fstype. */ fstype = cp = s; while (*cp && *cp != ':' && *cp != ' ' && *cp != '\t') cp++; if (fstype == cp || *cp != ':') { DBG(1, sprintf(output, "%s: Missing FS type\n", from)); err = -1; goto out; } *cp++ = '\0'; s = cp; /* * Eat leading white. */ while (*s && *s == ' ' && *s == '\t') s++; /* * Get source. */ source = cp = s; while (*cp && *cp != ' ' && *cp != '\t') cp++; if (source == cp) { DBG(1, sprintf(output, "%s: Missing source\n", from)); err = -1; goto out; } if (*cp) *cp++ = '\0'; s = to; /* * Eat leading white. */ while (*s && *s == ' ' && *s == '\t') s++; /* * Get opts. */ opts = cp = s; while (*cp && *cp != ' ' && *cp != '\t') cp++; if (opts == cp) { DBG(1,sprintf(output, "%s: Missing target\n", to)); err = -1; goto out; } if (*cp) *cp++ = '\0'; s = cp; /* * Eat leading white. */ while (*s && *s == ' ' && *s == '\t') s++; /* * Get target */ target = cp = s; while (*cp && *cp != ' ' && *cp != '\t') cp++; if (target == cp) { target = opts; opts = NULL; } if (*cp) *cp++ = '\0'; err = mount(source, target, fstype, 0, opts); if (err) my_perror(from); out: free(buf); last_ret_val = err; my_errno = errno; return SUCCESS; } int sysio_chdir(char *newdir) { char *buf; if (chdir(newdir) != 0) { my_perror(newdir); return -1; } /* buf = getcwd(NULL, 0); if (!buf) { my_perror(newdir); last_ret_val = -1; my_errno = errno; return SUCCESS; } DBG(4, sprintf(output, "New dir is %s\n", buf)); free(buf); */ return SUCCESS; } static mode_t get_mode(char *arg, int type, int start_mode); #define SYMBOLIC 0 #define DEFINED 1 #define NUMERIC 2 /* * Change the permissions on a given file * * sysio_chmod <filename> <permissions> * */ int sysio_chmod(char *mode_arg, const char *path) { int err; mode_t mode; struct stat st; /* Get the current mode */ err = stat(path, &st); /* Is the new mode symbolic? */ if (isalpha(mode_arg[0])) { /* Could be specifying defines */ if (mode_arg[0] == 'S') mode = get_mode(mode_arg, DEFINED, st.st_mode); else mode = get_mode(mode_arg, SYMBOLIC, st.st_mode); } else mode = get_mode(mode_arg, NUMERIC, st.st_mode); DBG(3,sprintf(output, "Using a mode of %o and a file of %s\n", mode, path)); if (mode == 0) { DBG(2,sprintf(output, "Invalid mode\n")); return INVALID_ARGS; } last_ret_val = chmod(path, mode); my_errno = errno; return SUCCESS; } #define USER_STATE 0 /* Specifies that the users are still being listed */ #define MODE_STATE_ADD 1 #define MODE_STATE_REMOVE 2 #define READ 00444 #define WRITE 00222 #define EXECUTE 00111 #define OWNER 00700 #define GROUP 00070 #define OTHER 00007 mode_t get_mode(char *arg, int type, int start_mode) { int i, j,digit, total; char c; int state = USER_STATE; int len = strlen(arg); unsigned int users = 0; unsigned int modes = 0; if (type == DEFINED) { char curr_word[10]; total = digit = 0; j = 0; DBG(4, sprintf(output, "len is %d\n", len)); for (i=0; i < len; i++) { if (arg[i] == '|') { curr_word[j] = '\0'; DBG(3, sprintf(output, "Got mode word %s\n", curr_word)); digit = get_obj(curr_word); if (digit < 0 ) { DBG(2, sprintf(output, "Unable to understand mode arg %s\n", curr_word)); return -1; } total |= digit; j = 0; } else curr_word[j++] = arg[i]; } curr_word[j] = '\0'; DBG(3, sprintf(output, "Got mode word %s\n", curr_word)); digit = get_obj(curr_word); if (digit < 0 ) { DBG(3, sprintf(output, "Unable to understand mode arg %s\n", curr_word)); return -1; } total |= digit; return total; } if (type == SYMBOLIC) { for (i=0; i < len; i++) { c = arg[i]; if (state == USER_STATE) { switch(c){ case 'u': users |= OWNER; break; case 'g': users |= GROUP; break; case 'o': users |= OTHER; break; case 'a': users |= (OWNER|GROUP|OTHER); break; case '+': state = MODE_STATE_ADD; break; case '-': state = MODE_STATE_REMOVE; break; default: return 0; } } else { switch(c){ case 'r': modes |= READ; break; case 'w': modes |= WRITE; break; case 'x': modes |= EXECUTE; break; default: return 0; } } } if (state == MODE_STATE_ADD) { return (start_mode | (users & modes)); } else { return (start_mode & ~(users & modes)); } } else { /* Digits should be octal digits, so should convert */ total = 0; for (i=0; i < len; i++) { c = arg[i]; digit = atoi(&c); if (digit > 7) return 0; for (j=len-i-1; j >0; j--) digit *= 8; total += digit; } return total; } } /* * Changes the ownership of the file. The new_id * is of the format owner:group. Either the owner * or the group may be omitted, but, in order to * change the group, the : must preced the group. */ int sysio_chown(char *new_id, char *file) { char *owner = NULL; char *group = NULL; struct group *g_ent = NULL; struct passwd *o_ent = NULL; uid_t o_id=-1, g_id=-1; int len, j, i=0; int state = 0; /* Correspond to getting owner name */ len = strlen(new_id); for (i=0; i < len; i++) { if (new_id[i] == ':') { /* Group name */ if (!group) group = malloc(strlen(new_id) -i +2); state = 1; /* Now getting group name */ j = 0; if (owner) owner[i] = '\0'; } if (!state) { /* Getting owner name */ if (!owner) owner = malloc(strlen(new_id) +1 ); owner[i] = new_id[i]; } else { /* Group name */ group[j] = new_id[i]; j++; } } if (group) group[i] = '\0'; else owner[i] = '\0'; /* Are the owner and/or group symbolic or numeric? */ if (owner) { if (isdigit(owner[0])) { /* Numeric -- just convert */ o_id = (uid_t) atoi(owner); /* Make sure it is valid */ if ((o_ent = getpwuid(o_id)) == NULL) { DBG(2, sprintf(output, "Error: uid %d not found \n", o_id)); return INVALID_ARGS; } } else { /* Get the id from the passwd file */ if ((o_ent = getpwnam(owner)) == NULL) { DBG(2, sprintf(output, "Error: name %s not found\n", owner)); return INVALID_ARGS; } o_id = o_ent->pw_uid; } } if (group) { if (isdigit(group[0])) { /* Numeric -- just convert */ g_id = (uid_t) atoi(group); /* Make sure it is valid */ if ((g_ent = getgrgid(g_id)) == NULL) { DBG(2, sprintf(output, "Error: gid %d not found \n", g_id)); return INVALID_ARGS; } } else { /* Find group in group file */ if ((g_ent = getgrnam(group)) == NULL) { DBG(2, sprintf(output, "Error: group %s not found \n", group)); return INVALID_ARGS; } g_id = g_ent->gr_gid; } } /* Now issue the syscall */ DBG(4, sprintf(output, "Changing owner of file %s to %d (group %d)\n", file, o_id, g_id)); last_ret_val = chown(file, o_id, g_id); my_errno = errno; return SUCCESS; } int sysio_open(char *path, int flags) { DBG(4, sprintf(output, "Opening file %s with flags %x\n", path, flags)); last_ret_val = open(path, flags); my_errno = errno; return SUCCESS; } int sysio_open3(char *path, int flags, char *mode_arg) { mode_t mode; /* Is the new mode symbolic? */ if (isalpha(mode_arg[0])) { /* Could be specifying defines */ if (mode_arg[0] == 'S') mode = get_mode(mode_arg, DEFINED, 0); else mode = get_mode(mode_arg, SYMBOLIC, 0); } else mode = get_mode(mode_arg, NUMERIC, 0); last_ret_val = open(path, flags, mode); my_errno = errno; return SUCCESS; } int sysio_close(int fd) { last_ret_val = close(fd); my_errno = errno; return SUCCESS; } int sysio_fcntl(int fd, struct cmd_map* cmdptr, char *arg) { int fd_new, index, cmd, flag; char *cmdname; void *buf; cmd = cmdptr->cmd; cmdname = cmdptr->cmd_name; switch(cmd) { case F_DUPFD: fd_new = get_obj(arg); last_ret_val = fcntl(fd, F_DUPFD, fd_new); my_errno = errno; return SUCCESS; break; case F_GETFD: case F_GETFL: case F_GETOWN: /* case F_GETSIG: case F_GETLEASE: */ last_ret_val= fcntl(fd, cmd); my_errno = errno; return SUCCESS; break; case F_SETFD: case F_SETFL: case F_SETOWN: /*case F_SETSIG: case F_SETLEASE: case F_NOTIFY: */ flag = atoi(arg); last_ret_val = fcntl(fd, cmd, flag); my_errno = errno; return SUCCESS; break; case F_SETLK: case F_SETLKW: case F_GETLK: /* Get the buffer to hold the lock structure */ index = get_obj(arg); if (index < 0) { sprintf(output, "Unable to find buffer %s\n", arg+1); return INVALID_VAR; } buf = buflist[index]; if (!buf) { sprintf(output, "Buffer at index %d (mapped by %s) is null\n", index, arg); return INVALID_VAR; } last_ret_val = fcntl(fd, cmd, (struct flock *)buf); my_errno = errno; return SUCCESS; default: /* THis should be impossible */ return INVALID_ARGS; } return INVALID_ARGS; } void print_stat(struct stat *st) { DBG(3, sprintf(output, "%sstruct stat: \n", output)); DBG(3, sprintf(output, "%s st_dev: %#16x\n", output, (unsigned int)st->st_dev)); DBG(3, sprintf(output, "%s st_ino: %#16x\n", output, (unsigned int) st->st_ino)); DBG(3, sprintf(output, "%s st_mode: %#16x\n", output, st->st_mode)); DBG(3, sprintf(output, "%s st_nlink: %#16x\n", output, st->st_nlink)); DBG(3, sprintf(output, "%s st_uid: %#16x\n", output, st->st_uid)); DBG(3, sprintf(output, "%s st_gid: %#16x\n", output, st->st_gid)); DBG(3, sprintf(output, "%s st_rdev: %#16x\n", output, (int)st->st_rdev)); DBG(3, sprintf(output, "%s st_size: %#16x\n", output, (int) st->st_size)); DBG(3, sprintf(output, "%s st_blksize: %#16x\n", output, (int) st->st_blksize)); DBG(3, sprintf(output, "%s st_blocks: %#16x\n", output, (int) st->st_blocks)); DBG(3, sprintf(output, "%s st_atime: %#16x\n", output, (unsigned int) st->st_atime)); DBG(3, sprintf(output, "%s st_mtime: %#16x\n", output, (unsigned int) st->st_mtime)); DBG(3, sprintf(output, "%s st_ctime: %#16x", output, (unsigned int) st->st_ctime)); } int sysio_fstat(int fd, void *buf) { int err; struct stat *st = (struct stat *)buf; err = fstat(fd, st); if (err < 0) { my_perror("fstat"); } my_errno = errno; last_ret_val = err; print_stat(st); return SUCCESS; } int sysio_lstat(char *filename, void *buf) { int err; struct stat *st = (struct stat *)buf; err = lstat(filename, st); if (err < 0) { my_perror("lstat"); } my_errno = errno; last_ret_val = err; print_stat(st); return SUCCESS; } int sysio_stat(char *filename, void *buf) { int err; struct stat *st = (struct stat *)buf; err = stat(filename, st); if (err < 0) { my_perror("stat"); } my_errno = errno; last_ret_val = err; print_stat(st); return SUCCESS; } int sysio_getdirentries(int fd, char *buf, size_t nbytes, off_t *basep) { int err; struct dirent *dp; err = getdirentries(fd, buf, nbytes, basep); last_ret_val = err; DBG(4, sprintf(output, "%sRead %d bytes\n", output, err)); dp = (struct dirent *)buf; while (err > 0) { DBG(3, sprintf(output, "%s\t%s: ino %llu off %llu len %x type %c\n", output, dp->d_name, (unsigned long long )dp->d_ino, (unsigned long long )dp->d_off, dp->d_reclen, (char )dp->d_type)); DBG(3, fprintf(outfp, "\t%s: ino %x off %x len %x type %x\n", dp->d_name, (unsigned long long )dp->d_ino, (unsigned long long )dp->d_off, dp->d_reclen, (char )dp->d_type)); err -= dp->d_reclen; dp = (void *)dp + dp->d_reclen; } my_errno = errno; return last_ret_val; } int sysio_mkdir(char *path, char *mode_arg) { int err; mode_t mode; struct stat st; /* Is the new mode symbolic? */ if (isalpha(mode_arg[0])) { /* Could be specifying defines */ if (mode_arg[0] == 'S') mode = get_mode(mode_arg, DEFINED, st.st_mode); else mode = get_mode(mode_arg, SYMBOLIC, st.st_mode); } else mode = get_mode(mode_arg, NUMERIC, st.st_mode); DBG(3, sprintf(output, "Using a mode of %o and a file of %s\n", mode, path)); if (mode == 0) { DBG(2, sprintf(output, "Invalid mode\n")); return INVALID_ARGS; } err = mkdir(path, mode); my_errno = errno; last_ret_val = err; return SUCCESS; } int sysio_creat(char *path, char *mode_arg) { mode_t mode; int err; /* Is the new mode symbolic? */ if (isalpha(mode_arg[0])) { /* Could be specifying defines */ if (mode_arg[0] == 'S') mode = get_mode(mode_arg, DEFINED, 0); else mode = get_mode(mode_arg, SYMBOLIC, 0); } else mode = get_mode(mode_arg, NUMERIC, 0); DBG(3, sprintf(output, "Using a mode of %o and a file of %s\n", mode, path)); if (mode == 0) { DBG(2, sprintf(output, "Invalid mode\n")); return INVALID_ARGS; } err = creat(path, mode); my_errno = errno; last_ret_val = err; return SUCCESS; } void print_statvfs(struct statvfs *st) { DBG(3, sprintf(output, "%sstruct statvfs: \n", output)); DBG(3, sprintf(output, "%s f_bsize: %x\n", output, (unsigned int) st->f_bsize)); DBG(3, sprintf(output, "%s f_frsize: %x\n", output, (unsigned int) st->f_frsize)); DBG(3, sprintf(output, "%s f_blocks: %x\n", output, (unsigned int) st->f_blocks)); DBG(3, sprintf(output, "%s f_bfree: %x\n", output, (unsigned int) st->f_bfree)); DBG(3, sprintf(output, "%s f_bavail: %x\n", output, (unsigned int) st->f_bavail)); DBG(3, sprintf(output, "%s f_files: %x\n", output, (unsigned int) st->f_files)); DBG(3, sprintf(output, "%s f_ffree: %x\n", output, (unsigned int) st->f_ffree)); DBG(3, sprintf(output, "%s f_favail: %x\n", output, (unsigned int) st->f_favail)); DBG(3, sprintf(output, "%s f_files: %x\n", output, (unsigned int) st->f_files)); DBG(3, sprintf(output, "%s f_fsid: %x\n", output, (unsigned int) st->f_fsid)); DBG(3, sprintf(output, "%s f_flag: %x\n", output, (unsigned int) st->f_flag)); DBG(3, sprintf(output, "%s f_fnamemax: %x\n", output, (unsigned int) st->f_namemax)); } int sysio_statvfs(char *filename, void *buf) { int err; struct statvfs *st = (struct statvfs *)buf; err = statvfs(filename, st); if ( err == -1) { my_perror("statvfs"); } my_errno = errno; last_ret_val = err; print_statvfs(st); return SUCCESS; } int sysio_fstatvfs(int fd, void *buf) { int err; struct statvfs *st = (struct statvfs *)buf; err = fstatvfs(fd, st); if (err == -1) { my_perror("fstatvfs"); } my_errno = errno; last_ret_val = err; print_statvfs(st); return SUCCESS; } int sysio_umask(char *mode_arg) { mode_t mode; /* Is the new mode symbolic? */ if (isalpha(mode_arg[0])) { /* Could be specifying defines */ if (mode_arg[0] == 'S') mode = get_mode(mode_arg, DEFINED, 0); else mode = get_mode(mode_arg, SYMBOLIC, 0); } else mode = get_mode(mode_arg, NUMERIC, 0); last_ret_val = umask(mode); my_errno = errno; return SUCCESS; } int sysio_mknod(char *path, char *mode_arg, dev_t dev) { int err; int mode; mode = get_obj(mode_arg); if (mode < 0) { DBG(2,sprintf(output, "Cant get mode from %s\n", mode_arg)); fprintf(stderr, "Cant get mode from %s\n", mode_arg); return INVALID_VAR; } err = mknod(path, (mode_t) mode, dev); if (err < 0) my_perror("mknod"); last_ret_val = err; my_errno = errno; return SUCCESS; } --- NEW FILE --- #!/usr/bin/perl -w # # VERY basic functionality test for sysio. To run, just type ./test_all.pl # Absolutely no guarantees for running on alpha/cplant # use strict; my $alpha_arg = ""; my $is_broke = 1; # Don't test certain areas known to not work on Cplant if ((@ARGV > 0) && ($ARGV[0] eq "-alpha")) { $alpha_arg = "-alpha"; } else { my $alpha_env = $ENV{"IS_ALPHA"}; # If there is no command line arg, check the environment vars if ($alpha_env eq "yes") { $alpha_arg = "-alpha"; } } # Will use this directory... system("mkdir -p ./tmp_dir"); my $failures = 0; my $success = 0; # Get cwd.. my $cwd = $ENV{PWD}; # Get the sysio dir my $sysdir = $cwd; $sysdir =~ s/\/\w+$//; my $res; if (($alpha_arg eq "") || ($is_broke == 0)) { # Test getdirentries $res = `./test_list.pl $alpha_arg $sysdir`; chop($res); if ($res ne "list test successful") { print "Basic getdirentries test failed with message: $res\n"; $failures++; } else { print "test_list finished successfully\n"; $success++; } } # Test path my @resarr = `./test_path.pl $alpha_arg $sysdir $cwd $cwd/tmp_dir`; $res = $sysdir.": d\n"; if ($resarr[0] ne $res) { print "path test returned $resarr[0] instead of $res\n"; $failures++; } else { $res = $cwd.": d\n"; if ($resarr[1] ne $res) { print "path test returned $resarr[1] instead of $res\n"; $failures++; } else { $res = $cwd."/tmp_dir: d\n"; if ($resarr[2] ne $res) { print "path test returned $resarr[2] instead of $res\n"; $failures++; } else { print "test_path finished successfully\n"; $success++; } } } if (($alpha_arg eq "") || ($is_broke == 0)) { # Test mount $res = `./test_list.pl $alpha_arg -m native:$sysdir $cwd/tmp_dir`; chop($res); if ($res ne "list test successful") { print "Mount test failed with message: $res\n"; $failures++; } else { $success++; print "test_mount finished successfully\n"; } # Test getcwd $res = `./test_getcwd.pl $alpha_arg $sysdir`; chop($res); if ($res ne "getcwd test successful") { print "getcwd test failed with message: $res\n"; $failures++; } else { $success++; print "test_getcwd finished successfully\n"; } } # Test copy $res = `./test_copy.pl $alpha_arg $sysdir/README $cwd/tmp_dir/README`; chop($res); if ($res ne "copy test successful") { print "copy test failed with message: $res\n"; $failures++; } else { $success++; print "test_copy finished successfully\n"; } # Test stats $res = `./test_stats.pl $alpha_arg $cwd/tmp_dir/README`; chop($res); if ($res ne "stat test successful") { print "stat test failed with message: $res\n"; $failures++; } else { $success++; print "test_stats finished successfully\n"; } # Test stdfd $res = `./test_stdfd.pl $alpha_arg foo_dir`; chop($res); if ($res ne "test_stdfd successful") { print "stdfd test failed with message: $res\n"; $failures++; } else { $success++; print "test_stdfd finished successfully\n"; } print "$failures tests failed and $success tests succeeded\n"; # cleanup system(`rm -rf tmp_dir`); exit $failures; --- NEW FILE --- #!/usr/bin/perl -w # # copy test: Copy a file from src to dest and verify that the new file # : is the same as the old # use IPC::Open2; use strict; use helper; sub usage { print "Usage: ./test_copy.pl [-alpha] <src> <dest>: Copy a file from src to dest\n"; exit(-1); } sub process_cmd { my ($src, $dest, $is_alpha) = @_; eval { if ($is_alpha == 0) { open2(\*OUTFILE, \*CMDFILE, "./test_driver --np"); } else { open2(\*OUTFILE, \*CMDFILE, "yod -quiet -sz 1 ./test_driver --np"); } }; if ($@) { if ($@ =~ /^open2/) { warn "open2 failed: $!\n$@\n"; return; } die; } my $outfh = \*... [truncated message content] |
From: Lee W. <lw...@us...> - 2003-09-26 21:28:50
|
Update of /cvsroot/libsysio/libsysio/dev/stdfd In directory sc8-pr-cvs1:/tmp/cvs-serv12723/dev/stdfd Modified Files: Tag: RedStorm Makefile.am stdfd.c Log Message: Merged with current head. Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/dev/stdfd/Makefile.am,v retrieving revision 1.2 retrieving revision 1.2.6.1 diff -u -w -b -B -p -r1.2 -r1.2.6.1 --- Makefile.am 24 Mar 2003 22:09:02 -0000 1.2 +++ Makefile.am 26 Sep 2003 21:28:33 -0000 1.2.6.1 @@ -5,3 +5,11 @@ EXTRA_DIST = stdfd.h libsysio_stdfd_a_SOURCES = stdfd.c include $(top_srcdir)/Rules.make + +if WITH_CPLANT_YOD +YOD_DRIVER_FLAGS = -DCPLANT_YOD $(YOD_DRIVER_INCLUDE) +else +YOD_DRIVER_FLAGS = +endif + +AM_CPPFLAGS += $(YOD_DRIVER_FLAGS) Index: stdfd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/dev/stdfd/stdfd.c,v retrieving revision 1.2 retrieving revision 1.2.6.1 diff -u -w -b -B -p -r1.2 -r1.2.6.1 --- stdfd.c 24 Mar 2003 22:09:02 -0000 1.2 +++ stdfd.c 26 Sep 2003 21:28:33 -0000 1.2.6.1 @@ -58,6 +58,16 @@ #include "stdfd.h" +#ifdef CPLANT_YOD +#include <sys/statfs.h> +#include "cplant-yod.h" +#define dowrite(f, b, n) write_yod(f, b, n) +#define doread(f, b, n) read_yod(f, b, n) +#else +#define dowrite(f, b, n) syscall(SYS_write, f, b, n) +#define doread(f, b, n) syscall(SYS_read, f, b, n) +#endif + /* * Pre-opened standard file descriptors driver. */ @@ -120,7 +130,7 @@ doio(ssize_t (*f)(int, char *, size_t), struct ioctx *ioctx; const struct iovec *iov; size_t n; - ssize_t cc; + ssize_t cc = 0; ioctx = _sysio_ioctx_new(ino, ioargs); if (!ioctx) @@ -153,7 +163,7 @@ static ssize_t stdfd_read(int fd, char *buf, size_t nbytes) { - return syscall(SYS_read, fd, buf, nbytes); + return doread(fd, buf, nbytes); } static int @@ -171,7 +181,7 @@ stdfd_write(int fd, size_t nbytes) { - return syscall(SYS_write, fd, buf, nbytes); + return dowrite(fd, buf, nbytes); } static int |
From: Lee W. <lw...@us...> - 2003-09-26 21:28:50
|
Update of /cvsroot/libsysio/libsysio/misc In directory sc8-pr-cvs1:/tmp/cvs-serv12723/misc Modified Files: Tag: RedStorm gdb-libsysio Log Message: Merged with current head. Index: gdb-libsysio =================================================================== RCS file: /cvsroot/libsysio/libsysio/misc/gdb-libsysio,v retrieving revision 1.2 retrieving revision 1.2.12.1 diff -u -w -b -B -p -r1.2 -r1.2.12.1 --- gdb-libsysio 7 Mar 2003 03:31:36 -0000 1.2 +++ gdb-libsysio 26 Sep 2003 21:28:34 -0000 1.2.12.1 @@ -66,21 +66,45 @@ Dump path-base node and it's aliases Usage: x_dump_pbnode <pbnode> end -define x_dump_mounts - set $x_m = mounts.lh_first - while $x_m - printf "MOUNT %p:", $x_m - if $x_m->mnt_root - printf "\n root " - x_dump_pbnode $x_m->mnt_root->p_base - else - printf "\n" - end - if $x_m->mnt_covers - printf " covers " - x_dump_pbnode $x_m->mnt_covers->p_base +define __x_dump_pnode + printf "%spnode %p, mount %p, base: ", $arg0, $arg1, $arg1->p_mount + x_dump_pbnode $arg1->p_base +end + +define x_dump_pnode + __x_dump_pnode "" $arg0 +end +document x_dump_pnode +Dump path node information + +Usage: x_dump_pnode <pnode> +end + +define x_dump_mount + printf "MOUNT %p: root pnode %p, covers %p\n", \ + $arg0, $arg0->mnt_root, $arg0->mnt_covers + set $_x_dump_mount_var_pno = _sysio_pnodes->tqh_first + while $_x_dump_mount_var_pno != 0 +printf "%p, %p\n", $_x_dump_mount_var_pno, $arg0 + if $_x_dump_mount_var_pno->p_mount == $arg0 + __x_dump_pnode " " $_x_dump_mount_var_pno + end + set $_x_dump_mount_var_pno = \ + $_x_dump_mount_var_pno->p_nodes.tqe_next end - set $x_m = $x_m->mnt_link.le_next +end +document x_dump_mount +Dump single mount record information + +Usage: x_dump_mount <mnt> +end + +define x_dump_mounts + set $__x_dump_mounts_var_mnt = mounts.lh_first + while $__x_dump_mounts_var_mnt + x_dump_mount $__x_dump_mounts_var_mnt + set $__x_dump_mounts_var_mnt = \ + $__x_dump_mounts_var_mnt->mnt_link.le_next end end document x_dump_mounts @@ -89,3 +113,15 @@ Dump the contents of the libsysio mount Usage: x_dump_mounts end +define x_dump_pnodes + set $_x_dump_pnodes_var_pno = _sysio_pnodes.tqh_first + while $_x_dump_pnodes_var_pno + x_dump_pnode $_x_dump_pnodes_var_pno + set $_x_dump_pnodes_var_pno = \ + $_x_dump_pnodes_var_pno->p_nodes.tqe_next + end +end + +br _sysio_unmount_all +run -r /tmp/lee foo bar +x_dump_pnodes |
From: Lee W. <lw...@us...> - 2003-09-26 21:28:50
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv12723/src Modified Files: Tag: RedStorm Makefile.am access.c chdir.c fcntl.c file.c inode.c ioctl.c lseek.c mount.c namei.c open.c read.c statvfs.c statvfs64.c write.c Log Message: Merged with current head. Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/Makefile.am,v retrieving revision 1.5.6.3 retrieving revision 1.5.6.4 diff -u -w -b -B -p -r1.5.6.3 -r1.5.6.4 --- Makefile.am 30 Jul 2003 14:00:02 -0000 1.5.6.3 +++ Makefile.am 26 Sep 2003 21:28:34 -0000 1.5.6.4 @@ -3,6 +3,13 @@ lib_LIBRARIES = libsysio.a libsysio_a_SOURCES = chdir.c chmod.c chown.c dev.c dup.c fcntl.c file.c fs.c \ fsync.c getdirentries.c init.c inode.c ioctl.c ioctx.c iowait.c \ lseek.c mkdir.c mknod.c mount.c namei.c open.c read.c rmdir.c stat.c \ - stat64.c symlink.c truncate.c unlink.c write.c access.c + stat64.c statvfs.c symlink.c truncate.c unlink.c write.c access.c include $(top_srcdir)/Rules.make + +if WITH_CPLANT_YOD +YOD_DRIVER_FLAGS = -DCPLANT_YOD +else +YOD_DRIVER_FLAGS = +endif +AM_CPPFLAGS += ${YOD_DRIVER_FLAGS} Index: access.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/access.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -w -b -B -p -r1.1.2.1 -r1.1.2.2 --- access.c 29 Jul 2003 20:17:22 -0000 1.1.2.1 +++ access.c 26 Sep 2003 21:28:34 -0000 1.1.2.2 @@ -52,10 +52,9 @@ access(const char *path, int amode) { gid_t *list, *entry; size_t n; - int err; + int err = 0; unsigned mask, mode; struct stat stbuf; - int oerrno; err = 0; @@ -69,7 +68,7 @@ access(const char *path, int amode) } } err = getgroups(n, list); - if (err) + if (err != (int ) n) goto out; err = stat(path, &stbuf); @@ -85,36 +84,27 @@ access(const char *path, int amode) mask |= S_IXUSR; mode = stbuf.st_mode; - if (stbuf.st_uid == getuid() && (mode & mask) != mask) { - err = -1; + if (stbuf.st_uid == getuid() && (mode & mask) == mask) goto out; - } + mask >>= 3; - entry = list; - while (n--) { - if (stbuf.st_gid == *entry++) { - if ((mode & mask) != mask) { - err = -1; + if (stbuf.st_gid == getgid() && (mode & mask) == mask) goto out; - } - break; - } - } - if (stbuf.st_gid == getgid() && (mode & mask) != mask) { - err = -1; + + entry = list; + while (n--) + if (stbuf.st_gid == *entry++ && (mode & mask) == mask) goto out; - } + mask >>= 3; - if ((mode & mask) != mask) { - err = -1; + if ((mode & mask) == mask) goto out; - } + + err = -1; out: - oerrno = errno; if (list) free(list); - errno = oerrno; return err; } Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.3 retrieving revision 1.3.10.1 diff -u -w -b -B -p -r1.3 -r1.3.10.1 --- chdir.c 9 Mar 2003 16:57:47 -0000 1.3 +++ chdir.c 26 Sep 2003 21:28:34 -0000 1.3.10.1 @@ -98,62 +98,6 @@ chdir(const char *path) return 0; } -char * -getwd(char *buf) -{ - size_t len, n; - struct pnode *tmp; - char *cp; - - /* - * First pass: Traverse to the root of the sub-tree, remembering - * lengths. - */ - len = 0; - tmp = _sysio_cwd; - do { - n = tmp->p_base->pb_name.len; - len += tmp->p_base->pb_name.len; - if (n) - len++; - tmp = tmp->p_parent; - /* - * Traverse mount points. - */ - while (tmp->p_mount->mnt_root == tmp && - tmp != tmp->p_mount->mnt_covers) - tmp = tmp->p_mount->mnt_root; - } while (tmp != tmp->p_parent); - if (!len) - len++; - /* - * Fill in the path buffer -- Backwards, since we're starting - * from the end. - */ - cp = buf; - *cp = PATH_SEPARATOR; - cp += len; - *cp = '\0'; /* NUL term */ - tmp = _sysio_cwd; - do { - cp -= tmp->p_base->pb_name.len; - n = tmp->p_base->pb_name.len; - if (n) { - (void )strncpy(cp, tmp->p_base->pb_name.name, n); - *--cp = PATH_SEPARATOR; - } - tmp = tmp->p_parent; - /* - * Traverse mount points. - */ - while (tmp->p_mount->mnt_root == tmp && - tmp != tmp->p_mount->mnt_covers) - tmp = tmp->p_mount->mnt_root; - } while (tmp != tmp->p_parent); - - return buf; -} - /* * Return path tracked by the path ancestor chain. * @@ -178,12 +122,6 @@ _sysio_p_path(struct pnode *pno, char ** n = 0; do { /* - * Traverse back through mounts. - */ - while (pno->p_mount->mnt_root == pno && - pno != pno->p_mount->mnt_covers) - pno = pno->p_mount->mnt_root; - /* * Add length of this component to running sum and * account for this vertex. */ @@ -217,20 +155,13 @@ _sysio_p_path(struct pnode *pno, char ** *cp = '\0'; /* NUL terminate */ do { /* - * Traverse back through mounts. - */ - while (pno->p_mount->mnt_root == pno && - pno != pno->p_mount->mnt_covers) - pno = pno->p_mount->mnt_root; - /* * Add component and separator. */ cp -= pno->p_base->pb_name.len; - if (pno->p_base->pb_name.len) - (void )memcpy(cp--, - pno->p_base->pb_name.name, + (void )memcpy(cp, pno->p_base->pb_name.name, pno->p_base->pb_name.len); - *cp = PATH_SEPARATOR; + + *--cp = PATH_SEPARATOR; pno = pno->p_parent; } while (pno != pno->p_parent); @@ -249,3 +180,23 @@ getcwd(char *buf, size_t size) } return buf; } + +#if defined(__GLIBC__) && defined(ALPHA_LINUX) +char * +__getcwd(char *buf, size_t size) +{ + return getcwd(buf, size); +} +#endif + +#ifdef PATH_MAX +char * +getwd(char *buf) +{ + + if (!buf) + return -EFAULT; + + return getcwd(buf, PATH_MAX); +} +#endif Index: fcntl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -w -b -B -p -r1.3 -r1.3.4.1 --- fcntl.c 4 Apr 2003 20:09:47 -0000 1.3 +++ fcntl.c 26 Sep 2003 21:28:34 -0000 1.3.4.1 @@ -95,3 +95,18 @@ out: } return err; } + +#if defined(__GLIBC__) && defined(ALPHA_LINUX) +int +__fcntl(int fd, int cmd, ...) +{ + int rc; + va_list ap; + + va_start(ap, cmd); + rc = fcntl(fd, cmd, ap); + va_end(ap); + + return rc; +} +#endif Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.4 retrieving revision 1.4.10.1 diff -u -w -b -B -p -r1.4 -r1.4.10.1 --- file.c 9 Mar 2003 17:18:57 -0000 1.4 +++ file.c 26 Sep 2003 21:28:34 -0000 1.4.10.1 @@ -128,7 +128,7 @@ fd_grow(size_t n) if (n < 8) n = 8; - if (n > _sysio_oftab_size && n - _sysio_oftab_size < _sysio_oftab_size) + if (n >= _sysio_oftab_size && n - _sysio_oftab_size < _sysio_oftab_size) n = (n + 1) * 2; noftab = realloc(_sysio_oftab, n * sizeof(struct file *)); if (!noftab) Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.7.4.1 retrieving revision 1.7.4.2 diff -u -w -b -B -p -r1.7.4.1 -r1.7.4.2 --- inode.c 29 Jul 2003 19:05:08 -0000 1.7.4.1 +++ inode.c 26 Sep 2003 21:28:34 -0000 1.7.4.2 @@ -497,43 +497,19 @@ _sysio_p_gone(struct pnode *pno) int _sysio_p_validate(struct pnode *pno, struct intent *intnt, const char *path) { - struct pnode *parent; - int err; struct inode *ino; + struct pnode_base *rootpb; + int err; - err = 0; - + ino = pno->p_base->pb_ino; /* - * Make sure we can use the parent. We don't validate that - * unless we have to. Beware of this! It's assuming the caller - * recently revalidated. Namei will do this for instance. - */ - parent = pno->p_parent; - if (!parent->p_base->pb_ino) { - err = _sysio_p_validate(parent, NULL, NULL); - if (err) { - /* - * I really, really want to smash the association - * of the passed path node with it's i-node. Can't - * do it, though, since at least one FS driver can - * still accomplish IO accesses to the currently - * held i-node. For now, the driver needs to - * record that the i-node has become (semi) invalid - * and return appropriate errors itself. - * - * We *might* be able to do this, now, with the - * recent changes to the open file table. Must check - * on it. It is so annoying to have these half - * dead i-nodes hanging around. + * An invalid pnode will not have an associated inode. We'll use + * the FS root inode, then -- It *must* be valid. */ - return err; - } - } - - ino = pno->p_base->pb_ino; - if (!err) + rootpb = pno->p_mount->mnt_root->p_base; + assert(rootpb->pb_ino); err = - parent->p_base->pb_ino->i_ops.inop_lookup(pno, + rootpb->pb_ino->i_ops.inop_lookup(pno, &ino, intnt, path); @@ -630,6 +606,30 @@ _sysio_p_find_alias(struct pnode *parent } /* + * Prune idle path base nodes freom the passed sub-tree, including the root. + */ +static void +_sysio_prune(struct pnode_base *rpb) +{ + struct pnode_base *nxtpb, *pb; + + nxtpb = rpb->pb_children.lh_first; + while ((pb = nxtpb)) { + nxtpb = pb->pb_sibs.le_next; + if (pb->pb_aliases.lh_first) + continue; + if (pb->pb_children.lh_first) { + _sysio_prune(pb); + continue; + } + _sysio_pb_gone(pb); + } + if (rpb->pb_children.lh_first) + return; + _sysio_pb_gone(rpb); +} + +/* * Prune idle nodes from the passed sub-tree, including the root. * * Returns the number of aliases on the same mount that could not be pruned. @@ -647,6 +647,10 @@ _sysio_p_prune(struct pnode *root) while ((pb = nxtpb)) { nxtpb = pb->pb_sibs.le_next; nxtpno = pb->pb_aliases.lh_first; + if (!nxtpno) { + _sysio_prune(pb); + continue; + } while ((pno = nxtpno)) { nxtpno = pno->p_links.le_next; if (pno->p_mount != root->p_mount) { @@ -688,10 +692,10 @@ _sysio_p_prune(struct pnode *root) if (_sysio_do_unmount(pno->p_mount) != 0) { P_RELE(pno); count++; - continue; } + continue; #endif - } else + } _sysio_p_gone(pno); } } @@ -706,9 +710,9 @@ _sysio_p_prune(struct pnode *root) /* * All that is left is the root. Try for it too. */ - if (root->p_ref) + if (root->p_ref) { count++; - else if (root->p_mount->mnt_root == root) { + } else if (root->p_mount->mnt_root == root) { #ifndef AUTOMOUNT_FILE_NAME count++; #else Index: ioctl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.14.1 diff -u -w -b -B -p -r1.1.1.1 -r1.1.1.1.14.1 --- ioctl.c 22 Feb 2003 16:33:07 -0000 1.1.1.1 +++ ioctl.c 26 Sep 2003 21:28:34 -0000 1.1.1.1.14.1 @@ -75,3 +75,19 @@ out: } return err; } + + +#if defined(__GLIBC__) && defined(ALPHA_LINUX) +int +__ioctl(int fd, unsigned long request, ...) +{ + va_list ap; + int rc; + + va_start(ap, request); + rc = ioctl(fd, request, ap); + va_end(ap); + + return rc; +} +#endif Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.4.4.1 retrieving revision 1.4.4.2 diff -u -w -b -B -p -r1.4.4.1 -r1.4.4.2 --- lseek.c 12 May 2003 11:48:45 -0000 1.4.4.1 +++ lseek.c 26 Sep 2003 21:28:34 -0000 1.4.4.2 @@ -58,7 +58,7 @@ _sysio_lseek(int fd, _SYSIO_OFF_T offset { int err; struct file *fil; - off_t off; + off_t off = 0; struct intnl_stat stbuf; err = 0; @@ -113,3 +113,31 @@ lseek(int fd, off_t offset, int whence) return (off_t )_sysio_lseek(fd, offset, whence); } + +#if defined(__GLIBC__) && defined(ALPHA_LINUX) + +off_t +__lseek(int fd, off_t offset, int whence) +{ + return lseek(fd, offset, whence); +} + +loff_t +__lseek64( int fd, loff_t offset, int whence) +{ + return lseek( fd, offset, whence ); +} + +loff_t +__llseek( int fd, loff_t offset, int whence) +{ + return __lseek64(fd, offset, whence); +} + +loff_t +__llseek64( int fd, loff_t offset, int whence) +{ + return __lseek64(fd, offset, whence); +} + +#endif Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.5 retrieving revision 1.5.4.1 diff -u -w -b -B -p -r1.5 -r1.5.4.1 --- mount.c 18 Apr 2003 20:24:05 -0000 1.5 +++ mount.c 26 Sep 2003 21:28:34 -0000 1.5.4.1 @@ -106,8 +106,8 @@ _sysio_do_mount(struct filesys *fs, struct inode *ino; /* - * It's really poor form to allow the new root to be - * descendant of the pnode being covered.the one being covered. + * It's really poor form to allow the new root to be a + * descendant of the pnode being covered. */ if (tocover) { struct pnode_base *pb; @@ -142,7 +142,8 @@ _sysio_do_mount(struct filesys *fs, /* * Get alias for the new root. */ - mnt->mnt_root = _sysio_p_new_alias(NULL, rootpb, mnt); + mnt->mnt_root = + _sysio_p_new_alias(tocover ? tocover->p_parent : NULL, rootpb, mnt); if (!mnt->mnt_root) { err = -ENOMEM; goto error; @@ -541,11 +542,12 @@ parse_opts(char *opts, unsigned *flagsp) *dst++ = *src++; while (src != cp); } - *dst = '\0'; if (!*src) break; + *dst = '\0'; src++; /* skip comma */ } + *dst = '\0'; *flagsp = flags; return opts; Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.5.6.1 retrieving revision 1.5.6.2 diff -u -w -b -B -p -r1.5.6.1 -r1.5.6.2 --- namei.c 29 Jul 2003 19:05:09 -0000 1.5.6.1 +++ namei.c 26 Sep 2003 21:28:34 -0000 1.5.6.2 @@ -434,6 +434,33 @@ _sysio_path_walk(struct pnode *parent, s return err; } +#ifdef CPLANT_YOD +static const char * +strip_prefix(const char *path) +{ + + /* + * for backward compatibility w/protocol switch + * remove 'prefix:' iff first ':' immediately + * precedes first '/' + */ + + char *colon, *slash; + + colon = strchr(path, ':'); + slash = strchr(path, '/'); + + if (slash == colon + 1) + return(slash); + else + return(path); + +} +#define STRIP_PREFIX(p) strip_prefix(p) +#else +#define STRIP_PREFIX(p) p +#endif + /* * Expanded form of the path-walk routine, with the common arguments, builds * the nameidata bundle and calls path-walk. @@ -448,7 +475,7 @@ _sysio_namei(struct pnode *parent, struct nameidata nameidata; int err; - ND_INIT(&nameidata, flags, path, _sysio_root, intnt); + ND_INIT(&nameidata, flags, STRIP_PREFIX(path), _sysio_root, intnt); err = _sysio_path_walk(parent, &nameidata); if (!err) *pnop = nameidata.nd_pno; Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.7.4.1 retrieving revision 1.7.4.2 diff -u -w -b -B -p -r1.7.4.1 -r1.7.4.2 --- open.c 19 May 2003 13:51:20 -0000 1.7.4.1 +++ open.c 26 Sep 2003 21:28:34 -0000 1.7.4.2 @@ -49,6 +49,7 @@ #include <sys/stat.h> #include <fcntl.h> #include <sys/queue.h> +#include <features.h> #include "sysio.h" #include "inode.h" @@ -56,6 +57,13 @@ #include "fs.h" #include "mount.h" +#ifdef __GLIBC__ +#undef open +#undef __open +#undef open64 +#undef __open64 +#endif + /* * Open file support. */ @@ -230,3 +238,49 @@ umask(mode_t mask) _sysio_umask = mask & 0777; return omask; } + +#if defined(__GLIBC__) && defined(ALPHA_LINUX) +int +open64(const char *fname, int flags, ...) +{ + va_list ap; + mode_t mode; + + va_start(ap, flags); + mode = va_arg(ap, mode_t); + va_end(ap); + + return open(fname, flags, mode); +} + +int +__open64(const char *fname, int flags, ...) +{ + va_list ap; + mode_t mode; + + va_start(ap, flags); + mode = va_arg(ap, mode_t); + va_end(ap); + + return open(fname, flags, mode); +} +int +__open(const char *fname, int flags, ...) +{ + va_list ap; + mode_t mode; + + va_start(ap, flags); + mode = va_arg(ap, mode_t); + va_end(ap); + + return open(fname, flags, mode); +} + +int +__close(int fd) { + + return close(fd); +} +#endif Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.2 retrieving revision 1.2.10.1 diff -u -w -b -B -p -r1.2 -r1.2.10.1 --- read.c 9 Mar 2003 06:36:37 -0000 1.2 +++ read.c 26 Sep 2003 21:28:34 -0000 1.2.10.1 @@ -57,9 +57,10 @@ * Schedule asynchronous read of iovec at some file extent. */ static struct ioctx * -do_ipreadv(struct file *fil, +do_ixreadv(struct file *fil, const struct iovec *iov, size_t count, - off_t offset) + off_t offset, + void (*fcompletio)(struct ioctx *)) { struct inode *ino; int err; @@ -82,7 +83,7 @@ do_ipreadv(struct file *fil, IOARG_INIT(&ioarguments, iov, count, offset, - (void (*)(void *))_sysio_fcompletio, fil); + (void (*)(void *))fcompletio, fil); err = ino->i_ops.inop_ipreadv(fil->f_ino, &ioarguments, &ioctx); if (err) { errno = -err; @@ -106,7 +107,7 @@ ipreadv(int fd, const struct iovec *iov, return IOID_FAIL; } - ioctxp = do_ipreadv(fil, iov, count, offset); + ioctxp = do_ixreadv(fil, iov, count, offset, NULL); return ioctxp ? ioctxp->ioctx_id : IOID_FAIL; } @@ -168,7 +169,7 @@ ireadv(int fd, const struct iovec *iov, return IOID_FAIL; } - ioctxp = do_ipreadv(fil, iov, count, fil->f_pos); + ioctxp = do_ixreadv(fil, iov, count, fil->f_pos, _sysio_fcompletio); if (!ioctxp) return IOID_FAIL; return ioctxp->ioctx_id; @@ -222,5 +223,13 @@ read_list(int fd, { errno = ENOSYS; return -1; +} +#endif + +#if defined(__GLIBC__) && defined(ALPHA_LINUX) +ssize_t +__read(int fd, void *buf, size_t count) +{ + return read(fd, buf, count); } #endif Index: statvfs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs.c,v retrieving revision 1.3.6.1 retrieving revision 1.3.6.2 diff -u -w -b -B -p -r1.3.6.1 -r1.3.6.2 --- statvfs.c 12 May 2003 11:48:45 -0000 1.3.6.1 +++ statvfs.c 26 Sep 2003 21:28:34 -0000 1.3.6.2 @@ -41,6 +41,8 @@ * le...@sa... */ +#ifdef _HAVE_STATVFS + #if !(defined(BSD) || defined(REDSTORM)) #include <unistd.h> @@ -139,3 +141,4 @@ out: return err; } #endif /* if !(defined(BSD) || defined(REDSTORM)) */ +#endif /* defined(_HAVE_STATVFS) */ Index: statvfs64.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs64.c,v retrieving revision 1.3.6.1 retrieving revision 1.3.6.2 diff -u -w -b -B -p -r1.3.6.1 -r1.3.6.2 --- statvfs64.c 12 May 2003 11:48:45 -0000 1.3.6.1 +++ statvfs64.c 26 Sep 2003 21:28:34 -0000 1.3.6.2 @@ -41,6 +41,8 @@ * le...@sa... */ +#ifdef _HAVE_STATVFS + #if !(defined(BSD) || defined(REDSTORM)) #include <unistd.h> #include <errno.h> @@ -95,3 +97,4 @@ out: return err; } #endif /* if !(defined(BSD) || defined(REDSTORM)) */ +#endif /* define(_HAVE_STATVFS) */ Index: write.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/write.c,v retrieving revision 1.2 retrieving revision 1.2.12.1 diff -u -w -b -B -p -r1.2 -r1.2.12.1 --- write.c 7 Mar 2003 03:31:36 -0000 1.2 +++ write.c 26 Sep 2003 21:28:34 -0000 1.2.12.1 @@ -59,9 +59,10 @@ * Schedule asynchronous write of iovec at some file extent. */ static struct ioctx * -do_ipwritev(struct file *fil, +do_ixwritev(struct file *fil, const struct iovec *iov, size_t count, - off_t offset) + off_t offset, + void (*fcompletio)(struct ioctx *)) { struct inode *ino; int err; @@ -88,7 +89,7 @@ do_ipwritev(struct file *fil, IOARG_INIT(&ioarguments, iov, count, offset, - (void (*)(void *))_sysio_fcompletio, fil); + (void (*)(void *))fcompletio, fil); err = ino->i_ops.inop_ipwritev(fil->f_ino, &ioarguments, &ioctx); if (err) { errno = -err; @@ -112,7 +113,7 @@ ipwritev(int fd, const struct iovec *iov return IOID_FAIL; } - ioctxp = do_ipwritev(fil, iov, count, offset); + ioctxp = do_ixwritev(fil, iov, count, offset, NULL); return ioctxp ? ioctxp->ioctx_id : IOID_FAIL; } @@ -174,7 +175,7 @@ iwritev(int fd, const struct iovec *iov, return IOID_FAIL; } - ioctxp = do_ipwritev(fil, iov, count, fil->f_pos); + ioctxp = do_ixwritev(fil, iov, count, fil->f_pos, _sysio_fcompletio); if (!ioctxp) return IOID_FAIL; return ioctxp->ioctx_id; @@ -230,3 +231,18 @@ write_list(int fd, return -1; } #endif + +#if defined(__GLIBC__) && defined(ALPHA_LINUX) +ssize_t +__write(int fd, const void *buf, size_t count) +{ + return write(fd, buf, count); +} + +ssize_t +__writev(int fd, const struct iovec *iov, int count) +{ + return writev(fd, iov, count); +} +#endif + |
From: Lee W. <lw...@us...> - 2003-09-26 21:28:49
|
Update of /cvsroot/libsysio/libsysio/drivers In directory sc8-pr-cvs1:/tmp/cvs-serv12723/drivers Modified Files: Tag: RedStorm Makefile.am Log Message: Merged with current head. Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/Makefile.am,v retrieving revision 1.2 retrieving revision 1.2.6.1 diff -u -w -b -B -p -r1.2 -r1.2.6.1 --- Makefile.am 24 Mar 2003 22:09:03 -0000 1.2 +++ Makefile.am 26 Sep 2003 21:28:33 -0000 1.2.6.1 @@ -11,4 +11,10 @@ else INCORE_DRIVER = endif -SUBDIRS = $(NATIVE_DRIVER) $(INCORE_DRIVER) +if WITH_CPLANT_YOD +YOD_DRIVER = yod +else +YOD_DRIVER = +endif + +SUBDIRS = $(NATIVE_DRIVER) $(INCORE_DRIVER) $(YOD_DRIVER) |
From: Lee W. <lw...@us...> - 2003-09-26 21:28:49
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1:/tmp/cvs-serv12723/include Modified Files: Tag: RedStorm inode.h Added Files: Tag: RedStorm cplant-yod.h Log Message: Merged with current head. --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2003 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1110 * * le...@sa... */ /* * cplant yod I/O functions */ extern int chmod_yod(const char* path, mode_t); extern int chown_yod(const char* path, uid_t, gid_t); extern int stat_yod(const char *path, struct stat *sbuf); extern int fstat_yod(int fd, struct stat *buf); extern int statfs_yod(const char *path, struct statfs *sbuf); extern int fstatfs_yod(int fd, struct statfs *buf); extern int mkdir_yod(const char *path, mode_t mode); extern int rmdir_yod(const char *path); extern int getdirentries_yod(int fd, char *buf, size_t nbytes, loff_t *basep); extern int link_yod(const char *path1, const char *path2); extern int unlink_yod(const char *path); extern int symlink_yod(const char *path1, const char *path2 ); extern int open_yod(const char *fname, int flags, mode_t mode); extern int close_yod(int); extern ssize_t write_yod(int fd, const void *buff, size_t nbytes); extern ssize_t read_yod(int fd, void *buff, size_t nbytes); extern int fsync_yod(int fd); extern int truncate_yod(const char *path, off_t length); extern int ftruncate_yod(int fd, long length); extern off_t lseek_yod(int fd, off_t offset, int whence); Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.6.4.2 retrieving revision 1.6.4.3 diff -u -w -b -B -p -r1.6.4.2 -r1.6.4.3 --- inode.h 29 Jul 2003 19:05:08 -0000 1.6.4.2 +++ inode.h 26 Sep 2003 21:28:34 -0000 1.6.4.3 @@ -132,8 +132,9 @@ struct inode_ops { */ struct inode { LIST_ENTRY(inode) i_link; /* FS i-nodes link */ - unsigned i_immune : 1; /* immune from GC */ - unsigned i_zombie : 1; /* stale inode */ + unsigned + i_immune : 1, /* immune from GC */ + i_zombie : 1; /* stale inode */ unsigned i_ref; /* soft ref counter */ ino_t i_num; /* i-num (deprecate!) */ mode_t i_mode; /* mode (see stat.h) */ |