libsysio-commit Mailing List for libsysio (Page 47)
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: Lee W. <lw...@us...> - 2003-07-29 19:53:20
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs1:/tmp/cvs-serv12924 Modified Files: Tag: RedStorm configure.in Log Message: Pull in recent changes from the HEAD branch, to incorporate fixes there. Index: configure.in =================================================================== RCS file: /cvsroot/libsysio/libsysio/configure.in,v retrieving revision 1.5.6.2 retrieving revision 1.5.6.3 diff -u -w -b -B -p -r1.5.6.2 -r1.5.6.3 --- configure.in 19 May 2003 13:51:20 -0000 1.5.6.2 +++ configure.in 29 Jul 2003 19:05:06 -0000 1.5.6.3 @@ -213,6 +213,19 @@ AC_MSG_RESULT($have__st_ino) if test x$have__st_ino = xyes; then AC_DEFINE(HAVE__ST_INO) fi +# Check for st_gen +# +AC_MSG_CHECKING(for st_gen) +AC_TRY_COMPILE([ +#include <sys/stat.h>], +[struct stat st; +st.st_gen = 0;], + have_st_gen=yes, + have_st_gen=no) +AC_MSG_RESULT($have_st_gen) +if test x$have_st_gen = xyes; then + AC_DEFINE(HAVE_GENERATION) +fi # Check for getdents64 call # |
From: Lee W. <lw...@us...> - 2003-07-29 18:56:56
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv2952 Modified Files: Tag: RedStorm test_unlink.c Log Message: -Don't need dirent.h -Check return from unlink appropriately Index: test_unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_unlink.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 --- test_unlink.c 19 Jun 2003 17:48:14 -0000 1.1.2.1 +++ test_unlink.c 29 Jul 2003 18:33:01 -0000 1.1.2.2 @@ -50,8 +50,9 @@ #include <unistd.h> #endif #include <errno.h> -#if 0 +#include <sys/types.h> #include <sys/queue.h> +#if 0 #include <dirent.h> #endif @@ -180,7 +181,7 @@ static int unlinkit(const char *path) { - if (!unlink(path)) { + if (unlink(path) != 0) { perror(path); return -1; } |
From: Ruth K. <rk...@us...> - 2003-07-29 18:46:25
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv1879 Modified Files: fs_native.c Log Message: correct error setting Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -b -B -p -r1.12 -r1.13 --- fs_native.c 25 Jul 2003 14:45:34 -0000 1.12 +++ fs_native.c 29 Jul 2003 18:29:32 -0000 1.13 @@ -1024,7 +1024,8 @@ native_inop_unlink(struct pnode *pno) * (usually .NFSXXXXXX, where the X's are replaced by the PID and some * unique characters) in order to simulate the proper semantic. */ - err = syscall(SYS_unlink, path); + if (!syscall(SYS_unlink, path)) + err = -errno; free(path); return err; } |
From: Ruth K. <rk...@us...> - 2003-07-26 05:21:22
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv25000/drivers/native Modified Files: fs_native.c Log Message: Add capability of checking inode generation numbers, if a field for it exists in the stat struct. Bug fix for unlink/creat failure: Changes allow re-use of an inode which is no longer in use, but still exists in the inode cache. If the stat info for the new use matches cached info, the inode is re-used. If not, the old inode is marked 'zombie' and removed from the inode cache to make way for the new inode. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -w -b -B -p -r1.11 -r1.12 --- fs_native.c 23 Apr 2003 18:18:38 -0000 1.11 +++ fs_native.c 25 Jul 2003 14:45:34 -0000 1.12 @@ -151,6 +151,9 @@ do { struct native_inode_identifier { dev_t dev; /* device number */ ino_t ino; /* i-number */ +#ifdef HAVE_GENERATION + unsigned int gen; /* generation number */ +#endif }; /* @@ -310,8 +313,12 @@ native_i_new(struct filesys *fs, struct nino = malloc(sizeof(struct native_inode)); if (!nino) return NULL; + bzero(&nino->ni_ident, sizeof(nino->ni_ident)); nino->ni_ident.dev = buf->st_dev; nino->ni_ident.ino = buf->st_ino; +#ifdef HAVE_GENERATION + nino->ni_ident.gen = buf->st_gen; +#endif nino->ni_fileid.fid_data = &nino->ni_ident; nino->ni_fileid.fid_len = sizeof(nino->ni_ident); nino->ni_fd = -1; @@ -496,6 +503,27 @@ native_fsswop_mount(const char *source, return err; } +static int +native_i_validate(struct inode *inop, struct intnl_stat stbuf) +{ + /* + * Validate passed in inode against stat struct info + */ + struct native_inode *nino = I2NI(inop); + + if ((nino->ni_ident.dev == stbuf.st_dev && + nino->ni_ident.ino == stbuf.st_ino && +#ifdef HAVE_GENERATION + nino->ni_ident.gen == stbuf.st_gen && +#endif + ((inop)->i_mode & stbuf.st_mode) == (inop)->i_mode) && + ((!(S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)) || + (inop)->i_rdev == stbuf.st_rdev))) + return 0; + + return 1; +} + /* * Find, and validate, or create i-node by host-relative path. Returned i-node * is referenced. @@ -525,11 +553,7 @@ native_iget(struct filesys *fs, * Validate? */ if (*inop) { - struct native_inode *nino = I2NI(*inop); - - if (nino->ni_ident.dev == stbuf.st_dev && - nino->ni_ident.ino == stbuf.st_ino && - ((*inop)->i_mode & stbuf.st_mode) == (*inop)->i_mode) + if (!native_i_validate(*inop, stbuf)) return 0; /* * Invalidate. @@ -540,23 +564,40 @@ native_iget(struct filesys *fs, /* * I-node is not already known. Find or create it. */ + bzero(&ident, sizeof(ident)); ident.dev = stbuf.st_dev; ident.ino = stbuf.st_ino; +#ifdef HAVE_GENERATION + ident.gen = stbuf.st_gen; +#endif fileid.fid_data = &ident; fileid.fid_len = sizeof(ident); ino = _sysio_i_find(fs, stbuf.st_ino, &fileid); - if (!ino) { - ino = native_i_new(fs, &stbuf); - if (!ino) - err = -ENOMEM; - } else if (forced) { + if (ino && forced) { /* * Insertion was forced but it's already present! */ + if (native_i_validate(ino, stbuf)) { + /* + * Cached inode has stale attrs + * make way for the new one + */ I_RELE(ino); - err = -EEXIST; + _sysio_i_undead(ino); + ino = NULL; + } else + /* + * OK to reuse cached inode + */ + goto out; } + if (!ino) { + ino = native_i_new(fs, &stbuf); + if (!ino) + err = -ENOMEM; + } +out: if (!err) *inop = ino; return err; |
From: Ruth K. <rk...@us...> - 2003-07-26 05:21:22
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1:/tmp/cvs-serv25000/include Modified Files: inode.h Log Message: Add capability of checking inode generation numbers, if a field for it exists in the stat struct. Bug fix for unlink/creat failure: Changes allow re-use of an inode which is no longer in use, but still exists in the inode cache. If the stat info for the new use matches cached info, the inode is re-used. If not, the old inode is marked 'zombie' and removed from the inode cache to make way for the new inode. Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- inode.h 23 Apr 2003 19:45:51 -0000 1.6 +++ inode.h 25 Jul 2003 14:45:34 -0000 1.7 @@ -129,6 +129,7 @@ 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_ref; /* soft ref counter */ ino_t i_num; /* i-num (deprecate!) */ mode_t i_mode; /* mode (see stat.h) */ @@ -146,6 +147,7 @@ struct inode { #define I_INIT(ino, fs, inum, mode, rdev, ops, fid, immunity, private) \ do { \ (ino)->i_immune = (immunity) ? 1 : 0; \ + (ino)->i_zombie = 0; \ (ino)->i_ref = 0; \ (ino)->i_num = (inum); \ (ino)->i_mode = (mode); \ @@ -407,6 +409,7 @@ extern struct inode *_sysio_i_find(struc ino_t ino, struct file_identifier *fid); extern void _sysio_i_gone(struct inode *ino); +extern void _sysio_i_undead(struct inode *ino); extern int _sysio_p_find_alias(struct pnode *parent, struct qstr *name, struct pnode **pnop); |
From: Ruth K. <rk...@us...> - 2003-07-26 05:21:22
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs1:/tmp/cvs-serv24840 Modified Files: configure.in Log Message: Add check for existence of st_gen in stat struct Index: configure.in =================================================================== RCS file: /cvsroot/libsysio/libsysio/configure.in,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- configure.in 26 Mar 2003 00:05:59 -0000 1.5 +++ configure.in 25 Jul 2003 14:44:14 -0000 1.6 @@ -209,6 +209,19 @@ AC_MSG_RESULT($have__st_ino) if test x$have__st_ino = xyes; then AC_DEFINE(HAVE__ST_INO) fi +# Check for st_gen +# +AC_MSG_CHECKING(for st_gen) +AC_TRY_COMPILE([ +#include <sys/stat.h>], +[struct stat st; +st.st_gen = 0;], + have_st_gen=yes, + have_st_gen=no) +AC_MSG_RESULT($have_st_gen) +if test x$have_st_gen = xyes; then + AC_DEFINE(HAVE_GENERATION) +fi AC_MSG_CHECKING(whether .text pseudo-op must be used) AC_CACHE_VAL(sysio_asm_dot_text, [dnl |
From: Ruth K. <rk...@us...> - 2003-07-26 05:21:22
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv25000/src Modified Files: inode.c Log Message: Add capability of checking inode generation numbers, if a field for it exists in the stat struct. Bug fix for unlink/creat failure: Changes allow re-use of an inode which is no longer in use, but still exists in the inode cache. If the stat info for the new use matches cached info, the inode is re-used. If not, the old inode is marked 'zombie' and removed from the inode cache to make way for the new inode. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- inode.c 23 Apr 2003 19:45:52 -0000 1.7 +++ inode.c 25 Jul 2003 14:45:34 -0000 1.8 @@ -265,6 +265,7 @@ _sysio_i_gone(struct inode *ino) if (ino->i_ref) abort(); + if (!ino->i_zombie) LIST_REMOVE(ino, i_link); TAILQ_REMOVE(&_sysio_inodes, ino, i_nodes); (*ino->i_ops.inop_gone)(ino); @@ -272,6 +273,17 @@ _sysio_i_gone(struct inode *ino) assert(n_inodes); n_inodes--; +} + +/* + * Stale inode, zombie it and move it out of the way + */ +void +_sysio_i_undead(struct inode *ino) +{ + + LIST_REMOVE(ino, i_link); + ino->i_zombie = 1; } /* |
From: Ruth K. <rk...@us...> - 2003-07-24 22:53:01
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv19555/src Modified Files: Tag: cplant inode.c Log Message: Add capability of checking inode generation numbers, if a field for it exists in the stat struct. Bug fix for unlink/creat failure: Changes allow re-use of an inode which is no longer in use, but still exists in the inode cache. If the stat info for the new use matches cached info, the inode is re-used. If not, the old inode is marked 'zombie' and removed from the inode cache to make way for the new inode. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.5.2.1 retrieving revision 1.5.2.2 diff -u -w -b -B -p -r1.5.2.1 -r1.5.2.2 --- inode.c 28 Apr 2003 20:55:56 -0000 1.5.2.1 +++ inode.c 24 Jul 2003 22:52:57 -0000 1.5.2.2 @@ -265,6 +265,7 @@ _sysio_i_gone(struct inode *ino) if (ino->i_ref) abort(); + if (!ino->i_zombie) LIST_REMOVE(ino, i_link); TAILQ_REMOVE(&_sysio_inodes, ino, i_nodes); (*ino->i_ops.inop_gone)(ino); @@ -272,6 +273,17 @@ _sysio_i_gone(struct inode *ino) assert(n_inodes); n_inodes--; +} + +/* + * Stale inode, zombie it and move it out of the way + */ +void +_sysio_i_undead(struct inode *ino) +{ + + LIST_REMOVE(ino, i_link); + ino->i_zombie = 1; } /* |
From: Ruth K. <rk...@us...> - 2003-07-24 22:53:00
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1:/tmp/cvs-serv19555/drivers/native Modified Files: Tag: cplant fs_native.c Log Message: Add capability of checking inode generation numbers, if a field for it exists in the stat struct. Bug fix for unlink/creat failure: Changes allow re-use of an inode which is no longer in use, but still exists in the inode cache. If the stat info for the new use matches cached info, the inode is re-used. If not, the old inode is marked 'zombie' and removed from the inode cache to make way for the new inode. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.8.2.4 retrieving revision 1.8.2.5 diff -u -w -b -B -p -r1.8.2.4 -r1.8.2.5 --- fs_native.c 12 Jun 2003 23:47:04 -0000 1.8.2.4 +++ fs_native.c 24 Jul 2003 22:52:57 -0000 1.8.2.5 @@ -161,6 +161,9 @@ do { struct native_inode_identifier { dev_t dev; /* device number */ ino_t ino; /* i-number */ +#ifdef HAVE_GENERATION + unsigned int gen; /* generation number */ +#endif }; /* @@ -322,8 +325,12 @@ native_i_new(struct filesys *fs, struct nino = malloc(sizeof(struct native_inode)); if (!nino) return NULL; + bzero(&nino->ni_ident, sizeof(nino->ni_ident)); nino->ni_ident.dev = buf->st_dev; nino->ni_ident.ino = buf->st_ino; +#ifdef HAVE_GENERATION + nino->ni_ident.gen = buf->st_gen; +#endif nino->ni_fileid.fid_data = &nino->ni_ident; nino->ni_fileid.fid_len = sizeof(nino->ni_ident); nino->ni_fd = -1; @@ -508,6 +515,27 @@ native_fsswop_mount(const char *source, return err; } +static int +native_i_validate(struct inode *inop, struct intnl_stat stbuf) +{ + /* + * Validate passed in inode against stat struct info + */ + struct native_inode *nino = I2NI(inop); + + if ((nino->ni_ident.dev == stbuf.st_dev && + nino->ni_ident.ino == stbuf.st_ino && +#ifdef HAVE_GENERATION + nino->ni_ident.gen == stbuf.st_gen && +#endif + ((inop)->i_mode & stbuf.st_mode) == (inop)->i_mode) && + ((!(S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)) || + (inop)->i_rdev == stbuf.st_rdev))) + return 0; + + return 1; +} + /* * Find, and validate, or create i-node by host-relative path. Returned i-node * is referenced. @@ -537,11 +565,7 @@ native_iget(struct filesys *fs, * Validate? */ if (*inop) { - struct native_inode *nino = I2NI(*inop); - - if (nino->ni_ident.dev == stbuf.st_dev && - nino->ni_ident.ino == stbuf.st_ino && - ((*inop)->i_mode & stbuf.st_mode) == (*inop)->i_mode) + if (!native_i_validate(*inop, stbuf)) return 0; /* * Invalidate. @@ -552,23 +576,40 @@ native_iget(struct filesys *fs, /* * I-node is not already known. Find or create it. */ + bzero(&ident, sizeof(ident)); ident.dev = stbuf.st_dev; ident.ino = stbuf.st_ino; +#ifdef HAVE_GENERATION + ident.gen = stbuf.st_gen; +#endif fileid.fid_data = &ident; fileid.fid_len = sizeof(ident); ino = _sysio_i_find(fs, stbuf.st_ino, &fileid); - if (!ino) { - ino = native_i_new(fs, &stbuf); - if (!ino) - err = -ENOMEM; - } else if (forced) { + if (ino && forced) { /* * Insertion was forced but it's already present! */ + if (native_i_validate(ino, stbuf)) { + /* + * Cached inode has stale attrs + * make way for the new one + */ I_RELE(ino); - err = -EEXIST; + _sysio_i_undead(ino); + ino = NULL; + } else + /* + * OK to reuse cached inode + */ + goto out; } + if (!ino) { + ino = native_i_new(fs, &stbuf); + if (!ino) + err = -ENOMEM; + } +out: if (!err) *inop = ino; return err; |
From: Ruth K. <rk...@us...> - 2003-07-24 22:53:00
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1:/tmp/cvs-serv19555/drivers/yod Modified Files: Tag: cplant fs_yod.c Log Message: Add capability of checking inode generation numbers, if a field for it exists in the stat struct. Bug fix for unlink/creat failure: Changes allow re-use of an inode which is no longer in use, but still exists in the inode cache. If the stat info for the new use matches cached info, the inode is re-used. If not, the old inode is marked 'zombie' and removed from the inode cache to make way for the new inode. Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/Attic/fs_yod.c,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -w -b -B -p -r1.1.2.5 -r1.1.2.6 --- fs_yod.c 12 Jun 2003 19:48:37 -0000 1.1.2.5 +++ fs_yod.c 24 Jul 2003 22:52:57 -0000 1.1.2.6 @@ -126,6 +126,9 @@ do { struct yod_inode_identifier { dev_t dev; /* device number */ ino_t ino; /* i-number */ +#ifdef HAVE_GENERATION + unsigned int gen; /* generation number */ +#endif }; /* @@ -281,8 +284,12 @@ yod_i_new(struct filesys *fs, struct int nino = malloc(sizeof(struct yod_inode)); if (!nino) return NULL; + bzero(&nino->ni_ident, sizeof(nino->ni_ident)); nino->ni_ident.dev = buf->st_dev; nino->ni_ident.ino = buf->st_ino; +#ifdef HAVE_GENERATION + nino->ni_ident.gen = buf->st_gen; +#endif nino->ni_fileid.fid_data = &nino->ni_ident; nino->ni_fileid.fid_len = sizeof(nino->ni_ident); nino->ni_fd = -1; @@ -468,6 +475,27 @@ yod_fsswop_mount(const char *source, } /* + * Validate passed in inode against stat struct info + */ +static int +yod_i_validate(struct inode *inop, struct intnl_stat stbuf) +{ + struct yod_inode *nino = I2NI(inop); + + if ((nino->ni_ident.dev == stbuf.st_dev && + nino->ni_ident.ino == stbuf.st_ino && +#ifdef HAVE_GENERATION + nino->ni_ident.gen == stbuf.st_gen && +#endif + ((inop)->i_mode & stbuf.st_mode) == (inop)->i_mode) && + (!(S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)) || + (inop)->i_rdev == stbuf.st_rdev)) + return 0; + + return 1; +} + +/* * Find, and validate, or create i-node by host-relative path. Returned i-node * is referenced. */ @@ -496,11 +524,7 @@ yod_iget(struct filesys *fs, * Validate? */ if (*inop) { - struct yod_inode *nino = I2NI(*inop); - - if (nino->ni_ident.dev == stbuf.st_dev && - nino->ni_ident.ino == stbuf.st_ino && - ((*inop)->i_mode & stbuf.st_mode) == (*inop)->i_mode) + if (!yod_i_validate(*inop, stbuf)) return 0; /* * Invalidate. @@ -511,24 +535,40 @@ yod_iget(struct filesys *fs, /* * I-node is not already known. Find or create it. */ + bzero(&ident, sizeof(ident)); ident.dev = stbuf.st_dev; ident.ino = stbuf.st_ino; +#ifdef HAVE_GENERATION + ident.gen = stbuf.st_gen; +#endif fileid.fid_data = &ident; fileid.fid_len = sizeof(ident); ino = _sysio_i_find(fs, stbuf.st_ino, &fileid); - - if (!ino) { - ino = yod_i_new(fs, &stbuf); - if (!ino) - err = -ENOMEM; - } else if (forced) { + if (ino && forced) { /* * Insertion was forced but it's already present! */ + if (yod_i_validate(ino, stbuf)) { + /* + * Cached inode has stale attrs + * make way for the new one + */ I_RELE(ino); - err = -EEXIST; + _sysio_i_undead(ino); + ino = NULL; + } else + /* + * OK to reuse cached inode + */ + goto out; } + if (!ino) { + ino = yod_i_new(fs, &stbuf); + if (!ino) + err = -ENOMEM; + } +out: if (!err) *inop = ino; return err; |
From: Ruth K. <rk...@us...> - 2003-07-24 22:53:00
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1:/tmp/cvs-serv19555/include Modified Files: Tag: cplant inode.h Log Message: Add capability of checking inode generation numbers, if a field for it exists in the stat struct. Bug fix for unlink/creat failure: Changes allow re-use of an inode which is no longer in use, but still exists in the inode cache. If the stat info for the new use matches cached info, the inode is re-used. If not, the old inode is marked 'zombie' and removed from the inode cache to make way for the new inode. Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,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 --- inode.h 28 Apr 2003 20:43:50 -0000 1.4.2.1 +++ inode.h 24 Jul 2003 22:52:57 -0000 1.4.2.2 @@ -129,6 +129,7 @@ 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_ref; /* soft ref counter */ ino_t i_num; /* i-num (deprecate!) */ mode_t i_mode; /* mode (see stat.h) */ @@ -146,6 +147,7 @@ struct inode { #define I_INIT(ino, fs, inum, mode, rdev, ops, fid, immunity, private) \ do { \ (ino)->i_immune = (immunity) ? 1 : 0; \ + (ino)->i_zombie = 0; \ (ino)->i_ref = 0; \ (ino)->i_num = (inum); \ (ino)->i_mode = (mode); \ @@ -407,6 +409,7 @@ extern struct inode *_sysio_i_find(struc ino_t ino, struct file_identifier *fid); extern void _sysio_i_gone(struct inode *ino); +extern void _sysio_i_undead(struct inode *ino); extern int _sysio_p_find_alias(struct pnode *parent, struct qstr *name, struct pnode **pnop); |
From: Ruth K. <rk...@us...> - 2003-07-24 22:25:10
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs1:/tmp/cvs-serv14747 Modified Files: Tag: cplant configure.in Log Message: Add check for existence of st_gen in stat struct Index: configure.in =================================================================== RCS file: /cvsroot/libsysio/libsysio/configure.in,v retrieving revision 1.5.2.4 retrieving revision 1.5.2.5 diff -u -w -b -B -p -r1.5.2.4 -r1.5.2.5 --- configure.in 13 Jun 2003 01:02:22 -0000 1.5.2.4 +++ configure.in 24 Jul 2003 22:25:06 -0000 1.5.2.5 @@ -237,6 +237,19 @@ AC_MSG_RESULT($have__st_ino) if test x$have__st_ino = xyes; then AC_DEFINE(HAVE__ST_INO) fi +# Check for __st_ino +# +AC_MSG_CHECKING(for st_gen) +AC_TRY_COMPILE([ +#include <sys/stat.h>], +[struct stat st; +st.st_gen = 0;], + have_st_gen=yes, + have_st_gen=no) +AC_MSG_RESULT($have_st_gen) +if test x$have_st_gen = xyes; then + AC_DEFINE(HAVE_GENERATION) +fi AC_MSG_CHECKING(whether .text pseudo-op must be used) AC_CACHE_VAL(sysio_asm_dot_text, [dnl |
From: Sonja T. <so...@us...> - 2003-07-14 21:02:11
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv32726/tests Modified Files: Tag: libsysio_tests test_all.pl Log Message: Modified test_all.pl to exclude tests known to be broke on Cplant (broke due to libsysio/yod/etc bugs) Index: test_all.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_all.pl,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -w -b -B -p -r1.1.2.4 -r1.1.2.5 --- test_all.pl 9 Jul 2003 20:07:13 -0000 1.1.2.4 +++ test_all.pl 14 Jul 2003 21:02:05 -0000 1.1.2.5 @@ -8,13 +8,14 @@ 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"; } # Will use this directory... -system("mkdir tmp_dir"); +system("mkdir ./tmp_dir"); my $failures = 0; my $success = 0; @@ -24,27 +25,19 @@ 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 -my $res = `./test_list.pl $alpha_arg ../`; + $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 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++; } # Test path @@ -69,6 +62,17 @@ if ($resarr[0] ne $res) { } } +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`; @@ -78,26 +82,30 @@ if ($res ne "getcwd test successful") { $failures++; } else { $success++; + print "test_getcwd finished successfully\n"; + } } # Test copy -$res = `./test_copy.pl $alpha_arg ../README tmp_dir/README`; +$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 tmp_dir/README`; +$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 @@ -108,11 +116,10 @@ if ($res ne "test_stdfd successful") { $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; |
From: Sonja T. <so...@us...> - 2003-07-09 20:35:39
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv3812/tests Modified Files: Tag: libsysio_tests test_path.pl Log Message: Fixed test_path.pl bug Index: test_path.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_path.pl,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -w -b -B -p -r1.1.2.3 -r1.1.2.4 --- test_path.pl 9 Jul 2003 15:22:16 -0000 1.1.2.3 +++ test_path.pl 9 Jul 2003 20:35:35 -0000 1.1.2.4 @@ -152,7 +152,7 @@ my $isalpha = 0; # (if they exist) if ( (@ARGV > 0) && ($ARGV[0] eq "-alpha")) { $isalpha = 1; - pop(@ARGV); + shift(@ARGV); } if (@ARGV == 0) { |
From: Sonja T. <so...@us...> - 2003-07-09 20:07:15
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv27855/tests Modified Files: Tag: libsysio_tests test_all.pl Log Message: Added test_path.pl to test_all.pl Index: test_all.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_all.pl,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -w -b -B -p -r1.1.2.3 -r1.1.2.4 --- test_all.pl 9 Jul 2003 15:22:16 -0000 1.1.2.3 +++ test_all.pl 9 Jul 2003 20:07:13 -0000 1.1.2.4 @@ -45,6 +46,29 @@ if ($res ne "list test successful") { } else { $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 { + $success++; + } + } +} + # Test getcwd $res = `./test_getcwd.pl $alpha_arg $sysdir`; |
From: Sonja T. <so...@us...> - 2003-07-09 15:22:19
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv10139/tests Modified Files: Tag: libsysio_tests Makefile.am README test_all.pl test_copy.pl test_getcwd.pl test_list.pl test_path.pl Log Message: Improving documentation Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.9.2.1 retrieving revision 1.9.2.2 diff -u -w -b -B -p -r1.9.2.1 -r1.9.2.2 --- Makefile.am 30 May 2003 18:12:02 -0000 1.9.2.1 +++ Makefile.am 9 Jul 2003 15:22:16 -0000 1.9.2.2 @@ -38,7 +38,8 @@ DRIVERS=$(NATIVE_DRIVER_NAME) $(INCORE_D CMNSRC=drv_init_all.c drv_data.c BUILT_SOURCES=drv_data.c - +check_PROGRAMS=test_driver +TESTS=test_all.pl CFL=$(AM_CFLAGS) $(AM_CPPFLAGS) \ $(NATIVE_DRIVER_CFLAGS) $(INCORE_DRIVER_CFLAGS) \ $(STDFD_DEV_CFLAGS) Index: README =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/README,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 --- README 30 May 2003 18:14:15 -0000 1.1.2.1 +++ README 9 Jul 2003 15:22:16 -0000 1.1.2.2 @@ -1,5 +1,71 @@ To run the tests, just do ./test_all.pl (at some point I will -integrate that into the build environment). +integrate that into the build environment). This will run the 6 +basic functionality tests (explained below) and report the total +number of passes and failures. This is not currently working on +alpha/cplant architectures, however. + +-----------------------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). Index: test_all.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_all.pl,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -w -b -B -p -r1.1.2.2 -r1.1.2.3 --- test_all.pl 8 Jul 2003 16:41:18 -0000 1.1.2.2 +++ test_all.pl 9 Jul 2003 15:22:16 -0000 1.1.2.3 @@ -90,3 +90,5 @@ print "$failures tests failed and $succe # cleanup system(`rm -rf tmp_dir`); + +exit $failures; Index: test_copy.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_copy.pl,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -w -b -B -p -r1.1.2.2 -r1.1.2.3 --- test_copy.pl 1 Jul 2003 16:04:12 -0000 1.1.2.2 +++ test_copy.pl 9 Jul 2003 15:22:16 -0000 1.1.2.3 @@ -1,10 +1,8 @@ #!/usr/bin/perl -w # -# getdirentries test: Tests the equivalent of a ls. Note that this is not -# the most robust test in the world; it simply verifies -# that libsysio returns all the entries in the directory -# +# copy test: Copy a file from src to dest and verify that the new file +# : is the same as the old # use IPC::Open2; @@ -14,7 +12,7 @@ use helper; sub usage { - print "Usage: ./test_copy.pl <src> <dest>: Copy a file from src to dest\n"; + print "Usage: ./test_copy.pl [-alpha] <src> <dest>: Copy a file from src to dest\n"; exit(-1); } Index: test_getcwd.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_getcwd.pl,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -w -b -B -p -r1.1.2.2 -r1.1.2.3 --- test_getcwd.pl 1 Jul 2003 16:04:12 -0000 1.1.2.2 +++ test_getcwd.pl 9 Jul 2003 15:22:16 -0000 1.1.2.3 @@ -7,7 +7,7 @@ use helper; sub usage { - print "Usage: ./test_getcwd.pl <dir> : Test getcwd by verifying that it \n"; + print "Usage: ./test_getcwd.pl [-alpha] <dir> : Test getcwd by verifying that it \n"; print " : setting the directory to dir and \n"; print " : verifying that getcwd reflects \n"; print " : the change\n"; Index: test_list.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_list.pl,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -w -b -B -p -r1.1.2.2 -r1.1.2.3 --- test_list.pl 1 Jul 2003 16:04:12 -0000 1.1.2.2 +++ test_list.pl 9 Jul 2003 15:22:16 -0000 1.1.2.3 @@ -14,7 +14,7 @@ use helper; sub usage { - print "Usage: ./test_list.pl [-p|-ni] <dir> \n"; + print "Usage: ./test_list.pl [-p|-alpha] <dir> \n"; print " ./test_list.pl -m [-p|-alpha] fstype:mdir dir\n"; print " In the first form, will attempt to verify libsysio's\n"; print " getdirentries. If no dir is given, will use the \n"; Index: test_path.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_path.pl,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -w -b -B -p -r1.1.2.2 -r1.1.2.3 --- test_path.pl 1 Jul 2003 16:04:12 -0000 1.1.2.2 +++ test_path.pl 9 Jul 2003 15:22:16 -0000 1.1.2.3 @@ -130,8 +130,12 @@ sub process_cmd process_path($cmdfh, $outfh, $path); if ($usestdin) { $path = <STDIN>; + if (defined($path)) { chop($path); + } + if ($path eq "quit") { + helper::print_and_exit($cmdfh, $outfh, 0, "path test successful\n"); } } else { $path = $paths[$i++]; |
From: Sonja T. <so...@us...> - 2003-07-08 16:41:22
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv9376/tests Modified Files: Tag: libsysio_tests helper.pm sysio_stubs.c sysio_tests.c test_all.pl test_driver.c Log Message: Completed stdfd test and added it to test_all.pl Index: helper.pm =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/helper.pm,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -w -b -B -p -r1.1.2.2 -r1.1.2.3 --- helper.pm 1 Jul 2003 16:04:12 -0000 1.1.2.2 +++ helper.pm 8 Jul 2003 16:41:18 -0000 1.1.2.3 @@ -7,6 +7,7 @@ package helper; use strict; +use Fcntl ':mode'; BEGIN{} Index: sysio_stubs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/sysio_stubs.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -w -b -B -p -r1.1.2.2 -r1.1.2.3 --- sysio_stubs.c 1 Jul 2003 16:04:12 -0000 1.1.2.2 +++ sysio_stubs.c 8 Jul 2003 16:41:18 -0000 1.1.2.3 @@ -367,7 +367,7 @@ int do_init(int argc, char **argv) } rdriver = get_str(argv[0]); - rsize = sizeof(rdriver)+1; + rsize = strlen(rdriver)+1; if (rsize > 75) { DBG(2, fprintf(outfp, "%s too long for root driver\n", rdriver)); return INVALID_ARGS; @@ -376,7 +376,7 @@ int do_init(int argc, char **argv) memcpy(root_driver, rdriver, rsize); mpath = get_str(argv[1]); - msize = sizeof(mpath)+1; + msize = strlen(mpath)+1; if (msize > 250) { DBG(2, fprintf(outfp, "%s too long for mount path\n", mpath)); return INVALID_ARGS; @@ -393,6 +393,8 @@ int do_init(int argc, char **argv) DBG(5, fprintf(outfp, "In do_init\n")); last_type = SINT; + DBG(3, fprintf(outfp, "Using driver %s, path %s, flags %x\n", + root_driver, mntpath, mntflgs)); return initilize_sysio(root_driver, mntpath, mntflgs); } @@ -1745,10 +1747,10 @@ int do_readv(int argc, char **argv) int do_read(int argc, char **argv) { - int fd, count, index, numbytes; + int fd, count, index, numbytes=0; char *buf; - if (argc != 3) { + if (argc < 3) { DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to read\n", argc)); return INVALID_ARGS; } @@ -1775,7 +1777,18 @@ int do_read(int argc, char **argv) count = get_obj(argv[2]); + if ( (argc == 4) && (!strcmp(argv[3], "delay")) ){ + int i; + /* Wait a little while for input */ + for (i=0; i < count; i++) { + sleep(0.005); + numbytes += (int) read(fd, buf, 1); + last_ret_val = numbytes; + + } + } else { last_ret_val = numbytes = (int) read(fd, buf, count); + } my_errno = errno; DBG(3, fprintf(outfp, "Read %d bytes out of %d\n", numbytes, count)); Index: sysio_tests.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/sysio_tests.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -w -b -B -p -r1.1.2.2 -r1.1.2.3 --- sysio_tests.c 1 Jul 2003 16:04:12 -0000 1.1.2.2 +++ sysio_tests.c 8 Jul 2003 16:41:18 -0000 1.1.2.3 @@ -52,9 +52,10 @@ int initilize_sysio(char *root_driver, c } err = _sysio_mount_root(root_path, root_driver, mntflgs, NULL); if (err) { - my_errno = err; + my_errno = errno; my_perror("_sysio_mount_root"); - last_ret_val = errno; + perror("_sysio_mount_root"); + last_ret_val = err; return SUCCESS; } @@ -891,6 +892,7 @@ int sysio_mknod(char *path, char *mode_a 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; } Index: test_all.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_all.pl,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 --- test_all.pl 30 May 2003 18:14:15 -0000 1.1.2.1 +++ test_all.pl 8 Jul 2003 16:41:18 -0000 1.1.2.2 @@ -2,10 +2,17 @@ # # 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 = ""; +if ((@ARGV > 0) && ($ARGV[0] eq "-alpha")) { + $alpha_arg = "-alpha"; +} + + # Will use this directory... system("mkdir tmp_dir"); @@ -20,7 +27,7 @@ $sysdir =~ s/\/\w+$//; # Test getdirentries -my $res = `./test_list.pl ../`; +my $res = `./test_list.pl $alpha_arg ../`; chop($res); if ($res ne "list test successful") { print "Basic getdirentries test failed with message: $res\n"; @@ -30,7 +37,7 @@ if ($res ne "list test successful") { } # Test mount -$res = `./test_list.pl -m native:$sysdir $cwd/tmp_dir`; +$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"; @@ -40,7 +47,7 @@ if ($res ne "list test successful") { } # Test getcwd -$res = `./test_getcwd.pl $sysdir`; +$res = `./test_getcwd.pl $alpha_arg $sysdir`; chop($res); if ($res ne "getcwd test successful") { print "getcwd test failed with message: $res\n"; @@ -50,7 +57,7 @@ if ($res ne "getcwd test successful") { } # Test copy -$res = `./test_copy.pl ../README tmp_dir/README`; +$res = `./test_copy.pl $alpha_arg ../README tmp_dir/README`; chop($res); if ($res ne "copy test successful") { print "copy test failed with message: $res\n"; @@ -60,10 +67,20 @@ if ($res ne "copy test successful") { } # Test stats -$res = `./test_stats.pl tmp_dir/README`; +$res = `./test_stats.pl $alpha_arg tmp_dir/README`; chop($res); if ($res ne "stat test successful") { print "stat test failed with message: $res\n"; + $failures++; +} else { + $success++; +} + +# 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++; Index: test_driver.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_driver.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -w -b -B -p -r1.1.2.2 -r1.1.2.3 --- test_driver.c 1 Jul 2003 16:04:12 -0000 1.1.2.2 +++ test_driver.c 8 Jul 2003 16:41:18 -0000 1.1.2.3 @@ -189,7 +189,7 @@ struct var_mapping *get_map(char *var_na index = dx_hack_hash(var_name, strlen(var_name)); index %= MAX_VARS -1; - DBG(5, fprintf(outfp, "Got index of %d\n", index)); + DBG(5, fprintf(outfp, "Got index of %d for %s\n", index, var_name)); curr = &map[index]; while ((curr) && (curr->map.obj != -1) ) { @@ -220,6 +220,8 @@ int get_obj(char *var_name) struct var_mapping *var_map; int i; + DBG(5, fprintf(outfp, "Getting object for %s\n", var_name)); + /* If var_name is a digit, we assume it is a literal */ if (isdigit(var_name[0])) return atoi(var_name); @@ -236,6 +238,7 @@ int get_obj(char *var_name) struct var_mapping *tmp_map; memcpy(str1, var_name, i); + str1[i] = '\0'; memcpy(str2, (char *)&var_name[i+1], strlen(var_name)-i); if (isdigit(str1[0])) { |
From: Sonja T. <so...@us...> - 2003-07-01 16:04:16
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv9480/libsysio/tests Modified Files: Tag: libsysio_tests help.c helper.pm sysio_stubs.c sysio_tests.c test_copy.pl test_driver.c test_driver.h test_getcwd.pl test_list.pl test_path.pl test_stats.pl Log Message: Adding more tests and bug fixes Index: help.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/help.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 --- help.c 30 May 2003 18:14:15 -0000 1.1.2.1 +++ help.c 1 Jul 2003 16:04:12 -0000 1.1.2.2 @@ -5,13 +5,13 @@ 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 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 = command\"\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:\n\n"); + fprintf(outfp, "\n\nAvailable commands are (always preceded by CALL):\n\n"); /* Get total number of commands */ while (cmd_list[count].cmd) @@ -21,9 +21,10 @@ void do_help() { if (count %4) d++; for (i=0; i < d; i++) { - if (cmd_list[i+d].cmd) { - if (cmd_list[i+2*d].cmd) { - if (cmd_list[i+3*d].cmd) + + 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); @@ -45,6 +46,11 @@ 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"); @@ -103,9 +109,13 @@ void usage_cmpbufs() void usage_init() { - fprintf(outfp, "init: initilizes libsysio to default values for root directory and \n"); - fprintf(outfp, " : current directory. Must be called before any other libsysio calls\n"); - fprintf(outfp, " : Returns 0 on success, -1 on failure\n"); + 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() Index: helper.pm =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/helper.pm,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 --- helper.pm 30 May 2003 18:14:15 -0000 1.1.2.1 +++ helper.pm 1 Jul 2003 16:04:12 -0000 1.1.2.2 @@ -21,7 +21,14 @@ sub print_and_exit # Clean up my $cmdstr = 'FREE $buf'; $cmdstr = $cmdstr."\n"; - send_cmd($cmdfh, $outfh, "FREE", $cmdstr); + + 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; @@ -70,7 +78,7 @@ sub verify_cmd my $err = <$outfh>; chop($err); - print_and_exit($cmdfh, $outfh, 1, "ERROR! $cmd returned $res\n"); + print_and_exit($cmdfh, $outfh, 1, "ERROR! $cmd returned $err\n"); } return $res; } @@ -82,12 +90,41 @@ 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(1, $str); + 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{} Index: sysio_stubs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/sysio_stubs.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 --- sysio_stubs.c 30 May 2003 18:14:15 -0000 1.1.2.1 +++ sysio_stubs.c 1 Jul 2003 16:04:12 -0000 1.1.2.2 @@ -98,6 +98,7 @@ int do_fillbuff(int argc, char **argv) DBG(2, fprintf(outfp, "fillbuff requires a value, a type, a size, an offset, and the target buffer\n")); + fprintf(stderr, "fillbuff requires 5 args, you gave %d\n", argc); return INVALID_ARGS; } @@ -112,7 +113,7 @@ int do_fillbuff(int argc, char **argv) DBG(2, fprintf(outfp, "Can't find buffer at %s\n", argv[4])); return INVALID_VAR; } - buf = buflist[index]->buf+offset; + buf = (char *)(buflist[index]->buf)+offset; DBG(4, fprintf(outfp, "Buffer start is at %p\n", buflist[index])); @@ -157,6 +158,8 @@ int do_fillbuff(int argc, char **argv) } else { DBG(2, fprintf(outfp, "Unknown type %s. Valid types are UINT, STR, and PTR\n", typestr)); + fprintf(stderr, "Unknown type %s. Valid types are UINT, STR, and PTR\n", + typestr); return INVALID_ARGS; } @@ -238,15 +241,19 @@ int do_printbuf(int argc, char **argv) index = mobj->obj; buf_st = buflist[index]; + DBG(2, fprintf(outfp, "buf_st is %x:\n", buf_st)); buf = buf_st->buf; DBG(2, fprintf(outfp, "buf %s:\n", argv[0])); if (mobj->type == STR) { sprintf(output, "\n%s", (char *)buf); } else { sprintf(output,"%s\n", output); + DBG(2, fprintf(outfp, "buf_st->len is %d, buf is %x\n", buf_st->len, buf)); if (argc == 1) { for (i = 0; i < buf_st->len/4; i++) + DBG(2, fprintf(outfp, "%#x ", ((int *)buf)[i])); sprintf(output, "%s%#x ", output, ((int *)buf)[i]); + } for (i = 1; i < argc; i++) { @@ -297,6 +304,28 @@ int do_mount(int argc, char **argv) return SUCCESS; } +int do_clear(int argc, char **argv) +{ + int index; + struct buf_t *buf; + + if (argc != 1) { + DBG(2, fprintf(outfp, "Invalid number of args (%d) for clear\n", + argc)); + return INVALID_ARGS; + } + index = get_obj(argv[0]); + if (index < 0) { + fprintf(outfp, "Unable to locate buffer %s\n", + argv[0]); + return -1; + } + buf = buflist[index]; + bzero(buf->buf, buf->len); + + return SUCCESS; +} + int do_list(int argc, char **argv) { char *buf; @@ -321,12 +350,46 @@ int do_list(int argc, char **argv) return sysio_list(*argv); } -int do_init(int argc, char **args) +/* + * Initlizes sysio library. Will use default initlization + * unless arguments are given + */ +int do_init(int argc, char **argv) { - if ((argc) || (args)) { - DBG(2, fprintf(outfp, "Expected no args for init\n")); + if (argc > 0) { + char *rdriver; + char *mpath; + int mflags, rsize, msize; + if (argc != 3) { + DBG(2, fprintf(outfp, "Invalid number of args (%d) for init\n", + argc)); + return INVALID_ARGS; + } + + rdriver = get_str(argv[0]); + rsize = sizeof(rdriver)+1; + if (rsize > 75) { + DBG(2, fprintf(outfp, "%s too long for root driver\n", rdriver)); + return INVALID_ARGS; + } + bzero(root_driver, 75); + memcpy(root_driver, rdriver, rsize); + + mpath = get_str(argv[1]); + msize = sizeof(mpath)+1; + if (msize > 250) { + DBG(2, fprintf(outfp, "%s too long for mount path\n", mpath)); + return INVALID_ARGS; + } + bzero(mntpath, 250); + memcpy(mntpath, mpath, msize); + + mflags = get_obj(argv[2]); + if (mflags == -1) { + DBG(2, fprintf(outfp, "Invalid flags argument %s\n", argv[2])); return INVALID_ARGS; } + } DBG(5, fprintf(outfp, "In do_init\n")); last_type = SINT; @@ -413,8 +477,10 @@ int do_exit(int argc, char **argv) if (argc) DBG(3, printf("Exiting with %d from %s\n", val, argv[0])); - fclose(outfp); + exit(val); + + return 0; } int get_buffer(int argc, char **argv) @@ -423,7 +489,7 @@ int get_buffer(int argc, char **argv) struct buf_t *buf; if (argc == 1) /* Just put size, not alignment */ - align = 8; + align = 16; else if (argc == 2) align = get_obj(argv[1]); else { @@ -444,8 +510,8 @@ int get_buffer(int argc, char **argv) buf->buf = alloc_buff32(size, align); buf->len = size; buflist[next] = buf; - DBG(3, fprintf(outfp, "Your buffer (%p) is at index %d\n", - buf, next)); + DBG(3, fprintf(outfp, "Your buffer (%p) (%p) is at index %d\n", + buf, buf->buf, next)); next++; last_type = PTR; @@ -498,6 +564,7 @@ int cmp_bufs(int argc, char **argv) argv[0]); return -1; } + buf1 = buflist[index1]->buf; index2 = get_obj(argv[1]); if (index2 < 0) { @@ -506,7 +573,7 @@ int cmp_bufs(int argc, char **argv) return -1; } - + buf2 = buflist[index2]->buf; res = strcmp(buf1, buf2); DBG(3, fprintf(outfp, "strcmp returned %d\n", res)); @@ -550,12 +617,9 @@ int do_chown(int argc, char **argv) int do_open(int argc, char **argv) { char *name = argv[0]; - int flags; + int flags = O_RDWR; - if (!flags) { - /* Default to O_RDWR */ - flags |= O_RDWR; - } else + if (argc > 1) flags = get_obj(argv[1]); if (name[0] == '$') { @@ -709,7 +773,6 @@ int do_fcntl(int argc, char **argv) struct cmd_map *cmd; int fd; - int ret; /* * get_cmd translates a symbolic command into @@ -734,7 +797,7 @@ int do_fcntl(int argc, char **argv) last_ret_val = sysio_fcntl(fd, cmd, argv[2]); else last_ret_val = sysio_fcntl(fd, cmd, NULL); - DBG(4, fprintf(outfp, "Got return value of %d\n", ret)); + DBG(4, fprintf(outfp, "Got return value of %d\n", last_ret_val)); my_errno = errno; last_type = SINT; @@ -2113,17 +2176,18 @@ int do_mknod(int argc, char **argv) int dev; if (argc != 3) { - fprintf(outfp, "Invalid number of args (%d) for mknod\n", argc); + DBG(2, fprintf(outfp, "Invalid number of args (%d) for mknod\n", argc)); return INVALID_ARGS; } dev = get_obj(argv[2]); if (dev < 0) { - fprintf(outfp, "Unable to understand %s\n", argv[2]); + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); return INVALID_ARGS; } last_type = SINT; + return sysio_mknod(argv[0], argv[1], (dev_t) dev); } Index: sysio_tests.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/sysio_tests.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 --- sysio_tests.c 30 May 2003 18:14:15 -0000 1.1.2.1 +++ sysio_tests.c 1 Jul 2003 16:04:12 -0000 1.1.2.2 @@ -269,7 +269,7 @@ int sysio_chdir(char *newdir) my_perror(newdir); return -1; } - + /* buf = getcwd(NULL, 0); if (!buf) { my_perror(newdir); @@ -280,6 +280,7 @@ int sysio_chdir(char *newdir) DBG(4, sprintf(output, "New dir is %s\n", buf)); free(buf); + */ return SUCCESS; } @@ -655,19 +656,19 @@ int sysio_fcntl(int fd, struct cmd_map* void print_stat(struct stat *st) { DBG(3, sprintf(output, "%sstruct stat: \n", output)); - DBG(3, sprintf(output, "%s st_dev: %#10x\n", output, (unsigned int)st->st_dev)); - DBG(3, sprintf(output, "%s st_ino: %#10x\n", output, (unsigned int) st->st_ino)); - DBG(3, sprintf(output, "%s st_mode: %o\n", output, st->st_mode)); - DBG(3, sprintf(output, "%s st_nlink: %d\n", output, st->st_nlink)); - DBG(3, sprintf(output, "%s st_uid: %d\n", output, st->st_uid)); - DBG(3, sprintf(output, "%s st_gid: %d\n", output, st->st_gid)); - DBG(3, sprintf(output, "%s st_rdev: %d\n", output, (int)st->st_rdev)); - DBG(3, sprintf(output, "%s st_size: %d\n", output, (int) st->st_size)); - DBG(3, sprintf(output, "%s st_blksize: %d\n", output, (int) st->st_blksize)); - DBG(3, sprintf(output, "%s st_blocks: %d\n", output, (int) st->st_blocks)); - DBG(3, sprintf(output, "%s st_atime: %#10x\n", output, (unsigned int) st->st_atime)); - DBG(3, sprintf(output, "%s st_mtime: %#10x\n", output, (unsigned int) st->st_mtime)); - DBG(3, sprintf(output, "%s st_ctime: %#10x", output, (unsigned int) st->st_ctime)); + 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) @@ -726,11 +727,18 @@ int sysio_getdirentries(int fd, char *bu err = getdirentries(fd, buf, nbytes, basep); last_ret_val = err; - DBG(4, sprintf(output, "Read %d bytes\n", err)); + DBG(4, sprintf(output, "%sRead %d bytes\n", output, err)); dp = (struct dirent *)buf; while (err > 0) { - DBG(3, sprintf(output, "\t%s: ino %llu off %llu len %x type %c\n", + 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, @@ -879,16 +887,7 @@ int sysio_mknod(char *path, char *mode_a int err; int 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); + mode = get_obj(mode_arg); if (mode < 0) { DBG(2,sprintf(output, "Cant get mode from %s\n", mode_arg)); Index: test_copy.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_copy.pl,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 --- test_copy.pl 30 May 2003 18:14:15 -0000 1.1.2.1 +++ test_copy.pl 1 Jul 2003 16:04:12 -0000 1.1.2.2 @@ -20,11 +20,15 @@ sub usage sub process_cmd { - my ($src, $dest) = @_; + 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 ($@) { @@ -39,8 +43,9 @@ sub process_cmd my $outfh = \*OUTFILE; my $cmdfh = \*CMDFILE; + if ($is_alpha == 0) { helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); - + } # Get the filesize of src my $size = -s $src; @@ -103,14 +108,21 @@ sub process_cmd helper::print_and_exit($cmdfh, $outfh, 0, "copy test successful\n"); } -if (@ARGV != 2) { +my $currarg = 0; +my $is_alpha = 0; + +if (@ARGV < 2) { usage; +} elsif (@ARGV > 2 ) { + if ($ARGV[$currarg++] eq "-alpha") { + $is_alpha = 1; + } } -my $src = $ARGV[0]; -my $dest = $ARGV[1]; +my $src = $ARGV[$currarg++]; +my $dest = $ARGV[$currarg]; -process_cmd($src, $dest); +process_cmd($src, $dest, $is_alpha); exit 0; Index: test_driver.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_driver.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 --- test_driver.c 30 May 2003 18:14:15 -0000 1.1.2.1 +++ test_driver.c 1 Jul 2003 16:04:12 -0000 1.1.2.2 @@ -42,6 +42,7 @@ struct cmd_t cmd_list[] = { {"chdir", do_chdir, usage_chdir}, {"chmod", do_chmod, usage_chmod}, {"chown", do_chown, usage_chown}, + {"clear", do_clear, usage_clear}, {"close", do_close, usage_close}, {"cmpstr", cmp_bufs, usage_cmpbufs}, {"creat", do_creat, usage_creat}, @@ -116,10 +117,22 @@ cmd_tree* build_tree(char **cmd, int *le void * alloc_buff32(unsigned int size, int align) { void* buf; - - if (posix_memalign(&buf, align, size)) + long buf_ptr; + int err; + /* + if ((err = posix_memalign(&buf, align, size)) != 0) { + perror("posix_memalign"); return 0; - return buf; + } + */ + size += align; + buf = malloc(size); + align--; + DBG(3, fprintf(outfp, "Buf is at %p\n", (void *)buf)); + buf_ptr = (long)buf + ((long)buf & align); + + DBG(3, fprintf(outfp, "Buf is at %p\n", (void *)buf_ptr)); + return (void *)buf_ptr; } void free_buf32(void * ptr) @@ -180,7 +193,7 @@ struct var_mapping *get_map(char *var_na curr = &map[index]; while ((curr) && (curr->map.obj != -1) ) { - if (strcmp(curr->map.name, var_name)) + if ( (curr->map.name == NULL) || (strcmp(curr->map.name, var_name)) ) curr = curr->next; else return &curr->map; @@ -211,7 +224,6 @@ int get_obj(char *var_name) if (isdigit(var_name[0])) return atoi(var_name); - /* * Check for '|', indicates that one or more values are or'd * together @@ -226,6 +238,13 @@ int get_obj(char *var_name) memcpy(str1, var_name, i); memcpy(str2, (char *)&var_name[i+1], strlen(var_name)-i); + if (isdigit(str1[0])) { + if (str1[0] == '0') { + /* Assume octal format */ + obj = strtol(str1, NULL, 8); + } else + obj = atoi(str1); + } else { tmp_map = get_map(str1); if (!tmp_map) { free(str1); @@ -233,6 +252,15 @@ int get_obj(char *var_name) return -1; } obj = tmp_map->obj; + } + + if (isdigit(str2[0])) { + if (str2[0] == '0') { + /* Assume octal format */ + obj |= strtol(str2, NULL, 8); + } else + obj = atoi(str2); + } else { tmp_map = get_map(str2); if (!tmp_map) { free(str1); @@ -240,6 +268,7 @@ int get_obj(char *var_name) return -1; } obj |= tmp_map->obj; + } free(str1); free(str2); return obj; @@ -446,10 +475,13 @@ int run_cmd(cmd_tree *cmd_arg) char **args; int res, i; struct buf_t *buf; - char *cmd = cmd_arg->val; + char *cmd; struct queue_t *child; + if (cmd_arg == NULL) + return INVALID_CMD; + cmd = cmd_arg->val; cmdptr = cmdstr; child = cmd_arg->children; if ( (!strcmp("exit", cmd)) || (!strcmp("quit", cmd)) || @@ -593,6 +625,33 @@ int add_args(char **cmd, int length, int return total; } +void free_tree(cmd_tree* tree) +{ + if (!tree) + return; + + if (tree->children) { + struct queue_t *child = tree->children; + struct queue_t *next; + do { + next = child->next; + if (child->cmd) + free_tree(child->cmd); + free(child->val); + free(child); + child = next; + } while (child); + } + + if (tree->res_name) + free(tree->res_name); + + if (tree->val) + free(tree->val); + + free(tree); +} + cmd_tree* build_tree(char **cmd, int *length, int total) { int index = 0, used_args = 0; @@ -666,7 +725,6 @@ char *getline(char *prompt) while (feof(infp) && (line[i] != '\n')) { clearerr(infp); count++; - sleep(0.05); fseek(infp, 0, SEEK_CUR); } } else { @@ -725,6 +783,12 @@ struct var_mapping flags_map[] = { {"S_IROTH", S_IROTH, UINT }, {"S_IWOTH", S_IWOTH, UINT }, {"S_IXOTH", S_IXOTH, UINT }, + {"S_IFCHR", S_IFCHR, UINT }, + {"S_IFMT", S_IFMT, UINT }, + {"S_IFBLK", S_IFBLK, UINT }, + {"S_IFREG", S_IFREG, UINT }, + {"S_IFIFO", S_IFIFO, UINT }, + {"S_IFLNK", S_IFLNK, UINT }, { NULL, -1, SINT } }; @@ -740,9 +804,10 @@ void init_map() int main(int argc, char *argv[]) { - int count, err, i; + int count, err, i, orig_count; char *input, *name; char **cmd; + cmd_tree *tree; infp = stdin; outfp = stdout; @@ -803,7 +868,7 @@ int main(int argc, char *argv[]) bzero(output, 4096); input = getline("> "); cmd = malloc(MAX_COMMAND * sizeof(char *)); - count = parser(input, cmd); + count = orig_count = parser(input, cmd); name = NULL; if ((!count) || (count > MAX_COMMAND)){ fprintf(outfp, "%s: invalid command\n", input); @@ -820,12 +885,17 @@ int main(int argc, char *argv[]) count--; } i++; - err = run_cmd(build_tree(&cmd[i], &count, 0)); + tree = build_tree(&cmd[i], &count, 0); + err = run_cmd(tree); store_result((char *)(&cmd[0][1]), last_ret_val); - } else - err = run_cmd(build_tree(cmd, &count, 0)); + } else { + tree = build_tree(cmd, &count, 0); + err = run_cmd(tree); + } /* Print out return code and any string from command */ fprintf(outfp, "%#04x %s\n", err, output); + if (tree) + free_tree(tree); /* fprintf(stderr, "%#04x %s\n", err, output); */ for (i=0; i < count; i++) free(cmd[i]); Index: test_driver.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_driver.h,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 --- test_driver.h 30 May 2003 18:14:15 -0000 1.1.2.1 +++ test_driver.h 1 Jul 2003 16:04:12 -0000 1.1.2.2 @@ -153,6 +153,7 @@ extern int do_chmod(int argc, char **arg extern int do_chown(int argc, char **args); extern int do_open(int argc, char **args); extern int do_close(int argc, char **args); +extern int do_clear(int argc, char **argv); extern int do_dup(int argc, char **args); extern int do_dup2(int argc, char **args); extern int do_fcntl(int argc, char **args); @@ -236,6 +237,7 @@ extern void usage_chmod(); extern void usage_chown(); extern void usage_open(); extern void usage_close(); +extern void usage_clear(); extern void usage_mount(); extern void usage_dup(); extern void usage_dup2(); Index: test_getcwd.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_getcwd.pl,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 --- test_getcwd.pl 30 May 2003 18:14:15 -0000 1.1.2.1 +++ test_getcwd.pl 1 Jul 2003 16:04:12 -0000 1.1.2.2 @@ -1,12 +1,5 @@ #!/usr/bin/perl -w -# -# getcwd test: Tests chdir and getcwd; will first verify that getcwd returns -# the current working directory and will then call chdir and verify -# that getcwd reflects the new directory -# -# - use IPC::Open2; use strict; @@ -14,9 +7,10 @@ use helper; sub usage { - print "Usage: ./test_getcwd.pl <dir> : Test getcwd by verifying that it returns the\n"; - print " : current directory and then setting the directory\n"; - print " : to dir and verifying that getcwd reflects the change\n"; + print "Usage: ./test_getcwd.pl <dir> : Test getcwd by verifying that it \n"; + print " : setting the directory to dir and \n"; + print " : verifying that getcwd reflects \n"; + print " : the change\n"; exit(-1); } @@ -47,10 +41,15 @@ sub check_wkdir sub process_cmd { - my ($dir) = @_; + my ($dir, $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 ($@) { @@ -65,12 +64,14 @@ sub process_cmd my $outfh = \*OUTFILE; my $cmdfh = \*CMDFILE; + if ($is_alpha == 0) { helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); # Get current working directory from environment my $cwd = $ENV{PWD}; check_wkdir($cwd, $outfh, $cmdfh); + } # Now change to dir helper::send_cmd($cmdfh, $outfh, "chdir", "CALL chdir $dir\n"); @@ -85,12 +86,23 @@ sub process_cmd } -if (@ARGV != 1) { +my $currarg = 0; +my $is_alpha = 0; + +if (@ARGV < 1) { usage; +} elsif (@ARGV > 1) { + if ($ARGV[$currarg++] eq "-alpha") { + $is_alpha = 1; + } } -my $dir = $ARGV[0]; +my $dir = $ARGV[$currarg]; -process_cmd($dir); +process_cmd($dir, $is_alpha); exit 0; + + + + Index: test_list.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_list.pl,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 --- test_list.pl 30 May 2003 18:14:15 -0000 1.1.2.1 +++ test_list.pl 1 Jul 2003 16:04:12 -0000 1.1.2.2 @@ -14,30 +14,36 @@ use helper; sub usage { - print "Usage: ./test_list.pl [-p] <dir> \n"; - print " ./test_list.pl -m [-p] fstype:mdir dir\n"; - print " In the first form, will compare output of libsysio's getdirentries\n"; - print " with that of Perl's readdir. If no dir is given, will use the \n"; + print "Usage: ./test_list.pl [-p|-ni] <dir> \n"; + print " ./test_list.pl -m [-p|-alpha] fstype:mdir dir\n"; + print " In the first form, will attempt to verify libsysio's\n"; + print " getdirentries. If no dir is given, will use the \n"; print " current working directory\n"; print " In the second form, will mount the given mdir (of type fstype) in dir.\n"; - print " It will then compare the output of libsysio's getdirentries on the \n"; - print " filesystem with Perl's readdir on the original mdir. It will then \n"; - print " umount the directory and verify that the umount worked\n"; + print " It will then verify the output of libsysio's getdirentries. It will \n"; + print " then umount the directory and verify that the umount worked\n"; print " The -p option will print the directory listing\n"; + print " The -alpha option is for alpha architecture \n"; exit(-1); } sub write_print { - my ($offset, $outfh, $cmdfh, $do_print) = @_; + my ($offset, $outfh, $cmdfh, $do_print, $is_alpha) = @_; my $bytes = 0; - my $shortoffset = $offset+8; + my $intsize = 8; + my $intcmd = "INT"; + if ($is_alpha == 1) { + $intsize = 16; + $intcmd = "LONG" + } + my $shortoffset = $offset+$intsize; my $charoffset = $shortoffset+2; my $stroffset = $charoffset+1; my $cmdstr = 'PRINT $buf '. - "$offset 8 INT $shortoffset 2 SHORT $charoffset 1 CHAR $stroffset 1 STR\n"; + "$offset $intsize $intcmd $shortoffset 2 SHORT $charoffset 1 CHAR $stroffset 1 STR\n"; helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); my $res = <$outfh>; @@ -58,7 +64,7 @@ sub write_print sub do_print_cmds { - my ($numbytes, $outfh, $cmdfh, $start, $do_print) = @_; + my ($numbytes, $outfh, $cmdfh, $start, $do_print, $is_alpha) = @_; my $offset = 0; my $bytes = 0; @@ -69,13 +75,17 @@ sub do_print_cmds $numbytes = 8192; } while ($bytes < $numbytes) { - my $len = write_print($offset, $outfh, $cmdfh, $do_print); + my $len = write_print($offset, $outfh, $cmdfh, $do_print, $is_alpha); if ($len <= 0) { # write_print saw a 0 length record, indicating end of dir return $numfiles; } $numfiles++; + if ($is_alpha == 0) { $len += $len%4; + } else { + $len += $len%8; + } $offset += $len; $bytes += $len; $i++; @@ -86,7 +96,7 @@ sub do_print_cmds sub print_dir_cmd { - my ($outfh, $cmdfh, $start, $mdir, $do_print) = @_; + my ($outfh, $cmdfh, $start, $mdir, $do_print, $is_alpha) = @_; my $cmdstr = "CALL getdirentries ( ".'$fd = CALL open '."$mdir O_RDONLY ) ( "; $cmdstr .= '$buf = ALLOC 8192 ) 8192 $basep'."\n"; @@ -98,7 +108,7 @@ sub print_dir_cmd while ($numbytes > 0) { - do_print_cmds($numbytes, $outfh, $cmdfh, $start, $do_print); + do_print_cmds($numbytes, $outfh, $cmdfh, $start, $do_print, $is_alpha); $cmdstr = "CALL getdirentries ".'$fd $buf 8192 $basep'."\n"; helper::send_cmd($cmdfh, $outfh, "getdirentries", $cmdstr); @@ -111,12 +121,16 @@ sub print_dir_cmd sub process_cmd { - my ($mdir, $tdir, $do_mount, $do_print) = @_; + my ($mdir, $tdir, $do_mount, $is_alpha, $do_print) = @_; my $size = 8192; my $done_files = 0; eval { + if ($is_alpha == 1) { + open2(\*OUTFILE, \*CMDFILE, "yod -quiet -sz 1 ./test_driver --np"); + } else { open2(\*OUTFILE, \*CMDFILE, "./test_driver --np"); + } }; if ($@) { @@ -131,15 +145,17 @@ sub process_cmd my $outfh = \*OUTFILE; my $cmdfh = \*CMDFILE; + if ($is_alpha == 0) { helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); + } my $start = 0; if ($do_mount == 1) { helper::send_cmd($cmdfh, $outfh, "mount", "CALL mount $mdir $tdir\n"); - print_dir_cmd($outfh, $cmdfh, $start, $tdir, $do_print); + print_dir_cmd($outfh, $cmdfh, $start, $tdir, $do_print, $is_alpha); } else { - print_dir_cmd($outfh, $cmdfh, $start, $mdir, $do_print); + print_dir_cmd($outfh, $cmdfh, $start, $mdir, $do_print, $is_alpha); } # Attempt to unmount and verify the contents @@ -181,6 +197,7 @@ sub process_cmd my @mydir; $mydir[0] = "./"; my $do_mount = 0; +my $is_alpha = 0; my $do_print = 0; my $dircnt = 0; for (my $i = 0; $i < @ARGV; $i++) @@ -189,6 +206,8 @@ for (my $i = 0; $i < @ARGV; $i++) $do_print = 1; } elsif ($ARGV[$i] eq "-m") { $do_mount = 1; + } elsif ($ARGV[$i] eq "-alpha") { + $is_alpha = 1; } else { $mydir[$dircnt] = $ARGV[$i]; $dircnt++; @@ -207,6 +226,6 @@ if ($do_mount == 1) { ($fstype, $dir) = split(/:/, $mydir[0]); } -process_cmd($mydir[0], $mydir[1], $do_mount, $do_print); +process_cmd($mydir[0], $mydir[1], $do_mount, $is_alpha, $do_print); exit 0; Index: test_path.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_path.pl,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 --- test_path.pl 30 May 2003 18:14:15 -0000 1.1.2.1 +++ test_path.pl 1 Jul 2003 16:04:12 -0000 1.1.2.2 @@ -80,12 +80,17 @@ sub process_path sub process_cmd { - my ($usestdin, @paths) = @_; + my ($usestdin, $isalpha, @paths) = @_; my $path; eval { + if ($isalpha == 0) { open2(\*OUTFILE, \*CMDFILE, "./test_driver --np"); + } else { + open2(\*OUTFILE, \*CMDFILE, + "yod -batch -quiet -sz 1 ./test_driver --np"); + } }; if ($@) { @@ -99,7 +104,9 @@ sub process_cmd my $outfh = \*OUTFILE; my $cmdfh = \*CMDFILE; + if ($isalpha == 0) { helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); + } # Allocate the stat buffer my $cmdstr = '$buf = ALLOC ( $size = CALL sizeof stat )'; @@ -135,9 +142,18 @@ sub process_cmd my $usestdin = 0; +my $isalpha = 0; + +# The -alpha arg must be before the paths +# (if they exist) +if ( (@ARGV > 0) && ($ARGV[0] eq "-alpha")) { + $isalpha = 1; + pop(@ARGV); +} + if (@ARGV == 0) { $usestdin = 1; } -process_cmd($usestdin, @ARGV); +process_cmd($usestdin, $isalpha, @ARGV); Index: test_stats.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Attic/test_stats.pl,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 --- test_stats.pl 30 May 2003 18:14:15 -0000 1.1.2.1 +++ test_stats.pl 1 Jul 2003 16:04:12 -0000 1.1.2.2 @@ -8,13 +8,6 @@ # # -# -# Usage ./test_stats.pl file: Verifies that the set of stat calls (stat, fstat, fstatvfs, and -# : 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) -# -# use IPC::Open2; use strict; @@ -22,11 +15,11 @@ use helper; sub usage { - print "Usage ./test_stats.pl file : Verifies that the set of stat calls (stat, fstat,\n"; - print " : fstatvfs, statvfs) return the same set of stats for \n"; - print " : file and that the calls return the same items as Perl's \n"; - print " : stat call (which would use a native library and not \n"; - print " : libsysio)\n"; + print "Usage ./test_stats.pl file : Verifies that the set of stat calls (stat, \n"; + print " : fstat, fstatvfs, statvfs) return the same set\n"; + print " : of stats for file and that the calls return the\n"; + print " : same items as Perl's stat call (which would use\n"; + print " : a native library and not libsysio)\n"; exit(-1); } @@ -35,13 +28,22 @@ sub usage sub cmp_stats { - my ( $cmdfh, $outfh, - $iodev, $ioino, $iomode, $ionlink, $iouid, $iogid, $iordev, - $iosize, $ioblksize, $ioblks, $ioatime, $iomtime, $ioctime, - $pdev, $pino, $pmode, $pnlink, $puid, $pgid, $prdev, - $psize, $patime, $pmtime, $pctime, $pblksize, $pblks) = @_; + my ( $cmdfh, $outfh, $is_alpha, @stats) = @_; - helper::cmp_nums($cmdfh, $outfh, $iodev, $pdev, "device numbers"); + + my ($iodev, $ioino, $iomode, $ionlink, $iouid, $iogid, $iordev, + $iosize, $ioblksize, $ioblks, $ioatime, $iomtime, $ioctime, @pstats) = + @stats; + + if ($is_alpha == 1) { + ($iodev, $ioino, $iomode, $ionlink, $iouid, $iogid, $iordev, + $iosize, $ioatime, $iomtime, $ioctime, $ioblks, $ioblksize, @pstats) = + @stats; + } + my ($pdev, $pino, $pmode, $pnlink, $puid, $pgid, $prdev, + $psize, $patime, $pmtime, $pctime, $pblksize, $pblks) = @pstats; + +# helper::cmp_nums($cmdfh, $outfh, $iodev, $pdev, "device numbers"); helper::cmp_nums($cmdfh, $outfh, $ioino, $pino, "inode numbers"); helper::cmp_nums($cmdfh, $outfh, $iomode, $pmode, "file modes"); helper::cmp_nums($cmdfh, $outfh, $ionlink, $pnlink, "number of links"); @@ -61,11 +63,16 @@ sub cmp_stats # Perl's output sub verify_stat { - my ($cmdfh, $outfh, $cmd, @stats) = @_; + my ($cmdfh, $outfh, $cmd, $is_alpha, @stats) = @_; my $i=0; + my $cmdstr; # Print out the stat buffer - my $cmdstr = 'PRINT $buf 0 8 LONG 12 24 INT 44 8 LONG 52 8 INT 64 24 LONG'."\n"; + if ($is_alpha == 0) { + $cmdstr = 'PRINT $buf 0 8 LONG 12 24 INT 44 8 LONG 52 8 INT 64 24 LONG'."\n"; + } else { + $cmdstr = 'PRINT $buf 0 16 LONG 16 16 INT 32 8 LONG 40 4 INT 48 40 LONG'."\n"; + } helper::send_cmd($cmdfh, $outfh, "PRINT", $cmdstr); my $res = <$outfh>; @@ -76,16 +84,21 @@ sub verify_stat $i++; } - cmp_stats($cmdfh, $outfh, @iostats, @stats); + cmp_stats($cmdfh, $outfh, $is_alpha, @iostats, @stats); } sub process_cmd { - my ($file) = $_[0]; + my ($file, $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 ($@) { @@ -100,8 +113,9 @@ sub process_cmd my $outfh = \*OUTFILE; my $cmdfh = \*CMDFILE; + if ($is_alpha == 0) { helper::send_cmd($cmdfh, $outfh, "init", "CALL init\n"); - + } # Get stats for file my @stats = stat($file); @@ -116,9 +130,11 @@ sub process_cmd helper::send_cmd($cmdfh, $outfh, "stat", $cmdstr); helper::verify_cmd($cmdfh, $outfh, "stat"); + #if ($is_alpha == 0) { # Now print the buffer out and verify that it matches # what Perl has - verify_stat($cmdfh, $outfh, "stat", @stats); + verify_stat($cmdfh, $outfh, "stat", $is_alpha, @stats); + #} # Open the file $cmdstr = '$fd = CALL open '."$file O_RDONLY\n"; @@ -131,7 +147,7 @@ sub process_cmd helper::send_cmd($cmdfh, $outfh, "fstat", $cmdstr); helper::verify_cmd($cmdfh, $outfh, "fstat"); - verify_stat($cmdfh, $outfh, "fstat", @stats); + verify_stat($cmdfh, $outfh, "fstat", $is_alpha, @stats); # Test lstat @stats = lstat($file); @@ -140,7 +156,7 @@ sub process_cmd helper::send_cmd($cmdfh, $outfh, "lstat", $cmdstr); helper::verify_cmd($cmdfh, $outfh, "lstat"); - verify_stat($cmdfh, $outfh, "lstat", @stats); + verify_stat($cmdfh, $outfh, "lstat", $is_alpha, @stats); # Now do statvfs functions @@ -190,11 +206,20 @@ sub process_cmd } -if (@ARGV != 1) { + + +my $currarg = 0; +my $is_alpha = 0; +if (@ARGV < 1) { usage; +} elsif (@ARGV > 1) { + if ($ARGV[$currarg++] eq "-alpha") { + $is_alpha = 1; + } } -my $file = $ARGV[0]; -process_cmd($file); +my $file = $ARGV[$currarg]; + +process_cmd($file, $is_alpha); |
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv5026/src Modified Files: Tag: b_lustre chdir.c chmod.c chown.c dup.c fcntl.c fsync.c getdirentries.c init.c ioctl.c lseek.c mkdir.c mknod.c open.c read.c rmdir.c stat.c stat64.c statvfs.c statvfs64.c symlink.c truncate.c unlink.c write.c Log Message: make lustre could hook functions on when enter/leave system calls. Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.3.8.1 retrieving revision 1.3.8.2 diff -u -w -b -B -p -r1.3.8.1 -r1.3.8.2 --- chdir.c 17 Jun 2003 05:46:57 -0000 1.3.8.1 +++ chdir.c 29 Jun 2003 10:15:32 -0000 1.3.8.2 @@ -84,10 +84,12 @@ chdir(const char *path) { int err; struct pnode *pno; + SYSIO_ENTER; err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); if (err) { errno = -err; + SYSIO_LEAVE; return -1; } @@ -95,6 +97,7 @@ chdir(const char *path) P_RELE(_sysio_cwd); _sysio_cwd = pno; + SYSIO_LEAVE; return 0; } @@ -104,6 +107,7 @@ getwd(char *buf) size_t len, n; struct pnode *tmp; char *cp; + SYSIO_ENTER; /* * First pass: Traverse to the root of the sub-tree, remembering @@ -151,6 +155,7 @@ getwd(char *buf) tmp = tmp->p_mount->mnt_root; } while (tmp != tmp->p_parent); + SYSIO_LEAVE; return buf; } @@ -240,11 +245,14 @@ char * getcwd(char *buf, size_t size) { int err; + SYSIO_ENTER; err = _sysio_p_path(_sysio_cwd, &buf, buf ? size : 0); if (err) { errno = -err; + SYSIO_LEAVE; return NULL; } + SYSIO_LEAVE; return buf; } Index: chmod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chmod.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 --- chmod.c 17 Jun 2003 03:38:31 -0000 1.3.4.1 +++ chmod.c 29 Jun 2003 10:15:32 -0000 1.3.4.2 @@ -59,6 +59,7 @@ chmod(const char *path, mode_t mode) struct pnode *pno; struct intnl_stat stbuf; unsigned mask; + SYSIO_ENTER; err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); if (err) @@ -73,5 +74,6 @@ out: errno = -err; err = -1; } + SYSIO_LEAVE; return err; } Index: chown.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chown.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -w -b -B -p -r1.3 -r1.3.4.1 --- chown.c 24 Mar 2003 22:09:06 -0000 1.3 +++ chown.c 29 Jun 2003 10:15:32 -0000 1.3.4.1 @@ -59,6 +59,7 @@ chown(const char *path, uid_t owner, gid struct pnode *pno; struct intnl_stat stbuf; unsigned mask; + SYSIO_ENTER; err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); if (err) @@ -83,5 +84,6 @@ out: errno = -err; err = -1; } + SYSIO_LEAVE; return err; } Index: dup.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/dup.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.12.1 diff -u -w -b -B -p -r1.1.1.1 -r1.1.1.1.12.1 --- dup.c 22 Feb 2003 16:33:05 -0000 1.1.1.1 +++ dup.c 29 Jun 2003 10:15:32 -0000 1.1.1.1.12.1 @@ -52,21 +52,34 @@ int dup2(int oldfd, int newfd) { + int rc; + SYSIO_ENTER; if (newfd < 0) { errno = EBADF; + SYSIO_LEAVE; return -1; } - if (oldfd == newfd) + if (oldfd == newfd) { + SYSIO_LEAVE; return newfd; + } + + rc = _sysio_fd_dup2(oldfd, newfd); - return _sysio_fd_dup2(oldfd, newfd); + SYSIO_LEAVE; + return rc; } int dup(int oldfd) { + int rc; + SYSIO_ENTER; + + rc = _sysio_fd_dup2(oldfd, -1); - return _sysio_fd_dup2(oldfd, -1); + SYSIO_LEAVE; + return rc; } Index: fcntl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fcntl.c,v retrieving revision 1.3.2.3 retrieving revision 1.3.2.4 diff -u -w -b -B -p -r1.3.2.3 -r1.3.2.4 --- fcntl.c 19 Jun 2003 12:18:29 -0000 1.3.2.3 +++ fcntl.c 29 Jun 2003 10:15:32 -0000 1.3.2.4 @@ -59,6 +59,7 @@ fcntl(int fd, int cmd, ...) int err; struct file *fil; va_list ap; + SYSIO_ENTER; err = 0; fil = _sysio_fd_find(fd); @@ -66,6 +67,7 @@ fcntl(int fd, int cmd, ...) va_start(ap, cmd); err = __bypass_fcntl(fd, cmd, ap); va_end(ap); + SYSIO_LEAVE; return err; } @@ -74,6 +76,7 @@ fcntl(int fd, int cmd, ...) case F_DUPFD: { long newfd; + int rc; va_start(ap, cmd); newfd = va_arg(ap, long); @@ -82,7 +85,10 @@ fcntl(int fd, int cmd, ...) err = -EBADF; goto out; } - return _sysio_fd_dup2(fd, (int )newfd); + rc = _sysio_fd_dup2(fd, (int )newfd); + + SYSIO_LEAVE; + return rc; } break; default: @@ -97,5 +103,6 @@ out: errno = -err; err = -1; } + SYSIO_LEAVE; return err; } Index: fsync.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fsync.c,v retrieving revision 1.2 retrieving revision 1.2.8.1 diff -u -w -b -B -p -r1.2 -r1.2.8.1 --- fsync.c 9 Mar 2003 06:22:43 -0000 1.2 +++ fsync.c 29 Jun 2003 10:15:32 -0000 1.2.8.1 @@ -55,17 +55,22 @@ fsync(int fd) { struct file *fil; int err; + SYSIO_ENTER; fil = _sysio_fd_find(fd); if (!(fil && fil->f_ino)) { errno = -EBADF; + SYSIO_LEAVE; return -1; } err = (*fil->f_ino->i_ops.inop_sync)(fil->f_ino); if (err) { errno = -err; + SYSIO_LEAVE; return -1; } + + SYSIO_LEAVE; return 0; } @@ -74,16 +79,21 @@ fdatasync(int fd) { struct file *fil; int err; + SYSIO_ENTER; fil = _sysio_fd_find(fd); if (!(fil && fil->f_ino)) { errno = -EBADF; + SYSIO_LEAVE; return -1; } err = (*fil->f_ino->i_ops.inop_datasync)(fil->f_ino); if (err) { errno = -err; + SYSIO_LEAVE; return -1; } + + SYSIO_LEAVE; return 0; } Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.1 retrieving revision 1.1.8.1 diff -u -w -b -B -p -r1.1 -r1.1.8.1 --- getdirentries.c 9 Mar 2003 13:53:53 -0000 1.1 +++ getdirentries.c 29 Jun 2003 10:15:32 -0000 1.1.8.1 @@ -68,6 +67,7 @@ getdirentries(int fd, char *buf, size_t size_t n; size_t reclen; char *cp; + SYSIO_ENTER; #define _dbaselen ((size_t )&((struct dirent *)0)->d_name[0]) #ifdef __GNUC__ @@ -93,6 +93,7 @@ getdirentries(int fd, char *buf, size_t ibuf = _fast_alloc(inbytes); if (!ibuf) { errno = ENOMEM; + SYSIO_LEAVE; return -1; } @@ -150,11 +151,13 @@ out: if (dp == (struct dirent *)buf && cc < 0) { errno = (int )-cc; + SYSIO_LEAVE; return -1; } cc = (char *)dp - buf; if (cc) *basep = od64p->d_off; + SYSIO_LEAVE; return cc; #ifdef __GNUC__ Index: init.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/init.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -w -b -B -p -r1.3 -r1.3.4.1 --- init.c 24 Mar 2003 22:09:06 -0000 1.3 +++ init.c 29 Jun 2003 10:15:32 -0000 1.3.4.1 @@ -56,6 +56,9 @@ #include "stdfd.h" #endif +int __sysio_in_syscall = 0; +__sysio_hook_func *__sysio_hook_sys_enter = NULL; +__sysio_hook_func *__sysio_hook_sys_leave = NULL; /* * Sysio library initialization. Must be called before anything else in the * library. Index: ioctl.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctl.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.12.1 diff -u -w -b -B -p -r1.1.1.1 -r1.1.1.1.12.1 --- ioctl.c 22 Feb 2003 16:33:07 -0000 1.1.1.1 +++ ioctl.c 29 Jun 2003 10:15:32 -0000 1.1.1.1.12.1 @@ -56,6 +56,7 @@ ioctl(int fd, unsigned long request, ... int err; struct file *fil; va_list ap; + SYSIO_ENTER; err = 0; fil = _sysio_fd_find(fd); @@ -73,5 +74,6 @@ out: errno = -err; err = -1; } + SYSIO_LEAVE; return err; } Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -w -b -B -p -r1.4 -r1.4.2.1 --- lseek.c 27 Apr 2003 13:20:01 -0000 1.4 +++ lseek.c 29 Jun 2003 10:15:32 -0000 1.4.2.1 @@ -110,6 +110,11 @@ sysio_sym_weak_alias(_sysio_lseek, lseek extern off_t lseek(int fd, off_t offset, int whence) { + off_t rc; + SYSIO_ENTER; - return (off_t )_sysio_lseek(fd, offset, whence); + rc = (off_t )_sysio_lseek(fd, offset, whence); + + SYSIO_LEAVE; + return rc; } Index: mkdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mkdir.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -w -b -B -p -r1.3 -r1.3.4.1 --- mkdir.c 24 Mar 2003 22:09:06 -0000 1.3 +++ mkdir.c 29 Jun 2003 10:15:32 -0000 1.3.4.1 @@ -58,6 +58,7 @@ mkdir(const char *path, mode_t mode) int err; struct intent intent; struct pnode *pno; + SYSIO_ENTER; INTENT_INIT(&intent, INT_CREAT, &mode, NULL); err = _sysio_namei(_sysio_cwd, path, ND_NEGOK, &intent, &pno); @@ -80,5 +81,7 @@ out: errno = -err; err = -1; } + + SYSIO_LEAVE; return err; } Index: mknod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mknod.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -w -b -B -p -r1.3 -r1.3.4.1 --- mknod.c 26 Mar 2003 00:06:05 -0000 1.3 +++ mknod.c 29 Jun 2003 10:15:32 -0000 1.3.4.1 @@ -110,8 +110,13 @@ out: static int __mknod(const char *path, mode_t mode, dev_t dev) { + int rc; + SYSIO_ENTER; - return __xmknod(_MKNOD_VER, path, mode, &dev); + rc = __xmknod(_MKNOD_VER, path, mode, &dev); + + SYSIO_LEAVE; + return rc; } sysio_sym_weak_alias(__mknod, mknod) Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.7.2.1 retrieving revision 1.7.2.2 diff -u -w -b -B -p -r1.7.2.1 -r1.7.2.2 --- open.c 17 May 2003 11:59:56 -0000 1.7.2.1 +++ open.c 29 Jun 2003 10:15:32 -0000 1.7.2.2 @@ -125,6 +125,7 @@ open(const char *path, int flags, ...) int err; struct pnode *pno; struct file *fil; + SYSIO_ENTER; /* * Get mode argument and determine parameters for namei @@ -187,6 +188,7 @@ open(const char *path, int flags, ...) P_RELE(pno); + SYSIO_LEAVE; return err; error: @@ -195,6 +197,7 @@ error: if (pno) P_RELE(pno); errno = -err; + SYSIO_LEAVE; return -1; } @@ -202,10 +205,12 @@ int close(int fd) { int err; + SYSIO_ENTER; err = _sysio_fd_close(fd); if (err) errno = -err; + SYSIO_LEAVE; return err ? -1 : 0; } Index: read.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/read.c,v retrieving revision 1.2.8.2 retrieving revision 1.2.8.3 diff -u -w -b -B -p -r1.2.8.2 -r1.2.8.3 --- read.c 19 Jun 2003 12:18:29 -0000 1.2.8.2 +++ read.c 29 Jun 2003 10:15:32 -0000 1.2.8.3 @@ -101,13 +101,19 @@ ipreadv(int fd, const struct iovec *iov, { struct file *fil; struct ioctx *ioctxp; - int i; + ioid_t rc; + SYSIO_ENTER; fil = _sysio_fd_find(fd); - if (!fil) - return __bypass_preadv(fd, iov, count, offset); + if (!fil) { + rc = __bypass_preadv(fd, iov, count, offset); + SYSIO_LEAVE; + return rc; + } ioctxp = do_ipreadv(fil, iov, count, offset); + + SYSIO_LEAVE; return ioctxp ? ioctxp->ioctx_id : IOID_FAIL; } @@ -162,15 +168,20 @@ ireadv(int fd, const struct iovec *iov, { struct file *fil; struct ioctx *ioctxp; + ioid_t rc; + SYSIO_ENTER; fil = _sysio_fd_find(fd); - if (!fil) - return __bypass_ireadv(fd, iov, count); + if (!fil) { + rc = __bypass_ireadv(fd, iov, count); + SYSIO_LEAVE; + return rc; + } ioctxp = do_ipreadv(fil, iov, count, fil->f_pos); - if (!ioctxp) - return IOID_FAIL; - return ioctxp->ioctx_id; + + SYSIO_LEAVE; + return ioctxp ? ioctxp->ioctx_id : IOID_FAIL; } /* Index: rmdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rmdir.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -w -b -B -p -r1.3 -r1.3.4.1 --- rmdir.c 24 Mar 2003 22:09:06 -0000 1.3 +++ rmdir.c 29 Jun 2003 10:15:32 -0000 1.3.4.1 @@ -58,6 +58,7 @@ rmdir(const char *path) struct intent intent; int err; struct pnode *pno; + SYSIO_ENTER; INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno); @@ -75,5 +76,6 @@ out: errno = -err; err = -1; } + SYSIO_LEAVE; return err; } Index: stat.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/stat.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -w -b -B -p -r1.3 -r1.3.4.1 --- stat.c 24 Mar 2003 22:09:07 -0000 1.3 +++ stat.c 29 Jun 2003 10:15:32 -0000 1.3.4.1 @@ -98,8 +98,13 @@ out: static int __fstat(int fd, struct stat *buf) { + int rc; + SYSIO_ENTER; - return __fxstat(_STAT_VER, fd, buf); + rc = __fxstat(_STAT_VER, fd, buf); + + SYSIO_LEAVE; + return rc; } sysio_sym_weak_alias(__fstat, fstat) @@ -138,8 +143,13 @@ out: int __stat(const char *filename, struct stat *buf) { + int rc; + SYSIO_ENTER; + + rc = __xstat(_STAT_VER, filename, buf); - return __xstat(_STAT_VER, filename, buf); + SYSIO_LEAVE; + return rc; } sysio_sym_weak_alias(__stat, stat) @@ -178,8 +188,13 @@ out: static int __lstat(const char *filename, struct stat *buf) { + int rc; + SYSIO_ENTER; + + rc = __lxstat(_STAT_VER, filename, buf); - return __lxstat(_STAT_VER, filename, buf); + SYSIO_LEAVE; + return rc; } sysio_sym_weak_alias(__lstat, lstat) Index: stat64.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/stat64.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -w -b -B -p -r1.3 -r1.3.4.1 --- stat64.c 24 Mar 2003 22:09:07 -0000 1.3 +++ stat64.c 29 Jun 2003 10:15:32 -0000 1.3.4.1 @@ -89,8 +89,13 @@ out: int fstat64(int fd, struct stat64 *buf) { + int rc; + SYSIO_ENTER; - return __fxstat64(_STAT_VER, fd, buf); + rc = __fxstat64(_STAT_VER, fd, buf); + + SYSIO_LEAVE; + return rc; } int @@ -125,8 +130,13 @@ out: int stat64(const char *filename, struct stat64 *buf) { + int rc; + SYSIO_ENTER; + + rc = __xstat64(_STAT_VER, filename, buf); - return __xstat64(_STAT_VER, filename, buf); + SYSIO_LEAVE; + return rc; } int @@ -161,6 +171,11 @@ out: int lstat64(const char *filename, struct stat64 *buf) { + int rc; + SYSIO_ENTER; + + rc = __lxstat64(_STAT_VER, filename, buf); - return __lxstat64(_STAT_VER, filename, buf); + SYSIO_LEAVE; + return rc; } Index: statvfs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -w -b -B -p -r1.3 -r1.3.4.1 --- statvfs.c 24 Mar 2003 22:09:07 -0000 1.3 +++ statvfs.c 29 Jun 2003 10:15:32 -0000 1.3.4.1 @@ -84,6 +84,7 @@ statvfs(const char *path, struct statvfs struct intnl_statvfs _call_buffer; struct intnl_statvfs *_call_buf = &_call_buffer; #endif + SYSIO_ENTER; err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); if (err) @@ -101,6 +102,7 @@ err: errno = -err; err = -1; out: + SYSIO_LEAVE; return err; } @@ -115,6 +117,7 @@ fstatvfs(int fd, struct statvfs *buf) struct intnl_statvfs _call_buffer; struct intnl_statvfs *_call_buf = &_call_buffer; #endif + SYSIO_ENTER; err = 0; filp = _sysio_fd_find(fd); @@ -134,5 +137,6 @@ err: errno = -err; err = -1; out: + SYSIO_LEAVE; return err; } Index: statvfs64.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs64.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -w -b -B -p -r1.3 -r1.3.4.1 --- statvfs64.c 24 Mar 2003 22:09:07 -0000 1.3 +++ statvfs64.c 29 Jun 2003 10:15:32 -0000 1.3.4.1 @@ -57,6 +57,7 @@ statvfs64(const char *path, struct statv { int err; struct pnode *pno; + SYSIO_ENTER; err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); if (err) @@ -69,6 +70,8 @@ out: errno = -err; err = -1; } + + SYSIO_LEAVE; return err; } @@ -77,6 +80,7 @@ fstatvfs(int fd, struct statvfs64 *buf) { int err; struct file *filp; + SYSIO_ENTER; err = 0; filp = _sysio_fd_find(fd); @@ -91,5 +95,7 @@ out: errno = -err; err = -1; } + + SYSIO_LEAVE; return err; } Index: symlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/symlink.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -w -b -B -p -r1.3 -r1.3.4.1 --- symlink.c 24 Mar 2003 22:09:07 -0000 1.3 +++ symlink.c 29 Jun 2003 10:15:32 -0000 1.3.4.1 @@ -58,6 +58,7 @@ symlink(const char *oldpath, const char int err; struct intent intent; struct pnode *pno; + SYSIO_ENTER; INTENT_INIT(&intent, INT_CREAT, NULL, NULL); err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &pno); @@ -81,5 +82,6 @@ out: errno = -err; err = -1; } + SYSIO_LEAVE; return err; } Index: truncate.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/truncate.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -w -b -B -p -r1.3 -r1.3.4.1 --- truncate.c 24 Mar 2003 22:09:07 -0000 1.3 +++ truncate.c 29 Jun 2003 10:15:32 -0000 1.3.4.1 @@ -80,6 +80,7 @@ truncate(const char *path, off_t length) { int err; struct pnode *pno; + SYSIO_ENTER; err = _sysio_namei(_sysio_cwd, path, 0, NULL, &pno); if (err) @@ -92,6 +93,7 @@ out: errno = -err; err = -1; } + SYSIO_LEAVE; return err; } @@ -100,6 +102,7 @@ ftruncate(int fd, off_t length) { int err; struct file *fil; + SYSIO_ENTER; err = 0; fil = _sysio_fd_find(fd); @@ -113,5 +116,6 @@ out: errno = -err; err = -1; } + SYSIO_LEAVE; return err; } Index: unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/unlink.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 --- unlink.c 29 Jun 2003 07:56:47 -0000 1.3.4.1 +++ unlink.c 29 Jun 2003 10:15:32 -0000 1.3.4.2 @@ -58,6 +58,7 @@ unlink(const char *path) struct intent intent; int err; struct pnode *pno; + SYSIO_ENTER; INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = _sysio_namei(_sysio_cwd, path, ND_NOFOLLOW, &intent, &pno); @@ -75,5 +76,6 @@ out: errno = -err; err = -1; } + SYSIO_LEAVE; return err; } Index: write.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/write.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 --- write.c 19 Jun 2003 12:18:29 -0000 1.2.10.2 +++ write.c 29 Jun 2003 10:15:32 -0000 1.2.10.3 @@ -107,12 +107,19 @@ ipwritev(int fd, const struct iovec *iov { struct file *fil; struct ioctx *ioctxp; + ioid_t rc; + SYSIO_ENTER; fil = _sysio_fd_find(fd); - if (!fil) - return __bypass_pwritev(fd, iov, count, offset); + if (!fil) { + rc = __bypass_pwritev(fd, iov, count, offset); + SYSIO_LEAVE; + return rc; + } ioctxp = do_ipwritev(fil, iov, count, offset); + + SYSIO_LEAVE; return ioctxp ? ioctxp->ioctx_id : IOID_FAIL; } @@ -166,15 +173,20 @@ iwritev(int fd, const struct iovec *iov, { struct file *fil; struct ioctx *ioctxp; + ioid_t rc; + SYSIO_ENTER; fil = _sysio_fd_find(fd); - if (!fil) - return __bypass_iwritev(fd, iov, count); + if (!fil) { + rc = __bypass_iwritev(fd, iov, count); + SYSIO_LEAVE; + return rc; + } ioctxp = do_ipwritev(fil, iov, count, fil->f_pos); - if (!ioctxp) - return IOID_FAIL; - return ioctxp->ioctx_id; + + SYSIO_LEAVE; + return ioctxp ? ioctxp->ioctx_id : IOID_FAIL; } /* |
From: Mei <me...@us...> - 2003-06-29 10:15:34
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1:/tmp/cvs-serv5026/include Modified Files: Tag: b_lustre sysio.h Log Message: make lustre could hook functions on when enter/leave system calls. Index: sysio.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio.h,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -u -w -b -B -p -r1.7 -r1.7.4.1 --- sysio.h 26 Mar 2003 00:06:04 -0000 1.7 +++ sysio.h 29 Jun 2003 10:15:32 -0000 1.7.4.1 @@ -183,3 +183,25 @@ extern int mount(const char *source, con unsigned long mountflags, const void *data); extern int umount(const char *target); + +/* This allow lustre's function hook into libsysio */ +extern int __sysio_in_syscall; +typedef void __sysio_hook_func(void); +extern __sysio_hook_func *__sysio_hook_sys_enter; +extern __sysio_hook_func *__sysio_hook_sys_leave; + +#define SYSIO_ENTER \ + do { \ + if (__sysio_hook_sys_enter) \ + __sysio_hook_sys_enter(); \ + if (__sysio_in_syscall++) \ + abort(); \ + } while(0) + +#define SYSIO_LEAVE \ + do { \ + if (--__sysio_in_syscall != 0) \ + abort(); \ + if (__sysio_hook_sys_leave) \ + __sysio_hook_sys_leave(); \ + } while(0) |
From: Mei <me...@us...> - 2003-06-29 07:56:50
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv23729 Modified Files: Tag: b_lustre unlink.c Log Message: don't try to follow symbol links in sycall unlink(). Index: unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/unlink.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -w -b -B -p -r1.3 -r1.3.4.1 --- unlink.c 24 Mar 2003 22:09:07 -0000 1.3 +++ unlink.c 29 Jun 2003 07:56:47 -0000 1.3.4.1 @@ -60,7 +60,7 @@ unlink(const char *path) struct pnode *pno; INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); - err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno); + err = _sysio_namei(_sysio_cwd, path, ND_NOFOLLOW, &intent, &pno); if (err) goto out; if (IS_RDONLY(pno, pno->p_base->pb_ino)) { |
From: Ruth K. <rk...@us...> - 2003-06-27 18:31:18
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv27841 Modified Files: Tag: cplant namei.c Log Message: add function to provide backwards compatibility for path prefix on cplant Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.5.2.1 retrieving revision 1.5.2.2 diff -u -w -b -B -p -r1.5.2.1 -r1.5.2.2 --- namei.c 12 Jun 2003 23:48:48 -0000 1.5.2.1 +++ namei.c 27 Jun 2003 18:11:04 -0000 1.5.2.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; |
From: Ruth K. <rk...@us...> - 2003-06-27 18:17:05
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv27926 Modified Files: Tag: cplant Makefile.am Log Message: add function to provide backwards compatibility for path prefix on cplant Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/Makefile.am,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -w -b -B -p -r1.5 -r1.5.2.1 --- Makefile.am 24 Mar 2003 22:09:06 -0000 1.5 +++ Makefile.am 27 Jun 2003 18:11:52 -0000 1.5.2.1 @@ -6,3 +6,10 @@ libsysio_a_SOURCES = chdir.c chmod.c cho stat64.c statvfs.c symlink.c truncate.c unlink.c write.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} |
From: Ruth K. <rk...@us...> - 2003-06-27 18:09:31
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1:/tmp/cvs-serv27463 Modified Files: Tag: cplant chdir.c Log Message: merged bug fix Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.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 --- chdir.c 12 Jun 2003 23:54:54 -0000 1.3.6.1 +++ chdir.c 27 Jun 2003 18:09:26 -0000 1.3.6.2 @@ -226,11 +226,10 @@ _sysio_p_path(struct pnode *pno, char ** * 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); |
From: Lee W. <lw...@us...> - 2003-06-19 17:48:17
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1:/tmp/cvs-serv20060 Modified Files: Tag: RedStorm Makefile.am Added Files: Tag: RedStorm test_unlink.c Log Message: Added test_unlink test. --- 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 <stdio.h> #include <stdlib.h> #include <string.h> #ifndef REDSTORM #include <getopt.h> #else #include <unistd.h> #endif #include <errno.h> #if 0 #include <sys/queue.h> #include <dirent.h> #endif #include "sysio.h" #include "mount.h" #include "test.h" /* * Unlink files. * * Usage: unlink [-a] [-m <fsname>] [-r <mntpath>] [path...] * * Without any path arguments, the program unlinks files named * by the ocmmand line args. */ static int unlinkit(const char *path); static void usage(void); static const char *root_driver = DEFAULT_DRIVER; static const char *mntpath = "/"; static unsigned mntflgs = 0; #ifdef AUTOMOUNT_FILE_NAME #define EXTRA_AUTOMOUNT_OPT "a" #else #define EXTRA_AUTOMOUNT_OPT #endif const char *opts = EXTRA_AUTOMOUNT_OPT "m:r:"; int main(int argc, char *const argv[]) { int i; int err; int n; /* * Parse command line arguments. */ while ((i = getopt(argc, argv, opts)) != -1) switch (i) { #ifdef AUTOMOUNT_FILE_NAME case 'a': mntflgs |= MOUNT_F_AUTO; break; #endif case 'm': root_driver = optarg; break; case 'r': mntpath = optarg; break; default: usage(); } /* * Init sysio lib. */ _sysio_init(); /* * Init native file system driver and request mount of specified * source directory. */ err = drv_init_all(); if (err) { errno = -err; perror("drv_init_all"); exit(1); } err = _sysio_mount_root(mntpath, root_driver, mntflgs, NULL); if (err) { errno = -err; perror("_sysio_mount_root"); exit(1); } n = argc - optind; /* * Try path(s) listed on command-line. */ while (optind < argc) { const char *path; path = argv[optind++]; (void )unlinkit(path); } /* * If no command-line arguments, read from stdin until EOF. */ if (!n) { int doflush; static char buf[4096]; size_t len; char *cp; char c; doflush = 0; while (fgets(buf, sizeof(buf), stdin) != NULL) { len = strlen(buf); cp = buf + len - 1; c = *cp; *cp = '\0'; if (!doflush) unlinkit(buf); doflush = c == '\n' ? 0 : 1; } } /* * Clean up. */ _sysio_shutdown(); return 0; } static int unlinkit(const char *path) { if (!unlink(path)) { perror(path); return -1; } return 0; } static void usage() { (void )fprintf(stderr, "Usage: unlink [-a] [-m <driver>] [-r <mntpath>]" " [<path> ...\n]"); exit(1); } Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.8.6.1 retrieving revision 1.8.6.2 diff -u -w -b -B -p -r1.8.6.1 -r1.8.6.2 --- Makefile.am 27 May 2003 12:37:00 -0000 1.8.6.1 +++ Makefile.am 19 Jun 2003 17:48:13 -0000 1.8.6.2 @@ -1,5 +1,5 @@ noinst_PROGRAMS = test_copy test_stats test_path test_mounts test_list \ - test_getcwd test_stdfd + test_getcwd test_stdfd test_unlink CLEANFILES=drv_data.c @@ -81,6 +81,11 @@ test_stdfd_SOURCES=test_stdfd.c $(CMNSRC test_stdfd_CFLAGS=$(CFL) test_stdfd_LDADD=$(LIBS) test_stdfd_DEPENDENCIES=$(LIBS) + +test_unlink_SOURCES=test_unlink.c $(CMNSRC) +test_unlink_CFLAGS=$(CFL) +test_unlink_LDADD=$(LIBS) +test_unlink_DEPENDENCIES=$(LIBS) EXTRA_DIST=gendrvdata.sh test.h |