libsysio-commit Mailing List for libsysio (Page 31)
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...> - 2004-02-24 15:12:45
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32223/src Modified Files: fs.c getdirentries.c inode.c ioctx.c module.mk statvfs.c statvfs64.c Log Message: Cleaned out all the pointer arithmetic utilizing void pointers. No longer build the empty statvfs{64} modules. All in an attempt to make the code C99 compliant. Index: fs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fs.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -b -B -p -r1.9 -r1.10 --- fs.c 6 Feb 2004 20:07:30 -0000 1.9 +++ fs.c 24 Feb 2004 14:58:26 -0000 1.10 @@ -96,7 +96,7 @@ _sysio_fssw_register(const char *name, s fssw = malloc(sizeof(struct fsswent) + strlen(name) + 1); if (!fssw) return -errno; - fssw->fssw_name = (void *)fssw + sizeof(struct fsswent); + fssw->fssw_name = (char *)fssw + sizeof(struct fsswent); (void )strcpy((char *)fssw->fssw_name, name); fssw->fssw_ops = *ops; Index: getdirentries.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/getdirentries.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- getdirentries.c 26 Jan 2004 16:48:34 -0000 1.7 +++ getdirentries.c 24 Feb 2004 14:58:26 -0000 1.8 @@ -186,13 +186,13 @@ getdirentries(int fd, } dp->d_type = d64p->d_type; dp->d_reclen = reclen; - nxtdp = (void *)dp + dp->d_reclen; + nxtdp = (struct dirent *)((char *)dp + dp->d_reclen); (void )memcpy(dp->d_name, d64p->d_name, n); for (cp = dp->d_name + n; cp < (char *)nxtdp; *cp++ = '\0') ; cc -= d64p->d_reclen; od64p = d64p; - d64p = (void *)d64p + d64p->d_reclen; + d64p = (struct dirent64 *)((char *)d64p + d64p->d_reclen); nbytes -= reclen; #if defined(BSD) || defined(REDSTORM) off += reclen; Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -w -b -B -p -r1.13 -r1.14 --- inode.c 6 Feb 2004 20:07:30 -0000 1.13 +++ inode.c 24 Feb 2004 14:58:26 -0000 1.14 @@ -196,15 +196,15 @@ static unsigned hash(struct file_identifier *fid) { size_t n; - void *p; + unsigned char *ucp; unsigned hkey; n = fid->fid_len; - p = fid->fid_data; + ucp = fid->fid_data; hkey = 0; do { hkey <<= 1; - hkey += *(unsigned char *)p++; + hkey += *ucp++; } while (--n); return hkey; } @@ -388,7 +388,7 @@ _sysio_pb_new(struct qstr *name, struct * We have put the space for the name immediately behind * the record in order to maximize spatial locality. */ - cp = (void *)pb + sizeof(struct pnode_base); + cp = (char *)pb + sizeof(struct pnode_base); (void )strncpy(cp, name->name, name->len); pb->pb_name.name = cp; assert(name->hashval); Index: ioctx.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- ioctx.c 14 Feb 2004 19:42:59 -0000 1.8 +++ ioctx.c 24 Feb 2004 14:58:26 -0000 1.9 @@ -386,7 +386,7 @@ _sysio_enumerate_extents(const struct in if (acc && cc <= acc) abort(); /* paranoia */ acc = cc; - iovec.iov_base += cc; + iovec.iov_base = (char *)iovec.iov_base + cc; iovec.iov_len -= cc; } else { start = iov; Index: module.mk =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/module.mk,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- module.mk 6 Feb 2004 20:07:30 -0000 1.2 +++ module.mk 24 Feb 2004 14:58:26 -0000 1.3 @@ -1,3 +1,7 @@ +# +# Note; Remove statvfs{,64}.c until we decide what to do with them. +# Lee; Tue Feb 24 09:37:32 EST 2004 +# SRCDIR_SRCS = src/access.c src/chdir.c src/chmod.c \ src/chown.c src/dev.c src/dup.c src/fcntl.c \ src/file.c src/fs.c src/fsync.c \ @@ -7,6 +11,6 @@ SRCDIR_SRCS = src/access.c src/chdir.c s src/mknod.c src/mount.c src/namei.c \ src/open.c src/rw.c src/rename.c \ src/rmdir.c src/stat64.c src/stat.c \ - src/statvfs64.c src/statvfs.c src/symlink.c \ + src/symlink.c \ src/truncate.c src/unlink.c src/utime.c SRCDIR_EXTRA = src/module.mk Index: statvfs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- statvfs.c 26 Jan 2004 16:34:54 -0000 1.6 +++ statvfs.c 24 Feb 2004 14:58:26 -0000 1.7 @@ -41,8 +41,6 @@ * le...@sa... */ -#ifdef _HAVE_STATVFS - #ifndef BSD #include <unistd.h> @@ -157,4 +155,3 @@ sysio_sym_weak_alias(fstatvfs, __fstatvf #endif #endif /* ifndef BSD */ -#endif /* defined(_HAVE_STATVFS) */ Index: statvfs64.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs64.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- statvfs64.c 6 Feb 2004 20:07:30 -0000 1.8 +++ statvfs64.c 24 Feb 2004 14:58:26 -0000 1.9 @@ -41,8 +41,6 @@ * le...@sa... */ -#ifdef _HAVE_STATVFS - #ifndef BSD #include <unistd.h> #include <errno.h> @@ -115,4 +113,3 @@ sysio_sym_weak_alias(fstatvfs64, __fstat #endif #endif /* ifndef BSD */ -#endif /* define(_HAVE_STATVFS) */ |
|
From: Lee W. <lw...@us...> - 2004-02-24 15:12:44
|
Update of /cvsroot/libsysio/libsysio/drivers/incore In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32223/drivers/incore Modified Files: fs_incore.c Log Message: Cleaned out all the pointer arithmetic utilizing void pointers. No longer build the empty statvfs{64} modules. All in an attempt to make the code C99 compliant. Index: fs_incore.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/incore/fs_incore.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -w -b -B -p -r1.14 -r1.15 --- fs_incore.c 14 Feb 2004 19:42:57 -0000 1.14 +++ fs_incore.c 24 Feb 2004 14:58:26 -0000 1.15 @@ -377,7 +377,7 @@ _sysio_incore_init() /* * Move to entry for `..' */ - de = (void *)de + off; + de = (struct intnl_dirent *)((char *)de + off); de->d_reclen = INCORE_D_RECLEN(2); #ifdef _DIRENT_HAVE_D_NAMLEN de->d_namlen = 2; @@ -446,7 +446,7 @@ incore_trunc(struct incore_inode *icino, return -ENOSPC; icino->ici_data = p; if (clear && n > icino->ici_st.st_size) - (void )memset(icino->ici_data + icino->ici_st.st_size, + (void )memset((char *)icino->ici_data + icino->ici_st.st_size, 0, (size_t )(n - icino->ici_st.st_size)); out: @@ -495,12 +495,14 @@ incore_directory_new(struct incore_files sizeof(incore_dir_template)); de = icino->ici_data; de->d_ino = st->st_ino; - (void *)de += + de = + (struct intnl_dirent *)((char *)de + #ifdef _DIRENT_HAVE_D_OFF - de->d_off; + de->d_off #else - de->d_reclen; + de->d_reclen #endif + ); de->d_ino = parent->ici_st.st_ino; /* @@ -754,7 +756,7 @@ incore_directory_probe(void *data, } if (n >= siz) break; - de = data + n; + de = (struct intnl_dirent *)((char *)data + n); } return NULL; @@ -948,7 +950,7 @@ incore_directory_enumerate(struct intnl_ if (reclen > cinfo->nbytes) return de; (void *)memcpy(cinfo->data, de, reclen); - cinfo->data += reclen; + cinfo->data = (char *)cinfo->data + reclen; cinfo->nbytes -= reclen; return NULL; } @@ -973,7 +975,7 @@ _sysio_incore_dirop_getdirentries(struct *basep, (probe_ty )incore_directory_position, NULL, - icino->ici_data + *basep); + (char *)icino->ici_data + *basep); if (!de) { /* * Past EOF. @@ -984,7 +986,7 @@ _sysio_incore_dirop_getdirentries(struct copy_info.data = buf; copy_info.nbytes = nbytes; - off = (void *)de - icino->ici_data; + off = (char *)de - (char *)icino->ici_data; de = incore_directory_probe(de, icino->ici_st.st_size - off, @@ -1037,7 +1039,7 @@ incore_directory_insert(struct incore_in if (de) return -EEXIST; de = lookup_data.de; - xt = (void *)lookup_data.de - parent->ici_data; + xt = (char *)lookup_data.de - (char *)parent->ici_data; n = #ifdef _DIRENT_HAVE_D_OFF de->d_off; @@ -1057,7 +1059,7 @@ incore_directory_insert(struct incore_in err = incore_trunc(parent, xt + r + reclen, 1); if (err) return err; - de = parent->ici_data + xt; + de = (struct intnl_dirent *)((char *)parent->ici_data + xt); n = parent->ici_st.st_size; } @@ -1066,7 +1068,7 @@ incore_directory_insert(struct incore_in #else de->d_reclen = r; #endif - (void *)de += r; /* reposition */ + de = (struct intnl_dirent *)((char *)de + r); /* reposition */ xt += r; #ifndef _DIRENT_HAVE_D_OFF @@ -1213,13 +1215,13 @@ incore_unlink_entry(struct incore_inode &lookup_data); if (!de) return -ENOENT; - assert((size_t )((void *)de - - icino->ici_data) >= sizeof(incore_dir_template)); + assert((size_t )((char *)de - (char *)icino->ici_data) >= + sizeof(incore_dir_template)); #ifndef _DIRENT_HAVE_D_OFF reclen = de->d_reclen; #else off = de->d_off; - reclen = off - ((void *)de - icino->ici_data); + reclen = off - ((char *)de - (char *)icino->ici_data); #endif (void )memset(de, 0, reclen); #ifndef _DIRENT_HAVE_D_OFF @@ -1492,7 +1494,7 @@ incore_read(void *buf, size_t nbytes, n = icino->ici_st.st_size - (size_t )off; if (n > nbytes) n = nbytes; - (void )memcpy(buf, icino->ici_data + off, (size_t )n); + (void )memcpy(buf, (char *)icino->ici_data + off, (size_t )n); return (ssize_t )n; } @@ -1531,7 +1533,7 @@ incore_write(const void *buf, size_t nby if (err) return err; } - (void )memcpy(icino->ici_data + off, buf, nbytes); + (void )memcpy((char *)icino->ici_data + off, buf, nbytes); return (ssize_t )nbytes; } |
|
From: Lee W. <lw...@us...> - 2004-02-24 15:12:44
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32223/tests Modified Files: test_list.c Log Message: Cleaned out all the pointer arithmetic utilizing void pointers. No longer build the empty statvfs{64} modules. All in an attempt to make the code C99 compliant. Index: test_list.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_list.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- test_list.c 14 Feb 2004 19:43:00 -0000 1.7 +++ test_list.c 24 Feb 2004 14:58:26 -0000 1.8 @@ -175,7 +175,7 @@ listit(const char *path) (unsigned long long )dp->d_ino, (int )dp->d_type); cc -= dp->d_reclen; - dp = (void *)dp + dp->d_reclen; + dp = (struct dirent *)((char *)dp + dp->d_reclen); } if (!base) break; |
|
From: Lee W. <lw...@us...> - 2004-02-24 14:18:11
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19788 Modified Files: sysio.h Log Message: Turned off the local ASSERT/ERROR and SYSIO_{ENTER,LEAVE} for now. Must define these differently. Index: sysio.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio.h,v retrieving revision 1.17 retrieving revision 1.18 diff -u -w -b -B -p -r1.17 -r1.18 --- sysio.h 14 Feb 2004 19:42:58 -0000 1.17 +++ sysio.h 24 Feb 2004 14:03:55 -0000 1.18 @@ -298,7 +298,7 @@ extern int mount(const char *source, con extern int umount(const char *target); /* for debugging */ -#if 1 +#if 0 #define ASSERT(cond) \ if (!(cond)) { \ printf("ASSERTION(" #cond ") failed: " __FILE__ ":" \ @@ -317,11 +317,7 @@ extern int umount(const char *target); #endif /* syscall enter/leave hook functions */ -#if 1 -#define SYSIO_ENTER -#define SYSIO_LEAVE - -#else +#if 0 extern void _sysio_sysenter(); extern void _sysio_sysleave(); @@ -334,4 +330,8 @@ extern void _sysio_sysleave(); do { \ _sysio_sysleave(); \ } while(0) +#else +#define SYSIO_ENTER +#define SYSIO_LEAVE + #endif |
|
From: Lee W. <le...@sa...> - 2004-02-14 21:09:08
|
The "namespace merge" included some bug fixes in the fs_native driver. If you based a driver on it, it might be worth a diff to see if you inherited some nastiness. --Lee -- Lee Ward <le...@sa...> Sandia National Laboratories |
|
From: Lee W. <lw...@us...> - 2004-02-14 19:50:07
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16325 Modified Files: Makefile.am Log Message: + Merged in changes from namespace_assembly branch (see .../misc/init-env.sh) This provoked a bunch of bugs. See below. + Fixed a bug in _sysio_enumerate_extents(). If the IO operation was short, it would go round the loop again, mistakenly trying to fill more of the extent. + In rw.c, fixed bugs in [p]{read,write}[vx] (all the synchronous routines) that improperly propagated error returns. They were returning -errno instead of setting errno and returning -1. + In fs_native.c:doiov, fixed a bug where a zero-length IO was improperly thought to be an error. + In lseek.c:_sysio_lseek, fixed final position check to properly determine {under,over}flow. + In link.c:link, fixed the existence check. No error is returned for nonexistent files when ND_NEGOK is specified. We're supposed to check whether it's a negative entry or not. + A new macro, I_GONE, was added to inode.h. This will *try* to kill an inode but if it can't, it becomes a zombie instead. + In unlink.c:unlink, link.c:link, rename.c:rename, the driver ops were being called but the actual operation in the internal path tree was not reflected. Also, for unlink and rename, use the new I_GONE macro on the destroyed inode. + In fs_native.c:native_inop_gone, close() was always called, even when the fildes was -1. + In fs_native.c:native_inop_gone, close() was called. We really meant to call syscal(SYS_close, ...); + In namei.c:_sysio_path_walk, fixed broken symlink handling. It wasn't following symlinks anywhere if ND_NOFOLLOW was set. That flag only means that the *last* component should not be followed. + In namei.c:_sysio_path_walk, fixed buffer overrun problem for very long symlinks. + In fs_incore.c, fixed dirop_{link,rename,unlink,rmdir} because they were manipulating the system path cache and shouldn't. + In mount.c:_sysio_unmount_all we were mistakenly releasing an FS root after a failed unmount attempt. + Fixes in test_regions.c free allocated memory at the end so valgrind doesn't show a leak. Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/Makefile.am,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- Makefile.am 21 Jan 2004 14:44:53 -0000 1.10 +++ Makefile.am 14 Feb 2004 19:42:57 -0000 1.11 @@ -65,7 +65,7 @@ __LIBBUILD_DIR__libsysio_a_SOURCES = \ include $(top_srcdir)/Rules.make -EXTRA_DIST = Rules.make $(TESTS_EXTRA) $(SRCDIR_EXTRA) \ +EXTRA_DIST = Rules.make misc/init-env.sh $(TESTS_EXTRA) $(SRCDIR_EXTRA) \ $(INCLUDE_EXTRA) $(STDFD_EXTRA) $(INCORE_EXTRA) \ $(SOCKETS_EXTRA) $(NATIVE_EXTRA) $(YOD_EXTRA) |
|
From: Lee W. <lw...@us...> - 2004-02-14 19:49:44
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16325/tests Modified Files: Makefile.am sysio_stubs.c sysio_tests.c test.h test_all.pl test_copy.c test_copy.pl test_driver.c test_driver.h test_getcwd.c test_link.c test_list.c test_path.c test_regions.c test_rename.c test_stats.c test_unlink.c Added Files: startup.c Removed Files: test_mounts.c test_stdfd.c Log Message: + Merged in changes from namespace_assembly branch (see .../misc/init-env.sh) This provoked a bunch of bugs. See below. + Fixed a bug in _sysio_enumerate_extents(). If the IO operation was short, it would go round the loop again, mistakenly trying to fill more of the extent. + In rw.c, fixed bugs in [p]{read,write}[vx] (all the synchronous routines) that improperly propagated error returns. They were returning -errno instead of setting errno and returning -1. + In fs_native.c:doiov, fixed a bug where a zero-length IO was improperly thought to be an error. + In lseek.c:_sysio_lseek, fixed final position check to properly determine {under,over}flow. + In link.c:link, fixed the existence check. No error is returned for nonexistent files when ND_NEGOK is specified. We're supposed to check whether it's a negative entry or not. + A new macro, I_GONE, was added to inode.h. This will *try* to kill an inode but if it can't, it becomes a zombie instead. + In unlink.c:unlink, link.c:link, rename.c:rename, the driver ops were being called but the actual operation in the internal path tree was not reflected. Also, for unlink and rename, use the new I_GONE macro on the destroyed inode. + In fs_native.c:native_inop_gone, close() was always called, even when the fildes was -1. + In fs_native.c:native_inop_gone, close() was called. We really meant to call syscal(SYS_close, ...); + In namei.c:_sysio_path_walk, fixed broken symlink handling. It wasn't following symlinks anywhere if ND_NOFOLLOW was set. That flag only means that the *last* component should not be followed. + In namei.c:_sysio_path_walk, fixed buffer overrun problem for very long symlinks. + In fs_incore.c, fixed dirop_{link,rename,unlink,rmdir} because they were manipulating the system path cache and shouldn't. + In mount.c:_sysio_unmount_all we were mistakenly releasing an FS root after a failed unmount attempt. + Fixes in test_regions.c free allocated memory at the end so valgrind doesn't show a leak. Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.18 retrieving revision 1.19 diff -u -w -b -B -p -r1.18 -r1.19 --- Makefile.am 6 Feb 2004 20:07:30 -0000 1.18 +++ Makefile.am 14 Feb 2004 19:42:59 -0000 1.19 @@ -1,12 +1,5 @@ - -if WITH_STDFD_DEV -STDFD_DEV_TEST = test_stdfd -else -STDFD_DEV_TEST = -endif - -noinst_PROGRAMS = test_copy test_stats test_path test_mounts test_list \ - test_getcwd $(STDFD_DEV_TEST) test_link test_unlink test_rename \ +noinst_PROGRAMS = test_copy test_stats test_path test_list \ + test_getcwd test_link test_unlink test_rename \ test_regions test_driver CLEANFILES=drv_data.c @@ -27,14 +20,6 @@ INCORE_DRIVER_NAME= INCORE_DRIVER_CFLAGS= endif -if WITH_STDFD_DEV -STDFD_DEV_NAME=stdfd -STDFD_DEV_CFLAGS= -I$(top_srcdir)/dev/stdfd -else -STDFD_DEV_NAME= -STDFD_DEV_CFLAGS= -endif - if WITH_CPLANT_YOD YOD_DRIVER_NAME=yod YOD_DRIVER_CFLAGS= -DCPLANT_YOD @@ -54,7 +39,7 @@ endif DRIVERS=$(NATIVE_DRIVER_NAME) $(INCORE_DRIVER_NAME) $(YOD_DRIVER_NAME) \ $(STFD_DEV_NAME) $(SOCKETS_DRIVER_NAME) -CMNSRC=drv_init_all.c drv_data.c +CMNSRC=startup.c drv_init_all.c drv_data.c BUILT_SOURCES=drv_data.c check_PROGRAMS=test_driver @@ -86,11 +71,6 @@ test_path_CFLAGS=$(CFL) test_path_LDADD=$(LIBS) test_path_DEPENDENCIES=$(LIBS) -test_mounts_SOURCES=test_mounts.c $(CMNSRC) -test_mounts_CFLAGS=$(CFL) -test_mounts_LDADD=$(LIBS) -test_mounts_DEPENDENCIES=$(LIBS) - test_list_SOURCES=test_list.c $(CMNSRC) test_list_CFLAGS=$(CFL) test_list_LDADD=$(LIBS) @@ -101,11 +81,6 @@ test_getcwd_CFLAGS=$(CFL) test_getcwd_LDADD=$(LIBS) test_getcwd_DEPENDENCIES=$(LIBS) -test_stdfd_SOURCES=test_stdfd.c $(CMNSRC) -test_stdfd_CFLAGS=$(CFL) -test_stdfd_LDADD=$(LIBS) -test_stdfd_DEPENDENCIES=$(LIBS) - test_link_SOURCES=test_link.c $(CMNSRC) test_link_CFLAGS=$(CFL) test_link_LDADD=$(LIBS) Index: sysio_stubs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/sysio_stubs.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- sysio_stubs.c 6 Feb 2004 20:07:31 -0000 1.8 +++ sysio_stubs.c 14 Feb 2004 19:42:59 -0000 1.9 @@ -394,9 +394,8 @@ int test_do_init(int argc, char **argv) DBG(5, fprintf(outfp, "In test_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); + DBG(3, fprintf(outfp, "initializing\n")); + return initilize_sysio(); } Index: sysio_tests.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/sysio_tests.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -b -B -p -r1.4 -r1.5 --- sysio_tests.c 21 Jan 2004 15:38:45 -0000 1.4 +++ sysio_tests.c 14 Feb 2004 19:43:00 -0000 1.5 @@ -29,37 +29,23 @@ * # every function document in sysio.h # * ################################################### */ -int initilize_sysio(char *root_driver, char *root_path, int mntflgs) +int initilize_sysio() { int err; char *wd; + extern int _test_sysio_startup(void); /* * Init sysio lib. */ - _sysio_init(); - - /* - * Init native file system driver and request mount of specified - * source directory. - */ - err = drv_init_all(); - DBG(5, sprintf(output, "%sdrv_init_all: err %d\n", output, err)); + err = _test_sysio_startup(); + DBG(5, sprintf(output, "%s_test_sysio_startup: err %d\n", output, err)); if (err) { my_errno = err; - my_perror("drv_init_all"); + my_perror("sysio startup"); last_ret_val = errno; return SUCCESS; } - err = _sysio_mount_root(root_path, root_driver, mntflgs, NULL); - DBG(5, sprintf(output, "%ssysio_mount_root: err %d\n", output, err)); - if (err) { - my_errno = errno; - my_perror("_sysio_mount_root"); - perror("_sysio_mount_root"); - last_ret_val = err; - return SUCCESS; - } /* * Attempt to set the cwd by getting it out of the Index: test.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -b -B -p -r1.1 -r1.2 --- test.h 22 Feb 2003 20:30:20 -0000 1.1 +++ test.h 14 Feb 2004 19:43:00 -0000 1.2 @@ -41,8 +41,6 @@ * le...@sa... */ -#define DEFAULT_DRIVER "native" - extern int (*drvinits[])(void); extern int drv_init_all(void); Index: test_all.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_all.pl,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- test_all.pl 6 Feb 2004 20:07:31 -0000 1.8 +++ test_all.pl 14 Feb 2004 19:43:00 -0000 1.9 @@ -35,6 +35,38 @@ my $cwd = $ENV{PWD}; # Get tests directory my $testdir = $FindBin::Bin; +my $namespace_env = "SYSIO_NAMESPACE"; +my $home = $ENV{"HOME"}; +my $auto_mount = $ENV{"SYSIO_AUTOMOUNT"}; +my $root_flags = "0"; +my $extras = ""; +if ((defined($auto_mount)) && ($auto_mount == "xyes")) { + $root_flags = "2"; + + # + # Add a /auto directory for automounted file systems. We + # craft one automount that mounts /usr/home from the native + # file system. Further automounts in the sub-mounts are not enabled. + # + $extras=" \ + {mnt, dev=\"incore:0755+0+0\",dir=\"/mnt\",fl=2} \ + {creat, ft=dir,nm=\"/mnt/home\",pm=0755,ow=0,gr=0} \ + {creat, ft=file,nm=\"/mnt/home/.mount\",pm=0600, \ + str=\"native:/usr/home\"}"; +} +$ENV{$namespace_env} = "\ + {mnt, dev=\"native:/\",dir=/,fl=$root_flags} \ + {mnt, dev=\"incore:0755+0+0\",dir=\"/dev\"} \ + {creat, ft=chr,nm=\"/dev/stdin\",pm=0400,mm=0+0} \ + {creat, ft=chr,nm=\"/dev/stdout\",pm=0200,mm=0+1} \ + {creat, ft=chr,nm=\"/dev/stderr\",pm=0200,mm=0+2} \ + {creat, ft=dir,nm=\"/dev/fd\",pm=0755,ow=0,gr=0} \ + {creat, ft=chr,nm=\"/dev/fd/0\",pm=0400,mm=0+0} \ + {creat, ft=chr,nm=\"/dev/fd/1\",pm=0200,mm=0+1} \ + {creat, ft=chr,nm=\"/dev/fd/2\",pm=0200,mm=0+2} \ + {cd, dir=\"$home\"} \ + $extras "; + my $res; if ($use_system == 1) { @@ -93,19 +125,6 @@ if ($resarr[0] ne $res) { } } -if (($alpha_arg eq "") || ($is_broke == 0)) { - # Test mount - $res = `perl $testdir/test_list.pl $alpha_arg -m native:$testdir $cwd/tmp_dir/test2`; - 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 = `perl $testdir/test_getcwd.pl $alpha_arg $cwd/tmp_dir/test1`; chop($res); @@ -140,9 +159,9 @@ if ($res ne "stat test successful") { } # Test stdfd -$res = `perl $testdir/test_stdfd.pl $alpha_arg foo_dir`; +$res = `echo "foobar" | perl $testdir/test_copy.pl $alpha_arg -o /dev/stdin /dev/stdout`; chop($res); -if ($res ne "test_stdfd successful") { +if ($res ne "copy test successful") { print "stdfd test failed with message: $res\n"; $failures++; } else { @@ -185,5 +204,4 @@ if ($use_system == 1) { exit 1; } } - exit $failures; Index: test_copy.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_copy.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- test_copy.c 10 Oct 2003 18:50:31 -0000 1.8 +++ test_copy.c 14 Feb 2004 19:43:00 -0000 1.9 @@ -65,14 +65,12 @@ /* * Copy one file to another. * - * Usage: test_copy [-a] [-r <source>] [-m <root-driver>] <src> <dest> + * Usage: test_copy [-o] <src> <dest> * * Destination will not be overwritten if it already exist. */ -char *root_driver = DEFAULT_DRIVER; -char *mntpath = "/"; -unsigned mntflgs = 0; +static int overwrite = 0; /* over-write? */ void usage(void); int copy_file(const char *spath, const char *dpath); @@ -83,28 +81,19 @@ main(int argc, char * const argv[]) int i; int err; const char *spath, *dpath; + extern int _test_sysio_startup(void); /* * Parse command-line args. */ while ((i = getopt(argc, argv, -#ifdef AUTOMOUNT_FILE_NAME - "a" -#endif - "r:m:")) != -1) + "o" + )) != -1) switch (i) { -#ifdef AUTOMOUNT_FILE_NAME - case 'a': - mntflgs |= MOUNT_F_AUTO; - break; -#endif - case 'r': /* set working dir */ - mntpath = optarg; - break; - case 'm': - root_driver = optarg; + case 'o': + overwrite = 1; break; default: usage(); @@ -112,24 +101,12 @@ main(int argc, char * const argv[]) if (!(argc - optind)) usage(); -#ifndef CPLANT_YOD - if (_sysio_init() != 0) { - perror("init sysio"); - exit(1); - } - err = drv_init_all(); - if (err) { - perror("init drivers"); - exit(1); - } - err = _sysio_mount_root(mntpath, root_driver, mntflgs, NULL); + err = _test_sysio_startup(); if (err) { errno = -err; - perror(root_driver); + perror("sysio startup"); exit(1); } -#endif - (void )umask(022); /* * Source @@ -146,9 +123,7 @@ main(int argc, char * const argv[]) err = copy_file(spath, dpath); -#ifndef CPLANT_YOD _sysio_shutdown(); -#endif return err; } @@ -159,10 +134,6 @@ usage() (void )fprintf(stderr, "Usage: test_copy " -#ifdef AUTOMOUNT_FILE_NAME - "[-a] " -#endif - "[-r <source>] [-m <fsname>]" " source destination\n"); exit(1); } @@ -183,6 +154,7 @@ int copy_file(const char *spath, const char *dpath) { int sfd, dfd; + int flags; int rtn; static char buf[1024]; ssize_t cc, wcc; @@ -193,7 +165,10 @@ copy_file(const char *spath, const char sfd = open_file(spath, O_RDONLY, 0); if (sfd < 0) goto out; - dfd = open_file(dpath, O_CREAT|O_EXCL|O_WRONLY, 0666); + flags = O_CREAT|O_WRONLY; + if (!overwrite) + flags |= O_EXCL; + dfd = open_file(dpath, flags, 0666); if (dfd < 0) goto out; Index: test_copy.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_copy.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -b -B -p -r1.4 -r1.5 --- test_copy.pl 21 Jan 2004 15:13:56 -0000 1.4 +++ test_copy.pl 14 Feb 2004 19:43:00 -0000 1.5 @@ -20,7 +20,7 @@ sub usage sub process_cmd { - my ($src, $dest, $is_alpha) = @_; + my ($src, $dest, $overwrite, $is_alpha) = @_; # Get tests directory my $testdir = $FindBin::Bin; @@ -53,6 +55,13 @@ sub process_cmd my $size = -s $src; my $bufsize; + # If reading from stdin, just read one line + my $line; + if ($src eq "/dev/stdin") { + $line = <STDIN>; + $size = length($line); + } + if ( $size > 1024) { # Arbitrary limit $bufsize = 1024; } else { @@ -63,10 +72,16 @@ sub process_cmd # Open src my $cmdstr = '$src = CALL open '."$src O_RDONLY\n"; helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); + helper::verify_cmd($cmdfh, $outfh, "open $src"); # Open dest - $cmdstr = '$dest = CALL open '."$dest O_RDWR|O_CREAT 7777\n"; + my $flags = "O_WRONLY|O_CREAT"; + if ($overwrite == 0) { + $flags .= "|O_EXCL"; + } + $cmdstr = '$dest = CALL open '."$dest $flags 0666\n"; helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); + my $destfile = helper::verify_cmd($cmdfh, $outfh, "open $dest"); # Allocate buffer $cmdstr = '$buf = ALLOC '."$bufsize\n"; @@ -75,15 +90,60 @@ sub process_cmd # Read size bytes from src and write them out to dest my $bytes = $size; while ($bytes > 0) { + + my $readb; + my $res; + if ($src eq "/dev/stdin") { + # Send "delay" option to read which will give us time to + # put something in stdin (since we can't send an eof) + my $cmdstr = "CALL read ".'$src $buf '."$bytes delay\n"; + print $cmdfh $cmdstr; + # Give time to process command + sleep 1; + + # Send line from stdin + print $cmdfh $line; + sleep 0.5; + + # Make sure read was OK + $res = <$outfh>; + chop($res); + if ($res ne "0000 ") { + helper::print_and_exit($cmdfh, $outfh, 1, "ERROR! Read failed with code $res\n"); + } + + # See how many bytes we got... + $readb = helper::verify_cmd($cmdfh, $outfh, "read"); + $readb = oct($readb); + if ($readb != $bytes) { + helper::print_and_exit($cmdfh, $outfh, 0, "Short read\n"); + } + + $cmdstr = "CALL write ".'$dest $buf '."$readb\n"; + print $cmdfh $cmdstr; + + # Suck up the stdout... + $res = <$outfh>; + chop($res); + + $res = <$outfh>; + chop($res); + $res = oct($res); + + if ($res != 0) { + helper::print_and_exit($cmdfh, $outfh, 1, "ERROR! Write failed with code $res\n"); + } + } else { $cmdstr = 'CALL read $src $buf '."$bufsize\n"; helper::send_cmd($cmdfh, $outfh, "read", $cmdstr); - my $res = helper::verify_cmd($cmdfh, $outfh, "read"); - my $readb = oct($res); + $res = helper::verify_cmd($cmdfh, $outfh, "read"); + $readb = oct($res); # Now write $readb back out to dest $cmdstr = 'CALL write $dest $buf '."$readb\n"; helper::send_cmd($cmdfh, $outfh, "write", $cmdstr); + } $res = helper::verify_cmd($cmdfh, $outfh, "write"); @@ -101,31 +161,41 @@ sub process_cmd $cmdstr = 'CALL close $dest'."\n"; helper::send_cmd($cmdfh, $outfh, "close", $cmdstr); + if ($src ne "/dev/stdin") { my $cmpres = system("cmp -s $src $dest"); if ($cmpres != 0) { print STDOUT "ERROR! File $src differs from $dest\n"; exit 1; } - + } helper::print_and_exit($cmdfh, $outfh, 0, "copy test successful\n"); } my $currarg = 0; my $is_alpha = 0; +my $overwrite = 0; + +my $len = @ARGV-2; if (@ARGV < 2) { usage; -} elsif (@ARGV > 2 ) { - if ($ARGV[$currarg++] eq "-alpha") { +} + +my $i; +for ($i=0; $i < $len; $i++ ) { + if ($ARGV[$i] eq "-alpha") { $is_alpha = 1; } + if ($ARGV[$i] eq "-o") { + $overwrite = 1; + } } -my $src = $ARGV[$currarg++]; -my $dest = $ARGV[$currarg]; +my $src = $ARGV[$i++]; +my $dest = $ARGV[$i]; -process_cmd($src, $dest, $is_alpha); +process_cmd($src, $dest, $overwrite, $is_alpha); exit 0; Index: test_driver.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_driver.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- test_driver.c 6 Feb 2004 20:07:31 -0000 1.6 +++ test_driver.c 14 Feb 2004 19:43:00 -0000 1.7 @@ -227,10 +227,47 @@ char *get_str(char *var_name) return var_name; } +static char* +get_or_part(char **str, int* did_alloc) +{ + char *tmp_str = *str; + int i, norm_str=0; + + if (tmp_str == NULL) + return NULL; + + if (tmp_str[0] == '|') { + tmp_str++; + norm_str=1; + } + + for (i=0; (unsigned int)i < strlen(tmp_str); i++) { + if (tmp_str[i] == '|') { + char *new_str = (char *)malloc(i+1); + memcpy(new_str, tmp_str, i); + new_str[i] = '\0'; + *did_alloc = 1; + *str = &tmp_str[i]; + return new_str; + } + } + + if (norm_str) { + *did_alloc = 0; + *str = NULL; + return tmp_str; + } + + return NULL; +} + int get_obj(char *var_name) { + char** str = &var_name; + char *str1; struct var_mapping *var_map; - int i; + int did_alloc=0; + int obj=0, got_obj=0; DBG(5, fprintf(outfp, "Getting object for %s\n", var_name)); @@ -242,53 +279,33 @@ int get_obj(char *var_name) * Check for '|', indicates that one or more values are or'd * together */ - for (i=0; (unsigned int)i < strlen(var_name); i++) { - if (var_name[i] == '|') { - char *str1 = malloc(i+1); - char *str2 = malloc(strlen(var_name)-i+1); - int obj; - struct var_mapping *tmp_map; - - memcpy(str1, var_name, i); - str1[i] = '\0'; - memcpy(str2, (char *)&var_name[i+1], strlen(var_name)-i); + while ((str1 = get_or_part(str, &did_alloc)) != NULL) { if (isdigit(str1[0])) { if (str1[0] == '0') { /* Assume octal format */ - obj = strtol(str1, NULL, 8); + obj |= strtol(str1, NULL, 8); } else - obj = atoi(str1); + obj |= atoi(str1); } else { - tmp_map = get_map(str1); - if (!tmp_map) { + var_map = get_map(str1); + if (!var_map) { + if (did_alloc) free(str1); - free(str2); return -1; } - obj = tmp_map->obj; + obj |= var_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) { + if (did_alloc) { + did_alloc = 0; free(str1); - free(str2); - return -1; } - obj |= tmp_map->obj; + got_obj++; } - free(str1); - free(str2); + + if (got_obj) return obj; - } - } var_map = get_map(var_name); if (!var_map) @@ -983,10 +1000,12 @@ int main(int argc, char *argv[]) print_line = 0; +#if 0 /* sysio defaults */ strcpy(root_driver, DEFAULT_DRIVER); strcpy(mntpath, "/"); mntflgs = 0; +#endif my_errno = 0; Index: test_driver.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_driver.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -b -B -p -r1.4 -r1.5 --- test_driver.h 6 Feb 2004 20:07:31 -0000 1.4 +++ test_driver.h 14 Feb 2004 19:43:00 -0000 1.5 @@ -209,7 +209,7 @@ extern int test_do_umount(int argc, char /* Functions defined in sysio_tests.c */ extern int sysio_mount(char *from, char *to); extern int sysio_list(char *path); -extern int initilize_sysio(char *root_driver, char *root_path, int mntflgs); +extern int initilize_sysio(void); extern int sysio_chdir(char *newdir); extern int sysio_chmod(char *mode_arg, const char *path); extern int sysio_chown(char *new_id, char *file); Index: test_getcwd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_getcwd.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- test_getcwd.c 10 Oct 2003 18:50:31 -0000 1.3 +++ test_getcwd.c 14 Feb 2004 19:43:00 -0000 1.4 @@ -64,7 +64,7 @@ /* * Test getcwd() * - * Usage: test_cwd [-a] [-m <fsname>] [-r <mntpath>] [<working-dir>...] + * Usage: test_cwd [<working-dir>...] * * Without any path arguments, the program reads from standard-in, dealing with * each line as an absolute or relative path until EOF. @@ -73,68 +73,32 @@ static int doit(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; + extern int _test_sysio_startup(void); /* * Parse command line arguments. */ - while ((i = getopt(argc, argv, opts)) != -1) + while ((i = getopt(argc, argv, "")) != -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(); } -#ifndef CPLANT_YOD /* * 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); + err = _test_sysio_startup(); if (err) { errno = -err; - perror("_sysio_mount_root"); + perror("sysio startup"); exit(1); } -#endif n = argc - optind; @@ -170,12 +134,10 @@ main(int argc, char *const argv[]) } } -#ifndef CPLANT_YOD /* * Clean up. */ _sysio_shutdown(); -#endif return 0; } @@ -205,10 +167,6 @@ usage() (void )fprintf(stderr, "Usage: test_getcwd " -#ifdef AUTOMOUNT_FILE_NAME - "[-a] " -#endif - "[-m <driver>] [-r <mntpath>]" " [<path> ...\n]"); exit(1); Index: test_link.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_link.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -b -B -p -r1.1 -r1.2 --- test_link.c 20 Oct 2003 16:32:29 -0000 1.1 +++ test_link.c 14 Feb 2004 19:43:00 -0000 1.2 @@ -46,11 +46,11 @@ #include <string.h> #ifndef REDSTORM #include <getopt.h> -#else -#include <unistd.h> #endif +#include <unistd.h> #include <errno.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> #if 0 #include <dirent.h> @@ -64,49 +64,26 @@ /* * Test hard link * - * Usage: link [-a] [-m <fsname>] [-r <mntpath>] oldpath newpath + * Usage: link oldpath newpath * */ -static int linkit(const char *old, const char *new); 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; + extern int _test_sysio_startup(void); /* * Parse command line arguments. */ - while ((i = getopt(argc, argv, opts)) != -1) + while ((i = getopt(argc, argv, "")) != -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(); } @@ -114,22 +91,10 @@ main(int argc, char *const argv[]) /* * Init sysio lib. */ - _sysio_init(); - - /* - * Init native file system driver and request mount of specified - * source directory. - */ - err = drv_init_all(); + err = _test_sysio_startup(); 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"); + perror("sysio startup"); exit(1); } @@ -141,10 +106,18 @@ main(int argc, char *const argv[]) */ while (optind < argc) { const char *old, *new; + struct stat stbuf; old = argv[optind++]; new = argv[optind++]; - (void )linkit(old, new); + if ((err = link(old, new)) != 0) { + perror("link"); + break; + } + if ((err = lstat(new, &stbuf)) != 0) { + perror(new); + break; + } } /* @@ -152,19 +125,7 @@ main(int argc, char *const argv[]) */ _sysio_shutdown(); - return 0; -} - -static int -linkit(const char *old, const char *new) -{ - unlink(new); - if (link(old, new) < 0) { - perror(old); - return -1; - } - - return 0; + return err ? -1 : 0; } static void @@ -172,7 +133,7 @@ usage() { (void )fprintf(stderr, - "Usage: unlink [-a] [-m <driver>] [-r <mntpath>]" + "Usage: unlink" " oldpath newpath\n"); exit(1); Index: test_list.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_list.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- test_list.c 10 Oct 2003 18:50:31 -0000 1.6 +++ test_list.c 14 Feb 2004 19:43:00 -0000 1.7 @@ -64,7 +64,7 @@ /* * Stat files. * - * Usage: test_list [-a] [-m <fsname>] [-r <mntpath>] [path...] + * Usage: test_list [path...] * * Without any path arguments, the program reads from standard-in, dealing with * each line as an absolute or relative path until EOF. @@ -73,69 +73,34 @@ static int listit(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; + extern int _test_sysio_startup(void); /* * Parse command line arguments. */ - while ((i = getopt(argc, argv, opts)) != -1) + while ((i = getopt(argc, argv, "")) != -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(); } -#ifndef CPLANT_YOD /* * 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); + err = _test_sysio_startup(); if (err) { errno = -err; - perror("_sysio_mount_root"); + perror("sysio startup"); exit(1); } -#endif + n = argc - optind; /* @@ -170,12 +135,10 @@ main(int argc, char *const argv[]) } } -#ifndef CPLANT_YOD /* * Clean up. */ _sysio_shutdown(); -#endif return 0; } @@ -243,7 +206,7 @@ usage() { (void )fprintf(stderr, - "Usage: list_path [-a] [-m <driver>] [-r <mntpath>]" + "Usage: list_path" " [<path> ...\n]"); exit(1); Index: test_path.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_path.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- test_path.c 10 Oct 2003 18:50:31 -0000 1.6 +++ test_path.c 14 Feb 2004 19:43:00 -0000 1.7 @@ -64,7 +64,7 @@ /* * Stat files. * - * Usage: test_path [-a] [-m <fsname>] [-r <mntpath>] [path...] + * Usage: test_path [path...] * * Without any path arguments, the program reads from standard-in, dealing with * each line as an absolute or relative path until EOF. @@ -73,69 +73,33 @@ static int statit(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; + extern int _test_sysio_startup(void); /* * Parse command line arguments. */ - while ((i = getopt(argc, argv, opts)) != -1) + while ((i = getopt(argc, argv, "")) != -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(); } -#ifndef CPLANT_YOD /* * Init sysio lib. */ - _sysio_init(); - - /* - * Init native file system driver and request mount of specified - * source directory. - */ - err = drv_init_all(); + err = _test_sysio_startup(); if (err) { errno = -err; - perror("drv_init_all"); + perror("sysio startup"); exit(1); } - err = _sysio_mount_root(mntpath, root_driver, mntflgs, NULL); - if (err) { - errno = -err; - perror("_sysio_mount_root"); - exit(1); - } -#endif n = argc - optind; @@ -171,12 +135,10 @@ main(int argc, char *const argv[]) } } -#ifndef CPLANT_YOD /* * Clean up. */ _sysio_shutdown(); -#endif return 0; } @@ -248,7 +210,7 @@ usage() { (void )fprintf(stderr, - "Usage: test_path [-a] [-m <driver>] [-r <mntpath>]" + "Usage: test_path" " [<path> ...\n]"); exit(1); Index: test_regions.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_regions.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- test_regions.c 6 Feb 2004 20:07:31 -0000 1.2 +++ test_regions.c 14 Feb 2004 19:43:00 -0000 1.3 @@ -76,7 +76,7 @@ /* * Copy one file to another. * - * Usage: test_regions [-a] [-r <source>] [-m <root-driver>] [-x] \ + * Usage: test_regions [-x] \ * {r,w} <off> <count> <path> * * Destination will not be overwritten if it already exist. @@ -90,10 +90,6 @@ #warning Cannot prompt the 64-bit interface #endif -char *root_driver = DEFAULT_DRIVER; -char *mntpath = "/"; -unsigned mntflgs = 0; - char which; #ifdef GO64 int use64 = 0; /* 64-bit interface? */ @@ -119,6 +115,7 @@ main(int argc, char * const argv[]) int flags; int fd; ssize_t cc; + extern int _test_sysio_startup(void); /* * Parse command-line args. @@ -128,26 +125,12 @@ main(int argc, char * const argv[]) #ifdef __GLIBC__ "+" #endif -#ifdef AUTOMOUNT_FILE_NAME - "a" -#endif #ifdef GO64 "x" #endif - "r:m:")) != -1) + "")) != -1) switch (i) { -#ifdef AUTOMOUNT_FILE_NAME - case 'a': - mntflgs |= MOUNT_F_AUTO; - break; -#endif - case 'r': /* set working dir */ - mntpath = optarg; - break; - case 'm': - root_driver = optarg; - break; #ifdef GO64 case 'x': use64 = 1; @@ -196,30 +179,22 @@ main(int argc, char * const argv[]) usage(); path = argv[optind++]; -#ifndef CPLANT_YOD - if (_sysio_init() != 0) { - perror("init sysio"); - exit(1); - } - err = drv_init_all(); - if (err) { - perror("init drivers"); - exit(1); - } - err = _sysio_mount_root(mntpath, root_driver, mntflgs, NULL); + err = _test_sysio_startup(); if (err) { errno = -err; - perror(root_driver); + perror("sysio startup"); exit(1); } -#endif + (void )umask(022); buf = malloc(nbytes); if (!buf) { perror("malloc"); - exit(1); + err = 1; + goto out; } + (void )memset(buf, 0, nbytes); err = 0; flags = which == 'r' ? O_RDONLY : (O_WRONLY|O_CREAT|O_EXCL); @@ -231,7 +206,7 @@ main(int argc, char * const argv[]) if (fd < 0) { perror(path); err = 1; - goto out; + goto error; } #ifdef GO64 if (use64) @@ -243,12 +218,14 @@ main(int argc, char * const argv[]) #ifdef GO64 if ((use64 && off64 < 0) || (!use64 && off < 0)) { perror(use64 ? "lseek64" : "lseek"); - exit(1); + err = 1; + goto error; } #else if (off < 0) { perror("lseek"); - exit(1); + err = 1; + goto error; } #endif if (which == 'r') @@ -297,12 +274,11 @@ main(int argc, char * const argv[]) ); error: - if (close(fd) != 0) + if (fd > 0 && close(fd) != 0) perror(path); + free(buf); out: -#ifndef CPLANT_YOD _sysio_shutdown(); -#endif return err; } @@ -313,13 +289,9 @@ usage() (void )fprintf(stderr, "Usage: test_regions " -#ifdef AUTOMOUNT_FILE_NAME - "[-a] " -#endif #ifdef GO64 "[-x] " #endif - "[-r <source>] [-m <fsname>]" " {r,w} <offset> <nbytes> <path>\n"); exit(1); } Index: test_rename.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_rename.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- test_rename.c 28 Oct 2003 18:54:19 -0000 1.3 +++ test_rename.c 14 Feb 2004 19:43:00 -0000 1.4 @@ -65,13 +65,9 @@ /* * Rename a file system object. * - * Usage: test_rename [-a] [-r <source>] [-m <root-driver>] <src> <dest> + * Usage: test_rename <src> <dest> */ -char *root_driver = DEFAULT_DRIVER; -char *mntpath = "/"; -unsigned mntflgs = 0; - void usage(void); int rename_file(const char *spath, const char *dpath); @@ -81,52 +77,31 @@ main(int argc, char * const argv[]) int i; int err; const char *spath, *dpath; + extern int _test_sysio_startup(void); /* * Parse command-line args. */ while ((i = getopt(argc, argv, -#ifdef AUTOMOUNT_FILE_NAME - "a" -#endif - "r:m:")) != -1) + "" + )) != -1) switch (i) { -#ifdef AUTOMOUNT_FILE_NAME - case 'a': - mntflgs |= MOUNT_F_AUTO; - break; -#endif - case 'r': /* set working dir */ - mntpath = optarg; - break; - case 'm': - root_driver = optarg; - break; default: usage(); } if (!(argc - optind)) usage(); -#ifndef CPLANT_YOD - if (_sysio_init() != 0) { - perror("init sysio"); - exit(1); - } - err = drv_init_all(); - if (err) { - perror("init drivers"); - exit(1); - } - err = _sysio_mount_root(mntpath, root_driver, mntflgs, NULL); + + err = _test_sysio_startup(); if (err) { errno = -err; - perror(root_driver); + perror("sysio startup"); exit(1); } -#endif + (void )umask(022); /* @@ -146,9 +121,7 @@ main(int argc, char * const argv[]) if (err) perror("rename"); -#ifndef CPLANT_YOD _sysio_shutdown(); -#endif return err; } @@ -159,10 +132,6 @@ usage() (void )fprintf(stderr, "Usage: test_rename " -#ifdef AUTOMOUNT_FILE_NAME - "[-a] " -#endif - "[-r <source>] [-m <fsname>]" " source destination\n"); exit(1); } Index: test_stats.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_stats.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- test_stats.c 10 Oct 2003 18:50:31 -0000 1.5 +++ test_stats.c 14 Feb 2004 19:43:00 -0000 1.6 @@ -66,79 +66,45 @@ /* * Get stats of file and file system. * - * Usage: test_stats [-a] [-r <root-path>] [-m <root-driver>] [<path> ...] + * Usage: test_stats [<path> ...] */ -char *root_driver = DEFAULT_DRIVER; -char *root_path = "/"; -unsigned mntflgs = 0; - void usage(void); void do_stats(const char *path); -#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; + extern int _test_sysio_startup(void); /* * Parse command-line args. */ - while ((i = getopt(argc, argv, opts)) != -1) + while ((i = getopt(argc, argv, "")) != -1) switch (i) { -#ifdef AUTOMOUNT_FILE_NAME - case 'a': - mntflgs |= MOUNT_F_AUTO; - break; -#endif - case 'r': - root_path = optarg; - break; - case 'm': - root_driver = optarg; - break; default: usage(); } -#ifndef CPLANT_YOD - if (_sysio_init() != 0) { - perror("init sysio"); - exit(1); - } - err = drv_init_all(); - if (err) { - perror("init drivers"); - exit(1); - } - err = _sysio_mount_root(root_path, root_driver, mntflgs, NULL); + err = _test_sysio_startup(); if (err) { errno = -err; - perror(root_driver); + perror("sysio startup"); exit(1); } -#endif + (void )umask(022); while (optind < argc) do_stats(argv[optind++]); -#ifndef CPLANT_YOD /* * Clean up. */ _sysio_shutdown(); -#endif return 0; } @@ -148,7 +114,7 @@ usage() { (void )fprintf(stderr, - "Usage: test_stats [-a] [-m <fsname>] [-r <root-path>]" + "Usage: test_stats" " source destination\n"); exit(1); } Index: test_unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_unlink.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- test_unlink.c 10 Oct 2003 18:50:32 -0000 1.2 +++ test_unlink.c 14 Feb 2004 19:43:00 -0000 1.3 @@ -64,7 +64,7 @@ /* * Unlink files. * - * Usage: unlink [-a] [-m <fsname>] [-r <mntpath>] [path...] + * Usage: unlink [path...] * * Without any path arguments, the program unlinks files named * by the ocmmand line args. @@ -73,42 +73,20 @@ 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; + extern int _test_sysio_startup(void); /* * Parse command line arguments. */ - while ((i = getopt(argc, argv, opts)) != -1) + while ((i = getopt(argc, argv, "")) != -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(); } @@ -116,22 +94,10 @@ main(int argc, char *const argv[]) /* * 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); + err = _test_sysio_startup(); if (err) { errno = -err; - perror("_sysio_mount_root"); + perror("sysio startup"); exit(1); } @@ -194,7 +160,7 @@ usage() { (void )fprintf(stderr, - "Usage: unlink [-a] [-m <driver>] [-r <mntpath>]" + "Usage: unlink" " [<path> ...\n]"); exit(1); --- test_mounts.c DELETED --- --- test_stdfd.c DELETED --- |
|
From: Lee W. <lw...@us...> - 2004-02-14 19:49:41
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16325/src Modified Files: init.c ioctx.c link.c lseek.c mount.c namei.c rename.c rmdir.c rw.c unlink.c Log Message: + Merged in changes from namespace_assembly branch (see .../misc/init-env.sh) This provoked a bunch of bugs. See below. + Fixed a bug in _sysio_enumerate_extents(). If the IO operation was short, it would go round the loop again, mistakenly trying to fill more of the extent. + In rw.c, fixed bugs in [p]{read,write}[vx] (all the synchronous routines) that improperly propagated error returns. They were returning -errno instead of setting errno and returning -1. + In fs_native.c:doiov, fixed a bug where a zero-length IO was improperly thought to be an error. + In lseek.c:_sysio_lseek, fixed final position check to properly determine {under,over}flow. + In link.c:link, fixed the existence check. No error is returned for nonexistent files when ND_NEGOK is specified. We're supposed to check whether it's a negative entry or not. + A new macro, I_GONE, was added to inode.h. This will *try* to kill an inode but if it can't, it becomes a zombie instead. + In unlink.c:unlink, link.c:link, rename.c:rename, the driver ops were being called but the actual operation in the internal path tree was not reflected. Also, for unlink and rename, use the new I_GONE macro on the destroyed inode. + In fs_native.c:native_inop_gone, close() was always called, even when the fildes was -1. + In fs_native.c:native_inop_gone, close() was called. We really meant to call syscal(SYS_close, ...); + In namei.c:_sysio_path_walk, fixed broken symlink handling. It wasn't following symlinks anywhere if ND_NOFOLLOW was set. That flag only means that the *last* component should not be followed. + In namei.c:_sysio_path_walk, fixed buffer overrun problem for very long symlinks. + In fs_incore.c, fixed dirop_{link,rename,unlink,rmdir} because they were manipulating the system path cache and shouldn't. + In mount.c:_sysio_unmount_all we were mistakenly releasing an FS root after a failed unmount attempt. + Fixes in test_regions.c free allocated memory at the end so valgrind doesn't show a leak. Index: init.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/init.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- init.c 6 Feb 2004 20:07:30 -0000 1.6 +++ init.c 14 Feb 2004 19:42:59 -0000 1.7 @@ -9,7 +9,7 @@ * 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. + * Cplant(TM) Copyright 1998-2004 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 @@ -41,26 +41,50 @@ * le...@sa... */ +#define _BSD_SOURCE + #include <stdlib.h> +#include <unistd.h> +#include <string.h> #include <errno.h> +#include <limits.h> +#include <assert.h> #include <sys/types.h> +#include <sys/stat.h> #include <sys/queue.h> +#include <sys/uio.h> + +#include <sys/stat.h> +#include <fcntl.h> #include "sysio.h" #include "inode.h" +#include "fs.h" #include "mount.h" #include "file.h" #include "dev.h" - -#if ZERO_SUM_MEMORY -#include "fs.h" -#endif +#include "xtio.h" #ifdef STDFD_DEV #include "stdfd.h" #endif /* + * The namespace assembly buffer passes args with a `name'=`value' + * syntax. We use the following to record that in various + * routines below. + */ +struct named_argument { + const char *name; /* arg name */ + char *value; /* arg value */ +}; + +/* + * White space characters. + */ +#define IGNORE_WHITE " \t\r\n" + +/* * Sysio library initialization. Must be called before anything else in the * library. */ @@ -124,3 +148,477 @@ _sysio_shutdown() _sysio_fssw_shutdown(); #endif } + +/* + * (kind of)Duplicates strtok function. + * + * Given a buffer, returns the longest string + * that does not contain any delim characters. Will + * remove ws and any characters in the ignore string. + * Returns the token. + * + * The parameter controlling acceptance controls whether a positive + * match for some delimiter be made or not. If set, then either a delimiter + * or NUL character is success. + * + */ +static const char * +get_token(const char *buf, + int accepts, + const char *delim, + const char *ignore, + char *tbuf) +{ + char c; + int escape, quote; + + /* + * Find the first occurance of delim, recording how many + * characters lead up to it. Ignore indicated characters. + */ + escape = quote = 0; + while ((c = *buf) != '\0') { + buf++; + if (!escape) { + if (c == '\\') { + escape = 1; + continue; + } + if (c == '\"') { + quote ^= 1; + continue; + } + if (!quote) { + if (strchr(delim, c) != NULL) { + accepts = 1; + break; + } + if (strchr(ignore, c) != NULL) + continue; + } + } else + escape = 0; + *tbuf++ = c; + } + if (!accepts) + return NULL; + *tbuf = '\0'; /* NUL term */ + return buf; +} + +/* + * Parse and record named arguments given as `name = value', comma-separated + * pairs. + * + * NB: Alters the passed buffer. + */ +static char * +get_args(char *buf, struct named_argument *vec) +{ + char *nxt; + char *name, *value; + struct named_argument *v; + + for (;;) { + nxt = (char *)get_token(buf, 1, "=,", IGNORE_WHITE, name = buf); + if (!nxt || + (nxt != buf && *name == '\0' && buf + strlen(buf) == nxt)) { + buf = NULL; + break; + } + if (*name == '\0') + break; + buf = (char *)get_token(nxt, 1, ",", IGNORE_WHITE, value = nxt); + if (*value == '\0') + value = NULL; + for (v = vec; v->name; v++) + if (strcmp(v->name, name) == 0) + break; + if (!v->name) + return NULL; + v->value = value; + } + + return buf; +} + +static int +parse_mm(const char *s, dev_t *devp) +{ + unsigned long ul; + char *cp; + dev_t dev; + + ul = strtoul(s, &cp, 0); + if (*cp != '+' || ul > USHRT_MAX) + return -EINVAL; + dev = ul << 16; + s = (const char *)++cp; + ul = strtoul(s, &cp, 0); + if (*cp != '\0' || ul > USHRT_MAX) + return -EINVAL; + dev |= ul & 0xffff; + *devp = dev; + return 0; +} + +/* + * Performs the creat command for the namespace assembly + * + * NB: Alters the passed buffer. + */ +static int +do_creat(char *args) +{ + size_t len; + struct named_argument v[] = { + { "ft", NULL }, /* file type */ + { "nm", NULL }, /* name */ + { "pm", NULL }, /* permissions */ + { "ow", NULL }, /* owner */ + { "gr", NULL }, /* group */ + { "mm", NULL }, /* major + minor */ + { "str", NULL }, /* file data */ + { NULL, NULL } + }; + const char *cp; + long perms; + long owner, group; + struct pnode *dir, *pno; + mode_t mode; + struct intent intent; + dev_t dev; + int err; + + len = strlen(args); + if (get_args(args, v) - args != (ssize_t )len || + !(v[0].value && + v[1].value && + v[2].value)) + return -EINVAL; + perms = strtol(v[2].value, (char **)&cp, 0); + if (*cp || + perms < 0 || + (perms == LONG_MAX && errno == ERANGE) || + ((unsigned)perms & ~0777)) + return -EINVAL; + if (v[3].value) { + owner = strtol(v[3].value, (char **)&cp, 0); + if (*cp || + ((owner == LONG_MIN || owner == LONG_MAX) + && errno == ERANGE)) + return -EINVAL; + } else + owner = getuid(); + if (v[4].value) { + group = strtol(v[4].value, (char **)&cp, 0); + if (*cp || + ((group == LONG_MIN || group == LONG_MAX) && + errno == ERANGE)) + return -EINVAL; + } else + group = getegid(); + + if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) + return -ENOENT; + err = 0; + mode = perms; + if (strcmp(v[0].value, "dir") == 0) { + INTENT_INIT(&intent, INT_CREAT, &mode, 0); + err = _sysio_namei(dir, v[1].value, ND_NEGOK, &intent, &pno); + if (err) + return err; + if (pno->p_base->pb_ino) + err = -EEXIST; + else if (IS_RDONLY(pno->p_parent, + pno->p_parent->p_base->pb_ino)) + err = -EROFS; + else { + struct inode *ino; + + ino = pno->p_parent->p_base->pb_ino; + err = (*ino->i_ops.inop_mkdir)(pno, mode); + } + P_RELE(pno); + } else if (strcmp(v[0].value, "chr") == 0) { + if (!(v[5].value && parse_mm(v[5].value, &dev) == 0)) + return -EINVAL; + mode |= S_IFCHR; + INTENT_INIT(&intent, INT_CREAT, &mode, 0); + err = _sysio_namei(dir, v[1].value, ND_NEGOK, &intent, &pno); + if (err) + return err; + if (pno->p_base->pb_ino) + err = -EEXIST; + else if (IS_RDONLY(pno->p_parent, + pno->p_parent->p_base->pb_ino)) + err = -EROFS; + else { + struct inode *ino; + + ino = pno->p_parent->p_base->pb_ino; + err = (*ino->i_ops.inop_mknod)(pno, mode, dev); + } + P_RELE(pno); + } else if (strcmp(v[0].value, "blk") == 0) { + /* + * We don't support block special files yet. + */ + return -EINVAL; + } else if (strcmp(v[0].value, "file") == 0) { + int i; + struct inode *ino; + + i = O_CREAT|O_EXCL; + INTENT_INIT(&intent, INT_CREAT, &mode, &i); + err = _sysio_namei(dir, v[1].value, ND_NEGOK, &intent, &pno); + if (err) + return err; + err = _sysio_open(pno, O_CREAT|O_EXCL, mode); + if (err) { + P_RELE(pno); + return err; + } + ino = pno->p_base->pb_ino; + if (!err && v[6].value) { + struct iovec iovec; + struct intnl_xtvec xtvec; + struct ioctx io_context; + + /* + * Deposit optional file content. + */ + iovec.iov_base = v[6].value; + iovec.iov_len = strlen(v[6].value); + xtvec.xtv_off = 0; + xtvec.xtv_len = iovec.iov_len; + IOCTX_INIT(&io_context, + 1, + (ioid_t )&io_context, + ino, + &iovec, 1, + &xtvec, 1); + _sysio_ioctx_enter(&io_context); + err = + (*ino->i_ops.inop_write)(pno->p_base->pb_ino, + &io_context); + if (!err) { + ssize_t cc; + + cc = _sysio_ioctx_wait(&io_context); + if (cc < 0) + err = cc; + else if ((size_t )cc != iovec.iov_len) + err = -EIO; /* huh? */ + } else + _sysio_ioctx_complete(&io_context); + } + i = (*ino->i_ops.inop_close)(ino); + if (!err) + err = i; + P_RELE(pno); + } else + err = -EINVAL; + + return err; +} + +/* + * Do mount. + * + * NB: The passed buffer is altered. + */ +static int +do_mnt(char *args) +{ + size_t len; + struct named_argument v[] = { + { "dev", NULL }, /* source (type:dev) */ + { "dir", NULL }, /* target dir */ + { "fl", NULL }, /* flags */ + { "da", NULL }, /* mount data */ + { NULL, NULL } + }; + char *ty, *name; + unsigned long flags; + struct pnode *dir; + + len = strlen(args); + if (get_args(args, v) - args != (ssize_t )len || + !(v[0].value && v[1].value)) + return -EINVAL; + ty = (char *)get_token(v[0].value, 1, ":", "", name = v[0].value); + flags = 0; + if (v[2].value) { + char *cp; + + /* + * Optional flags. + */ + flags = strtoul(v[2].value, &cp, 0); + if (*cp || (flags == ULONG_MAX && errno == ERANGE)) + return -EINVAL; + } + + if (strlen(v[1].value) == 1 && v[1].value[0] == PATH_SEPARATOR) { + /* + * Aha! It's root they want. Have to do that special. + */ + return _sysio_mount_root(ty, name, flags, v[3].value); + } + + if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) + return -ENOENT; + return _sysio_mount(dir, ty, v[1].value, name, flags, v[3].value); +} + + +/* + * Chdir + * + * NB: Alters the passed buffer. + */ +static int +do_cd(char *args) +{ + size_t len; + struct named_argument v[] = { + { "dir", NULL }, /* directory */ + { NULL, NULL } + }; + int err; + struct pnode *dir, *pno; + + len = strlen(args); + if (get_args(args, v) - args != (ssize_t )len || !v[0].value) + return -EINVAL; + + if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) + return -ENOENT; + err = _sysio_namei(dir, v[0].value, 0, NULL, &pno); + if (err) + return err; + err = _sysio_p_chdir(pno); + if (err) + P_RELE(pno); + return err; +} + +/* + * Does a chmod + * + * NB: Alters passed buffer. + */ +static int +do_chmd(char *args) +{ + size_t len; + struct named_argument v[] = { + { "src", NULL }, /* path */ + { "pm", NULL }, /* perms */ + { NULL, NULL } + }; + long perms; + char *cp; + struct intnl_stat stbuf; + int err; + struct pnode *dir, *pno; + + len = strlen(args); + if (get_args(args, v) - args != (ssize_t )len || + !(v[0].value && v[1].value)) + return -EINVAL; + perms = strtol(v[1].value, &cp, 0); + if (*cp || + perms < 0 || + (perms == LONG_MAX && errno == ERANGE) || + ((unsigned)perms & ~0777)) + return -EINVAL; + (void )memset(&stbuf, 0, sizeof(stbuf)); + stbuf.st_mode = (mode_t)perms; + + if (!(dir = _sysio_cwd) && !(dir = _sysio_root)) + return -ENOENT; + err = _sysio_namei(dir, v[0].value, 0, NULL, &pno); + if (err) + return err; + err = _sysio_setattr(pno, pno->p_base->pb_ino, SETATTR_MODE, &stbuf); + P_RELE(pno); + + return err; +} + +/* + * Execute the given cmd. + * + * NB: Buf is altered. + */ +static int +do_command(char *buf) +{ + size_t len; + char *args, *cmd; + + len = strlen(buf); + args = (char *)get_token(buf, 1, ",", IGNORE_WHITE, cmd = buf); + if (args) { + if (strcmp("creat", cmd) == 0) + return do_creat(args); + if (strcmp("mnt", cmd) == 0) + return do_mnt(args); + if (strcmp("cd", cmd) == 0) + return do_cd(args); + if (strcmp("chmd", cmd) == 0) + return do_chmd(args); + } + return -EINVAL; +} + +/* + * Given a command sequence buffer, parse it and run the given + * commands + */ +int +_sysio_boot(const char *buf) +{ + char c, *tok; + int err; + + /* + * Allocate token buffer. + */ + tok = malloc(strlen(buf)); + if (!tok) + return -ENOMEM; + err = 0; + while (1) { + /* + * Discard leading white space. + */ + while ((c = *buf) != '\0' && + !(c == '{' || strchr(IGNORE_WHITE, c) == NULL)) + buf++; + if (c == '\0') + break; + if (c != '{') { + err = -EINVAL; + break; + } + /* + * Get the command. + */ + buf = (char *)get_token(buf + 1, 0, "}", IGNORE_WHITE, tok); + if (!buf) { + err = -EINVAL; + break; + } + /* + * Perform. + */ + err = do_command(tok); + if (err) + break; + } + free(tok); + return err; +} Index: ioctx.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- ioctx.c 6 Feb 2004 20:07:30 -0000 1.7 +++ ioctx.c 14 Feb 2004 19:42:59 -0000 1.8 @@ -344,6 +344,7 @@ _sysio_enumerate_extents(const struct in const struct iovec *start; _SYSIO_OFF_T off; size_t n; + size_t remain; acc = 0; iovec.iov_len = 0; @@ -406,6 +407,7 @@ _sysio_enumerate_extents(const struct in iovec.iov_len = n; continue; } + remain = xtvec.xtv_len - n; cc = (*f)(start, iov - start, xtvec.xtv_off, @@ -416,10 +418,13 @@ _sysio_enumerate_extents(const struct in return acc; return cc; } + remain -= cc; cc += acc; if (acc && cc <= acc) abort(); /* paranoia */ acc = cc; + if (remain) + return acc; /* short */ } xtvec.xtv_off += cc; xtvec.xtv_len -= cc; Index: link.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/link.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- link.c 26 Jan 2004 16:34:54 -0000 1.3 +++ link.c 14 Feb 2004 19:42:59 -0000 1.4 @@ -67,32 +67,34 @@ link(const char *oldpath, const char *ne goto out; if (S_ISDIR(old->p_base->pb_ino->i_mode)) { err = -EPERM; - goto error2; + goto error1; } INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); + new = NULL; err = _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &new); - if (err && !new) - goto error2; - if (err && err != -ENOENT) { - err = -EEXIST; + if (err) goto error1; + if (new->p_base->pb_ino) { + err = -EEXIST; + goto error2; } if (old->p_mount->mnt_root != new->p_mount->mnt_root) { err = -EXDEV; - goto error1; + goto error2; } err = old->p_base->pb_ino->i_ops.inop_link(old, new); if (err) - goto error1; + goto error2; /* - * The new path-base node must point to the inode referenced by - * the old. As well, we need to record the new reference of the inode. + * The new p-node must be pointed at the inode referenced by the old. */ + assert(!new->p_base->pb_ino && old->p_base->pb_ino); new->p_base->pb_ino = old->p_base->pb_ino; I_REF(new->p_base->pb_ino); -error1: - P_RELE(new); + error2: + P_RELE(new); +error1: P_RELE(old); if (err) { errno = -err; Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -b -B -p -r1.12 -r1.13 --- lseek.c 6 Feb 2004 20:07:30 -0000 1.12 +++ lseek.c 14 Feb 2004 19:42:59 -0000 1.13 @@ -91,7 +91,8 @@ _sysio_lseek(int fd, _SYSIO_OFF_T offset return -EINVAL; } pos = off + offset; - if (pos < 0 || (off && pos <= off)) + if ((offset < 0 && -offset > off) || + (off && offset && pos <= off)) return -EINVAL; #ifdef O_LARGEFILE if (pos >= ((fil->f_flags & O_LARGEFILE) ? _SYSIO_OFF_T_MAX : LONG_MAX)) Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- mount.c 6 Feb 2004 20:07:30 -0000 1.10 +++ mount.c 14 Feb 2004 19:42:59 -0000 1.11 @@ -273,7 +273,8 @@ _sysio_mount_root(const char *source, } int -mount(const char *source, +_sysio_mount(struct pnode *cwd, + const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, @@ -296,18 +297,16 @@ mount(const char *source, * Look up the target path node. */ INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, target, 0, &intent, &tgt); + err = _sysio_namei(cwd, target, 0, &intent, &tgt); if (err) - goto out; + return err; if (tgt == _sysio_root) { /* * Attempting to mount over root. */ err = -EBUSY; - P_RELE(tgt); - } - + } else { /* * Do the deed. */ @@ -317,9 +316,28 @@ mount(const char *source, data, tgt, &mnt); + } if (err) P_RELE(tgt); -out: + return err; +} + +int +mount(const char *source, + const char *target, + const char *filesystemtype, + unsigned long mountflags, + const void *data) +{ + int err; + + err = + _sysio_mount(_sysio_cwd, + source, + target, + filesystemtype, + mountflags, + data); if (err) { errno = -err; err = -1; @@ -368,11 +386,13 @@ int _sysio_unmount_all() { int err; - struct mount *mnt; + struct mount *mnt, *nxt; struct pnode *pno; err = 0; - while ((mnt = mounts.lh_first)) { + nxt = mounts.lh_first; + while ((mnt = nxt)) { + nxt = mnt->mnt_link.le_next; pno = mnt->mnt_root; /* * If this is an automount generated mount, the root @@ -394,8 +414,8 @@ _sysio_unmount_all() if (err) { #ifdef notdef if (pno->p_cover != pno) -#endif P_RELE(pno); +#endif break; } if (pno == _sysio_root) Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- namei.c 6 Feb 2004 20:07:30 -0000 1.10 +++ namei.c 14 Feb 2004 19:42:59 -0000 1.11 @@ -200,9 +200,10 @@ _sysio_path_walk(struct pnode *parent, s */ for (;;) { ino = nd->nd_pno->p_base->pb_ino; - if (!(nd->nd_flags & ND_NOFOLLOW) && - S_ISLNK(ino->i_mode)) { + if (S_ISLNK(ino->i_mode) && + (next.len || !(nd->nd_flags & ND_NOFOLLOW))) { char *lpath; + ssize_t cc; struct nameidata nameidata; if (nd->nd_slicnt >= MAX_SYMLINK) { @@ -213,19 +214,21 @@ _sysio_path_walk(struct pnode *parent, s /* * Follow symbolic link. */ - lpath = malloc(MAXPATHLEN); + lpath = malloc(MAXPATHLEN + 1); if (!lpath) { err = -ENOMEM; break; } - err = + cc = ino->i_ops.inop_readlink(nd->nd_pno, lpath, MAXPATHLEN); - if (err < 0) { + if (cc < 0) { free(lpath); + err = (int )cc; break; } + lpath[cc] = '\0'; /* NUL term */ /* * Handle symbolic links with recursion. Yuck! */ Index: rename.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rename.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- rename.c 13 Oct 2003 21:23:44 -0000 1.2 +++ rename.c 14 Feb 2004 19:42:59 -0000 1.3 @@ -69,7 +69,7 @@ rename(const char *oldpath, const char * INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = _sysio_namei(_sysio_cwd, oldpath, 0, &intent, &old); if (err) - goto out; + goto error3; /* * Resolve newpath to a path node. */ @@ -148,7 +148,8 @@ rename(const char *oldpath, const char * * a rename. However, it is onerous and I don't want to do it right * now. If it becomes an issue, we can do it later. For now, I've * elected to use the semantic that says, basically, the entire - * sub-tree must be unreferenced. + * sub-tree must be unreferenced. That's per POSIX, but it's a nasty + * this to do to the caller. */ if (_sysio_p_prune(new) != 1) { err = -EBUSY; @@ -157,11 +158,19 @@ rename(const char *oldpath, const char * err = old->p_base->pb_ino->i_ops.inop_rename(old, new); if (err) goto error1; + /* + * Reflect the successful rename in the active name space graph. + */ + if (new->p_base->pb_ino) + I_GONE(new->p_base->pb_ino); + new->p_base->pb_ino = old->p_base->pb_ino; + I_REF(new->p_base->pb_ino); error1: P_RELE(new); error2: P_RELE(old); +error3: if (err) { errno = -err; err = -1; Index: rmdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rmdir.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- rmdir.c 6 Feb 2004 20:07:30 -0000 1.7 +++ rmdir.c 14 Feb 2004 19:42:59 -0000 1.8 @@ -59,8 +59,9 @@ rmdir(const char *path) struct intent intent; int err; struct pnode *pno; - SYSIO_ENTER; + struct inode *ino; + SYSIO_ENTER; INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno); if (err) @@ -73,10 +74,11 @@ rmdir(const char *path) if (err) goto error; /* - * Invalide the path-base node. The inode reference was dropped - * by the driver. + * Invalidate the path-base node and kill the i-node. */ + ino = pno->p_base->pb_ino; pno->p_base->pb_ino = NULL; + I_GONE(ino); error: P_RELE(pno); out: Index: rw.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rw.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- rw.c 6 Feb 2004 20:07:30 -0000 1.2 +++ rw.c 14 Feb 2004 19:42:59 -0000 1.3 @@ -286,6 +286,7 @@ readv(int fd, const struct iovec *iov, i struct intnl_xtvec xtvector; struct ioctx *ioctx; int err; + ssize_t cc; SYSIO_ENTER; fil = _sysio_fd_find_capable(fd, O_WRONLY); @@ -301,13 +302,14 @@ readv(int fd, const struct iovec *iov, i iov, count, NULL, &xtvector, NULL, &ioctx); + if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) + err = (int )cc; + SYSIO_LEAVE; if (err) { errno = -err; - SYSIO_LEAVE; - return -1; + cc = -1; } - SYSIO_LEAVE; - return _sysio_ioctx_wait(ioctx); + return cc; } #if defined(__GLIBC__) @@ -384,6 +386,7 @@ read(int fd, void *buf, size_t count) struct intnl_xtvec xtvector; int err; struct ioctx *ioctx; + ssize_t cc; SYSIO_ENTER; fil = _sysio_fd_find_capable(fd, O_WRONLY); @@ -401,13 +404,14 @@ read(int fd, void *buf, size_t count) &iovector, 1, NULL, &xtvector, NULL, &ioctx); + if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) + err = (int )cc; + SYSIO_LEAVE; if (err) { errno = -err; - SYSIO_LEAVE; - return -1; + cc = -1; } - SYSIO_LEAVE; - return _sysio_ioctx_wait(ioctx); + return cc; } #ifdef __GLIBC__ @@ -512,6 +516,7 @@ _preadv(int fd, const struct iovec *iov, struct intnl_xtvec xtvector; struct ioctx *ioctx; int err; + ssize_t cc; SYSIO_ENTER; fil = _sysio_fd_find_capable(fd, O_WRONLY); @@ -528,13 +533,14 @@ _preadv(int fd, const struct iovec *iov, offset, &xtvector, NULL, &ioctx); + if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) + err = (int )cc; + SYSIO_LEAVE; if (err) { errno = -err; - SYSIO_LEAVE; - return -1; + cc = -1; } - SYSIO_LEAVE; - return _sysio_ioctx_wait(ioctx); + return cc; } #if _LARGEFILE64_SOURCE @@ -616,6 +622,7 @@ _pread(int fd, void *buf, size_t count, struct iovec iovec; struct ioctx *ioctx; int err; + ssize_t cc; SYSIO_ENTER; fil = _sysio_fd_find_capable(fd, O_WRONLY); @@ -635,13 +642,14 @@ _pread(int fd, void *buf, size_t count, offset, &xtvec, NULL, &ioctx); + if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) + err = (int )cc; + SYSIO_LEAVE; if (err) { errno = -err; - SYSIO_LEAVE; - return -1; + cc = -1; } - SYSIO_LEAVE; - return _sysio_ioctx_wait(ioctx); + return cc; } #if _LARGEFILE64_SOURCE @@ -847,6 +855,7 @@ writev(int fd, const struct iovec *iov, struct intnl_xtvec xtvector; struct ioctx *ioctx; int err; + ssize_t cc; SYSIO_ENTER; fil = _sysio_fd_find_capable(fd, O_RDONLY); @@ -862,13 +871,14 @@ writev(int fd, const struct iovec *iov, iov, count, NULL, &xtvector, NULL, &ioctx); + if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) + err = (int )cc; + SYSIO_LEAVE; if (err) { errno = -err; - SYSIO_LEAVE; - return -1; + cc = -1; } - SYSIO_LEAVE; - return _sysio_ioctx_wait(ioctx); + return cc; } #ifdef __GLIBC__ @@ -937,6 +947,7 @@ write(int fd, const void *buf, size_t co struct intnl_xtvec xtvector; int err; struct ioctx *ioctx; + ssize_t cc; SYSIO_ENTER; fil = _sysio_fd_find_capable(fd, O_RDONLY); @@ -954,13 +965,14 @@ write(int fd, const void *buf, size_t co &iovector, 1, NULL, &xtvector, NULL, &ioctx); + if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) + err = (int )cc; + SYSIO_LEAVE; if (err) { errno = -err; - SYSIO_LEAVE; - return -1; + cc = -1; } - SYSIO_LEAVE; - return _sysio_ioctx_wait(ioctx); + return cc; } #ifdef __GLIBC__ @@ -1027,6 +1039,7 @@ _pwritev(int fd, const struct iovec *iov struct intnl_xtvec xtvector; struct ioctx *ioctx; int err; + ssize_t cc; SYSIO_ENTER; fil = _sysio_fd_find_capable(fd, O_RDONLY); @@ -1043,13 +1056,14 @@ _pwritev(int fd, const struct iovec *iov offset, &xtvector, NULL, &ioctx); + if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) + err = (int )cc; + SYSIO_LEAVE; if (err) { errno = -err; - SYSIO_LEAVE; - return -1; + cc = -1; } - SYSIO_LEAVE; - return _sysio_ioctx_wait(ioctx); + return cc; } #if _LARGEFILE64_SOURCE @@ -1131,6 +1145,7 @@ _pwrite(int fd, const void *buf, size_t struct iovec iovec; struct ioctx *ioctx; int err; + ssize_t cc; SYSIO_ENTER; fil = _sysio_fd_find_capable(fd, O_RDONLY); @@ -1150,13 +1165,14 @@ _pwrite(int fd, const void *buf, size_t offset, &xtvec, NULL, &ioctx); + if (!err && (cc = _sysio_ioctx_wait(ioctx)) < 0) + err = (int )cc; + SYSIO_LEAVE; if (err) { errno = -err; - SYSIO_LEAVE; - return -1; + cc = -1; } - SYSIO_LEAVE; - return _sysio_ioctx_wait(ioctx); + return cc; } #if _LARGEFILE64_SOURCE Index: unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/unlink.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- unlink.c 6 Feb 2004 20:07:30 -0000 1.8 +++ unlink.c 14 Feb 2004 19:42:59 -0000 1.9 @@ -59,24 +59,36 @@ unlink(const char *path) struct intent intent; int err; struct pnode *pno; - SYSIO_ENTER; + struct inode *ino; + SYSIO_ENTER; INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = _sysio_namei(_sysio_cwd, path, ND_NOFOLLOW, &intent, &pno); if (err) goto out; - if (IS_RDONLY(pno, pno->p_base->pb_ino)) { + ino = pno->p_base->pb_ino; + if (IS_RDONLY(pno, ino)) { err = -EROFS; goto error; } - err = (*pno->p_base->pb_ino->i_ops.inop_unlink)(pno); + err = (*ino->i_ops.inop_unlink)(pno); if (err) goto error; + assert(pno->p_base->pb_ino); /* - * Invalidate the path-base node. The inode reference was - * dropped by the driver. + * Invalidate the path node. */ + ino = pno->p_base->pb_ino; pno->p_base->pb_ino = NULL; + /* + * Kill the i-node. I've thought and thought about this. We + * can't allow it to be found via namei any longer because we + * can't count on generation numbers support and have no + * clue why there might be other soft-references -- Could + * be an open file. + */ + I_GONE(ino); + error: P_RELE(pno); out: |
|
From: Lee W. <lw...@us...> - 2004-02-14 19:49:38
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16325/include Modified Files: inode.h mount.h sysio.h Added Files: namespace.h Log Message: + Merged in changes from namespace_assembly branch (see .../misc/init-env.sh) This provoked a bunch of bugs. See below. + Fixed a bug in _sysio_enumerate_extents(). If the IO operation was short, it would go round the loop again, mistakenly trying to fill more of the extent. + In rw.c, fixed bugs in [p]{read,write}[vx] (all the synchronous routines) that improperly propagated error returns. They were returning -errno instead of setting errno and returning -1. + In fs_native.c:doiov, fixed a bug where a zero-length IO was improperly thought to be an error. + In lseek.c:_sysio_lseek, fixed final position check to properly determine {under,over}flow. + In link.c:link, fixed the existence check. No error is returned for nonexistent files when ND_NEGOK is specified. We're supposed to check whether it's a negative entry or not. + A new macro, I_GONE, was added to inode.h. This will *try* to kill an inode but if it can't, it becomes a zombie instead. + In unlink.c:unlink, link.c:link, rename.c:rename, the driver ops were being called but the actual operation in the internal path tree was not reflected. Also, for unlink and rename, use the new I_GONE macro on the destroyed inode. + In fs_native.c:native_inop_gone, close() was always called, even when the fildes was -1. + In fs_native.c:native_inop_gone, close() was called. We really meant to call syscal(SYS_close, ...); + In namei.c:_sysio_path_walk, fixed broken symlink handling. It wasn't following symlinks anywhere if ND_NOFOLLOW was set. That flag only means that the *last* component should not be followed. + In namei.c:_sysio_path_walk, fixed buffer overrun problem for very long symlinks. + In fs_incore.c, fixed dirop_{link,rename,unlink,rmdir} because they were manipulating the system path cache and shouldn't. + In mount.c:_sysio_unmount_all we were mistakenly releasing an FS root after a failed unmount attempt. + Fixes in test_regions.c free allocated memory at the end so valgrind doesn't show a leak. Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -w -b -B -p -r1.14 -r1.15 --- inode.h 6 Feb 2004 20:07:29 -0000 1.14 +++ inode.h 14 Feb 2004 19:42:58 -0000 1.15 @@ -180,6 +180,17 @@ struct inode { } while (0) /* + * Attempt to kill an inode. + */ +#define I_GONE(ino) \ + do { \ + _sysio_i_undead(ino); \ + I_RELE(ino); \ + if (!(ino)->i_ref) \ + _sysio_i_gone(ino); \ + } while (0) + +/* * The "quick string" record (inspired by the structure of the same name * from Linux) is used to pass a string without delimiters as well as useful * information about the string. Index: mount.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/mount.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- mount.h 7 Mar 2003 03:31:36 -0000 1.3 +++ mount.h 14 Feb 2004 19:42:58 -0000 1.4 @@ -86,6 +86,12 @@ extern int _sysio_mount_root(const char const char *type, unsigned flags, const void *data); +extern int _sysio_mount(struct pnode *cwd, + const char *source, + const char *target, + const char *filesystemtype, + unsigned long mountflags, + const void *data); extern int _sysio_unmount_all(void); #ifdef AUTOMOUNT_FILE_NAME extern int _sysio_automount(struct pnode *mntpno); Index: sysio.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -b -B -p -r1.16 -r1.17 --- sysio.h 6 Feb 2004 20:07:29 -0000 1.16 +++ sysio.h 14 Feb 2004 19:42:58 -0000 1.17 @@ -163,6 +163,7 @@ extern mode_t _sysio_umask; extern int _sysio_init(void); extern void _sysio_shutdown(void); +extern int _sysio_boot(const char *buf); /* * The following should be defined by the system includes, and probably are, |
|
From: Lee W. <lw...@us...> - 2004-02-14 19:49:38
|
Update of /cvsroot/libsysio/libsysio/misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16325/misc Added Files: init-env.sh Log Message: + Merged in changes from namespace_assembly branch (see .../misc/init-env.sh) This provoked a bunch of bugs. See below. + Fixed a bug in _sysio_enumerate_extents(). If the IO operation was short, it would go round the loop again, mistakenly trying to fill more of the extent. + In rw.c, fixed bugs in [p]{read,write}[vx] (all the synchronous routines) that improperly propagated error returns. They were returning -errno instead of setting errno and returning -1. + In fs_native.c:doiov, fixed a bug where a zero-length IO was improperly thought to be an error. + In lseek.c:_sysio_lseek, fixed final position check to properly determine {under,over}flow. + In link.c:link, fixed the existence check. No error is returned for nonexistent files when ND_NEGOK is specified. We're supposed to check whether it's a negative entry or not. + A new macro, I_GONE, was added to inode.h. This will *try* to kill an inode but if it can't, it becomes a zombie instead. + In unlink.c:unlink, link.c:link, rename.c:rename, the driver ops were being called but the actual operation in the internal path tree was not reflected. Also, for unlink and rename, use the new I_GONE macro on the destroyed inode. + In fs_native.c:native_inop_gone, close() was always called, even when the fildes was -1. + In fs_native.c:native_inop_gone, close() was called. We really meant to call syscal(SYS_close, ...); + In namei.c:_sysio_path_walk, fixed broken symlink handling. It wasn't following symlinks anywhere if ND_NOFOLLOW was set. That flag only means that the *last* component should not be followed. + In namei.c:_sysio_path_walk, fixed buffer overrun problem for very long symlinks. + In fs_incore.c, fixed dirop_{link,rename,unlink,rmdir} because they were manipulating the system path cache and shouldn't. + In mount.c:_sysio_unmount_all we were mistakenly releasing an FS root after a failed unmount attempt. + Fixes in test_regions.c free allocated memory at the end so valgrind doesn't show a leak. |
|
From: Lee W. <lw...@us...> - 2004-02-14 19:49:38
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16325/drivers/native Modified Files: fs_native.c Log Message: + Merged in changes from namespace_assembly branch (see .../misc/init-env.sh) This provoked a bunch of bugs. See below. + Fixed a bug in _sysio_enumerate_extents(). If the IO operation was short, it would go round the loop again, mistakenly trying to fill more of the extent. + In rw.c, fixed bugs in [p]{read,write}[vx] (all the synchronous routines) that improperly propagated error returns. They were returning -errno instead of setting errno and returning -1. + In fs_native.c:doiov, fixed a bug where a zero-length IO was improperly thought to be an error. + In lseek.c:_sysio_lseek, fixed final position check to properly determine {under,over}flow. + In link.c:link, fixed the existence check. No error is returned for nonexistent files when ND_NEGOK is specified. We're supposed to check whether it's a negative entry or not. + A new macro, I_GONE, was added to inode.h. This will *try* to kill an inode but if it can't, it becomes a zombie instead. + In unlink.c:unlink, link.c:link, rename.c:rename, the driver ops were being called but the actual operation in the internal path tree was not reflected. Also, for unlink and rename, use the new I_GONE macro on the destroyed inode. + In fs_native.c:native_inop_gone, close() was always called, even when the fildes was -1. + In fs_native.c:native_inop_gone, close() was called. We really meant to call syscal(SYS_close, ...); + In namei.c:_sysio_path_walk, fixed broken symlink handling. It wasn't following symlinks anywhere if ND_NOFOLLOW was set. That flag only means that the *last* component should not be followed. + In namei.c:_sysio_path_walk, fixed buffer overrun problem for very long symlinks. + In fs_incore.c, fixed dirop_{link,rename,unlink,rmdir} because they were manipulating the system path cache and shouldn't. + In mount.c:_sysio_unmount_all we were mistakenly releasing an FS root after a failed unmount attempt. + Fixes in test_regions.c free allocated memory at the end so valgrind doesn't show a leak. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -w -b -B -p -r1.31 -r1.32 --- fs_native.c 8 Feb 2004 23:48:51 -0000 1.31 +++ fs_native.c 14 Feb 2004 19:42:58 -0000 1.32 @@ -608,8 +608,7 @@ native_iget(struct filesys *fs, * Cached inode has stale attrs * make way for the new one */ - I_RELE(ino); - _sysio_i_undead(ino); + I_GONE(ino); ino = NULL; } else /* @@ -1263,10 +1262,10 @@ doiov(const struct iovec *iov, _SYSIO_OFF_T, void *))dopio, nio); - if (cc > 0) - nio->nio_nino->ni_fpos += cc; - else + if (cc < 0) cc = -errno; + else + nio->nio_nino->ni_fpos += cc; return cc; #if !(defined(REDSTORM) || defined(MAX_IOVEC)) @@ -1567,8 +1566,8 @@ native_inop_gone(struct inode *ino) { struct native_inode *nino = I2NI(ino); - if (nino->ni_fd) - (void )close(nino->ni_fd); + if (nino->ni_fd >= 0) + (void )syscall(SYS_close, nino->ni_fd); free(ino->i_private); } |
|
From: Lee W. <lw...@us...> - 2004-02-14 19:49:37
|
Update of /cvsroot/libsysio/libsysio/drivers/incore In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16325/drivers/incore Modified Files: fs_incore.c Log Message: + Merged in changes from namespace_assembly branch (see .../misc/init-env.sh) This provoked a bunch of bugs. See below. + Fixed a bug in _sysio_enumerate_extents(). If the IO operation was short, it would go round the loop again, mistakenly trying to fill more of the extent. + In rw.c, fixed bugs in [p]{read,write}[vx] (all the synchronous routines) that improperly propagated error returns. They were returning -errno instead of setting errno and returning -1. + In fs_native.c:doiov, fixed a bug where a zero-length IO was improperly thought to be an error. + In lseek.c:_sysio_lseek, fixed final position check to properly determine {under,over}flow. + In link.c:link, fixed the existence check. No error is returned for nonexistent files when ND_NEGOK is specified. We're supposed to check whether it's a negative entry or not. + A new macro, I_GONE, was added to inode.h. This will *try* to kill an inode but if it can't, it becomes a zombie instead. + In unlink.c:unlink, link.c:link, rename.c:rename, the driver ops were being called but the actual operation in the internal path tree was not reflected. Also, for unlink and rename, use the new I_GONE macro on the destroyed inode. + In fs_native.c:native_inop_gone, close() was always called, even when the fildes was -1. + In fs_native.c:native_inop_gone, close() was called. We really meant to call syscal(SYS_close, ...); + In namei.c:_sysio_path_walk, fixed broken symlink handling. It wasn't following symlinks anywhere if ND_NOFOLLOW was set. That flag only means that the *last* component should not be followed. + In namei.c:_sysio_path_walk, fixed buffer overrun problem for very long symlinks. + In fs_incore.c, fixed dirop_{link,rename,unlink,rmdir} because they were manipulating the system path cache and shouldn't. + In mount.c:_sysio_unmount_all we were mistakenly releasing an FS root after a failed unmount attempt. + Fixes in test_regions.c free allocated memory at the end so valgrind doesn't show a leak. Index: fs_incore.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/incore/fs_incore.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -w -b -B -p -r1.13 -r1.14 --- fs_incore.c 6 Feb 2004 20:07:29 -0000 1.13 +++ fs_incore.c 14 Feb 2004 19:42:57 -0000 1.14 @@ -1262,17 +1262,7 @@ _sysio_incore_dirop_rmdir(struct pnode * err = incore_unlink_entry(I2IC(pno->p_parent->p_base->pb_ino), &pno->p_base->pb_name); - if (err) return err; - I_RELE(ino); - - /* - * Adjust link count. - */ - assert(icino->ici_st.st_nlink > 2); - icino->ici_st.st_nlink--; - - return 0; } static int @@ -1417,9 +1407,6 @@ _sysio_incore_dirop_rename(struct pnode &new->p_base->pb_name); if (err) return err; - I_RELE(new->p_base->pb_ino); - _sysio_i_gone(new->p_base->pb_ino); - new->p_base->pb_ino = NULL; } /* @@ -1468,11 +1455,7 @@ _sysio_incore_dirop_unlink(struct pnode err = incore_unlink_entry(I2IC(pno->p_parent->p_base->pb_ino), &pno->p_base->pb_name); - if (err) return err; - I_RELE(ino); - - return 0; } static int |
|
From: Sonja T. <so...@us...> - 2004-02-10 14:42:14
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28921 Modified Files: Tag: namespace_assembly test_all.pl test_copy.pl test_driver.c test_stats.pl Log Message: Added support for namespace assembly. Removed usage of test_stdfd.pl from test_all, instead using test_copy to perform function. Also removed test_mounts from test_all since it is covered with the namespace assembly Index: test_all.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_all.pl,v retrieving revision 1.6.2.1 retrieving revision 1.6.2.2 diff -u -w -b -B -p -r1.6.2.1 -r1.6.2.2 --- test_all.pl 28 Jan 2004 13:16:57 -0000 1.6.2.1 +++ test_all.pl 10 Feb 2004 14:38:50 -0000 1.6.2.2 @@ -35,6 +35,38 @@ my $cwd = $ENV{PWD}; # Get tests directory my $testdir = $FindBin::Bin; +my $namespace_env = "SYSIO_NAMESPACE"; +my $home = $ENV{"HOME"}; +my $auto_mount = $ENV{"SYSIO_AUTOMOUNT"}; +my $root_flags = "0"; +my $extras = ""; +if ((defined($auto_mount)) && ($auto_mount == "xyes")) { + $root_flags = "2"; + + # + # Add a /auto directory for automounted file systems. We + # craft one automount that mounts /usr/home from the native + # file system. Further automounts in the sub-mounts are not enabled. + # + $extras=" \ + {mnt, dev=\"incore:0755+0+0\",dir=\"/mnt\",fl=2} \ + {creat, ft=dir,nm=\"/mnt/home\",pm=0755,ow=0,gr=0} \ + {creat, ft=file,nm=\"/mnt/home/.mount\",pm=0600, \ + str=\"native:/usr/home\"}"; +} +$ENV{$namespace_env} = "\ + {mnt, dev=\"native:/\",dir=/,fl=$root_flags} \ + {mnt, dev=\"incore:0755+0+0\",dir=\"/dev\"} \ + {creat, ft=chr,nm=\"/dev/stdin\",pm=0400,mm=0+0} \ + {creat, ft=chr,nm=\"/dev/stdout\",pm=0200,mm=0+1} \ + {creat, ft=chr,nm=\"/dev/stderr\",pm=0200,mm=0+2} \ + {creat, ft=dir,nm=\"/dev/fd\",pm=0755,ow=0,gr=0} \ + {creat, ft=chr,nm=\"/dev/fd/0\",pm=0400,mm=0+0} \ + {creat, ft=chr,nm=\"/dev/fd/1\",pm=0200,mm=0+1} \ + {creat, ft=chr,nm=\"/dev/fd/2\",pm=0200,mm=0+2} \ + {cd, dir=\"$home\"} \ + $extras "; + my $res; if ($use_system == 1) { @@ -93,19 +125,6 @@ if ($resarr[0] ne $res) { } } -if (($alpha_arg eq "") || ($is_broke == 0)) { - # Test mount - $res = `perl $testdir/test_list.pl $alpha_arg -m native:$testdir $cwd/tmp_dir/test2`; - 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 = `perl $testdir/test_getcwd.pl $alpha_arg $cwd/tmp_dir/test1`; chop($res); @@ -140,9 +159,9 @@ if ($res ne "stat test successful") { } # Test stdfd -$res = `perl $testdir/test_stdfd.pl $alpha_arg foo_dir`; +$res = `echo "foobar" | perl $testdir/test_copy.pl $alpha_arg -o /dev/stdin /dev/stdout`; chop($res); -if ($res ne "test_stdfd successful") { +if ($res ne "copy test successful") { print "stdfd test failed with message: $res\n"; $failures++; } else { @@ -174,5 +193,4 @@ if ($use_system == 1) { exit 1; } } - exit $failures; Index: test_copy.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_copy.pl,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -u -w -b -B -p -r1.3.2.1 -r1.3.2.2 --- test_copy.pl 28 Jan 2004 13:16:57 -0000 1.3.2.1 +++ test_copy.pl 10 Feb 2004 14:38:51 -0000 1.3.2.2 @@ -20,7 +20,7 @@ sub usage sub process_cmd { - my ($src, $dest, $is_alpha) = @_; + my ($src, $dest, $overwrite, $is_alpha) = @_; # Get tests directory my $testdir = $FindBin::Bin; @@ -53,6 +55,13 @@ sub process_cmd my $size = -s $src; my $bufsize; + # If reading from stdin, just read one line + my $line; + if ($src eq "/dev/stdin") { + $line = <STDIN>; + $size = length($line); + } + if ( $size > 1024) { # Arbitrary limit $bufsize = 1024; } else { @@ -63,10 +72,16 @@ sub process_cmd # Open src my $cmdstr = '$src = CALL open '."$src O_RDONLY\n"; helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); + helper::verify_cmd($cmdfh, $outfh, "open $src"); # Open dest - $cmdstr = '$dest = CALL open '."$dest O_RDWR|O_CREAT 7777\n"; + my $flags = "O_WRONLY|O_CREAT"; + if ($overwrite == 0) { + $flags .= "|O_EXCL"; + } + $cmdstr = '$dest = CALL open '."$dest $flags 0666\n"; helper::send_cmd($cmdfh, $outfh, "open", $cmdstr); + my $destfile = helper::verify_cmd($cmdfh, $outfh, "open $dest"); # Allocate buffer $cmdstr = '$buf = ALLOC '."$bufsize\n"; @@ -75,15 +90,60 @@ sub process_cmd # Read size bytes from src and write them out to dest my $bytes = $size; while ($bytes > 0) { + + my $readb; + my $res; + if ($src eq "/dev/stdin") { + # Send "delay" option to read which will give us time to + # put something in stdin (since we can't send an eof) + my $cmdstr = "CALL read ".'$src $buf '."$bytes delay\n"; + print $cmdfh $cmdstr; + # Give time to process command + sleep 1; + + # Send line from stdin + print $cmdfh $line; + sleep 0.5; + + # Make sure read was OK + $res = <$outfh>; + chop($res); + if ($res ne "0000 ") { + helper::print_and_exit($cmdfh, $outfh, 1, "ERROR! Read failed with code $res\n"); + } + + # See how many bytes we got... + $readb = helper::verify_cmd($cmdfh, $outfh, "read"); + $readb = oct($readb); + if ($readb != $bytes) { + helper::print_and_exit($cmdfh, $outfh, 0, "Short read\n"); + } + + $cmdstr = "CALL write ".'$dest $buf '."$readb\n"; + print $cmdfh $cmdstr; + + # Suck up the stdout... + $res = <$outfh>; + chop($res); + + $res = <$outfh>; + chop($res); + $res = oct($res); + + if ($res != 0) { + helper::print_and_exit($cmdfh, $outfh, 1, "ERROR! Write failed with code $res\n"); + } + } else { $cmdstr = 'CALL read $src $buf '."$bufsize\n"; helper::send_cmd($cmdfh, $outfh, "read", $cmdstr); - my $res = helper::verify_cmd($cmdfh, $outfh, "read"); - my $readb = oct($res); + $res = helper::verify_cmd($cmdfh, $outfh, "read"); + $readb = oct($res); # Now write $readb back out to dest $cmdstr = 'CALL write $dest $buf '."$readb\n"; helper::send_cmd($cmdfh, $outfh, "write", $cmdstr); + } $res = helper::verify_cmd($cmdfh, $outfh, "write"); @@ -101,31 +161,41 @@ sub process_cmd $cmdstr = 'CALL close $dest'."\n"; helper::send_cmd($cmdfh, $outfh, "close", $cmdstr); + if ($src ne "/dev/stdin") { my $cmpres = system("cmp -s $src $dest"); if ($cmpres != 0) { print STDOUT "ERROR! File $src differs from $dest\n"; exit 1; } - + } helper::print_and_exit($cmdfh, $outfh, 0, "copy test successful\n"); } my $currarg = 0; my $is_alpha = 0; +my $overwrite = 0; + +my $len = @ARGV-2; if (@ARGV < 2) { usage; -} elsif (@ARGV > 2 ) { - if ($ARGV[$currarg++] eq "-alpha") { +} + +my $i; +for ($i=0; $i < $len; $i++ ) { + if ($ARGV[$i] eq "-alpha") { $is_alpha = 1; } + if ($ARGV[$i] eq "-o") { + $overwrite = 1; + } } -my $src = $ARGV[$currarg++]; -my $dest = $ARGV[$currarg]; +my $src = $ARGV[$i++]; +my $dest = $ARGV[$i]; -process_cmd($src, $dest, $is_alpha); +process_cmd($src, $dest, $overwrite, $is_alpha); exit 0; Index: test_driver.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_driver.c,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -u -w -b -B -p -r1.4.2.2 -r1.4.2.3 --- test_driver.c 9 Feb 2004 13:11:19 -0000 1.4.2.2 +++ test_driver.c 10 Feb 2004 14:38:51 -0000 1.4.2.3 @@ -219,10 +219,47 @@ char *get_str(char *var_name) return var_name; } +static char* +get_or_part(char **str, int* did_alloc) +{ + char *tmp_str = *str; + int i, norm_str=0; + + if (tmp_str == NULL) + return NULL; + + if (tmp_str[0] == '|') { + tmp_str++; + norm_str=1; + } + + for (i=0; (unsigned int)i < strlen(tmp_str); i++) { + if (tmp_str[i] == '|') { + char *new_str = (char *)malloc(i+1); + memcpy(new_str, tmp_str, i); + new_str[i] = '\0'; + *did_alloc = 1; + *str = &tmp_str[i]; + return new_str; + } + } + + if (norm_str) { + *did_alloc = 0; + *str = NULL; + return tmp_str; + } + + return NULL; +} + int get_obj(char *var_name) { + char** str = &var_name; + char *str1; struct var_mapping *var_map; - int i; + int did_alloc=0; + int obj=0, got_obj=0; DBG(5, fprintf(outfp, "Getting object for %s\n", var_name)); @@ -234,53 +271,33 @@ int get_obj(char *var_name) * Check for '|', indicates that one or more values are or'd * together */ - for (i=0; (unsigned int)i < strlen(var_name); i++) { - if (var_name[i] == '|') { - char *str1 = malloc(i+1); - char *str2 = malloc(strlen(var_name)-i+1); - int obj; - struct var_mapping *tmp_map; - - memcpy(str1, var_name, i); - str1[i] = '\0'; - memcpy(str2, (char *)&var_name[i+1], strlen(var_name)-i); + while ((str1 = get_or_part(str, &did_alloc)) != NULL) { if (isdigit(str1[0])) { if (str1[0] == '0') { /* Assume octal format */ - obj = strtol(str1, NULL, 8); + obj |= strtol(str1, NULL, 8); } else - obj = atoi(str1); + obj |= atoi(str1); } else { - tmp_map = get_map(str1); - if (!tmp_map) { + var_map = get_map(str1); + if (!var_map) { + if (did_alloc) free(str1); - free(str2); return -1; } - obj = tmp_map->obj; + obj |= var_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) { + if (did_alloc) { + did_alloc = 0; free(str1); - free(str2); - return -1; } - obj |= tmp_map->obj; + got_obj++; } - free(str1); - free(str2); + + if (got_obj) return obj; - } - } var_map = get_map(var_name); if (!var_map) Index: test_stats.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_stats.pl,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 --- test_stats.pl 28 Jan 2004 13:16:57 -0000 1.5.2.1 +++ test_stats.pl 10 Feb 2004 14:38:51 -0000 1.5.2.2 @@ -172,6 +172,7 @@ sub process_cmd verify_stat($cmdfh, $outfh, "lstat", $is_alpha, @stats); } + if (0) { # Now do statvfs functions $cmdstr = '$buf2 = ALLOC ( $size2 = CALL sizeof statvfs )'."\n"; helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); @@ -223,6 +224,7 @@ sub process_cmd helper::print_and_exit($cmdfh, $outfh, 1, $str); } } + } helper::print_and_exit($cmdfh, $outfh, 0, "stat test successful\n"); } |
|
From: Lee W. <lw...@us...> - 2004-02-09 14:43:28
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19064 Added Files: Tag: namespace_assembly startup.c Log Message: Oops, forgot to `add' this when I checked in. --- NEW FILE --- #include <stdlib.h> #include <errno.h> #include <sys/types.h> #include <sys/queue.h> #include "sysio.h" #include "test.h" int _test_sysio_startup() { int err; const char *s; err = _sysio_init(); if (err) return err; err = drv_init_all(); if (err) return err; s = getenv("SYSIO_NAMESPACE"); err = s ? _sysio_boot(s) : -ENOTTY; if (err) return err; return 0; } |
|
From: Lee W. <lw...@us...> - 2004-02-09 13:18:27
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30756 Modified Files: Tag: namespace_assembly test_path.c Log Message: The _test_sysio_startup() routine returns an int and the compiler would like it declared as such. Fixed. Index: test_path.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_path.c,v retrieving revision 1.6.2.1 retrieving revision 1.6.2.2 diff -u -w -b -B -p -r1.6.2.1 -r1.6.2.2 --- test_path.c 9 Feb 2004 13:11:19 -0000 1.6.2.1 +++ test_path.c 9 Feb 2004 13:15:13 -0000 1.6.2.2 @@ -79,7 +79,7 @@ main(int argc, char *const argv[]) int i; int err; int n; - extern _test_sysio_startup(void); + extern int _test_sysio_startup(void); /* * Parse command line arguments. |
|
From: Lee W. <lw...@us...> - 2004-02-09 13:14:34
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29233/src Modified Files: Tag: namespace_assembly init.c mount.c Log Message: Namespace assembly at boot project: Adds the ability to craft an initial, arbitrarily complex, name space. Governed by the presence of the SYSIO_NAMESPACE environment variable formatted per Sonja Tideman's trial specification. For an example, see .../misc/init-env.sh. The mounts, namespace, and stdfd tests were all removed. They've been deprecated or obsoleted by this project. The remaining tests have been updated. They no longer require the complicated initialization they previously used in order to get a root set up. Index: init.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/init.c,v retrieving revision 1.3.12.2 retrieving revision 1.3.12.3 diff -u -w -b -B -p -r1.3.12.2 -r1.3.12.3 --- init.c 30 Jan 2004 21:54:22 -0000 1.3.12.2 +++ init.c 9 Feb 2004 13:11:18 -0000 1.3.12.3 @@ -9,7 +9,7 @@ * 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. + * Cplant(TM) Copyright 1998-2004 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 @@ -41,16 +41,25 @@ * le...@sa... */ [...1086 lines suppressed...] + * Get the command. + */ + buf = (char *)get_token(buf + 1, 0, "}", IGNORE_WHITE, tok); + if (!buf) { + err = -EINVAL; + break; } - return 0; + /* + * Perform. + */ + err = do_command(tok); + if (err) + break; + } + free(tok); + return err; } - - Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.9 retrieving revision 1.9.2.1 diff -u -w -b -B -p -r1.9 -r1.9.2.1 --- mount.c 27 Oct 2003 23:49:10 -0000 1.9 +++ mount.c 9 Feb 2004 13:11:18 -0000 1.9.2.1 @@ -270,7 +270,8 @@ _sysio_mount_root(const char *source, } int -mount(const char *source, +_sysio_mount(struct pnode *cwd, + const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, @@ -293,18 +294,16 @@ mount(const char *source, * Look up the target path node. */ INTENT_INIT(&intent, INT_GETATTR, NULL, NULL); - err = _sysio_namei(_sysio_cwd, target, 0, &intent, &tgt); + err = _sysio_namei(cwd, target, 0, &intent, &tgt); if (err) - goto out; + return err; if (tgt == _sysio_root) { /* * Attempting to mount over root. */ err = -EBUSY; - P_RELE(tgt); - } - + } else { /* * Do the deed. */ @@ -314,9 +313,28 @@ mount(const char *source, data, tgt, &mnt); + } if (err) P_RELE(tgt); -out: + return err; +} + +int +mount(const char *source, + const char *target, + const char *filesystemtype, + unsigned long mountflags, + const void *data) +{ + int err; + + err = + _sysio_mount(_sysio_cwd, + source, + target, + filesystemtype, + mountflags, + data); if (err) { errno = -err; err = -1; |
|
From: Lee W. <lw...@us...> - 2004-02-09 13:14:34
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29233/tests Modified Files: Tag: namespace_assembly Makefile.am sysio_stubs.c sysio_tests.c test.h test_copy.c test_driver.c test_driver.h test_getcwd.c test_link.c test_list.c test_path.c test_rename.c test_stats.c test_unlink.c Removed Files: Tag: namespace_assembly test_mounts.c test_namespace.c test_stdfd.c Log Message: Namespace assembly at boot project: Adds the ability to craft an initial, arbitrarily complex, name space. Governed by the presence of the SYSIO_NAMESPACE environment variable formatted per Sonja Tideman's trial specification. For an example, see .../misc/init-env.sh. The mounts, namespace, and stdfd tests were all removed. They've been deprecated or obsoleted by this project. The remaining tests have been updated. They no longer require the complicated initialization they previously used in order to get a root set up. Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.16.2.2 retrieving revision 1.16.2.3 diff -u -w -b -B -p -r1.16.2.2 -r1.16.2.3 --- Makefile.am 28 Jan 2004 13:16:57 -0000 1.16.2.2 +++ Makefile.am 9 Feb 2004 13:11:18 -0000 1.16.2.3 @@ -1,6 +1,6 @@ -noinst_PROGRAMS = test_copy test_stats test_path test_mounts test_list \ - test_getcwd test_stdfd test_link test_unlink test_rename \ - test_driver test_namespace +noinst_PROGRAMS = test_copy test_stats test_path test_list \ + test_getcwd test_link test_unlink test_rename \ + test_driver CLEANFILES=drv_data.c @@ -20,14 +20,6 @@ INCORE_DRIVER_NAME=incore INCORE_DRIVER_CFLAGS= endif -if WITH_STDFD_DEV -STDFD_DEV_NAME=stdfd -STDFD_DEV_CFLAGS= -I$(top_srcdir)/dev/stdfd -else -STDFD_DEV_NAME=stdfd -STDFD_DEV_CFLAGS= -endif - if WITH_CPLANT_YOD YOD_DRIVER_NAME=yod YOD_DRIVER_CFLAGS= -DCPLANT_YOD @@ -47,7 +39,7 @@ endif DRIVERS=$(NATIVE_DRIVER_NAME) $(INCORE_DRIVER_NAME) $(YOD_DRIVER_NAME) \ $(STFD_DEV_NAME) $(SOCKETS_DRIVER_NAME) -CMNSRC=drv_init_all.c drv_data.c +CMNSRC=startup.c drv_init_all.c drv_data.c BUILT_SOURCES=drv_data.c check_PROGRAMS=test_driver @@ -79,11 +71,6 @@ test_path_CFLAGS=$(CFL) test_path_LDADD=$(LIBS) test_path_DEPENDENCIES=$(LIBS) -test_mounts_SOURCES=test_mounts.c $(CMNSRC) -test_mounts_CFLAGS=$(CFL) -test_mounts_LDADD=$(LIBS) -test_mounts_DEPENDENCIES=$(LIBS) - test_list_SOURCES=test_list.c $(CMNSRC) test_list_CFLAGS=$(CFL) test_list_LDADD=$(LIBS) @@ -94,11 +81,6 @@ test_getcwd_CFLAGS=$(CFL) test_getcwd_LDADD=$(LIBS) test_getcwd_DEPENDENCIES=$(LIBS) -test_stdfd_SOURCES=test_stdfd.c $(CMNSRC) -test_stdfd_CFLAGS=$(CFL) -test_stdfd_LDADD=$(LIBS) -test_stdfd_DEPENDENCIES=$(LIBS) - test_link_SOURCES=test_link.c $(CMNSRC) test_link_CFLAGS=$(CFL) test_link_LDADD=$(LIBS) @@ -114,11 +96,6 @@ test_rename_CFLAGS=$(CFL) test_rename_LDADD=$(LIBS) test_rename_DEPENDENCIES=$(LIBS) -test_namespace_SOURCES=test_namespace.c $(CMNSRC) -test_namespace_CFLAGS=$(CFL) -test_namespace_LDADD=$(LIBS) -test_namespace_DEPENDENCIES=$(LIBS) - test_driver_SOURCES=test_driver.c sysio_tests.c sysio_stubs.c help.c $(CMNSRC) test_driver_CFLAGS=$(CFL) test_driver_LDADD=$(LIBS) Index: sysio_stubs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/sysio_stubs.c,v retrieving revision 1.6.2.1 retrieving revision 1.6.2.2 diff -u -w -b -B -p -r1.6.2.1 -r1.6.2.2 --- sysio_stubs.c 28 Jan 2004 13:16:57 -0000 1.6.2.1 +++ sysio_stubs.c 9 Feb 2004 13:11:18 -0000 1.6.2.2 @@ -393,9 +393,8 @@ int test_do_init(int argc, char **argv) DBG(5, fprintf(outfp, "In test_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); + DBG(3, fprintf(outfp, "initializing\n")); + return initilize_sysio(); } Index: sysio_tests.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/sysio_tests.c,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -u -w -b -B -p -r1.3.2.1 -r1.3.2.2 --- sysio_tests.c 28 Jan 2004 13:16:57 -0000 1.3.2.1 +++ sysio_tests.c 9 Feb 2004 13:11:18 -0000 1.3.2.2 @@ -29,37 +29,23 @@ * # every function document in sysio.h # * ################################################### */ -int initilize_sysio(char *root_driver, char *root_path, int mntflgs) +int initilize_sysio() { int err; char *wd; + extern int _test_sysio_startup(void); /* * Init sysio lib. */ - _sysio_init(); - - /* - * Init native file system driver and request mount of specified - * source directory. - */ - err = drv_init_all(); - DBG(5, sprintf(output, "%sdrv_init_all: err %d\n", output, err)); + err = _test_sysio_startup(); + DBG(5, sprintf(output, "%s_test_sysio_startup: err %d\n", output, err)); if (err) { my_errno = err; - my_perror("drv_init_all"); + my_perror("sysio startup"); last_ret_val = errno; return SUCCESS; } - err = _sysio_mount_root(root_path, root_driver, mntflgs, NULL); - DBG(5, sprintf(output, "%ssysio_mount_root: err %d\n", output, err)); - if (err) { - my_errno = errno; - my_perror("_sysio_mount_root"); - perror("_sysio_mount_root"); - last_ret_val = err; - return SUCCESS; - } /* * Attempt to set the cwd by getting it out of the Index: test.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test.h,v retrieving revision 1.1 retrieving revision 1.1.20.1 diff -u -w -b -B -p -r1.1 -r1.1.20.1 --- test.h 22 Feb 2003 20:30:20 -0000 1.1 +++ test.h 9 Feb 2004 13:11:19 -0000 1.1.20.1 @@ -41,8 +41,6 @@ * le...@sa... */ -#define DEFAULT_DRIVER "native" - extern int (*drvinits[])(void); extern int drv_init_all(void); Index: test_copy.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_copy.c,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -w -b -B -p -r1.8 -r1.8.2.1 --- test_copy.c 10 Oct 2003 18:50:31 -0000 1.8 +++ test_copy.c 9 Feb 2004 13:11:19 -0000 1.8.2.1 @@ -65,14 +65,12 @@ /* * Copy one file to another. * - * Usage: test_copy [-a] [-r <source>] [-m <root-driver>] <src> <dest> + * Usage: test_copy [-o] <src> <dest> * * Destination will not be overwritten if it already exist. */ -char *root_driver = DEFAULT_DRIVER; -char *mntpath = "/"; -unsigned mntflgs = 0; +static int overwrite = 0; /* over-write? */ void usage(void); int copy_file(const char *spath, const char *dpath); @@ -83,28 +81,19 @@ main(int argc, char * const argv[]) int i; int err; const char *spath, *dpath; + extern int _test_sysio_startup(void); /* * Parse command-line args. */ while ((i = getopt(argc, argv, -#ifdef AUTOMOUNT_FILE_NAME - "a" -#endif - "r:m:")) != -1) + "o" + )) != -1) switch (i) { -#ifdef AUTOMOUNT_FILE_NAME - case 'a': - mntflgs |= MOUNT_F_AUTO; - break; -#endif - case 'r': /* set working dir */ - mntpath = optarg; - break; - case 'm': - root_driver = optarg; + case 'o': + overwrite = 1; break; default: usage(); @@ -112,24 +101,12 @@ main(int argc, char * const argv[]) if (!(argc - optind)) usage(); -#ifndef CPLANT_YOD - if (_sysio_init() != 0) { - perror("init sysio"); - exit(1); - } - err = drv_init_all(); - if (err) { - perror("init drivers"); - exit(1); - } - err = _sysio_mount_root(mntpath, root_driver, mntflgs, NULL); + err = _test_sysio_startup(); if (err) { errno = -err; - perror(root_driver); + perror("sysio startup"); exit(1); } -#endif - (void )umask(022); /* * Source @@ -146,9 +123,7 @@ main(int argc, char * const argv[]) err = copy_file(spath, dpath); -#ifndef CPLANT_YOD _sysio_shutdown(); -#endif return err; } @@ -159,10 +134,6 @@ usage() (void )fprintf(stderr, "Usage: test_copy " -#ifdef AUTOMOUNT_FILE_NAME - "[-a] " -#endif - "[-r <source>] [-m <fsname>]" " source destination\n"); exit(1); } @@ -183,6 +154,7 @@ int copy_file(const char *spath, const char *dpath) { int sfd, dfd; + int flags; int rtn; static char buf[1024]; ssize_t cc, wcc; @@ -193,7 +165,10 @@ copy_file(const char *spath, const char sfd = open_file(spath, O_RDONLY, 0); if (sfd < 0) goto out; - dfd = open_file(dpath, O_CREAT|O_EXCL|O_WRONLY, 0666); + flags = O_CREAT|O_WRONLY; + if (!overwrite) + flags |= O_EXCL; + dfd = open_file(dpath, flags, 0666); if (dfd < 0) goto out; Index: test_driver.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_driver.c,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -u -w -b -B -p -r1.4.2.1 -r1.4.2.2 --- test_driver.c 28 Jan 2004 13:16:57 -0000 1.4.2.1 +++ test_driver.c 9 Feb 2004 13:11:19 -0000 1.4.2.2 @@ -862,10 +862,12 @@ int main(int argc, char *argv[]) print_line = 0; +#if 0 /* sysio defaults */ strcpy(root_driver, DEFAULT_DRIVER); strcpy(mntpath, "/"); mntflgs = 0; +#endif my_errno = 0; Index: test_driver.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_driver.h,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -w -b -B -p -r1.3 -r1.3.2.1 --- test_driver.h 10 Oct 2003 18:50:31 -0000 1.3 +++ test_driver.h 9 Feb 2004 13:11:19 -0000 1.3.2.1 @@ -201,7 +201,7 @@ extern int test_do_umount(int argc, char /* Functions defined in sysio_tests.c */ extern int sysio_mount(char *from, char *to); extern int sysio_list(char *path); -extern int initilize_sysio(char *root_driver, char *root_path, int mntflgs); +extern int initilize_sysio(void); extern int sysio_chdir(char *newdir); extern int sysio_chmod(char *mode_arg, const char *path); extern int sysio_chown(char *new_id, char *file); Index: test_getcwd.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_getcwd.c,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -w -b -B -p -r1.3 -r1.3.2.1 --- test_getcwd.c 10 Oct 2003 18:50:31 -0000 1.3 +++ test_getcwd.c 9 Feb 2004 13:11:19 -0000 1.3.2.1 @@ -64,7 +64,7 @@ /* * Test getcwd() * - * Usage: test_cwd [-a] [-m <fsname>] [-r <mntpath>] [<working-dir>...] + * Usage: test_cwd [<working-dir>...] * * Without any path arguments, the program reads from standard-in, dealing with * each line as an absolute or relative path until EOF. @@ -73,68 +73,32 @@ static int doit(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; + extern int _test_sysio_startup(void); /* * Parse command line arguments. */ - while ((i = getopt(argc, argv, opts)) != -1) + while ((i = getopt(argc, argv, "")) != -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(); } -#ifndef CPLANT_YOD /* * 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); + err = _test_sysio_startup(); if (err) { errno = -err; - perror("_sysio_mount_root"); + perror("sysio startup"); exit(1); } -#endif n = argc - optind; @@ -170,12 +134,10 @@ main(int argc, char *const argv[]) } } -#ifndef CPLANT_YOD /* * Clean up. */ _sysio_shutdown(); -#endif return 0; } @@ -205,10 +167,6 @@ usage() (void )fprintf(stderr, "Usage: test_getcwd " -#ifdef AUTOMOUNT_FILE_NAME - "[-a] " -#endif - "[-m <driver>] [-r <mntpath>]" " [<path> ...\n]"); exit(1); Index: test_link.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_link.c,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -u -w -b -B -p -r1.1 -r1.1.4.1 --- test_link.c 20 Oct 2003 16:32:29 -0000 1.1 +++ test_link.c 9 Feb 2004 13:11:19 -0000 1.1.4.1 @@ -64,49 +64,27 @@ /* * Test hard link * - * Usage: link [-a] [-m <fsname>] [-r <mntpath>] oldpath newpath + * Usage: link oldpath newpath * */ static int linkit(const char *old, const char *new); 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; + extern int _test_sysio_startup(void); /* * Parse command line arguments. */ - while ((i = getopt(argc, argv, opts)) != -1) + while ((i = getopt(argc, argv, "")) != -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(); } @@ -114,22 +92,10 @@ main(int argc, char *const argv[]) /* * 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); + err = _test_sysio_startup(); if (err) { errno = -err; - perror("_sysio_mount_root"); + perror("sysio startup"); exit(1); } @@ -172,7 +138,7 @@ usage() { (void )fprintf(stderr, - "Usage: unlink [-a] [-m <driver>] [-r <mntpath>]" + "Usage: unlink" " oldpath newpath\n"); exit(1); Index: test_list.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_list.c,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -w -b -B -p -r1.6 -r1.6.2.1 --- test_list.c 10 Oct 2003 18:50:31 -0000 1.6 +++ test_list.c 9 Feb 2004 13:11:19 -0000 1.6.2.1 @@ -64,7 +64,7 @@ /* * Stat files. * - * Usage: test_list [-a] [-m <fsname>] [-r <mntpath>] [path...] + * Usage: test_list [path...] * * Without any path arguments, the program reads from standard-in, dealing with * each line as an absolute or relative path until EOF. @@ -73,69 +73,34 @@ static int listit(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; + extern int _test_sysio_startup(void); /* * Parse command line arguments. */ - while ((i = getopt(argc, argv, opts)) != -1) + while ((i = getopt(argc, argv, "")) != -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(); } -#ifndef CPLANT_YOD /* * 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); + err = _test_sysio_startup(); if (err) { errno = -err; - perror("_sysio_mount_root"); + perror("sysio startup"); exit(1); } -#endif + n = argc - optind; /* @@ -170,12 +135,10 @@ main(int argc, char *const argv[]) } } -#ifndef CPLANT_YOD /* * Clean up. */ _sysio_shutdown(); -#endif return 0; } @@ -243,7 +206,7 @@ usage() { (void )fprintf(stderr, - "Usage: list_path [-a] [-m <driver>] [-r <mntpath>]" + "Usage: list_path" " [<path> ...\n]"); exit(1); Index: test_path.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_path.c,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -w -b -B -p -r1.6 -r1.6.2.1 --- test_path.c 10 Oct 2003 18:50:31 -0000 1.6 +++ test_path.c 9 Feb 2004 13:11:19 -0000 1.6.2.1 @@ -64,7 +64,7 @@ /* * Stat files. * - * Usage: test_path [-a] [-m <fsname>] [-r <mntpath>] [path...] + * Usage: test_path [path...] * * Without any path arguments, the program reads from standard-in, dealing with * each line as an absolute or relative path until EOF. @@ -73,69 +73,33 @@ static int statit(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; + extern _test_sysio_startup(void); /* * Parse command line arguments. */ - while ((i = getopt(argc, argv, opts)) != -1) + while ((i = getopt(argc, argv, "")) != -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(); } -#ifndef CPLANT_YOD /* * Init sysio lib. */ - _sysio_init(); - - /* - * Init native file system driver and request mount of specified - * source directory. - */ - err = drv_init_all(); + err = _test_sysio_startup(); if (err) { errno = -err; - perror("drv_init_all"); + perror("sysio startup"); exit(1); } - err = _sysio_mount_root(mntpath, root_driver, mntflgs, NULL); - if (err) { - errno = -err; - perror("_sysio_mount_root"); - exit(1); - } -#endif n = argc - optind; @@ -171,12 +135,10 @@ main(int argc, char *const argv[]) } } -#ifndef CPLANT_YOD /* * Clean up. */ _sysio_shutdown(); -#endif return 0; } @@ -248,7 +210,7 @@ usage() { (void )fprintf(stderr, - "Usage: test_path [-a] [-m <driver>] [-r <mntpath>]" + "Usage: test_path" " [<path> ...\n]"); exit(1); Index: test_rename.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_rename.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -w -b -B -p -r1.3 -r1.3.4.1 --- test_rename.c 28 Oct 2003 18:54:19 -0000 1.3 +++ test_rename.c 9 Feb 2004 13:11:19 -0000 1.3.4.1 @@ -65,13 +65,9 @@ /* * Rename a file system object. * - * Usage: test_rename [-a] [-r <source>] [-m <root-driver>] <src> <dest> + * Usage: test_rename <src> <dest> */ -char *root_driver = DEFAULT_DRIVER; -char *mntpath = "/"; -unsigned mntflgs = 0; - void usage(void); int rename_file(const char *spath, const char *dpath); @@ -81,52 +77,31 @@ main(int argc, char * const argv[]) int i; int err; const char *spath, *dpath; + extern int _test_sysio_startup(void); /* * Parse command-line args. */ while ((i = getopt(argc, argv, -#ifdef AUTOMOUNT_FILE_NAME - "a" -#endif - "r:m:")) != -1) + "" + )) != -1) switch (i) { -#ifdef AUTOMOUNT_FILE_NAME - case 'a': - mntflgs |= MOUNT_F_AUTO; - break; -#endif - case 'r': /* set working dir */ - mntpath = optarg; - break; - case 'm': - root_driver = optarg; - break; default: usage(); } if (!(argc - optind)) usage(); -#ifndef CPLANT_YOD - if (_sysio_init() != 0) { - perror("init sysio"); - exit(1); - } - err = drv_init_all(); - if (err) { - perror("init drivers"); - exit(1); - } - err = _sysio_mount_root(mntpath, root_driver, mntflgs, NULL); + + err = _test_sysio_startup(); if (err) { errno = -err; - perror(root_driver); + perror("sysio startup"); exit(1); } -#endif + (void )umask(022); /* @@ -146,9 +121,7 @@ main(int argc, char * const argv[]) if (err) perror("rename"); -#ifndef CPLANT_YOD _sysio_shutdown(); -#endif return err; } @@ -159,10 +132,6 @@ usage() (void )fprintf(stderr, "Usage: test_rename " -#ifdef AUTOMOUNT_FILE_NAME - "[-a] " -#endif - "[-r <source>] [-m <fsname>]" " source destination\n"); exit(1); } Index: test_stats.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_stats.c,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -w -b -B -p -r1.5 -r1.5.2.1 --- test_stats.c 10 Oct 2003 18:50:31 -0000 1.5 +++ test_stats.c 9 Feb 2004 13:11:19 -0000 1.5.2.1 @@ -66,79 +66,45 @@ /* * Get stats of file and file system. * - * Usage: test_stats [-a] [-r <root-path>] [-m <root-driver>] [<path> ...] + * Usage: test_stats [<path> ...] */ -char *root_driver = DEFAULT_DRIVER; -char *root_path = "/"; -unsigned mntflgs = 0; - void usage(void); void do_stats(const char *path); -#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; + extern int _test_sysio_startup(void); /* * Parse command-line args. */ - while ((i = getopt(argc, argv, opts)) != -1) + while ((i = getopt(argc, argv, "")) != -1) switch (i) { -#ifdef AUTOMOUNT_FILE_NAME - case 'a': - mntflgs |= MOUNT_F_AUTO; - break; -#endif - case 'r': - root_path = optarg; - break; - case 'm': - root_driver = optarg; - break; default: usage(); } -#ifndef CPLANT_YOD - if (_sysio_init() != 0) { - perror("init sysio"); - exit(1); - } - err = drv_init_all(); - if (err) { - perror("init drivers"); - exit(1); - } - err = _sysio_mount_root(root_path, root_driver, mntflgs, NULL); + err = _test_sysio_startup(); if (err) { errno = -err; - perror(root_driver); + perror("sysio startup"); exit(1); } -#endif + (void )umask(022); while (optind < argc) do_stats(argv[optind++]); -#ifndef CPLANT_YOD /* * Clean up. */ _sysio_shutdown(); -#endif return 0; } @@ -148,7 +114,7 @@ usage() { (void )fprintf(stderr, - "Usage: test_stats [-a] [-m <fsname>] [-r <root-path>]" + "Usage: test_stats" " source destination\n"); exit(1); } Index: test_unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_unlink.c,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -u -w -b -B -p -r1.2 -r1.2.4.1 --- test_unlink.c 10 Oct 2003 18:50:32 -0000 1.2 +++ test_unlink.c 9 Feb 2004 13:11:19 -0000 1.2.4.1 @@ -64,7 +64,7 @@ /* * Unlink files. * - * Usage: unlink [-a] [-m <fsname>] [-r <mntpath>] [path...] + * Usage: unlink [path...] * * Without any path arguments, the program unlinks files named * by the ocmmand line args. @@ -73,42 +73,20 @@ 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; + extern int _test_sysio_startup(void); /* * Parse command line arguments. */ - while ((i = getopt(argc, argv, opts)) != -1) + while ((i = getopt(argc, argv, "")) != -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(); } @@ -116,22 +94,10 @@ main(int argc, char *const argv[]) /* * 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); + err = _test_sysio_startup(); if (err) { errno = -err; - perror("_sysio_mount_root"); + perror("sysio startup"); exit(1); } @@ -194,7 +160,7 @@ usage() { (void )fprintf(stderr, - "Usage: unlink [-a] [-m <driver>] [-r <mntpath>]" + "Usage: unlink" " [<path> ...\n]"); exit(1); --- test_mounts.c DELETED --- --- test_namespace.c DELETED --- --- test_stdfd.c DELETED --- |
|
From: Lee W. <lw...@us...> - 2004-02-09 13:14:33
|
Update of /cvsroot/libsysio/libsysio/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29233/include Modified Files: Tag: namespace_assembly mount.h sysio.h Log Message: Namespace assembly at boot project: Adds the ability to craft an initial, arbitrarily complex, name space. Governed by the presence of the SYSIO_NAMESPACE environment variable formatted per Sonja Tideman's trial specification. For an example, see .../misc/init-env.sh. The mounts, namespace, and stdfd tests were all removed. They've been deprecated or obsoleted by this project. The remaining tests have been updated. They no longer require the complicated initialization they previously used in order to get a root set up. Index: mount.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/mount.h,v retrieving revision 1.3 retrieving revision 1.3.18.1 diff -u -w -b -B -p -r1.3 -r1.3.18.1 --- mount.h 7 Mar 2003 03:31:36 -0000 1.3 +++ mount.h 9 Feb 2004 13:11:18 -0000 1.3.18.1 @@ -86,6 +86,12 @@ extern int _sysio_mount_root(const char const char *type, unsigned flags, const void *data); +extern int _sysio_mount(struct pnode *cwd, + const char *source, + const char *target, + const char *filesystemtype, + unsigned long mountflags, + const void *data); extern int _sysio_unmount_all(void); #ifdef AUTOMOUNT_FILE_NAME extern int _sysio_automount(struct pnode *mntpno); Index: sysio.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/sysio.h,v retrieving revision 1.14.2.1 retrieving revision 1.14.2.2 diff -u -w -b -B -p -r1.14.2.1 -r1.14.2.2 --- sysio.h 28 Jan 2004 13:16:56 -0000 1.14.2.1 +++ sysio.h 9 Feb 2004 13:11:18 -0000 1.14.2.2 @@ -141,6 +141,7 @@ extern mode_t _sysio_umask; extern int _sysio_init(void); extern void _sysio_shutdown(void); +extern int _sysio_boot(const char *buf); /* * The following should be defined by the system includes, and probably are, |
|
From: Lee W. <lw...@us...> - 2004-02-09 13:14:33
|
Update of /cvsroot/libsysio/libsysio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29233 Modified Files: Tag: namespace_assembly Makefile.am Log Message: Namespace assembly at boot project: Adds the ability to craft an initial, arbitrarily complex, name space. Governed by the presence of the SYSIO_NAMESPACE environment variable formatted per Sonja Tideman's trial specification. For an example, see .../misc/init-env.sh. The mounts, namespace, and stdfd tests were all removed. They've been deprecated or obsoleted by this project. The remaining tests have been updated. They no longer require the complicated initialization they previously used in order to get a root set up. Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/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 28 Jan 2004 13:16:55 -0000 1.9.2.1 +++ Makefile.am 9 Feb 2004 13:11:18 -0000 1.9.2.2 @@ -65,7 +65,7 @@ __LIBBUILD_DIR__libsysio_a_SOURCES = \ include $(top_srcdir)/Rules.make -EXTRA_DIST = Rules.make $(TESTS_EXTRA) $(SRCDIR_EXTRA) \ +EXTRA_DIST = Rules.make misc/init-env.sh $(TESTS_EXTRA) $(SRCDIR_EXTRA) \ $(INCLUDE_EXTRA) $(STDFD_EXTRA) $(INCORE_EXTRA) \ $(SOCKETS_EXTRA) $(NATIVE_EXTRA) $(YOD_EXTRA) |
|
From: Lee W. <lw...@us...> - 2004-02-09 13:14:33
|
Update of /cvsroot/libsysio/libsysio/misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29233/misc Added Files: Tag: namespace_assembly init-env.sh Log Message: Namespace assembly at boot project: Adds the ability to craft an initial, arbitrarily complex, name space. Governed by the presence of the SYSIO_NAMESPACE environment variable formatted per Sonja Tideman's trial specification. For an example, see .../misc/init-env.sh. The mounts, namespace, and stdfd tests were all removed. They've been deprecated or obsoleted by this project. The remaining tests have been updated. They no longer require the complicated initialization they previously used in order to get a root set up. --- NEW FILE --- # # Source this file. It will craft a usable name space for your testing. # # Lee; Sun Feb 8 18:02:16 EST 2004 # # Note: We really should support symlinks someday. # unset _root_flags unset _extras if [ "x${SYSIO_AUTOMOUNT}" == "xyes" ]; then _root_flags="2" # # Add a /auto directory for automounted file systems. We # craft one automount that mounts /usr/home from the native # file system. Further automounts in the sub-mounts are not enabled. # _extras=" \ {mnt, dev=\"incore:0755+0+0\",dir=\"/mnt\",fl=2} \ {creat, ft=dir,nm=\"/mnt/home\",pm=0755,ow=0,gr=0} \ {creat, ft=file,nm=\"/mnt/home/.mount\",pm=0600, \ str=\"native:/usr/home\"} \ " fi export SYSIO_NAMESPACE="\ {mnt, dev=\"native:/\",dir=/,fl=${_root_flags:-0}} \ {mnt, dev=\"incore:0755+0+0\",dir=\"/dev\"} \ {creat, ft=chr,nm=\"/dev/stdin\",pm=0400,mm=0+0} \ {creat, ft=chr,nm=\"/dev/stdout\",pm=0200,mm=0+1} \ {creat, ft=chr,nm=\"/dev/stderr\",pm=0200,mm=0+2} \ {creat, ft=dir,nm=\"/dev/fd\",pm=0755,ow=0,gr=0} \ {creat, ft=chr,nm=\"/dev/fd/0\",pm=0400,mm=0+0} \ {creat, ft=chr,nm=\"/dev/fd/1\",pm=0200,mm=0+1} \ {creat, ft=chr,nm=\"/dev/fd/2\",pm=0200,mm=0+2} \ {cd, dir=\"$HOME\"} \ ${_extras} \ " unset _root_flags unset _extras |
|
From: Lee W. <lw...@us...> - 2004-02-08 23:51:58
|
Update of /cvsroot/libsysio/libsysio/drivers/native In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14749/drivers/native Modified Files: fs_native.c Log Message: This driver was nearly perfectly forgetting to pass the error number on failure. Fixed -- I think. Index: fs_native.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/native/fs_native.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -w -b -B -p -r1.30 -r1.31 --- fs_native.c 6 Feb 2004 20:07:29 -0000 1.30 +++ fs_native.c 8 Feb 2004 23:48:51 -0000 1.31 @@ -745,6 +745,8 @@ native_inop_setattr(struct pnode *pno, fd < 0 ? syscall(SYS_chmod, path, mode) : syscall(SYS_fchmod, fd, mode); + if (err) + err = -errno; } if (err) mask &= ~SETATTR_MODE; @@ -761,6 +763,8 @@ native_inop_setattr(struct pnode *pno, if (mask & SETATTR_ATIME) ut.actime = stbuf->st_atime; err = syscall(__SYS_UTIME, path, &ut); + if (err) + err = -errno; } if (err) mask &= ~(SETATTR_MTIME|SETATTR_ATIME); @@ -787,6 +791,8 @@ native_inop_setattr(struct pnode *pno, mask & SETATTR_GID ? stbuf->st_gid : (gid_t )-1); + if (err) + err = -errno; } if (err) mask &= ~(SETATTR_UID|SETATTR_GID); @@ -933,6 +939,8 @@ native_inop_mkdir(struct pnode *pno, mod return -ENOMEM; err = syscall(SYS_mkdir, path, mode); + if (err != 0) + err = -errno; free(path); return err; } @@ -948,6 +956,8 @@ native_inop_rmdir(struct pnode *pno) return -ENOMEM; err = syscall(SYS_rmdir, path); + if (err != 0) + err = -errno; free(path); return err; } @@ -963,6 +973,8 @@ native_inop_symlink(struct pnode *pno, c return -ENOMEM; err = syscall(SYS_symlink, data, path); + if (err != 0) + err = -errno; free(path); return err; } @@ -1110,6 +1122,8 @@ native_inop_link(struct pnode *old, stru } err = syscall(SYS_link, opath, npath); + if (err != 0) + err = -errno; out: if (opath) @@ -1162,6 +1176,8 @@ native_inop_rename(struct pnode *old, st } err = syscall(SYS_rename, opath, npath); + if (err != 0) + err = -errno; out: if (opath) @@ -1249,6 +1265,8 @@ doiov(const struct iovec *iov, nio); if (cc > 0) nio->nio_nino->ni_fpos += cc; + else + cc = -errno; return cc; #if !(defined(REDSTORM) || defined(MAX_IOVEC)) @@ -1412,6 +1430,7 @@ native_inop_fcntl(struct inode *ino, { struct native_inode *nino = I2NI(ino); long arg; + int err; if (nino->ni_fd < 0) abort(); @@ -1420,7 +1439,9 @@ native_inop_fcntl(struct inode *ino, case F_GETFD: case F_GETFL: case F_GETOWN: - return syscall(SYS_fcntl, nino->ni_fd, cmd); + err = syscall(SYS_fcntl, nino->ni_fd, cmd); + if (err < 0) + err = -errno; case F_DUPFD: case F_SETFD: case F_SETFL: @@ -1429,11 +1450,13 @@ native_inop_fcntl(struct inode *ino, case F_SETLKW: case F_SETOWN: arg = va_arg(ap, long); - return syscall(SYS_fcntl, nino->ni_fd, cmd, arg); + err = syscall(SYS_fcntl, nino->ni_fd, cmd, arg); + if (err) + err = -errno; default: - break; + err = -EINVAL; } - return -EINVAL; + return err; } static int @@ -1496,26 +1519,34 @@ native_inop_statvfs(struct pnode *pno, static int native_inop_sync(struct inode *ino) { + int err; assert(I2NI(ino)->ni_fd >= 0); - return syscall(SYS_fsync, I2NI(ino)->ni_fd); + err = syscall(SYS_fsync, I2NI(ino)->ni_fd); + if (err) + err = -errno; + return err; } static int native_inop_datasync(struct inode *ino) { + int err; assert(I2NI(ino)->ni_fd >= 0); #ifdef NATIVE_FDATASYNC - return syscall(NATIVE_FDATASYNC, I2NI(ino)->ni_fd); + err = syscall(NATIVE_FDATASYNC, I2NI(ino)->ni_fd); #else #if 0 #warning No fdatasync system call -- Using fsync instead! #endif - return syscall(SYS_fsync, I2NI(ino)->ni_fd); + err = syscall(SYS_fsync, I2NI(ino)->ni_fd); #endif + if (err) + err = -errno; + return err; } static int |
|
From: Lee W. <lw...@us...> - 2004-02-08 21:40:33
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19216 Modified Files: chdir.c Log Message: The chdir() function was not setting errno when errors occurred. Fixed. Index: chdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -b -B -p -r1.12 -r1.13 --- chdir.c 26 Jan 2004 16:34:54 -0000 1.12 +++ chdir.c 8 Feb 2004 21:37:26 -0000 1.13 @@ -128,8 +128,14 @@ chdir(const char *path) } err = _sysio_p_chdir(pno); + if (err) + P_RELE(pno); SYSIO_LEAVE; + if (err) { + errno = -err; + err = -1; + } return err; } |
|
From: Lee W. <lw...@us...> - 2004-02-06 20:12:54
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30753 Removed Files: read.c write.c Log Message: Strided-IO merge should have removed these files. --- read.c DELETED --- --- write.c DELETED --- |
|
From: Lee W. <lw...@us...> - 2004-02-06 20:10:48
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29990/src Modified Files: dev.c dup.c file.c fs.c init.c inode.c ioctx.c lseek.c mkdir.c module.mk mount.c namei.c rmdir.c statvfs64.c symlink.c truncate.c unlink.c Added Files: rw.c Log Message: Merging strided-IO branch + Strided-IO infrastructure. Internals altered to move data base don multiple targeted regions in both the file address space and local memory. + Added [i]{read,write}x, calls to perform extent-based or strided-IO directly. + Many bug fixes + Many uocnfig fixes + --with-zero-sum-memory; A config option that causes the shutdown code to carefully release *all* memory acquired from the heap, by the library. Useful for debugging tasks such as leak detection. Index: dev.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/dev.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- dev.c 12 Jan 2004 18:05:21 -0000 1.5 +++ dev.c 6 Feb 2004 20:07:30 -0000 1.6 @@ -66,8 +66,8 @@ const struct inode_ops _sysio_nodev_ops _sysio_nodev_inop_link, _sysio_nodev_inop_unlink, _sysio_nodev_inop_rename, - _sysio_nodev_inop_ipreadv, - _sysio_nodev_inop_ipwritev, + _sysio_nodev_inop_read, + _sysio_nodev_inop_write, _sysio_nodev_inop_iodone, _sysio_nodev_inop_fcntl, _sysio_nodev_inop_sync, Index: dup.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/dup.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -b -B -p -r1.4 -r1.5 --- dup.c 26 Jan 2004 16:34:54 -0000 1.4 +++ dup.c 6 Feb 2004 20:07:30 -0000 1.5 @@ -65,22 +65,12 @@ dup2(int oldfd, int newfd) } if (oldfd == newfd) { -#ifdef REDSTORM -#undef __dup2 -sysio_sym_weak_alias(dup2, __dup2) -#endif - SYSIO_LEAVE; return newfd; } rc = _sysio_fd_dup2(oldfd, newfd); if (rc < 0) { - -#ifdef REDSTORM -#undef __dup -sysio_sym_weak_alias(dup, __dup) -#endif errno = -rc; rc = -1; } @@ -89,6 +78,11 @@ sysio_sym_weak_alias(dup, __dup) return rc; } +#ifdef REDSTORM +#undef __dup2 +sysio_sym_weak_alias(dup2, __dup2) +#endif + int dup(int oldfd) { Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- file.c 13 Oct 2003 01:04:35 -0000 1.6 +++ file.c 6 Feb 2004 20:07:30 -0000 1.7 @@ -50,6 +50,7 @@ #include "sysio.h" #include "file.h" #include "inode.h" +#include "xtio.h" /* * Support for file IO. @@ -99,12 +100,16 @@ _sysio_fgone(struct file *fil) void _sysio_fcompletio(struct ioctx *ioctx, struct file *fil) { + _SYSIO_OFF_T off; - if (ioctx->ioctx_errno) + if (ioctx->ioctx_cc <= 0) return; assert(ioctx->ioctx_ino == fil->f_ino); - fil->f_pos = ioctx->ioctx_offset + ioctx->ioctx_cc; + off = fil->f_pos + ioctx->ioctx_cc; + if (fil->f_pos && off <= fil->f_pos) + abort(); + fil->f_pos = off; } /* @@ -143,6 +148,16 @@ fd_grow(size_t n) return 0; } +#if ZERO_SUM_MEMORY +void +_sysio_fd_shutdown() +{ + + free(_sysio_oftab); + _sysio_oftab_size = 0; +} +#endif + /* * Find a free slot in the open files table. */ Index: fs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/fs.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- fs.c 24 Apr 2003 02:15:29 -0000 1.8 +++ fs.c 6 Feb 2004 20:07:30 -0000 1.9 @@ -105,6 +105,22 @@ _sysio_fssw_register(const char *name, s return 0; } +#if ZERO_SUM_MEMORY +/* + * Shutdown + */ +void +_sysio_fssw_shutdown() +{ + struct fsswent *fssw; + + while ((fssw = fsswitch.lh_first)) { + LIST_REMOVE(fssw, fssw_link); + free(fssw); + } +} +#endif + /* * Allocate and initialize a new file system record. */ Index: init.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/init.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- init.c 21 Jan 2004 15:06:31 -0000 1.5 +++ init.c 6 Feb 2004 20:07:30 -0000 1.6 @@ -52,6 +52,10 @@ #include "file.h" #include "dev.h" +#if ZERO_SUM_MEMORY +#include "fs.h" +#endif + #ifdef STDFD_DEV #include "stdfd.h" #endif @@ -113,4 +117,10 @@ _sysio_shutdown() if (!(_sysio_fd_close_all() == 0 && _sysio_unmount_all() == 0)) abort(); + +#if ZERO_SUM_MEMORY + _sysio_fd_shutdown(); + _sysio_i_shutdown(); + _sysio_fssw_shutdown(); +#endif } Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -b -B -p -r1.12 -r1.13 --- inode.c 12 Jan 2004 18:05:22 -0000 1.12 +++ inode.c 6 Feb 2004 20:07:30 -0000 1.13 @@ -96,6 +96,24 @@ static size_t n_names = 0; static size_t max_names = (2 * NAMES_TABLE_LEN); /* + * Number of pnodes to grab per memory allocation when filling the + * free list. + */ +#define PNODES_PER_CHUNK ((8 * 1024) / sizeof(struct pnode) - 2) + +#if ZERO_SUM_MEMORY +/* + * Allocation information for pnodes bulk allocation. + */ +struct pnodes_block { + LIST_ENTRY(pnodes_block) pnblk_links; + struct pnode pnblk_nodes[PNODES_PER_CHUNK]; +}; + +static LIST_HEAD( ,pnodes_block) pnblocks; +#endif + +/* * List of all path-nodes (aliases) referenced by any tree. */ struct pnodes_head _sysio_pnodes; @@ -124,6 +142,9 @@ _sysio_i_init() for (i = 0; i < NAMES_TABLE_LEN; i++) LIST_INIT(&names[i]); +#if ZERO_SUM_MEMORY + LIST_INIT(&pnblocks); +#endif TAILQ_INIT(&_sysio_pnodes); LIST_INIT(&free_pnodes); @@ -205,6 +226,7 @@ _sysio_i_new(struct filesys *fs, { struct inode *ino; struct itable_entry *head; + struct inode_ops operations; if (n_inodes > max_inodes) { /* @@ -217,6 +239,7 @@ _sysio_i_new(struct filesys *fs, if (!ino) return NULL; ino->i_ops = *ops; + operations = *ops; if (S_ISBLK(type) || S_ISCHR(type) || S_ISFIFO(type)) { struct inode_ops *o; @@ -225,15 +248,15 @@ _sysio_i_new(struct filesys *fs, * those from the device table. */ o = _sysio_dev_lookup(type, rdev); - ino->i_ops.inop_open = o->inop_open; - ino->i_ops.inop_close = o->inop_close; - ino->i_ops.inop_ipreadv = o->inop_ipreadv; - ino->i_ops.inop_ipwritev = o->inop_ipwritev; - ino->i_ops.inop_iodone = o->inop_iodone; - ino->i_ops.inop_datasync = o->inop_datasync; - ino->i_ops.inop_ioctl = o->inop_ioctl; + operations.inop_open = o->inop_open; + operations.inop_close = o->inop_close; + operations.inop_read = o->inop_read; + operations.inop_write = o->inop_write; + operations.inop_iodone = o->inop_iodone; + operations.inop_datasync = o->inop_datasync; + operations.inop_ioctl = o->inop_ioctl; } - I_INIT(ino, fs, type, rdev, &ino->i_ops, fid, immunity, private); + I_INIT(ino, fs, type, rdev, &operations, fid, immunity, private); ino->i_ref = 1; TAILQ_INSERT_TAIL(&_sysio_inodes, ino, i_nodes); head = &fs->fs_itbl[hash(fid) % FS_ITBLSIZ]; @@ -437,19 +460,46 @@ static void more_pnodes() { size_t n; +#if ZERO_SUM_MEMORY + struct pnodes_block *pnblk; +#endif struct pnode *pno; - n = (8 * 1024) / sizeof(struct pnode); /* numbers! */ - assert(n); - pno = malloc(n * sizeof(struct pnode)); +#if ZERO_SUM_MEMORY + pnblk = malloc(sizeof(struct pnodes_block)); + pno = NULL; + if (pnblk) { + LIST_INSERT_HEAD(&pnblocks, pnblk, pnblk_links); + pno = pnblk->pnblk_nodes; + } +#else + pno = malloc(PNODES_PER_CHUNK * sizeof(struct pnode)); +#endif if (!pno) return; + n = PNODES_PER_CHUNK; do { LIST_INSERT_HEAD(&free_pnodes, pno, p_links); pno++; } while (--n); } +#if ZERO_SUM_MEMORY +/* + * Shutdown + */ +void +_sysio_i_shutdown() +{ + struct pnodes_block *pnblk; + + while ((pnblk = pnblocks.lh_first)) { + LIST_REMOVE(pnblk, pnblk_links); + free(pnblk); + } +} +#endif + /* * Allocate, initialize and establish appropriate links for new path (alias) * node. Index: ioctx.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/ioctx.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- ioctx.c 17 Oct 2003 21:30:29 -0000 1.6 +++ ioctx.c 6 Feb 2004 20:07:30 -0000 1.7 @@ -9,7 +9,7 @@ * 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. + * Cplant(TM) Copyright 1998-2004 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 @@ -51,16 +51,30 @@ #include "sysio.h" #include "inode.h" +#include "xtio.h" /* * Asynchronous IO context support. */ /* + * Arguments to IO vector enumerator callback when used by _sysio_doio(). + */ +struct doio_helper_args { + ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *); /* base func */ + void *arg; /* caller arg */ +}; + +/* * List of all outstanding (in-flight) asynch IO requests tracked * by the system. */ -LIST_HEAD( ,ioctx) aioq; +static LIST_HEAD( ,ioctx) aioq; + +/* + * Free callback entry. + */ +#define cb_free(cb) free(cb) /* * Initialization. Must be called before using any other routine in this @@ -75,39 +89,44 @@ _sysio_ioctx_init() } /* - * Allocate and initialisze a new IO context. + * Enter an IO context onto the async IO events queue. + */ +void +_sysio_ioctx_enter(struct ioctx *ioctx) +{ + + LIST_INSERT_HEAD(&aioq, ioctx, ioctx_link); +} + +/* + * Allocate and initialize a new IO context. */ struct ioctx * _sysio_ioctx_new(struct inode *ino, const struct iovec *iov, size_t iovlen, - _SYSIO_OFF_T offset) + const struct intnl_xtvec *xtv, + size_t xtvlen) { struct ioctx *ioctx; - ioctx = - malloc(sizeof(struct ioctx) + iovlen * sizeof(struct iovec)); + ioctx = malloc(sizeof(struct ioctx)); if (!ioctx) return NULL; I_REF(ino); - ioctx->ioctx_iovec = (void *)ioctx + sizeof(struct ioctx); - (void )memcpy((void *)ioctx->ioctx_iovec, - iov, - iovlen * sizeof(struct iovec)); IOCTX_INIT(ioctx, 0, (ioid_t )ioctx, ino, - ioctx->ioctx_iovec, - iovlen, - offset); + iov, iovlen, + xtv, xtvlen); /* * Link request onto the outstanding requests queue. */ - LIST_INSERT_HEAD(&aioq, ioctx, ioctx_link); + _sysio_ioctx_enter(ioctx); return ioctx; } @@ -166,7 +185,6 @@ _sysio_ioctx_find(ioid_t id) ssize_t _sysio_ioctx_wait(struct ioctx *ioctx) { - int err; ssize_t cc; /* @@ -179,7 +197,6 @@ _sysio_ioctx_wait(struct ioctx *ioctx) /* * Get status. */ - err = 0; cc = ioctx->ioctx_cc; if (cc < 0) cc = -ioctx->ioctx_errno; @@ -193,6 +210,16 @@ _sysio_ioctx_wait(struct ioctx *ioctx) } /* + * Free callback entry. + */ +void +_sysio_ioctx_cb_free(struct ioctx_callback *cb) +{ + + cb_free(cb); +} + +/* * Complete an asynchronous IO request. */ void @@ -206,17 +233,296 @@ _sysio_ioctx_complete(struct ioctx *ioct while ((entry = ioctx->ioctx_cbq.tqh_first)) { TAILQ_REMOVE(&ioctx->ioctx_cbq, entry, iocb_next); (*entry->iocb_f)(ioctx, entry->iocb_data); - free(entry); + cb_free(entry); } - if (ioctx->ioctx_fast) - return; - /* * Unlink from the file record's outstanding request queue. */ LIST_REMOVE(ioctx, ioctx_link); + if (ioctx->ioctx_fast) + return; + I_RELE(ioctx->ioctx_ino); + free(ioctx); } + +/* + * General help validating strided-IO vectors. + * + * A driver may call this to make sure underflow/overflow of an off_t can't + * occur and overflow of a ssize_t can't occur when writing. The sum + * of the reconciled transfer length is returned or some appropriate + * error depending on underflow/overflow. + * + * The following algorithm assumes: + * + * a) sizeof(size_t) >= sizeof(ssize_t) + * b) 2's complement arithmetic + * c) The compiler won't optimize away code because it's developers + * believed that something with an undefined result in `C' can't happen. + */ +ssize_t +_sysio_validx(const struct intnl_xtvec *xtv, size_t xtvlen, + const struct iovec *iov, size_t iovlen, + _SYSIO_OFF_T limit) +{ + ssize_t acc, cc; + struct iovec iovec; + struct intnl_xtvec xtvec; + _SYSIO_OFF_T off; + + if (!(xtvlen && iovlen)) + return -EINVAL; + + acc = 0; + xtvec.xtv_len = iovec.iov_len = 0; + do { + while (!xtvec.xtv_len) { + if (!xtvlen--) + break; + if (!xtv->xtv_len) { + xtv++; + continue; + } + xtvec = *xtv++; + if (xtvec.xtv_off < 0) + return -EINVAL; + } + if (!xtvec.xtv_len) + break; + do { + while (!iovec.iov_len) { + if (!iovlen--) + break; + if (!iov->iov_len) { + iov++; + continue; + } + iovec = *iov++; + } + if (!iovec.iov_len) + break; + cc = iovec.iov_len; + if (cc < 0) + return -EINVAL; + if ((size_t )cc > xtvec.xtv_len) + cc = xtvec.xtv_len; + xtvec.xtv_len -= cc; + iovec.iov_len -= cc; + off = xtvec.xtv_off + cc; + if (xtvec.xtv_off && off <= xtvec.xtv_off) + return off < 0 ? -EINVAL : -EOVERFLOW; + if (off > limit) + return -EFBIG; + xtvec.xtv_off = off; + cc += acc; + if (acc && (cc <= acc)) + return -EINVAL; + acc = cc; + } while (xtvec.xtv_len && iovlen); + } while ((xtvlen || xtvec.xtv_len) && iovlen); + return acc; +} + +/* + */ +ssize_t +_sysio_enumerate_extents(const struct intnl_xtvec *xtv, size_t xtvlen, + const struct iovec *iov, size_t iovlen, + ssize_t (*f)(const struct iovec *, int, + _SYSIO_OFF_T, + ssize_t, + void *), + void *arg) +{ + ssize_t acc, cc; + struct iovec iovec; + struct intnl_xtvec xtvec; + const struct iovec *start; + _SYSIO_OFF_T off; + size_t n; + + acc = 0; + iovec.iov_len = 0; + while (xtvlen) { + /* + * Coalesce contiguous extent vector entries. + */ + off = xtvec.xtv_off = xtv->xtv_off; + off += xtvec.xtv_len = xtv->xtv_len; + while (++xtv, --xtvlen) { + if (off != xtv->xtv_off) { + /* + * Not contiguous. + */ + break; + } + if (!xtv->xtv_len) { + /* + * Zero length. + */ + continue; + } + off += xtv->xtv_len; + xtvec.xtv_len += xtv->xtv_len; + } + while (xtvec.xtv_len) { + if (iovec.iov_len) { + cc = + (*f)(&iovec, 1, + xtvec.xtv_off, + xtvec.xtv_len, + arg); + if (cc <= 0) { + if (acc) + return acc; + return cc; + } + cc += acc; + if (acc && cc <= acc) + abort(); /* paranoia */ + acc = cc; + iovec.iov_base += cc; + iovec.iov_len -= cc; + } else { + start = iov; + n = xtvec.xtv_len; + do { + if (iov->iov_len > n) { + /* + * That'll do. + */ + break; + } + n -= iov->iov_len; + iov++; + } while (--iovlen); + if (iov == start) { + iovec = *iov++; + if (iovec.iov_len > n) + iovec.iov_len = n; + continue; + } + cc = + (*f)(start, iov - start, + xtvec.xtv_off, + xtvec.xtv_len - n, + arg); + if (cc <= 0) { + if (acc) + return acc; + return cc; + } + cc += acc; + if (acc && cc <= acc) + abort(); /* paranoia */ + acc = cc; + } + xtvec.xtv_off += cc; + xtvec.xtv_len -= cc; + } + } + return acc; +} + +ssize_t +_sysio_enumerate_iovec(const struct iovec *iov, size_t count, + _SYSIO_OFF_T off, + ssize_t limit, + ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *), + void *arg) +{ + ssize_t acc, cc; + size_t n; + unsigned indx; + size_t remain; + + if (!count) + return -EINVAL; + assert(limit >= 0); + acc = 0; + n = limit; + for (indx = 0; indx < count; indx++) { + if (limit < 0 || iov[indx].iov_len < n) { + cc = (ssize_t )iov[indx].iov_len; + if (cc < 0) + return -EINVAL; + } else + cc = (ssize_t )n; + if (!cc) + continue; + n -= cc; + cc += acc; + if (acc && cc <= acc) + return -EINVAL; + acc = cc; + } + if (!acc) + return 0; + acc = 0; + do { + if (!iov->iov_len) { + iov++; + continue; + } + n = + limit < 0 || iov[indx].iov_len < (size_t )limit + ? iov[indx].iov_len + : (size_t )limit; + cc = (*f)(iov->iov_base, n, off, arg); + if (cc <= 0) { + if (acc) + return acc; + return cc; + } + remain = iov->iov_len - cc; + cc += acc; + if (acc && cc <= acc) + abort(); /* bad driver! */ + acc = cc; + if (remain) + break; /* short/limited read */ + iov++; + } while (--count); + return acc; +} + +static ssize_t +_sysio_doio_helper(const struct iovec *iov, int count, + _SYSIO_OFF_T off, + ssize_t limit, + struct doio_helper_args *args) +{ + + return _sysio_enumerate_iovec(iov, count, + off, limit, + args->f, + args->arg); +} + +/* + * A meta-driver for the whole strided-io process. Appropriate when + * the driver can't handle anything but simple p{read,write}-like + * interface. + */ +ssize_t +_sysio_doio(const struct intnl_xtvec *xtv, size_t xtvlen, + const struct iovec *iov, size_t iovlen, + ssize_t (*f)(void *, size_t, _SYSIO_OFF_T, void *), + void *arg) +{ + struct doio_helper_args arguments; + + arguments.f = f; + arguments.arg = arg; + return _sysio_enumerate_extents(xtv, xtvlen, + iov, iovlen, + (ssize_t (*)(const struct iovec *, int, + _SYSIO_OFF_T, + ssize_t, + void *))_sysio_doio_helper, + &arguments); +} Index: lseek.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/lseek.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -w -b -B -p -r1.11 -r1.12 --- lseek.c 26 Jan 2004 16:34:54 -0000 1.11 +++ lseek.c 6 Feb 2004 20:07:30 -0000 1.12 @@ -43,6 +43,7 @@ #include <errno.h> #include <unistd.h> +#include <assert.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/queue.h> @@ -56,51 +57,50 @@ static _SYSIO_OFF_T _sysio_lseek(int fd, _SYSIO_OFF_T offset, int whence) { - int err; struct file *fil; - _SYSIO_OFF_T off = 0; + _SYSIO_OFF_T off, pos; struct intnl_stat stbuf; - err = 0; fil = _sysio_fd_find(fd); - if (!fil) { - err = -EBADF; - goto out; - } + if (!fil) + return -EBADF; - off = fil->f_pos; + off = -1; switch (whence) { case SEEK_SET: - off = offset; + off = 0; break; case SEEK_CUR: - off += offset; + off = fil->f_pos; break; case SEEK_END: + { + int err; + err = (*fil->f_ino->i_ops.inop_getattr)(NULL, fil->f_ino, &stbuf); if (err) - break; + return err; + } off = stbuf.st_size; - off += offset; break; default: - err = -EINVAL; - goto out; + return -EINVAL; } - - if (off < 0) - err = -EINVAL; - -out: - if (err) { - errno = -err; - return -1; - } - return fil->f_pos = off; + pos = off + offset; + if (pos < 0 || (off && pos <= off)) + return -EINVAL; +#ifdef O_LARGEFILE + if (pos >= ((fil->f_flags & O_LARGEFILE) ? _SYSIO_OFF_T_MAX : LONG_MAX)) + return -EOVERFLOW; +#else + if (pos >= _SYSIO_OFF_T_MAX) + return -EOVERFLOW; +#endif + return fil->f_pos = pos; } #if _LARGEFILE64_SOURCE @@ -127,15 +127,12 @@ lseek(int fd, off_t offset, int whence) off = _sysio_lseek(fd, offset, whence); if (off < 0) { + errno = -off; SYSIO_LEAVE; return -1; } rtn = (off_t )off; - if ((_SYSIO_OFF_T )rtn != off) { - errno = EINVAL; - SYSIO_LEAVE; - return -1; - } + assert(rtn == off); SYSIO_LEAVE; return rtn; } Index: mkdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mkdir.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- mkdir.c 26 Jan 2004 16:34:54 -0000 1.5 +++ mkdir.c 6 Feb 2004 20:07:30 -0000 1.6 @@ -83,11 +83,11 @@ out: err = -1; } + SYSIO_LEAVE; + return err; +} #ifdef REDSTORM #undef __mkdir sysio_sym_weak_alias(mkdir, __mkdir) #endif - SYSIO_LEAVE; - return err; -} Index: module.mk =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/module.mk,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -b -B -p -r1.1 -r1.2 --- module.mk 16 Dec 2003 15:43:14 -0000 1.1 +++ module.mk 6 Feb 2004 20:07:30 -0000 1.2 @@ -5,9 +5,8 @@ SRCDIR_SRCS = src/access.c src/chdir.c s src/ioctl.c src/ioctx.c src/iowait.c \ src/link.c src/lseek.c src/mkdir.c \ src/mknod.c src/mount.c src/namei.c \ - src/open.c src/read.c src/rename.c \ + src/open.c src/rw.c src/rename.c \ src/rmdir.c src/stat64.c src/stat.c \ src/statvfs64.c src/statvfs.c src/symlink.c \ - src/truncate.c src/unlink.c src/utime.c \ - src/write.c + src/truncate.c src/unlink.c src/utime.c SRCDIR_EXTRA = src/module.mk Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -b -B -p -r1.9 -r1.10 --- mount.c 27 Oct 2003 23:49:10 -0000 1.9 +++ mount.c 6 Feb 2004 20:07:30 -0000 1.10 @@ -57,6 +57,9 @@ #include "fs.h" #include "mount.h" #include "inode.h" +#ifdef AUTOMOUNT_FILE_NAME +#include "xtio.h" +#endif /* * File system and volume mount support. @@ -522,7 +525,6 @@ parse_opts(char *opts, unsigned *flagsp) flags |= MOUNT_F_RO; src += 2; } -#ifdef AUTOMOUNT_FILE_NAME else if (src + 4 == cp && strncmp(src, "auto", 4) == 0) { /* * Enable automounts. @@ -530,7 +532,6 @@ parse_opts(char *opts, unsigned *flagsp) flags |= MOUNT_F_AUTO; src += 4; } -#endif if (src < cp) { /* * Copy what we didn't consume. @@ -563,6 +564,7 @@ _sysio_automount(struct pnode *mntpno) struct intnl_stat stbuf; struct iovec iovec; struct ioctx iocontext; + struct intnl_xtvec xtvec; ssize_t cc; char *fstype, *source, *opts; unsigned flags; @@ -596,8 +598,16 @@ _sysio_automount(struct pnode *mntpno) err = _sysio_open(mntpno, O_RDONLY, 0); if (err) goto out; - IOCTX_INIT(&iocontext, 1, (ioid_t )&iocontext, ino, &iovec, 1, 0); - err = (*ino->i_ops.inop_ipreadv)(ino, &iocontext); + xtvec.xtv_off = 0; + xtvec.xtv_len = stbuf.st_size; + IOCTX_INIT(&iocontext, + 1, + (ioid_t )&iocontext, + ino, + &iovec, 1, + &xtvec, 1); + _sysio_ioctx_enter(&iocontext); + err = (*ino->i_ops.inop_read)(ino, &iocontext); if (err) { _sysio_ioctx_complete(&iocontext); (void )(*ino->i_ops.inop_close)(ino); Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -b -B -p -r1.9 -r1.10 --- namei.c 12 Jan 2004 23:02:08 -0000 1.9 +++ namei.c 6 Feb 2004 20:07:30 -0000 1.10 @@ -244,20 +244,19 @@ _sysio_path_walk(struct pnode *parent, s nd->nd_pno = nameidata.nd_pno; ino = nd->nd_pno->p_base->pb_ino; } - #ifdef AUTOMOUNT_FILE_NAME - /* - * We're committed to a lookup. It's time to see if we're - * going to do it in an automount-point and arrange the - * mount if so. - */ - if (ino && + else if (ino && S_ISDIR(ino->i_mode) && (nd->nd_pno->p_mount->mnt_flags & MOUNT_F_AUTO) && nd->nd_amcnt < MAX_MOUNT_DEPTH && ino->i_mode & S_ISVTX) { struct pnode *pno; + /* + * We're committed to a lookup. It's time to see if + * we're going to do it in an automount-point and + * arrange the mount if so. + */ assert(!nd->nd_pno->p_cover); err = lookup(nd->nd_pno, @@ -265,6 +264,8 @@ _sysio_path_walk(struct pnode *parent, s &pno, NULL, NULL); + if (pno) + P_RELE(pno); if (!err && _sysio_automount(pno) == 0) { struct pnode *root; @@ -285,7 +286,9 @@ _sysio_path_walk(struct pnode *parent, s assert(root); P_RELE(nd->nd_pno); nd->nd_pno = root; +#if 0 P_REF(nd->nd_pno); +#endif ino = nd->nd_pno->p_base->pb_ino; assert(ino); @@ -293,13 +296,11 @@ _sysio_path_walk(struct pnode *parent, s * Must send the intent-path again. */ path = nd->nd_path; - } - if (!err) { - P_RELE(pno); nd->nd_amcnt++; + /* * Must go back top and retry with this - * new pnode. + * new pnode as parent. */ continue; } @@ -426,7 +427,7 @@ _sysio_path_walk(struct pnode *parent, s * On error, we will want to drop our reference to the current * path node if at end. */ - if (err) { + if (err && nd->nd_pno) { P_RELE(nd->nd_pno); nd->nd_pno = NULL; } Index: rmdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rmdir.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- rmdir.c 26 Jan 2004 16:34:54 -0000 1.6 +++ rmdir.c 6 Feb 2004 20:07:30 -0000 1.7 @@ -84,11 +84,12 @@ out: errno = -err; err = -1; } + SYSIO_LEAVE; + return err; +} #ifdef REDSTORM #undef __rmdir sysio_sym_weak_alias(rmdir, __rmdir) #endif - return err; -} Index: statvfs64.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/statvfs64.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- statvfs64.c 26 Jan 2004 16:34:54 -0000 1.7 +++ statvfs64.c 6 Feb 2004 20:07:30 -0000 1.8 @@ -76,14 +76,14 @@ out: } SYSIO_LEAVE; + return err; +} + #ifdef REDSTORM #undef __statvfs64 sysio_sym_weak_alias(statvfs64, __statvfs64) #endif - return err; -} - int fstatvfs64(int fd, struct statvfs64 *buf) { Index: symlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/symlink.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- symlink.c 26 Jan 2004 16:34:54 -0000 1.5 +++ symlink.c 6 Feb 2004 20:07:30 -0000 1.6 @@ -84,10 +84,10 @@ out: err = -1; } SYSIO_LEAVE; + return err; +} #ifdef REDSTORM #undef __symlink sysio_sym_weak_alias(symlink, __symlink) #endif - return err; -} Index: truncate.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/truncate.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- truncate.c 21 Jan 2004 14:44:53 -0000 1.6 +++ truncate.c 6 Feb 2004 20:07:30 -0000 1.7 @@ -64,6 +64,9 @@ do_truncate(struct pnode *pno, struct in struct intnl_stat stbuf; unsigned mask; + if (length < 0) + return -EINVAL; + if (!ino && pno->p_base->pb_ino) ino = pno->p_base->pb_ino; if (!ino) Index: unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/unlink.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- unlink.c 26 Jan 2004 16:34:54 -0000 1.7 +++ unlink.c 6 Feb 2004 20:07:30 -0000 1.8 @@ -85,10 +85,10 @@ out: err = -1; } SYSIO_LEAVE; + return err; +} #ifdef REDSTORM #undef __unlink sysio_sym_weak_alias(unlink, __unlink) #endif - return err; -} |
|
From: Lee W. <lw...@us...> - 2004-02-06 20:10:48
|
Update of /cvsroot/libsysio/libsysio/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29990/tests Modified Files: Makefile.am help.c sysio_stubs.c test_all.pl test_driver.c test_driver.h test_stats.pl Added Files: test_regions.c test_rw.pl Log Message: Merging strided-IO branch + Strided-IO infrastructure. Internals altered to move data base don multiple targeted regions in both the file address space and local memory. + Added [i]{read,write}x, calls to perform extent-based or strided-IO directly. + Many bug fixes + Many uocnfig fixes + --with-zero-sum-memory; A config option that causes the shutdown code to carefully release *all* memory acquired from the heap, by the library. Useful for debugging tasks such as leak detection. Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.17 retrieving revision 1.18 diff -u -w -b -B -p -r1.17 -r1.18 --- Makefile.am 21 Jan 2004 14:44:54 -0000 1.17 +++ Makefile.am 6 Feb 2004 20:07:30 -0000 1.18 @@ -1,5 +1,13 @@ + +if WITH_STDFD_DEV +STDFD_DEV_TEST = test_stdfd +else +STDFD_DEV_TEST = +endif + noinst_PROGRAMS = test_copy test_stats test_path test_mounts test_list \ - test_getcwd test_stdfd test_link test_unlink test_rename test_driver + test_getcwd $(STDFD_DEV_TEST) test_link test_unlink test_rename \ + test_regions test_driver CLEANFILES=drv_data.c @@ -7,7 +15,7 @@ if WITH_NATIVE_DRIVER NATIVE_DRIVER_NAME=native NATIVE_DRIVER_CFLAGS= -I$(top_srcdir)/drivers/native else -NATIVE_DRIVER_NAME=native +NATIVE_DRIVER_NAME= NATIVE_DRIVER_CFLAGS= endif @@ -15,7 +23,7 @@ if WITH_INCORE_DRIVER INCORE_DRIVER_NAME=incore INCORE_DRIVER_CFLAGS= -I$(top_srcdir)/drivers/incore else -INCORE_DRIVER_NAME=incore +INCORE_DRIVER_NAME= INCORE_DRIVER_CFLAGS= endif @@ -23,7 +31,7 @@ if WITH_STDFD_DEV STDFD_DEV_NAME=stdfd STDFD_DEV_CFLAGS= -I$(top_srcdir)/dev/stdfd else -STDFD_DEV_NAME=stdfd +STDFD_DEV_NAME= STDFD_DEV_CFLAGS= endif @@ -113,6 +121,11 @@ test_rename_CFLAGS=$(CFL) test_rename_LDADD=$(LIBS) test_rename_DEPENDENCIES=$(LIBS) +test_regions_SOURCES=test_regions.c $(CMNSRC) +test_regions_CFLAGS=$(CFL) +test_regions_LDADD=$(LIBS) +test_regions_DEPENDENCIES=$(LIBS) + test_driver_SOURCES=test_driver.c sysio_tests.c sysio_stubs.c help.c $(CMNSRC) test_driver_CFLAGS=$(CFL) test_driver_LDADD=$(LIBS) Index: help.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/help.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- help.c 14 Aug 2003 21:16:33 -0000 1.2 +++ help.c 6 Feb 2004 20:07:31 -0000 1.3 @@ -46,6 +46,12 @@ void usage_setdebug() fprintf(outfp, "setdebug [level]: Set debugging level to level\n"); } +void usage_setbuf() +{ + fprintf(outfp, "setbuf val size buf: fill size bytes of buf with byte val\n"); +} + + void usage_clear() { fprintf(outfp, "clear buf: zero out the buffer\n"); @@ -492,6 +498,53 @@ void usage_umount() fprintf(outfp, "umount [path] : Umount file at path. Returns 0 on success and -1 on failure\n"); } +void usage_init_iovec() +{ + fprintf(outfp, "init_iovec buf offset len num iov_buf: Init iovector. iov_uf points to an array of\n"); + fprintf(outfp, " iovecs, num is the number of the iovec, \n"); + fprintf(outfp, " buf is the buffer to be used, offset \n"); + fprintf(outfp, " specifies how far into the buffer the iovec\n"); + fprintf(outfp, " should point and len is the iov length\n"); +} + +void usage_init_xtvec() +{ + fprintf(outfp, "init_xtvec offset len num buf: Init xtvector. Buf points to an array of\n"); + fprintf(outfp, " xtvecs, num is the number of the xtvec, offset\n"); + fprintf(outfp, " is xtv_off and len is the iov lenghth\n"); + fprintf(outfp, " the iov length\n"); +} + +void usage_writex() +{ + fprintf(outfp, "writex fd iovs iov_cnt xtvs xtvcnt: Write iov_cnt iovecs out to file using\n"); + fprintf(outfp, " xtvcnt xtvecs\n"); +} + +void usage_iwritex() +{ + fprintf(outfp, "iwritex fd iovs iov_cnt xtvs xtvcnt: Write iov_cnt iovecs out to file using\n"); + fprintf(outfp, " xtvcnt xtvecs\n"); +} + +void usage_readx() +{ + fprintf(outfp, "readx fd iovs iov_cnt xtvs xtvcnt: Read iov_cnt iovecs out from file using\n"); + fprintf(outfp, " xtvcnt xtvecs\n"); +} + +void usage_ireadx() +{ + fprintf(outfp, "ireadx fd iovs iov_cnt xtvs xtvcnt: Read iov_cnt iovecs out from file using\n"); + fprintf(outfp, " xtvcnt xtvecs\n"); +} + + +void usage_checkbuf() +{ + fprintf(outfp, "checkbuf buf size val: Checks to see if val is in first size bytes of buf\n"); +} + void usage_exit() { } Index: sysio_stubs.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/sysio_stubs.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- sysio_stubs.c 21 Jan 2004 15:38:45 -0000 1.7 +++ sysio_stubs.c 6 Feb 2004 20:07:31 -0000 1.8 @@ -13,6 +13,7 @@ #include "test_driver.h" #include "sysio.h" +#include "xtio.h" /* * ################################################ @@ -423,6 +424,43 @@ int get_endian(int argc, char **argv) return SUCCESS; } +int do_setbuf(int argc, char **argv) +{ + int val, size, index; + void *buf; + + if (argc != 3) { + DBG(2, fprintf(outfp, "Need val, size, and buffer for setbuf\n")); + return INVALID_ARGS; + } + val = get_obj(argv[0]); + if (val < 0) { + DBG(2, fprintf(outfp, "Unable to understand val of %s\n", + argv[0])); + return INVALID_VAR; + } + + size = get_obj(argv[1]); + if( size <=0 ) { + DBG(2, fprintf(outfp, "Size of %s is invalid\n", argv[1])); + return INVALID_VAR; + } + + index = get_obj(argv[2]); + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find buffer assocated with %s\n", + argv[2])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + memset(buf, val, size); + + return SUCCESS; +} + + int get_sizeof(int argc, char **argv) { char *type; @@ -450,6 +488,8 @@ int get_sizeof(int argc, char **argv) size = sizeof(struct statvfs); else if (!strcmp(type, "iovec")) size = sizeof(struct iovec); + else if (!strcmp(type, "xtvec")) + size = sizeof(struct xtvec); else return INVALID_ARGS; @@ -2229,3 +2269,416 @@ int test_do_umount(int argc, char **argv return SUCCESS; } +int test_do_init_iovec(int argc, char **argv) +{ + int iov_index, buf_index; + int offset, len, pos; + struct iovec *iov_ptr; + char *base_ptr; + + if (argc != 5) { + DBG(2, fprintf(outfp, "Need buffer, offset, len, array pos, and iov pointer\n")); + return INVALID_ARGS; + } + + if ((buf_index = get_obj(argv[0])) < 0) { + DBG(2, fprintf(outfp, "Unable to find object %s\n", argv[0])); + return INVALID_VAR; + } + base_ptr = buflist[buf_index]->buf; + + if ((offset = get_obj(argv[1])) < 0) { + DBG(2, fprintf(outfp, "Cannot understand offset of %s\n", argv[1])); + return INVALID_VAR; + } + + if ((len = get_obj(argv[2])) < 0) { + DBG(2, fprintf(outfp, "Cannot understand len of %s\n", argv[2])); + return INVALID_VAR; + } + + if ((pos = get_obj(argv[3])) < 0) { + DBG(2, fprintf(outfp, "Cannot understand array pos of %s\n", argv[3])); + return INVALID_VAR; + } + + if ((iov_index = get_obj(argv[4])) < 0) { + DBG(2, fprintf(outfp, "Unable to find object %s\n", argv[4])); + return INVALID_VAR; + } + iov_ptr = (struct iovec *)(buflist[iov_index]->buf); + + iov_ptr[pos].iov_len = len; + iov_ptr[pos].iov_base = (void *)(base_ptr + (char)offset); + + DBG(3, fprintf(outfp, "iov_ptr.len is %d and base is %p\n", + iov_ptr[pos].iov_len, iov_ptr[pos].iov_base)); + + my_errno = errno; + last_type = PTR; + + return SUCCESS; +} + + +int test_do_init_xtvec(int argc, char **argv) +{ + int xtv_index; + int offset, len, pos; + struct xtvec *xtv_ptr; + + if (argc != 4) { + DBG(2, fprintf(outfp, "Need offset, len, array pos, and xtv pointer\n")); + return INVALID_ARGS; + } + + if ((offset = get_obj(argv[0])) < 0) { + DBG(2, fprintf(outfp, "Cannot understand offset of %s\n", argv[0])); + return INVALID_VAR; + } + + if ((len = get_obj(argv[1])) < 0) { + DBG(2, fprintf(outfp, "Cannot understand len of %s\n", argv[1])); + return INVALID_VAR; + } + + if ((pos = get_obj(argv[2])) < 0) { + DBG(2, fprintf(outfp, "Cannot understand array pos of %s\n", argv[2])); + return INVALID_VAR; + } + + if ((xtv_index = get_obj(argv[3])) < 0) { + DBG(2, fprintf(outfp, "Unable to find object %s\n", argv[3])); + return INVALID_VAR; + } + xtv_ptr = (struct xtvec *)(buflist[xtv_index]->buf); + + xtv_ptr[pos].xtv_len = len; + xtv_ptr[pos].xtv_off = offset; + + DBG(3, fprintf(outfp, "xtv_ptr.len is %d and offset is %d\n", + xtv_ptr[pos].xtv_len, (int)xtv_ptr[pos].xtv_off)); + + my_errno = errno; + last_type = PTR; + + return SUCCESS; +} + +int test_do_writex(int argc, char **argv) +{ + int fd, iov_count, xtv_count,index; + char *buf; + struct iovec *iov; + struct xtvec *xtv; + + if (argc != 5) { + DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to writex\n", argc)); + return INVALID_ARGS; + } + + fd = get_obj(argv[0]); + + if (fd < 0) { + DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); + return INVALID_ARGS; + } + + index = get_obj(argv[1]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + iov = (struct iovec *)buf; + iov_count = get_obj(argv[2]); + + if (iov_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); + return INVALID_ARGS; + } + + index = get_obj(argv[3]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + xtv = (struct xtvec *)buf; + xtv_count = get_obj(argv[4]); + + if (xtv_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4])); + return INVALID_ARGS; + } + + DBG(3, fprintf(outfp, "writex(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n", + fd, iov, iov_count, xtv, xtv_count)); + + last_ret_val = writex(fd, iov, iov_count, xtv, xtv_count); + if (last_ret_val < 0) + my_perror("writex"); + my_errno = errno; + last_type = SINT; + + return SUCCESS; +} + + +int test_do_iwritex(int argc, char **argv) +{ + int fd, iov_count, xtv_count,index; + char *buf; + struct iovec *iov; + struct xtvec *xtv; + + if (argc != 5) { + DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to iwritex\n", argc)); + return INVALID_ARGS; + } + + fd = get_obj(argv[0]); + + if (fd < 0) { + DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); + return INVALID_ARGS; + } + + index = get_obj(argv[1]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + iov = (struct iovec *)buf; + iov_count = get_obj(argv[2]); + + if (iov_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); + return INVALID_ARGS; + } + + index = get_obj(argv[3]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + xtv = (struct xtvec *)buf; + xtv_count = get_obj(argv[4]); + + if (xtv_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4])); + return INVALID_ARGS; + } + + DBG(3, fprintf(outfp, "iwritex(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n", + fd, iov, iov_count, xtv, xtv_count)); + + last_ret_val = (int) iwritex(fd, iov, iov_count, xtv, xtv_count); + if (last_ret_val < 0) + my_perror("iwritex"); + my_errno = errno; + last_type = SINT; + + return SUCCESS; +} + + +int test_do_readx(int argc, char **argv) +{ + int fd, iov_count, xtv_count,index; + char *buf; + struct iovec *iov; + struct xtvec *xtv; + + if (argc != 5) { + DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to readx\n", argc)); + return INVALID_ARGS; + } + + fd = get_obj(argv[0]); + + if (fd < 0) { + DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); + return INVALID_ARGS; + } + + index = get_obj(argv[1]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + iov = (struct iovec *)buf; + iov_count = get_obj(argv[2]); + + if (iov_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); + return INVALID_ARGS; + } + + index = get_obj(argv[3]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + xtv = (struct xtvec *)buf; + xtv_count = get_obj(argv[4]); + + if (xtv_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4])); + return INVALID_ARGS; + } + + DBG(3, fprintf(outfp, "readx(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n", + fd, iov, iov_count, xtv, xtv_count)); + + last_ret_val = readx(fd, iov, iov_count, xtv, xtv_count); + if (last_ret_val < 0) + my_perror("readx"); + my_errno = errno; + last_type = SINT; + + return SUCCESS; +} + + +int test_do_ireadx(int argc, char **argv) +{ + int fd, iov_count, xtv_count,index; + char *buf; + struct iovec *iov; + struct xtvec *xtv; + + if (argc != 5) { + DBG(2, fprintf(outfp, "Invalid number of arguments (%d) to ireadx\n", argc)); + return INVALID_ARGS; + } + + fd = get_obj(argv[0]); + + if (fd < 0) { + DBG(2, fprintf(outfp, "Unable to find file described by %s\n", argv[0])); + return INVALID_ARGS; + } + + index = get_obj(argv[1]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find buffer described by %s\n", argv[1])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + iov = (struct iovec *)buf; + iov_count = get_obj(argv[2]); + + if (iov_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); + return INVALID_ARGS; + } + + index = get_obj(argv[3]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find xtvs described by %s\n", argv[3])); + return INVALID_VAR; + } + + buf = buflist[index]->buf; + + xtv = (struct xtvec *)buf; + xtv_count = get_obj(argv[4]); + + if (xtv_count < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[4])); + return INVALID_ARGS; + } + + DBG(3, fprintf(outfp, "ireadx(fd: %d, iov: %p iov_cnt: %d, xtv: %p, xtv_cnt: %d\n", + fd, iov, iov_count, xtv, xtv_count)); + + last_ret_val = (int) ireadx(fd, iov, iov_count, xtv, xtv_count); + if (last_ret_val < 0) + my_perror("ireadx"); + my_errno = errno; + last_type = SINT; + + return SUCCESS; +} + + +int do_checkbuf(int argc, char **argv) +{ + int size, val, index, i; + int *ref_buf, *buf; + + if (argc != 3) { + DBG(2, fprintf(outfp, "Need buffer and val for checkbuf\n")); + return INVALID_ARGS; + } + + index = get_obj(argv[0]); + + if (index < 0) { + DBG(2, fprintf(outfp, "Unable to find buf described by %s\n", argv[0])); + return INVALID_VAR; + } + + buf = (int *)buflist[index]->buf; + + val = get_obj(argv[1]); + + if (val < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[1])); + return INVALID_ARGS; + } + + size = get_obj(argv[2]); + + if (size < 0) { + DBG(2, fprintf(outfp, "Unable to understand %s\n", argv[2])); + return INVALID_ARGS; + } + + ref_buf = (int *)malloc(size); + memset((void *)ref_buf, val, size); + + last_ret_val =0; + for (i=0; i < size/sizeof(int); i++) { + if (buf[i] != ref_buf[i]) { + DBG(2, fprintf(stderr, "At pos %d I found a 0x%08x instead of 0x%08x\n", + i, buf[i], ref_buf[i])); + fprintf(stderr, "At pos %d I found a 0x%08x instead of 0x%08x\n", + i, buf[i], ref_buf[i]); + last_ret_val = 1; + break; + } + } + + my_errno = errno; + last_type = SINT; + + return SUCCESS; +} Index: test_all.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_all.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- test_all.pl 21 Jan 2004 15:13:56 -0000 1.7 +++ test_all.pl 6 Feb 2004 20:07:31 -0000 1.8 @@ -161,6 +161,17 @@ if ($res ne "Symlink test successful") { print "test_symlink finished successfully\n"; } +# Test r/w calls +$res = `perl $testdir/test_rw.pl $alpha_arg $cwd/tmp_dir/tmp.foo`; +chop($res); +if ($res ne "rw test successful") { + print "rw test failed with message: $res\n"; + $failures++; +} else { + $success++; + print "rw test finished successfully\n"; +} + print "$failures tests failed and $success tests succeeded\n"; # cleanup Index: test_driver.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_driver.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- test_driver.c 21 Jan 2004 15:38:45 -0000 1.5 +++ test_driver.c 6 Feb 2004 20:07:31 -0000 1.6 @@ -40,6 +40,7 @@ struct queue_t { struct cmd_t cmd_list[] = { {"alloc", get_buffer, usage_get_buffer}, {"chdir", test_do_chdir, usage_chdir}, + {"checkbuf", do_checkbuf, usage_checkbuf}, {"chmod", test_do_chmod, usage_chmod}, {"chown", test_do_chown, usage_chown}, {"clear", test_do_clear, usage_clear}, @@ -62,6 +63,8 @@ struct cmd_t cmd_list[] = { {"getcwd", test_do_getcwd, usage_getcwd}, {"getdirentries", test_do_getdirentries, usage_getdirentries}, {"init", test_do_init, usage_init}, + {"init_iovec", test_do_init_iovec, usage_init_iovec}, + {"init_xtvec", test_do_init_xtvec, usage_init_xtvec}, {"ioctl", test_do_ioctl, usage_ioctl}, {"iodone", test_do_iodone, usage_iodone}, {"iowait", test_do_iowait, usage_iowait}, @@ -71,8 +74,10 @@ struct cmd_t cmd_list[] = { {"ipwritev", test_do_ipwritev, usage_ipwritev}, {"iread", test_do_iread, usage_iread}, {"ireadv", test_do_ireadv, usage_ireadv}, + {"ireadx", test_do_ireadx, usage_ireadx}, {"iwrite", test_do_iwrite, usage_iwrite}, {"iwritev", test_do_iwritev, usage_iwritev}, + {"iwritex", test_do_iwritex, usage_iwritex}, {"list", test_do_list, usage_list}, {"lseek", test_do_lseek, usage_lseek}, {"lstat", test_do_lstat, usage_lstat}, @@ -89,7 +94,9 @@ struct cmd_t cmd_list[] = { {"quit", test_do_exit, usage_exit}, {"read", test_do_read, usage_read}, {"readv", test_do_readv, usage_readv}, + {"readx", test_do_readx, usage_readx}, {"rmdir", test_do_rmdir, usage_rmdir}, + {"setbuf", do_setbuf, usage_setbuf}, {"sizeof", get_sizeof, usage_sizeof}, /* {"setoutput", test_do_setoutput, usage_setoutput}, */ {"stat", test_do_stat, usage_stat}, @@ -101,6 +108,7 @@ struct cmd_t cmd_list[] = { {"unlink", test_do_unlink, usage_unlink}, {"write", test_do_write, usage_write}, {"writev", test_do_writev, usage_writev}, + {"writex", test_do_writex, usage_writex}, {NULL, NULL, NULL} }; @@ -310,7 +318,7 @@ void store_result(char *var_name, int re } else new_map = &map[index]; - new_map->map.name = malloc(sizeof(var_name) + 1); + new_map->map.name = malloc(strlen(var_name) + 1); strcpy(new_map->map.name, var_name); new_map->map.obj = result; new_map->map.type = last_type; @@ -415,7 +423,6 @@ int execute_cmd(char *cmd, char **args, if (!strcmp(cmd, "help")) { if (arg_count > 0) { - while(cmd_list[i].cmd != NULL) { if (!strcmp(cmd_list[i].cmd, args[0])) { (cmd_list[i].usage)(); @@ -430,8 +437,9 @@ int execute_cmd(char *cmd, char **args, return -1; } while(cmd_list[i].cmd != NULL) { - if (!strcmp(cmd_list[i].cmd, cmd)) + if (!strcmp(cmd_list[i].cmd, cmd)) { return (cmd_list[i].func)(arg_count, args); + } i++; } DBG(2, fprintf(outfp, "Command %s was invalid\n", cmd)); @@ -729,11 +737,6 @@ char *getline(char *prompt) if ((do_prompt) && (infp == stdin)) printf(prompt); - /* - fprintf(stderr, "getline: errno %x\n", errno); - fseek(infp, 0, SEEK_CUR); - fprintf(stderr, "getline: errno %x\n", errno); - */ do { /* If we get an end of file, just wait */ if (feof(infp)) { @@ -817,6 +820,124 @@ void init_map() } } +int getquotedlen(char *str) +{ + int i; + + if (str[0] != '"' && str[0] != '\'') + return -1; + + for (i=1; str[i] != '\0' && str[i] != '"' && str[i] != '\''; i++); + + return i; +} + +int perform_op(int num1, int num2, char op) +{ + switch(op) { + + case '+': + return num1 + num2; + break; + + case '*': + return num1 * num2; + break; + + case '/': + return num1 / num2; + break; + + case '-': + return num1 - num2; + break; + + case '%': + return num1%num2; + break; + + default: + return num1; + } + return 0; +} + +int get_constant_val(char **str_ptr, int type) +{ + struct buf_t *buf; + char *buf_ptr; + char *str = *str_ptr; + char ch; + int i, j, num1, num2, size; + + printf("Getting constant val from %s\n", str); + switch(type) { + case 1: + size = getquotedlen(str); + buf = (struct buf_t *)malloc(sizeof(struct buf_t)); + buf->buf = alloc_buff32(size, 8); + buf->len = size; + buf_ptr = buf->buf; + buflist[next] = buf; + j=0; + for (i=1; i < size; i++) { + buf_ptr[j] = str[i]; + j++; + } + buf_ptr[j] = '\0'; + + DBG(3, fprintf(outfp, "Your buffer (%p) (%p) is at index %d\n", + buf, buf->buf, next)); + next++; + + last_type = PTR; + last_ret_val = next-1; + return last_ret_val; + break; + + case 2: + if (str[0] == '$') { + num1 = get_obj(str); + } else { + num1 = atoi(str); + } + str = str_ptr[1]; + ch = str_ptr[1][0]; + if ((ch == '+') || (ch == '/') || (ch == '*') || + (ch == '-') || (ch == '%')) { + if (str_ptr[2][0] == '$') + num2 = get_obj(str_ptr[2]); + else + num2 = atoi(str_ptr[2]); + num1 = perform_op(num1, num2, ch); + } + + last_type = UINT; + last_ret_val = num1; + + break; + + default: + DBG(2, fprintf(outfp, "Can't understand type of %d\n", type)); + return INVALID_ARGS; + } + + return last_ret_val; +} + +int is_constant(char *str) +{ + if ((str[0] == '"') || (str[0] == '\'')) + return 1; + + + if ( (str[0] == '$') || + ( ((int)str[0] > 47) && ((int)str[0] < 57) ) ) + return 2; + + return 0; +} + int main(int argc, char *argv[]) { int count, err, i, orig_count; @@ -902,11 +1023,18 @@ int main(int argc, char *argv[]) count--; } i++; + if ((err=is_constant(cmd[i])) != 0) { + store_result((char *)(&cmd[0][1]), get_constant_val(&cmd[i], err)); + tree = NULL; + err = 0; + } else { + tree = build_tree(&cmd[i], &count, 0); if (tree != NULL) { err = run_cmd(tree); store_result((char *)(&cmd[0][1]), last_ret_val); } + } } else { tree = build_tree(cmd, &count, 0); Index: test_driver.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_driver.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- test_driver.h 10 Oct 2003 18:50:31 -0000 1.3 +++ test_driver.h 6 Feb 2004 20:07:31 -0000 1.4 @@ -145,10 +145,12 @@ extern int test_do_list(int argc, char * extern int test_do_init(int argc, char **args); extern int get_endian(int argc, char **args); extern int get_sizeof(int argc, char **args); +extern int do_setbuf(int argc, char **argv); extern int test_do_exit(int argc, char **args); extern int get_buffer(int argc, char **args); extern int free_buffer(int argc, char **args); extern int test_do_chdir(int argc, char **args); +extern int do_checkbuf(int argc, char **argv); extern int test_do_chmod(int argc, char **args); extern int test_do_chown(int argc, char **args); extern int test_do_open(int argc, char **args); @@ -161,6 +163,8 @@ extern int test_do_fstat(int argc, char extern int test_do_fsync(int argc, char **argv); extern int test_do_ftruncate(int argc, char **argv); extern int test_do_getcwd(int argc, char **argv); +extern int test_do_init_iovec(int argc, char **argv); +extern int test_do_init_xtvec(int argc, char **argv); extern int test_do_lseek(int argc, char **argv); extern int test_do_lstat(int argc, char **argv); extern int test_do_getdirentries(int argc, char **argv); @@ -183,8 +187,10 @@ extern int test_do_ipread(int argc, char extern int test_do_preadv(int argc, char **argv); extern int test_do_pread(int argc, char **argv); extern int test_do_ireadv(int argc, char **argv); +extern int test_do_ireadx(int argc, char **argv); extern int test_do_iread(int argc, char **argv); extern int test_do_readv(int argc, char **argv); +extern int test_do_readx(int argc, char **argv); extern int test_do_read(int argc, char **argv); extern int test_do_ipwritev(int argc, char **argv); extern int test_do_ipwrite(int argc, char **argv); @@ -192,7 +198,9 @@ extern int test_do_pwritev(int argc, cha extern int test_do_pwrite(int argc, char **argv); extern int test_do_iwritev(int argc, char **argv); extern int test_do_iwrite(int argc, char **argv); +extern int test_do_iwritex(int argc, char **argv); extern int test_do_writev(int argc, char **argv); +extern int test_do_writex(int argc, char **argv); extern int test_do_write(int argc, char **argv); extern int test_do_mknod(int argc, char **argv); extern int test_do_umount(int argc, char **argv); @@ -246,12 +254,16 @@ extern void usage_fstat(); extern void usage_fsync(); extern void usage_ftruncate(); extern void usage_getcwd(); +extern void usage_init_iovec(); +extern void usage_init_xtvec(); extern void usage_lseek(); extern void usage_lstat(); extern void usage_getdirentries(); extern void usage_mkdir(); +extern void usage_checkbuf(); extern void usage_cmpbufs(); extern void usage_creat(); +extern void usage_setbuf(); extern void usage_stat(); extern void usage_statvfs(); extern void usage_fstatvfs(); @@ -270,7 +282,9 @@ extern void usage_preadv(); extern void usage_pread(); extern void usage_ireadv(); extern void usage_iread(); +extern void usage_ireadx(); extern void usage_readv(); +extern void usage_readx(); extern void usage_read(); extern void usage_ipwritev(); extern void usage_ipwrite(); @@ -278,8 +292,10 @@ extern void usage_pwritev(); extern void usage_pwrite(); extern void usage_iwritev(); extern void usage_iwrite(); +extern void usage_iwritex(); extern void usage_writev(); extern void usage_write(); +extern void usage_writex(); extern void usage_mknod(); extern void usage_umount(); extern void usage_exit(); Index: test_stats.pl =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_stats.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- test_stats.pl 21 Jan 2004 15:13:56 -0000 1.6 +++ test_stats.pl 6 Feb 2004 20:07:31 -0000 1.7 @@ -172,6 +172,7 @@ sub process_cmd verify_stat($cmdfh, $outfh, "lstat", $is_alpha, @stats); } + if (0) { # Now do statvfs functions $cmdstr = '$buf2 = ALLOC ( $size2 = CALL sizeof statvfs )'."\n"; helper::send_cmd($cmdfh, $outfh, "alloc", $cmdstr); @@ -223,6 +224,7 @@ sub process_cmd helper::print_and_exit($cmdfh, $outfh, 1, $str); } } + } helper::print_and_exit($cmdfh, $outfh, 0, "stat test successful\n"); } |