libsysio-commit Mailing List for libsysio (Page 2)
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...> - 2009-08-31 21:38:42
|
Update of /cvsroot/libsysio/libsysio/include In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27009/include Modified Files: inode.h Log Message: The children of a directory are now maintained as a tree, instead of as a list. Along with this, the nasty resursive implementation of pb_prune is now a de-recursed implementation. This method is 1 to 1.5 percent slower than the previous list implementation in my tests. Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.60 retrieving revision 1.61 diff -u -w -b -B -p -r1.60 -r1.61 --- inode.h 17 Aug 2009 22:56:45 -0000 1.60 +++ inode.h 31 Aug 2009 21:38:29 -0000 1.61 @@ -318,8 +318,8 @@ struct pnode_base { struct pnode_base *pbk_parent; /* parent */ } pb_key; struct inode *pb_ino; /* inode */ - LIST_HEAD(, pnode_base) pb_children; /* children if a dir */ - LIST_ENTRY(pnode_base) pb_sibs; /* links to siblings */ + struct tree_node *pb_children; /* children if a dir */ + struct tree_node pb_sib; /* sibling tree rec */ LIST_HEAD(, pnode) pb_aliases; /* aliases */ #ifdef I_ASSOCIATIONS LIST_ENTRY(pnode_base) pb_alinks; /* names to same ino */ @@ -342,7 +342,9 @@ struct pnode_base { (_pb)->pb_key.pbk_name = *(_name); \ (_pb)->pb_key.pbk_parent = (_parent); \ (_pb)->pb_ino = NULL; \ - LIST_INIT(&(_pb)->pb_children); \ + (_pb)->pb_children = NULL; \ + (_pb)->pb_sib.tn_key = (_pb); \ + (_pb)->pb_sib.tn_left = (_pb)->pb_sib.tn_right = NULL; \ LIST_INIT(&(_pb)->pb_aliases); \ } while (0) |
From: Lee W. <lw...@us...> - 2009-08-31 21:38:42
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27009/src Modified Files: inode.c mount.c Log Message: The children of a directory are now maintained as a tree, instead of as a list. Along with this, the nasty resursive implementation of pb_prune is now a de-recursed implementation. This method is 1 to 1.5 percent slower than the previous list implementation in my tests. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.57 retrieving revision 1.58 diff -u -w -b -B -p -r1.57 -r1.58 --- inode.c 17 Aug 2009 23:00:20 -0000 1.57 +++ inode.c 31 Aug 2009 21:38:29 -0000 1.58 @@ -347,7 +347,7 @@ p_reclaim_debug() while ((pb = nxt)) { nxt = pb->pb_links.tqe_next; npb++; - if (!pb->pb_children.lh_first) + if (!pb->pb_children) npbleaves++; else if (!pb->pb_aliases.lh_first) npborphans++; @@ -386,7 +386,7 @@ p_reclaim(unsigned limit) P_UNLOCK(pno); continue; } - if (pno->p_base->pb_children.lh_first) { + if (pno->p_base->pb_children) { /* * Must not dismiss from interior nodes. There * might be aliases on the child pointing @@ -399,7 +399,7 @@ p_reclaim(unsigned limit) PB_LOCK(pno->p_base); pb = pno->p_base; _sysio_p_gone(pno); - if (!(pb->pb_children.lh_first || pb->pb_aliases.lh_first)) + if (!(pb->pb_children || pb->pb_aliases.lh_first)) _sysio_pb_gone(pb); else PB_UNLOCK(pb); @@ -486,6 +486,22 @@ ncache_lookup(struct pnode_base *pb, str } /* + * Compare two addresses. + */ +static int +compar_addr(const void *a, const void *b) +{ + ptrdiff_t diff; + + diff = (char *)a - (char *)b; + if (diff < 0) + return -1; + if (diff > 0) + return 1; + return 0; +} + +/* * Allocate and initialize a new base path node. */ struct pnode_base * @@ -525,7 +541,12 @@ _sysio_pb_new(struct qstr *name, struct TAILQ_REMOVE(&pb_leaf_nodes, parent, pb_links); } #endif - LIST_INSERT_HEAD(&parent->pb_children, pb, pb_sibs); + if (_sysio_tree_search(&pb->pb_sib, + &pb->pb_key.pbk_parent->pb_children, + (int (*)(const void *, + const void *))compar_addr) != + &pb->pb_sib) + abort(); /* can't happen */ } if (pb->pb_key.pbk_name.len) { char *cp; @@ -565,18 +586,23 @@ _sysio_pb_gone(struct pnode_base *pb) n_names--; assert(!pb->pb_aliases.lh_first); - assert(!pb->pb_children.lh_first); + assert(!pb->pb_children); if (pb->pb_key.pbk_name.len) ncache_delete(pb); if (pb->pb_key.pbk_parent) { - LIST_REMOVE(pb, pb_sibs); + if (_sysio_tree_delete(pb, + &pb->pb_key.pbk_parent->pb_children, + (int (*)(const void *, + const void *))compar_addr) != + &pb->pb_sib) + abort(); /* can't happen */ #if defined(PB_DEBUG) /* * If we just removed the last child, put the parent on * the list of leaves. */ - if (!pb->pb_key.pbk_parent->pb_children.lh_first) { + if (!pb->pb_key.pbk_parent->pb_children) { TAILQ_INSERT_TAIL(&pb_leaf_nodes, pb->pb_key.pbk_parent, pb_links); @@ -1056,6 +1082,7 @@ p_remove_aliases(struct mount *mnt, stru return count; } +#if 0 static size_t pb_prune(struct mount *mnt, struct pnode_base *pb) { @@ -1080,6 +1108,70 @@ pb_prune(struct mount *mnt, struct pnode PB_UNLOCK(pb); return count; } +#endif + +static size_t +pb_prune(struct mount *mnt, struct pnode_base *pb) +{ + size_t count; + struct pnode_base *stop, *parent; + struct tree_node *tn_next; + + count = 0; + stop = parent = pb->pb_key.pbk_parent; + do { + /* + * Just descended into this node. + */ + while (pb->pb_children) { + _sysio_splay(NULL, + &pb->pb_children, + (int (*)(const void *, + const void *))compar_addr); + parent = pb; + pb = + TREE_ENTRY(parent->pb_children, + pnode_base, + pb_sib); + } + /* + * No children. + */ + for (;;) { + count += p_remove_aliases(mnt, pb); + tn_next = pb->pb_sib.tn_right; + if (tn_next) { + _sysio_splay(NULL, + &pb->pb_sib.tn_right, + (int (*)(const void *, + const void *))compar_addr); + tn_next = pb->pb_sib.tn_right; + } + if (!(pb->pb_children || pb->pb_aliases.lh_first)) { + PB_LOCK(pb); + _sysio_pb_gone(pb); + } + if (!tn_next) { + /* + * Ascend. + */ + pb = parent; + if (pb == stop) + break; + parent = pb->pb_key.pbk_parent; + continue; + } + pb = TREE_ENTRY(tn_next, pnode_base, pb_sib); + _sysio_splay(pb, + &parent->pb_children, + (int (*)(const void *, + const void *))compar_addr); + break; + } + } while (pb != stop); + + return count; +} /* * Prune idle nodes from the passed sub-tree, including the root. Index: mount.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -w -b -B -p -r1.32 -r1.33 --- mount.c 6 Dec 2008 21:56:25 -0000 1.32 +++ mount.c 31 Aug 2009 21:38:29 -0000 1.33 @@ -282,7 +282,7 @@ _sysio_do_unmount(struct mount *mnt) rootpb = root->p_base; PB_LOCK(rootpb); _sysio_p_gone(root); - if (!(rootpb->pb_aliases.lh_first || rootpb->pb_children.lh_first)) + if (!(rootpb->pb_aliases.lh_first || rootpb->pb_children)) _sysio_pb_gone(rootpb); else PB_UNLOCK(rootpb); |
From: Lee W. <lw...@us...> - 2009-08-31 21:35:57
|
Update of /cvsroot/libsysio/libsysio/include In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv26922/include Modified Files: tree.h Log Message: The splay routine is now public, called _sysio_splay. Note, it's still a really bad idea to depend on the other tree routines maintaining their trees as a splay-tree. Index: tree.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/tree.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- tree.h 17 Apr 2009 14:54:35 -0000 1.3 +++ tree.h 31 Aug 2009 21:35:44 -0000 1.4 @@ -73,4 +73,7 @@ extern int _sysio_tree_enumerate(const s int (*in)(const struct tree_node *, void *), int (*post)(const struct tree_node *, void *), void *); +extern int _sysio_splay(const void *key, + struct tree_node **rootp, + int (*compar)(const void *, const void *)); #endif /* !defined(_TREE_H) */ |
From: Lee W. <lw...@us...> - 2009-08-31 21:35:56
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv26922/src Modified Files: tree.c Log Message: The splay routine is now public, called _sysio_splay. Note, it's still a really bad idea to depend on the other tree routines maintaining their trees as a splay-tree. Index: tree.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/tree.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- tree.c 17 Apr 2009 14:54:35 -0000 1.3 +++ tree.c 31 Aug 2009 21:35:45 -0000 1.4 @@ -52,8 +52,8 @@ * Returns the value from the last compare; The one that brought, or left, * the root node at return. */ -static int -splay(const void *key, +int +_sysio_splay(const void *key, struct tree_node **rootp, int (*compar)(const void *, const void *)) { @@ -120,7 +120,7 @@ _sysio_tree_search(struct tree_node *tn, if (!*rootp) { tn->tn_left = tn->tn_right = NULL; } else { - i = splay(tn->tn_key, rootp, compar); + i = _sysio_splay(tn->tn_key, rootp, compar); if (i < 0) { tn->tn_left = (*rootp)->tn_left; tn->tn_right = *rootp; @@ -147,7 +147,7 @@ _sysio_tree_find(const void *key, if (!*rootp) return NULL; - return splay(key, rootp, compar) == 0 ? *rootp : NULL; + return _sysio_splay(key, rootp, compar) == 0 ? *rootp : NULL; } /* @@ -169,7 +169,7 @@ _sysio_tree_delete(const void *key, if (!(*rootp)->tn_left) *rootp = (*rootp)->tn_right; else { - splay((*rootp)->tn_key, &(*rootp)->tn_left, compar); + _sysio_splay((*rootp)->tn_key, &(*rootp)->tn_left, compar); (*rootp)->tn_left->tn_right = (*rootp)->tn_right; *rootp = (*rootp)->tn_left; } |
From: Lee W. <lw...@us...> - 2009-08-20 01:06:13
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10820/src Modified Files: namei.c Log Message: The new logic in pathwalk introduced an error; Reported by Jason Cope at ANL. If a direcotry to be traversed did not grant X permission then the error was caught, the done flag set, and nd->nd_pno is left as NULL. The next thing that was done was to check that the parent mount was same as nd->nd_pno mount. Oops, nd->nd_pno was left set to NULL, resulting in the train wreck we know so well as SIGSEGV. In this change, when handling the error we now set the done flag, do the ENOENT check and if that fails, we break. No need to check if we crossed into a new mount point. Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -w -b -B -p -r1.35 -r1.36 --- namei.c 4 Aug 2009 14:19:00 -0000 1.35 +++ namei.c 20 Aug 2009 01:06:01 -0000 1.36 @@ -497,11 +497,13 @@ _sysio_path_walk(struct pnode *parent, s : NULL, (path && next.len) ? path : NULL); if (err) { + done = 1; if (err == -ENOENT && !next.len && (nd->nd_flags & ND_NEGOK)) err = 0; - done = 1; + else + break; } path = NULL; /* Stop that! */ /* |
From: Lee W. <lw...@us...> - 2009-08-17 23:37:21
|
Update of /cvsroot/libsysio/libsysio/tests In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3372 Modified Files: Makefile.am module.mk Log Message: Modified to include the new fhi tests. Index: Makefile.am =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/Makefile.am,v retrieving revision 1.35 retrieving revision 1.36 diff -u -w -b -B -p -r1.35 -r1.36 --- Makefile.am 4 Feb 2009 20:07:23 -0000 1.35 +++ Makefile.am 17 Aug 2009 23:37:08 -0000 1.36 @@ -5,7 +5,9 @@ STATVFS_PROG= endif if WITH_FILE_HANDLE_INTERFACE -FHI_PROG=test_fhipath +FHI_PROG=test_fhichmod test_fhicreate test_fhilink test_fhilist test_fhimkdir \ + test_fhipath test_fhirename test_fhirmdir \ + test_fhisymlink test_fhitrunc test_fhiunlink else FHI_PROG= endif @@ -109,10 +111,52 @@ test_statvfs_SOURCES=test_statvfs.c $(CM test_statvfs_CFLAGS=$(CFL) test_statvfs_DEPENDENCIES=$(LIBS) -test_fhipath_SOURCES=test_fhipath.c $(CMNSRC) +CMNFHISRC=fhi_support.c + +test_fhichmod_SOURCES=test_fhichmod.c $(CMNFHISRC) $(CMNSRC) +test_fhichmod_CFLAGS=$(CFL) +test_fhichmod_DEPENDENCIES=$(LIBS) + +test_fhicreate_SOURCES=test_fhicreate.c $(CMNFHISRC) $(CMNSRC) +test_fhicreate_CFLAGS=$(CFL) +test_fhicreate_DEPENDENCIES=$(LIBS) + +test_fhilink_SOURCES=test_fhilink.c $(CMNFHISRC) $(CMNSRC) +test_fhilink_CFLAGS=$(CFL) +test_fhilink_DEPENDENCIES=$(LIBS) + +test_fhilist_SOURCES=test_fhilist.c $(CMNFHISRC) $(CMNSRC) +test_fhilist_CFLAGS=$(CFL) +test_fhilist_DEPENDENCIES=$(LIBS) + +test_fhimkdir_SOURCES=test_fhimkdir.c $(CMNFHISRC) $(CMNSRC) +test_fhimkdir_CFLAGS=$(CFL) +test_fhimkdir_DEPENDENCIES=$(LIBS) + +test_fhipath_SOURCES=test_fhipath.c $(CMNFHISRC) $(CMNSRC) test_fhipath_CFLAGS=$(CFL) test_fhipath_DEPENDENCIES=$(LIBS) +test_fhirename_SOURCES=test_fhirename.c $(CMNFHISRC) $(CMNSRC) +test_fhirename_CFLAGS=$(CFL) +test_fhirename_DEPENDENCIES=$(LIBS) + +test_fhirmdir_SOURCES=test_fhirmdir.c $(CMNFHISRC) $(CMNSRC) +test_fhirmdir_CFLAGS=$(CFL) +test_fhirmdir_DEPENDENCIES=$(LIBS) + +test_fhisymlink_SOURCES=test_fhisymlink.c $(CMNFHISRC) $(CMNSRC) +test_fhisymlink_CFLAGS=$(CFL) +test_fhisymlink_DEPENDENCIES=$(LIBS) + +test_fhitrunc_SOURCES=test_fhitrunc.c $(CMNFHISRC) $(CMNSRC) +test_fhitrunc_CFLAGS=$(CFL) +test_fhitrunc_DEPENDENCIES=$(LIBS) + +test_fhiunlink_SOURCES=test_fhiunlink.c $(CMNFHISRC) $(CMNSRC) +test_fhiunlink_CFLAGS=$(CFL) +test_fhiunlink_DEPENDENCIES=$(LIBS) + drv_data.c: $(CONFIG_DEPENDENCIES) $(top_srcdir)/tests/gendrvdata.sh test -z "drv_data.c" && rm -f drv_data.c; \ $(SHELL) $(top_srcdir)/tests/gendrvdata.sh $(DRIVERS) > drv_data.c Index: module.mk =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/module.mk,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- module.mk 4 Feb 2009 20:07:23 -0000 1.5 +++ module.mk 17 Aug 2009 23:37:08 -0000 1.6 @@ -20,5 +20,15 @@ TESTS_EXTRA = \ tests/test_stddir.c \ tests/test_symlink.c \ tests/test_unlink.c \ + tests/test_fhichmod.c \ + tests/test_fhicreate.c \ + tests/test_fhilink.c \ + tests/test_fhilist.c \ + tests/test_fhimkdir.c \ tests/test_fhipath.c \ + tests/test_fhirename.c \ + tests/test_fhirmdir.c \ + tests/test_fhisymlink.c \ + tests/test_fhitrunc.c \ + tests/test_fhiunlink.c \ tests/Makefile.am tests/Makefile.in tests/module.mk |
From: Lee W. <lw...@us...> - 2009-08-17 23:36:53
|
Update of /cvsroot/libsysio/libsysio/tests In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3306 Modified Files: test_fhipath.c Log Message: Modified to use the new fhi test support goodies. Index: test_fhipath.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/tests/test_fhipath.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- test_fhipath.c 25 Feb 2009 05:08:58 -0000 1.2 +++ test_fhipath.c 17 Aug 2009 23:36:43 -0000 1.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-2009 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 @@ -36,7 +36,7 @@ * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 - * Albuquerque, NM 87185-1110 + * Albuquerque, NM 87185-1319 * * le...@sa... */ @@ -58,11 +58,12 @@ #include "xtio.h" #include "test.h" #include "../misc/fhi.h" +#include "fhi_support.h" /* * Stat files. * - * Usage: test_path [export-path] [path...] + * Usage: test_fhipath [export-path] [path...] * * Without any path arguments, the program reads from standard-in, dealing with * each line as an absolute or relative path until EOF. @@ -85,7 +86,6 @@ main(int argc, char *const argv[]) { int i; int err; - ssize_t cc; int n; extern int _test_sysio_startup(void); @@ -112,27 +112,7 @@ main(int argc, char *const argv[]) if (!(argc - optind)) usage(); key = 1; - err = - SYSIO_INTERFACE_NAME(fhi_export)(&key, - sizeof(key), - argv[optind], - 0, - &root_handle.fhi_export); - if (err) { - perror(argv[optind]); - exit(1); - } - cc = - SYSIO_INTERFACE_NAME(fhi_root_of)(root_handle.fhi_export, - &root_handle); - if (cc < 0) { - perror(argv[optind]); - exit(1); - } - if ((size_t )cc >= sizeof(root_handle_data)) { - (void )fprintf(stderr, - "%s: handle data too large\n", - argv[optind]); + if (_test_fhi_start(&key, argv[optind], &root_handle)) { exit(1); } optind++; @@ -207,12 +187,8 @@ statit(const char *path) perror(path); return -1; } - if ((size_t )cc >= sizeof(root_handle_data)) { - (void )fprintf(stderr, - "%s: handle data too large\n", - path); + if (_test_fhi_check_handle(path, &handle, cc)) exit(1); - } err = SYSIO_INTERFACE_NAME(fhi_getattr)(&handle, &stbuf); if (err) { perror(path); |
From: Lee W. <lw...@us...> - 2009-08-17 23:36:17
|
Update of /cvsroot/libsysio/libsysio/tests In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3159 Added Files: fhi_support.c fhi_support.h Log Message: New support for fhi tests. --- NEW FILE --- #include <stdio.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #if defined(SYSIO_LABEL_NAMES) #include "sysio.h" #endif #include "xtio.h" #include "../misc/fhi.h" int _test_fhi_check_handle(const char *path, struct file_handle_info *handle, ssize_t nbytes) { int err; err = errno; do { if (nbytes < 0) { perror(path); break; } if ((size_t )nbytes > handle->fhi_handle_len) { (void )fprintf(stderr, "Handle data for '%s' is too large\n", path); err = EINVAL; break; } if (!nbytes) { (void )fprintf(stderr, "Illegal handle for '%s'\n", path); err = EINVAL; break; } err = 0; } while (0); return err; } int _test_fhi_start(int *key, const char *path, struct file_handle_info *root) { int err; ssize_t cc; err = SYSIO_INTERFACE_NAME(fhi_export)(key, sizeof(*key), path, 0, &root->fhi_export); if (err) { (void )fprintf(stderr, "Export of '%s' failed: %s\n", path, strerror(errno)); return errno; } cc = SYSIO_INTERFACE_NAME(fhi_root_of)(root->fhi_export, root); if (cc < 0) { (void )fprintf(stderr, "Can't get root handle for '%s': %s\n", path, strerror(errno)); return errno; } return _test_fhi_check_handle(path, root, cc); } int _test_fhi_find(struct file_handle_info *parent, const char *path, struct file_handle_info *fhi) { ssize_t cc; cc = SYSIO_INTERFACE_NAME(fhi_lookup)(parent, path, 0, fhi); if (cc < 0) return errno; return _test_fhi_check_handle(path, fhi, cc); } --- NEW FILE --- extern int _test_fhi_check_handle(const char *path, struct file_handle_info *handle, size_t nbytes); extern int _test_fhi_start(int *key, const char *path, struct file_handle_info *root); extern int _test_fhi_find(struct file_handle_info *parent, const char *path, struct file_handle_info *fhi); |
Update of /cvsroot/libsysio/libsysio/tests In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3124 Added Files: test_fhichmod.c test_fhicreate.c test_fhilink.c test_fhilist.c test_fhimkdir.c test_fhirename.c test_fhirmdir.c test_fhisymlink.c test_fhitrunc.c test_fhiunlink.c Log Message: New test. --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2009 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1319 * * le...@sa... */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/uio.h> #include <getopt.h> #include <sys/statvfs.h> #if defined(SYSIO_LABEL_NAMES) #include "sysio.h" #endif #include "xtio.h" #include "test.h" #include "../misc/fhi.h" #include "fhi_support.h" /* * Link files. * * Usage: test_fhichmod <path> <perms> */ static int key; static char root_handle_data[128]; static struct file_handle_info root_handle = { NULL, root_handle_data, sizeof(root_handle_data) }; static int chmodit(const char *path, const char *s); static void usage(void); 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, "")) != -1) switch (i) { default: usage(); } /* * Init sysio lib. */ err = _test_sysio_startup(); if (err) { errno = -err; perror("sysio startup"); exit(1); } if (!(argc - optind)) usage(); key = 1; if (_test_fhi_start(&key, argv[optind], &root_handle)) { exit(1); } optind++; n = argc - optind; if (n != 2) usage(); n = chmodit(argv[optind], argv[optind + 1]); /* * Clean up. */ err = SYSIO_INTERFACE_NAME(fhi_unexport)(root_handle.fhi_export); if (err) { perror("FHI unexport"); exit(1); } _test_sysio_shutdown(); return n ? 1 : 0; } static int chmodit(const char *path, const char *s) { long perms; char *cp; char handle_data[128]; struct file_handle_info handle = { NULL, handle_data, sizeof(handle_data) }; int err; struct file_handle_info_sattr setattr; perms = strtol(s, &cp, 0); if (*s == '\0' || *cp != '\0' || perms < 0 || perms > 0xffff) { (void )fprintf(stderr, "Invalid permissions\n"); return -1; } err = _test_fhi_find(&root_handle, path, &handle); if (err) { perror(path); return -1; } FHISATTR_CLEAR(&setattr); FHISATTR_SET_MODE(&setattr, (mode_t )perms); err = SYSIO_INTERFACE_NAME(fhi_setattr)(&handle, &setattr); if (err) { perror("fhi_chmod"); return -1; } return 0; } static void usage() { (void )fprintf(stderr, "Usage: test_fhichmod" " <path> " " <perms>\n"); exit(1); } --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2009 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1319 * * le...@sa... */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/uio.h> #include <getopt.h> #include <sys/statvfs.h> #if defined(SYSIO_LABEL_NAMES) #include "sysio.h" #endif #include "xtio.h" #include "test.h" #include "../misc/fhi.h" #include "fhi_support.h" /* * Create files. * * Usage: test_fhicreate [export-path] [path...] * * Without any path arguments, the program reads from standard-in, dealing with * each line as an absolute or relative path until EOF. */ static int key; static char root_handle_data[128]; static struct file_handle_info root_handle = { NULL, root_handle_data, sizeof(root_handle_data) }; static int createit(const char *path); static void usage(void); 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, "")) != -1) switch (i) { default: usage(); } /* * Init sysio lib. */ err = _test_sysio_startup(); if (err) { errno = -err; perror("sysio startup"); exit(1); } if (!(argc - optind)) usage(); key = 1; if (_test_fhi_start(&key, argv[optind], &root_handle)) { exit(1); } optind++; n = argc - optind; /* * Try path(s) listed on command-line. */ while (optind < argc) { const char *path; path = argv[optind++]; (void )createit(path); } /* * If no command-line arguments, read from stdin until EOF. */ if (!n) { int doflush; static char buf[4096]; size_t len; char *cp; char c; doflush = 0; while (fgets(buf, sizeof(buf), stdin) != NULL) { len = strlen(buf); cp = buf + len - 1; c = *cp; *cp = '\0'; if (!doflush) createit(buf); doflush = c == '\n' ? 0 : 1; } } /* * Clean up. */ err = SYSIO_INTERFACE_NAME(fhi_unexport)(root_handle.fhi_export); if (err) { perror("FHI unexport"); exit(1); } _test_sysio_shutdown(); return 0; } static int createit(const char *path) { char handle_data[128]; struct file_handle_info handle = { NULL, handle_data, sizeof(handle_data) }; int err; struct file_handle_info_dirop_args where; err = _test_fhi_find(&root_handle, path, &handle); if (err == ENOENT) err = 0; else if (!err) err = -EEXIST; if (err) { perror(path); return -1; } where.fhida_path = path; where.fhida_dir = &root_handle; err = SYSIO_INTERFACE_NAME(fhi_create)(&where, 0644); if (err) { perror(path); return -1; } err = _test_fhi_find(&root_handle, path, &handle); if (err) { perror(path); return -1; } return 0; } static void usage() { (void )fprintf(stderr, "Usage: test_fhicreate" " <export-path> " " [<path>...]\n"); exit(1); } --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2009 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1319 * * le...@sa... */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/uio.h> #include <getopt.h> #include <sys/statvfs.h> #if defined(SYSIO_LABEL_NAMES) #include "sysio.h" #endif #include "xtio.h" #include "test.h" #include "../misc/fhi.h" #include "fhi_support.h" /* * Link files. * * Usage: test_fhilink <old-path> <new-path> */ static int key; static char root_handle_data[128]; static struct file_handle_info root_handle = { NULL, root_handle_data, sizeof(root_handle_data) }; static int linkit(const char *from, const char *to); static void usage(void); 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, "")) != -1) switch (i) { default: usage(); } /* * Init sysio lib. */ err = _test_sysio_startup(); if (err) { errno = -err; perror("sysio startup"); exit(1); } if (!(argc - optind)) usage(); key = 1; if (_test_fhi_start(&key, argv[optind], &root_handle)) { exit(1); } optind++; n = argc - optind; if (n != 2) usage(); n = linkit(argv[optind], argv[optind + 1]); /* * Clean up. */ err = SYSIO_INTERFACE_NAME(fhi_unexport)(root_handle.fhi_export); if (err) { perror("FHI unexport"); exit(1); } _test_sysio_shutdown(); return n ? 1 : 0; } static int linkit(const char *from, const char *to) { char handle_data[128]; struct file_handle_info handle = { NULL, handle_data, sizeof(handle_data) }; int err; struct file_handle_info_dirop_args args[2]; err = _test_fhi_find(&root_handle, to, &handle); if (err == ENOENT) err = 0; else if (!err) err = -EEXIST; if (err) { perror(to); return -1; } args[0].fhida_path = from; args[0].fhida_dir = &root_handle; args[1].fhida_path = to; args[1].fhida_dir = &root_handle; err = SYSIO_INTERFACE_NAME(fhi_link)(&args[0], &args[1]); if (err) { perror("Can't link"); return -1; } err = _test_fhi_find(&root_handle, to, &handle); if (err) { perror(to); return -1; } return 0; } static void usage() { (void )fprintf(stderr, "Usage: test_fhilink" " <old-path> " " <new-path>\n"); exit(1); } --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2009 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1319 * * le...@sa... */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <dirent.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/uio.h> #include <getopt.h> #include <sys/statvfs.h> #if defined(SYSIO_LABEL_NAMES) #include "sysio.h" #endif #include "xtio.h" #include "test.h" #include "../misc/fhi.h" #include "fhi_support.h" /* * list files in given directories * * Usage: test_fhilist [export-path] [path...] * * Without any path arguments, the program reads from standard-in, dealing with * each line as an absolute or relative path until EOF. */ static int key; static char root_handle_data[128]; static struct file_handle_info root_handle = { NULL, root_handle_data, sizeof(root_handle_data) }; static int listit(const char *path); static void usage(void); 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, "")) != -1) switch (i) { default: usage(); } /* * Init sysio lib. */ err = _test_sysio_startup(); if (err) { errno = -err; perror("sysio startup"); exit(1); } if (!(argc - optind)) usage(); key = 1; if (_test_fhi_start(&key, argv[optind], &root_handle)) { exit(1); } optind++; n = argc - optind; /* * Try path(s) listed on command-line. */ while (optind < argc) { const char *path; path = argv[optind++]; (void )listit(path); } /* * If no command-line arguments, read from stdin until EOF. */ if (!n) { int doflush; static char buf[4096]; size_t len; char *cp; char c; doflush = 0; while (fgets(buf, sizeof(buf), stdin) != NULL) { len = strlen(buf); cp = buf + len - 1; c = *cp; *cp = '\0'; if (!doflush) listit(buf); doflush = c == '\n' ? 0 : 1; } } /* * Clean up. */ err = SYSIO_INTERFACE_NAME(fhi_unexport)(root_handle.fhi_export); if (err) { perror("FHI unexport"); exit(1); } _test_sysio_shutdown(); return 0; } static int listit(const char *path) { char handle_data[128]; struct file_handle_info handle = { NULL, handle_data, sizeof(handle_data) }; int err; static char buf[4096]; ssize_t cc; struct dirent64 *dp; off64_t base; err = _test_fhi_find(&root_handle, path, &handle); if (err) { perror(path); return -1; } base = 0; for (;;) { cc = SYSIO_INTERFACE_NAME(fhi_getdirentries64)(&handle, buf, sizeof(buf), &base); if (cc <= 0) break; dp = (struct dirent64 *)buf; while (cc > 0) { (void )printf("\t%s: ino %llu type %u\n", dp->d_name, (unsigned long long )dp->d_ino, (unsigned )dp->d_type); assert(cc >= dp->d_reclen); cc -= dp->d_reclen; dp = (struct dirent64 *)((char *)dp + dp->d_reclen); } } if (cc < 0) { perror(path); return -1; } return 0; } static void usage() { (void )fprintf(stderr, "Usage: test_fhilist" " <export-path> " " [<path>...]\n"); exit(1); } --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2009 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1319 * * le...@sa... */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/uio.h> #include <getopt.h> #include <sys/statvfs.h> #if defined(SYSIO_LABEL_NAMES) #include "sysio.h" #endif #include "xtio.h" #include "test.h" #include "../misc/fhi.h" #include "fhi_support.h" /* * Stat files. * * Usage: test_fhimkdir [export-path] [path...] * * Without any path arguments, the program reads from standard-in, dealing with * each line as an absolute or relative path until EOF. */ static int key; static char root_handle_data[128]; static struct file_handle_info root_handle = { NULL, root_handle_data, sizeof(root_handle_data) }; static int mkdirit(const char *path); static void usage(void); 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, "")) != -1) switch (i) { default: usage(); } /* * Init sysio lib. */ err = _test_sysio_startup(); if (err) { errno = -err; perror("sysio startup"); exit(1); } if (!(argc - optind)) usage(); key = 1; if (_test_fhi_start(&key, argv[optind], &root_handle)) { exit(1); } optind++; n = argc - optind; /* * Try path(s) listed on command-line. */ while (optind < argc) { const char *path; path = argv[optind++]; (void )mkdirit(path); } /* * If no command-line arguments, read from stdin until EOF. */ if (!n) { int doflush; static char buf[4096]; size_t len; char *cp; char c; doflush = 0; while (fgets(buf, sizeof(buf), stdin) != NULL) { len = strlen(buf); cp = buf + len - 1; c = *cp; *cp = '\0'; if (!doflush) mkdirit(buf); doflush = c == '\n' ? 0 : 1; } } /* * Clean up. */ err = SYSIO_INTERFACE_NAME(fhi_unexport)(root_handle.fhi_export); if (err) { perror("FHI unexport"); exit(1); } _test_sysio_shutdown(); return 0; } static int mkdirit(const char *path) { char handle_data[128]; struct file_handle_info handle = { NULL, handle_data, sizeof(handle_data) }; int err; ssize_t cc; struct file_handle_info_dirop_args where; where.fhida_path = path; where.fhida_dir = &root_handle; err = SYSIO_INTERFACE_NAME(fhi_mkdir)(&where, 0755); if (err) { perror(path); return -1; } cc = _test_fhi_find(&root_handle, path, &handle); if (cc < 0) { perror(path); return -1; } return 0; } static void usage() { (void )fprintf(stderr, "Usage: test_fhimkdir" " <export-path> " " [<path>...]\n"); exit(1); } --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2009 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1319 * * le...@sa... */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/uio.h> #include <getopt.h> #include <sys/statvfs.h> #if defined(SYSIO_LABEL_NAMES) #include "sysio.h" #endif #include "xtio.h" #include "test.h" #include "../misc/fhi.h" #include "fhi_support.h" /* * Link files. * * Usage: test_fhirename <old-path> <new-path> */ static int key; static char root_handle_data[128]; static struct file_handle_info root_handle = { NULL, root_handle_data, sizeof(root_handle_data) }; static int renameit(const char *from, const char *to); static void usage(void); 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, "")) != -1) switch (i) { default: usage(); } /* * Init sysio lib. */ err = _test_sysio_startup(); if (err) { errno = -err; perror("sysio startup"); exit(1); } if (!(argc - optind)) usage(); key = 1; if (_test_fhi_start(&key, argv[optind], &root_handle)) { exit(1); } optind++; n = argc - optind; if (n != 2) usage(); n = renameit(argv[optind], argv[optind + 1]); /* * Clean up. */ err = SYSIO_INTERFACE_NAME(fhi_unexport)(root_handle.fhi_export); if (err) { perror("FHI unexport"); exit(1); } _test_sysio_shutdown(); return n ? 1 : 0; } static int renameit(const char *from, const char *to) { char handle_data[128]; struct file_handle_info handle = { NULL, handle_data, sizeof(handle_data) }; int err; struct file_handle_info_dirop_args args[2]; err = _test_fhi_find(&root_handle, to, &handle); if (err == ENOENT) err = 0; else if (!err) err = -EEXIST; if (err) { perror(to); return -1; } args[0].fhida_path = from; args[0].fhida_dir = &root_handle; args[1].fhida_path = to; args[1].fhida_dir = &root_handle; err = SYSIO_INTERFACE_NAME(fhi_rename)(&args[0], &args[1]); if (err) { perror("Can't rename"); return -1; } err = _test_fhi_find(&root_handle, to, &handle); if (err) { perror(to); return -1; } return 0; } static void usage() { (void )fprintf(stderr, "Usage: test_fhirename" " <old-path> " " <new-path>\n"); exit(1); } --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2009 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1319 * * le...@sa... */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/uio.h> #include <getopt.h> #include <sys/statvfs.h> #if defined(SYSIO_LABEL_NAMES) #include "sysio.h" #endif #include "xtio.h" #include "test.h" #include "../misc/fhi.h" #include "fhi_support.h" /* * Stat files. * * Usage: test_fhirmdir [export-path] [path...] * * Without any path arguments, the program reads from standard-in, dealing with * each line as an absolute or relative path until EOF. */ static int key; static char root_handle_data[128]; static struct file_handle_info root_handle = { NULL, root_handle_data, sizeof(root_handle_data) }; static int rmdirit(const char *path); static void usage(void); 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, "")) != -1) switch (i) { default: usage(); } /* * Init sysio lib. */ err = _test_sysio_startup(); if (err) { errno = -err; perror("sysio startup"); exit(1); } if (!(argc - optind)) usage(); key = 1; if (_test_fhi_start(&key, argv[optind], &root_handle)) { exit(1); } optind++; n = argc - optind; /* * Try path(s) listed on command-line. */ while (optind < argc) { const char *path; path = argv[optind++]; (void )rmdirit(path); } /* * If no command-line arguments, read from stdin until EOF. */ if (!n) { int doflush; static char buf[4096]; size_t len; char *cp; char c; doflush = 0; while (fgets(buf, sizeof(buf), stdin) != NULL) { len = strlen(buf); cp = buf + len - 1; c = *cp; *cp = '\0'; if (!doflush) rmdirit(buf); doflush = c == '\n' ? 0 : 1; } } /* * Clean up. */ err = SYSIO_INTERFACE_NAME(fhi_unexport)(root_handle.fhi_export); if (err) { perror("FHI unexport"); exit(1); } _test_sysio_shutdown(); return 0; } static int rmdirit(const char *path) { char handle_data[128]; struct file_handle_info handle = { NULL, handle_data, sizeof(handle_data) }; int err; ssize_t cc; struct file_handle_info_dirop_args where; where.fhida_path = path; where.fhida_dir = &root_handle; err = SYSIO_INTERFACE_NAME(fhi_rmdir)(&where); if (err) { perror(path); return -1; } cc = _test_fhi_find(&root_handle, path, &handle); if (cc < 0) { perror(path); return -1; } return 0; } static void usage() { (void )fprintf(stderr, "Usage: test_fhirmdir" " <export-path> " " [<path>...]\n"); exit(1); } --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2009 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1319 * * le...@sa... */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/uio.h> #include <getopt.h> #include <sys/statvfs.h> #if defined(SYSIO_LABEL_NAMES) #include "sysio.h" #endif #include "xtio.h" #include "test.h" #include "../misc/fhi.h" #include "fhi_support.h" /* * Link files. * * Usage: test_fhisymlink <old-path> <new-path> */ static int key; static char root_handle_data[128]; static struct file_handle_info root_handle = { NULL, root_handle_data, sizeof(root_handle_data) }; static int symlinkit(const char *from, const char *to); static void usage(void); 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, "")) != -1) switch (i) { default: usage(); } /* * Init sysio lib. */ err = _test_sysio_startup(); if (err) { errno = -err; perror("sysio startup"); exit(1); } if (!(argc - optind)) usage(); key = 1; if (_test_fhi_start(&key, argv[optind], &root_handle)) { exit(1); } optind++; n = argc - optind; if (n != 2) usage(); n = symlinkit(argv[optind], argv[optind + 1]); /* * Clean up. */ err = SYSIO_INTERFACE_NAME(fhi_unexport)(root_handle.fhi_export); if (err) { perror("FHI unexport"); exit(1); } _test_sysio_shutdown(); return n ? 1 : 0; } static int symlinkit(const char *from, const char *to) { char handle_data[128]; struct file_handle_info handle = { NULL, handle_data, sizeof(handle_data) }; int err; struct file_handle_info_dirop_args arg; err = _test_fhi_find(&root_handle, to, &handle); if (err == ENOENT) err = 0; else if (!err) err = -EEXIST; if (err) { perror(to); return -1; } arg.fhida_path = to; arg.fhida_dir = &root_handle; err = SYSIO_INTERFACE_NAME(fhi_symlink)(from, &arg); if (err) { perror("Can't symlink"); return -1; } err = _test_fhi_find(&root_handle, from, &handle); if (err) { perror(to); return -1; } return 0; } static void usage() { (void )fprintf(stderr, "Usage: test_fhisymlink" " <old-path> " " <new-path>\n"); exit(1); } --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2009 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1319 * * le...@sa... */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/uio.h> #include <getopt.h> #include <sys/statvfs.h> #if defined(SYSIO_LABEL_NAMES) #include "sysio.h" #endif #include "xtio.h" #include "test.h" #include "../misc/fhi.h" #include "fhi_support.h" /* * Link files. * * Usage: test_fhitrunc <path> <size> */ static int key; static char root_handle_data[128]; static struct file_handle_info root_handle = { NULL, root_handle_data, sizeof(root_handle_data) }; static int truncit(const char *path, const char *s); static void usage(void); 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, "")) != -1) switch (i) { default: usage(); } /* * Init sysio lib. */ err = _test_sysio_startup(); if (err) { errno = -err; perror("sysio startup"); exit(1); } if (!(argc - optind)) usage(); key = 1; if (_test_fhi_start(&key, argv[optind], &root_handle)) { exit(1); } optind++; n = argc - optind; if (n != 2) usage(); n = truncit(argv[optind], argv[optind + 1]); /* * Clean up. */ err = SYSIO_INTERFACE_NAME(fhi_unexport)(root_handle.fhi_export); if (err) { perror("FHI unexport"); exit(1); } _test_sysio_shutdown(); return n ? 1 : 0; } static int truncit(const char *path, const char *s) { long long fsiz; char *cp; char handle_data[128]; struct file_handle_info handle = { NULL, handle_data, sizeof(handle_data) }; int err; struct file_handle_info_sattr setattr; fsiz = strtoll(s, &cp, 0); if (*s == '\0' || *cp != '\0' || fsiz < 0 || (fsiz == LLONG_MAX && errno == ERANGE)) { (void )fprintf(stderr, "Invalid size\n"); return -1; } err = _test_fhi_find(&root_handle, path, &handle); if (err) { perror(path); return -1; } FHISATTR_CLEAR(&setattr); FHISATTR_SET_SIZE(&setattr, (off64_t )fsiz); err = SYSIO_INTERFACE_NAME(fhi_setattr)(&handle, &setattr); if (err) { perror("fhi_trunc"); return -1; } return 0; } static void usage() { (void )fprintf(stderr, "Usage: test_fhitrunc" " <path> " " <size>\n"); exit(1); } --- NEW FILE --- /* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2009 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. */ /* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1319 * * le...@sa... */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <sys/uio.h> #include <getopt.h> #include <sys/statvfs.h> #if defined(SYSIO_LABEL_NAMES) #include "sysio.h" #endif #include "xtio.h" #include "test.h" #include "../misc/fhi.h" #include "fhi_support.h" /* * Stat files. * * Usage: test_fhiunlink [export-path] [path...] * * Without any path arguments, the program reads from standard-in, dealing with * each line as an absolute or relative path until EOF. */ static int key; static char root_handle_data[128]; static struct file_handle_info root_handle = { NULL, root_handle_data, sizeof(root_handle_data) }; static int unlinkit(const char *path); static void usage(void); 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, "")) != -1) switch (i) { default: usage(); } /* * Init sysio lib. */ err = _test_sysio_startup(); if (err) { errno = -err; perror("sysio startup"); exit(1); } if (!(argc - optind)) usage(); key = 1; if (_test_fhi_start(&key, argv[optind], &root_handle)) { exit(1); } optind++; n = argc - optind; /* * Try path(s) listed on command-line. */ while (optind < argc) { const char *path; path = argv[optind++]; (void )unlinkit(path); } /* * If no command-line arguments, read from stdin until EOF. */ if (!n) { int doflush; static char buf[4096]; size_t len; char *cp; char c; doflush = 0; while (fgets(buf, sizeof(buf), stdin) != NULL) { len = strlen(buf); cp = buf + len - 1; c = *cp; *cp = '\0'; if (!doflush) unlinkit(buf); doflush = c == '\n' ? 0 : 1; } } /* * Clean up. */ err = SYSIO_INTERFACE_NAME(fhi_unexport)(root_handle.fhi_export); if (err) { perror("FHI unexport"); exit(1); } _test_sysio_shutdown(); return 0; } static int unlinkit(const char *path) { char handle_data[128]; struct file_handle_info handle = { NULL, handle_data, sizeof(handle_data) }; int err; ssize_t cc; struct file_handle_info_dirop_args where; where.fhida_path = path; where.fhida_dir = &root_handle; err = SYSIO_INTERFACE_NAME(fhi_unlink)(&where); if (err) { perror(path); return -1; } cc = _test_fhi_find(&root_handle, path, &handle); if (cc < 0) { perror(path); return -1; } return 0; } static void usage() { (void )fprintf(stderr, "Usage: test_fhiunlink" " <export-path> " " [<path>...]\n"); exit(1); } |
From: Lee W. <lw...@us...> - 2009-08-17 23:30:44
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv2540/src Modified Files: chmod.c Log Message: When checking permissions do not always return -EPERM;. Instead, return the error that _sysio_permitted gave to us. Index: chmod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/chmod.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -w -b -B -p -r1.21 -r1.22 --- chmod.c 17 Jun 2008 17:18:57 -0000 1.21 +++ chmod.c 17 Aug 2009 23:30:25 -0000 1.22 @@ -61,8 +61,9 @@ do_chmod(struct pnode *pno, mode_t mode) struct intnl_stat stbuf; unsigned mask; - if ((_sysio_permitted(pno, W_OK)) != 0) - return -EPERM; + err = _sysio_permitted(pno, W_OK); + if (err) + return err; (void )memset(&stbuf, 0, sizeof(struct intnl_stat)); stbuf.st_mode = mode & 07777; |
From: Lee W. <lw...@us...> - 2009-08-17 23:28:53
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv2321/src Modified Files: unlink.c Log Message: When I moved the permission check to the p-node routine it was incomplete. Now, check permission and return error if there was one, otherwise continue on with the operation. Index: unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/unlink.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -w -b -B -p -r1.24 -r1.25 --- unlink.c 17 Aug 2009 17:47:22 -0000 1.24 +++ unlink.c 17 Aug 2009 23:28:41 -0000 1.25 @@ -69,7 +69,8 @@ _sysio_p_unlink(struct pnode *pno) if (S_ISDIR(pno->p_base->pb_ino->i_stbuf.st_mode)) return -EISDIR; err = _sysio_permitted(pno->p_parent, W_OK); - return -EPERM; + if (err) + return err; /* * Call the FS implementation. */ |
From: Lee W. <lw...@us...> - 2009-08-17 23:21:38
|
Update of /cvsroot/libsysio/libsysio/misc In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1697 Modified Files: fhi.c fhi.h Log Message: The fhi_symlink arguments are now from (a path) to (a diroparg) instead of the other way round, which was wrong. Index: fhi.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/misc/fhi.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- fhi.c 17 Aug 2009 23:04:25 -0000 1.7 +++ fhi.c 17 Aug 2009 23:21:26 -0000 1.8 @@ -920,8 +920,8 @@ SYSIO_INTERFACE_NAME(fhi_link)(struct fi } int -SYSIO_INTERFACE_NAME(fhi_symlink)(struct file_handle_info_dirop_args *from, - const char *to) +SYSIO_INTERFACE_NAME(fhi_symlink)(const char *from, + struct file_handle_info_dirop_args *to) { struct intent intent; struct pnode *pno; @@ -929,21 +929,21 @@ SYSIO_INTERFACE_NAME(fhi_symlink)(struct SYSIO_INTERFACE_DISPLAY_BLOCK; SYSIO_INTERFACE_ENTER(fhi_symlink, - "%hY%s%s", - from->fhida_dir, from->fhida_path, - to); + "%s%hY%s", + from, + to->fhida_dir, to->fhida_path); do { INTENT_INIT(&intent, INT_CREAT, NULL, NULL); err = - fhi_namei(from->fhida_dir, - from->fhida_path, + fhi_namei(to->fhida_dir, + to->fhida_path, ND_NEGOK|ND_WANTPARENT, &intent, &pno); if (err) break; - err = _sysio_p_symlink(to, pno); + err = _sysio_p_symlink(from, pno); P_PUT(pno->p_parent); P_PUT(pno); } while (0); Index: fhi.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/misc/fhi.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -b -B -p -r1.3 -r1.4 --- fhi.h 17 Aug 2009 23:02:26 -0000 1.3 +++ fhi.h 17 Aug 2009 23:21:26 -0000 1.4 @@ -173,9 +173,9 @@ extern int SYSIO_INTERFACE_NAME(fhi_link *from, struct file_handle_info_dirop_args *to); -extern int SYSIO_INTERFACE_NAME(fhi_symlink)(struct file_handle_info_dirop_args - *from, - const char *to); +extern int SYSIO_INTERFACE_NAME(fhi_symlink)(const char *from, + struct file_handle_info_dirop_args + *to); extern int SYSIO_INTERFACE_NAME(fhi_mkdir)(struct file_handle_info_dirop_args *where, mode_t mode); |
From: Lee W. <lw...@us...> - 2009-08-17 23:04:34
|
Update of /cvsroot/libsysio/libsysio/misc In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32383 Modified Files: fhi.c Log Message: Both the getattr and rmdir routines could return early without going through SYSIO_INTERFACE_RETURN. This had the unfortunate side-effect of leaving the biglock in the locked state :( Fixed. Index: fhi.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/misc/fhi.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -b -B -p -r1.6 -r1.7 --- fhi.c 17 Aug 2009 17:49:40 -0000 1.6 +++ fhi.c 17 Aug 2009 23:04:25 -0000 1.7 @@ -417,10 +417,13 @@ SYSIO_INTERFACE_NAME(fhi_getattr)(struct "%hY", fhi); + err = 0; do { err = find_alias(fhi, &pno); - if (err) - return -ESTALE; + if (err) { + err = -ESTALE; + break; + } (void )memset(buf, 0, sizeof(struct stat64)); buf->st_dev = pno->p_base->pb_ino->i_stbuf.st_dev; @@ -1009,7 +1012,7 @@ SYSIO_INTERFACE_NAME(fhi_rmdir)(struct f &intent, &pno); if (err) - return err; + break; err = _sysio_p_rmdir(pno); P_PUT(pno->p_parent); P_PUT(pno); |
From: Lee W. <lw...@us...> - 2009-08-17 23:02:40
|
Update of /cvsroot/libsysio/libsysio/misc In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31901 Modified Files: fhi.h Log Message: It's official. I can't do token pasting to save my life. FIXED! The token pasting madness I was engaged in was generating bad symbols. Also, the attr CLEAR macro was clearing the values but setting all the indicators to 'set' those values. Big oops. All fixed now, I believe. Index: fhi.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/misc/fhi.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -b -B -p -r1.2 -r1.3 --- fhi.h 3 Aug 2009 23:03:53 -0000 1.2 +++ fhi.h 17 Aug 2009 23:02:26 -0000 1.3 @@ -76,9 +76,9 @@ struct file_handle_info_sattr { /* * Set an attribute value in the passed buffer. */ -#define _FHISATTR_SET(_fhisattr, _n, _v) \ +#define _FHISATTR_SET(_fhisattr, _n, _f, _v) \ do { \ - (_fhisattr)->fhisattr_ ##_n _set = 1; \ + (_fhisattr)->fhisattr_##_n##_set = (_f); \ (_fhisattr)->fhisattr_ ##_n = (_v); \ } while (0) @@ -87,17 +87,17 @@ struct file_handle_info_sattr { * attribute record. */ #define FHISATTR_SET_MODE(_fhisattr, _v) \ - _FHISATTR_SET((_fhisattr), mode, (_v) & 07777) + _FHISATTR_SET((_fhisattr), mode, 1, (_v) & 07777) #define FHISATTR_SET_UID(_fhisattr, _v) \ - _FHISATTR_SET((_fhisattr), uid, (_v)) + _FHISATTR_SET((_fhisattr), uid, 1, (_v)) #define FHISATTR_SET_GID(_fhisattr, _v) \ - _FHISATTR_SET((_fhisattr), gid, (_v)) + _FHISATTR_SET((_fhisattr), gid, 1, (_v)) #define FHISATTR_SET_SIZE(_fhisattr, _v) \ - _FHISATTR_SET((_fhisattr), size, (_v)) + _FHISATTR_SET((_fhisattr), size, 1, (_v)) #define FHISATTR_SET_ATIME(_fhisattr, _v) \ - _FHISATTR_SET((_fhisattr), atime, (_v)) + _FHISATTR_SET((_fhisattr), atime, 1, (_v)) #define FHISATTR_SET_MTIME(_fhisattr, _v) \ - _FHISATTR_SET((_fhisattr), mtime, (_v)) + _FHISATTR_SET((_fhisattr), mtime, 1, (_v)) /* * Clear all attribute values in passed file handle info set attribute record @@ -105,12 +105,12 @@ struct file_handle_info_sattr { */ #define FHISATTR_CLEAR(_fhisattr) \ do { \ - FHISATTR_MODE_SET((_fhisattr), 0); \ - FHISATTR_UID_SET((_fhisattr), -1); \ - FHISATTR_GID_SET((_fhisattr), -1); \ - FHISATTR_SIZE_SET((_fhisattr), 0); \ - FHISATTR_ATIME_SET((_fhisattr), 0); \ - FHISATTR_MTIME_SET((_fhisattr), 0); \ + _FHISATTR_SET((_fhisattr), mode, 0, 0); \ + _FHISATTR_SET((_fhisattr), uid, 0, -1); \ + _FHISATTR_SET((_fhisattr), gid, 0, -1); \ + _FHISATTR_SET((_fhisattr), size, 0, 0); \ + _FHISATTR_SET((_fhisattr), atime, 0, 0); \ + _FHISATTR_SET((_fhisattr), mtime, 0, 0); \ } while (0); /* |
From: Lee W. <lw...@us...> - 2009-08-17 23:00:33
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31563 Modified Files: inode.c Log Message: Two changes to _sysio_pb_gone 1) Use I_GONE instead of _sysio_i_gone directly. 2) BUGFIX! If the associated i-node is a zombie it was being released once by the PB_SET_ASSOC(..., NULL) and then again, later, when we are trying to force the i-node to go away. Added a special check to remove the latter, forced, gone if ref == 1 and zombie. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.56 retrieving revision 1.57 diff -u -w -b -B -p -r1.56 -r1.57 --- inode.c 4 Aug 2009 05:46:24 -0000 1.56 +++ inode.c 17 Aug 2009 23:00:20 -0000 1.57 @@ -587,8 +587,18 @@ _sysio_pb_gone(struct pnode_base *pb) TAILQ_REMOVE(&pb_leaf_nodes, pb, pb_links); #endif ino = pb->pb_ino; - if (ino) + if (ino) { I_LOCK(ino); + if (ino->i_ref == 1 && ino->i_zombie) { + /* + * The PB_UNLOCK, below, will kill it before + * we have a chance to force the issue. Avoid + * the double gone by resetting the pointer + * to NULL. + */ + ino = NULL; + } + } PB_SET_ASSOC(pb, NULL); PB_UNLOCK(pb); mutex_destroy(&pb->pb_mutex); @@ -596,7 +606,7 @@ _sysio_pb_gone(struct pnode_base *pb) if (ino) { if (!(ino->i_ref || ino->i_immune || I_ISASSOC(ino))) - _sysio_i_gone(ino); + I_GONE(ino); else I_UNLOCK(ino); } |
From: Lee W. <lw...@us...> - 2009-08-17 22:56:56
|
Update of /cvsroot/libsysio/libsysio/include In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31324 Modified Files: inode.h Log Message: Moved I_ISASSOC and I_GONE up. Switched _I_RELE_NO_LOCK to use the I_GONE macro instead of calling _sysio_i_gone directly. Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.59 retrieving revision 1.60 diff -u -w -b -B -p -r1.59 -r1.60 --- inode.h 17 Aug 2009 17:45:09 -0000 1.59 +++ inode.h 17 Aug 2009 22:56:45 -0000 1.60 @@ -171,6 +171,20 @@ struct inode { #endif /* + * Check association; Logical true if so, otherwise false. + * + * NB: The given i-node should be locked or otherwise protected from + * manipulation by others. + */ +#ifdef I_ASSOCIATIONS +#define I_ISASSOC(_ino) \ + ((_ino)->i_assoc.lh_first) +#else +#define I_ISASSOC(_ino) \ + (0) +#endif + +/* * Init an i-node record. */ #define I_INIT(ino, fs, stat, ops, fid, immunity, private) \ @@ -201,6 +215,15 @@ struct inode { #define _I_CHECK_LOCK(_ino, _test) #endif +/* + * Attempt to kill an inode. + */ +#define I_GONE(_ino) \ + do { \ + _I_CHECK_LOCK((_ino), 1); \ + _sysio_i_gone(_ino); \ + } while (0) + #define I_LOCK(_ino) \ do { \ mutex_lock(&(_ino)->i_mutex); \ @@ -241,7 +264,7 @@ struct inode { _I_CHECK_LOCK((_ino), 1); \ assert((_ino)->i_ref); \ if (!--(_ino)->i_ref && (_ino)->i_zombie) \ - _sysio_i_gone((_ino)); \ + I_GONE(_ino); \ } while (0) #define I_RELE(_ino) \ @@ -270,29 +293,6 @@ struct inode { } while (0) /* - * Attempt to kill an inode. - */ -#define I_GONE(_ino) \ - do { \ - _I_CHECK_LOCK((_ino), 1); \ - _sysio_i_gone(_ino); \ - } while (0) - -/* - * Check association; Logical true if so, otherwise false. - * - * NB: The given i-node should be locked or otherwise protected from - * manipulation by others. - */ -#ifdef I_ASSOCIATIONS -#define I_ISASSOC(_ino) \ - ((_ino)->i_assoc.lh_first) -#else -#define I_ISASSOC(_ino) \ - (0) -#endif - -/* * 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. |
From: Lee W. <lw...@us...> - 2009-08-17 17:50:01
|
Update of /cvsroot/libsysio/libsysio/misc In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30248 Modified Files: fhi.c Log Message: Modified to use the new ND_WATNPARENT flag everywhere it's appropriate; Calls that change the name space. Index: fhi.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/misc/fhi.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -b -B -p -r1.5 -r1.6 --- fhi.c 4 Aug 2009 06:03:58 -0000 1.5 +++ fhi.c 17 Aug 2009 17:49:40 -0000 1.6 @@ -753,7 +753,7 @@ SYSIO_INTERFACE_NAME(fhi_create)(struct err = fhi_namei(where->fhida_dir, where->fhida_path, - ND_NEGOK, + ND_NEGOK|ND_WANTPARENT, &intent, &pno); if (err) @@ -765,6 +765,7 @@ SYSIO_INTERFACE_NAME(fhi_create)(struct if (PNOP_CLOSE(pno) != 0) abort(); } while (0); + P_PUT(pno->p_parent); P_PUT(pno); } while (0); @@ -792,12 +793,13 @@ SYSIO_INTERFACE_NAME(fhi_unlink)(struct err = fhi_namei(where->fhida_dir, where->fhida_path, - ND_NOFOLLOW, + ND_NOFOLLOW|ND_WANTPARENT, &intent, &pno); if (err) break; err = _sysio_p_unlink(pno); + P_PUT(pno->p_parent); P_PUT(pno); } while (0); @@ -823,30 +825,35 @@ SYSIO_INTERFACE_NAME(fhi_rename)(struct to->fhida_dir, to->fhida_path); old = new = NULL; - INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); do { + INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = fhi_namei(from->fhida_dir, from->fhida_path, - 0, + ND_WANTPARENT, &intent, &old); if (err) break; + INTENT_INIT(&intent, INT_CREAT, NULL, NULL); err = fhi_namei(to->fhida_dir, to->fhida_path, - ND_NEGOK, + ND_NEGOK|ND_WANTPARENT, &intent, &new); if (err) break; err = _sysio_p_rename(old, new); } while (0); - if (new) + if (new) { + P_PUT(new->p_parent); P_PUT(new); - if (old) + } + if (old) { + P_PUT(old->p_parent); P_PUT(old); + } SYSIO_INTERFACE_RETURN(err, err, @@ -880,11 +887,11 @@ SYSIO_INTERFACE_NAME(fhi_link)(struct fi &old); if (err) break; - INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); + INTENT_INIT(&intent, INT_CREAT, NULL, NULL); err = fhi_namei(to->fhida_dir, to->fhida_path, - ND_NEGOK, + ND_NEGOK|ND_WANTPARENT, &intent, &new); if (err) @@ -895,8 +902,10 @@ SYSIO_INTERFACE_NAME(fhi_link)(struct fi } err = _sysio_p_link(old, new); } while (0); - if (new) + if (new) { + P_PUT(new->p_parent); P_PUT(new); + } if (old) P_PUT(old); @@ -926,12 +935,13 @@ SYSIO_INTERFACE_NAME(fhi_symlink)(struct err = fhi_namei(from->fhida_dir, from->fhida_path, - ND_NEGOK, + ND_NEGOK|ND_WANTPARENT, &intent, &pno); if (err) break; err = _sysio_p_symlink(to, pno); + P_PUT(pno->p_parent); P_PUT(pno); } while (0); @@ -961,12 +971,13 @@ SYSIO_INTERFACE_NAME(fhi_mkdir)(struct f err = fhi_namei(where->fhida_dir, where->fhida_path, - ND_NEGOK, + ND_NEGOK|ND_WANTPARENT, &intent, &pno); if (err) break; err = _sysio_mkdir(pno, mode); + P_PUT(pno->p_parent); P_PUT(pno); } while (0); @@ -994,12 +1005,13 @@ SYSIO_INTERFACE_NAME(fhi_rmdir)(struct f err = fhi_namei(where->fhida_dir, where->fhida_path, - 0, + ND_WANTPARENT, &intent, &pno); if (err) return err; err = _sysio_p_rmdir(pno); + P_PUT(pno->p_parent); P_PUT(pno); } while (0); |
From: Lee W. <lw...@us...> - 2009-08-17 17:47:36
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29758 Modified Files: unlink.c Log Message: Moved permission check from API call to the general p-node unlink so all paths exercise it. Index: unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/unlink.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -w -b -B -p -r1.23 -r1.24 --- unlink.c 4 Aug 2009 15:01:24 -0000 1.23 +++ unlink.c 17 Aug 2009 17:47:22 -0000 1.24 @@ -68,6 +68,8 @@ _sysio_p_unlink(struct pnode *pno) return -ENOENT; /* huh? */ if (S_ISDIR(pno->p_base->pb_ino->i_stbuf.st_mode)) return -EISDIR; + err = _sysio_permitted(pno->p_parent, W_OK); + return -EPERM; /* * Call the FS implementation. */ @@ -103,9 +105,6 @@ SYSIO_INTERFACE_NAME(unlink)(const char pno = NULL; break; } - err = _sysio_permitted(pno->p_parent, W_OK); - if (err) - break; err = _sysio_p_unlink(pno); if (err) break; |
From: Lee W. <lw...@us...> - 2009-08-17 17:46:30
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29618 Modified Files: symlink.c Log Message: Removed unused 'err' variable. Index: symlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/symlink.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -w -b -B -p -r1.22 -r1.23 --- symlink.c 4 Aug 2009 15:01:24 -0000 1.22 +++ symlink.c 17 Aug 2009 17:46:17 -0000 1.23 @@ -60,6 +60,7 @@ int _sysio_p_symlink(const char *oldpath, struct pnode *new) { + int err; if (new->p_base->pb_ino) return -EEXIST; |
From: Lee W. <lw...@us...> - 2009-08-17 17:45:54
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29582 Modified Files: mknod.c Log Message: Removed unused error label. Index: mknod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mknod.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -w -b -B -p -r1.24 -r1.25 --- mknod.c 4 Aug 2009 15:01:24 -0000 1.24 +++ mknod.c 17 Aug 2009 17:45:45 -0000 1.25 @@ -116,7 +116,6 @@ PREPEND(__, SYSIO_INTERFACE_NAME(xmknod) goto out; err = _sysio_mknod(pno, mode, *dev); -error: P_PUT(pno->p_parent); P_PUT(pno); out: |
From: Lee W. <lw...@us...> - 2009-08-17 17:45:19
|
Update of /cvsroot/libsysio/libsysio/include In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29439/include Modified Files: inode.h Log Message: ND_WANTPARENT was defined as 0x0a. I'm thinking I can't do hex :( It's now defined to be 0x10, a unique flag. Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.58 retrieving revision 1.59 diff -u -w -b -B -p -r1.58 -r1.59 --- inode.h 4 Aug 2009 14:19:01 -0000 1.58 +++ inode.h 17 Aug 2009 17:45:09 -0000 1.59 @@ -703,7 +703,7 @@ struct nameidata { #define ND_NEGOK 0x02 /* last missing is ok */ #define ND_NOPERMCHECK 0x04 /* don't check perms */ #define ND_NXMNT 0x08 /* don't cross mounts */ -#define ND_WANTPARENT 0x0a /* want parent too */ +#define ND_WANTPARENT 0x10 /* want parent too */ #ifdef AUTOMOUNT_FILE_NAME #define _ND_INIT_AUTOMOUNT(nd) ((nd)->nd_amcnt = 0) |
From: Lee W. <lw...@us...> - 2009-08-04 15:01:34
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv450 Modified Files: init.c link.c mkdir.c mknod.c open.c rename.c rmdir.c symlink.c unlink.c Log Message: Use the new ND_WANTPARENT flag as appropriate. Index: init.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/init.c,v retrieving revision 1.44 retrieving revision 1.45 diff -u -w -b -B -p -r1.44 -r1.45 --- init.c 6 Dec 2008 21:56:25 -0000 1.44 +++ init.c 4 Aug 2009 15:01:24 -0000 1.45 @@ -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-2007 Sandia Corporation. + * Cplant(TM) Copyright 1998-2009 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 @@ -469,27 +469,24 @@ do_creat(char *args) op = 0; if (strcmp(v[0].ovi_value, "dir") == 0) { op = CREATE_DIR; - INTENT_INIT(&intent, INT_CREAT, &mode, NULL); } else if (strcmp(v[0].ovi_value, "chr") == 0) { op = CREATE_CHR; mode |= S_IFCHR; - INTENT_INIT(&intent, INT_CREAT, &mode, NULL); if (!(v[5].ovi_value && parse_mm(v[5].ovi_value, &dev) == 0)) err = -EINVAL; } else if (strcmp(v[0].ovi_value, "blk") == 0) { op = CREATE_BLK; mode |= S_IFBLK; - INTENT_INIT(&intent, INT_CREAT, &mode, NULL); if (!(v[5].ovi_value && parse_mm(v[5].ovi_value, &dev) == 0)) err = -EINVAL; } else if (strcmp(v[0].ovi_value, "file") == 0) { op = CREATE_FILE; intent_mode = O_CREAT|O_EXCL; - INTENT_INIT(&intent, INT_CREAT, &mode, &intent_mode); } else err = -EINVAL; if (err) return err; + INTENT_INIT(&intent, INT_CREAT|INT_UPDPARENT, &mode, &intent_mode); /* * Lookup the given path. @@ -497,7 +494,7 @@ do_creat(char *args) err = _sysio_namei(dir, v[1].ovi_value, - ND_NEGOK|ND_NOPERMCHECK, + ND_NEGOK|ND_NOPERMCHECK|ND_WANTPARENT, &intent, &pno); if (err) @@ -550,6 +547,7 @@ do_creat(char *args) abort(); } + P_PUT(pno->p_parent); P_PUT(pno); return err; } Index: link.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/link.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -w -b -B -p -r1.20 -r1.21 --- link.c 4 Aug 2009 05:52:23 -0000 1.20 +++ link.c 4 Aug 2009 15:01:24 -0000 1.21 @@ -105,7 +105,11 @@ SYSIO_INTERFACE_NAME(link)(const char *o break; INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = - _sysio_namei(_sysio_cwd, newpath, ND_NEGOK, &intent, &new); + _sysio_namei(_sysio_cwd, + newpath, + ND_NEGOK|ND_WANTPARENT, + &intent, + &new); if (err) break; if (new->p_base->pb_ino) { @@ -114,8 +118,10 @@ SYSIO_INTERFACE_NAME(link)(const char *o } err = _sysio_p_link(old, new); } while (0); - if (new) + if (new) { + P_PUT(new->p_parent); P_PUT(new); + } if (old) P_PUT(old); SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, link, "%d", 0); Index: mkdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mkdir.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -w -b -B -p -r1.24 -r1.25 --- mkdir.c 17 Jun 2008 17:18:57 -0000 1.24 +++ mkdir.c 4 Aug 2009 15:01:24 -0000 1.25 @@ -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-2007 Sandia Corporation. + * Cplant(TM) Copyright 1998-2009 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 @@ -36,7 +36,7 @@ * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 - * Albuquerque, NM 87185-1110 + * Albuquerque, NM 87185-1319 * * le...@sa... */ @@ -80,12 +80,18 @@ SYSIO_INTERFACE_NAME(mkdir)(const char * SYSIO_INTERFACE_ENTER(mkdir, "%s%mZ", path, mode); INTENT_INIT(&intent, INT_CREAT, &mode, NULL); - err = _sysio_namei(_sysio_cwd, path, ND_NEGOK, &intent, &pno); + err = + _sysio_namei(_sysio_cwd, + path, + ND_NEGOK|ND_WANTPARENT, + &intent, + &pno); if (err) goto out; mode &= ~(_sysio_umask & 0777); /* apply umask */ err = _sysio_mkdir(pno, mode); + P_PUT(pno->p_parent); P_PUT(pno); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, mkdir, "%d", 0); Index: mknod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/mknod.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -w -b -B -p -r1.23 -r1.24 --- mknod.c 17 Jun 2008 17:18:57 -0000 1.23 +++ mknod.c 4 Aug 2009 15:01:24 -0000 1.24 @@ -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-2007 Sandia Corporation. + * Cplant(TM) Copyright 1998-2009 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 @@ -36,7 +36,7 @@ * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 - * Albuquerque, NM 87185-1110 + * Albuquerque, NM 87185-1319 * * le...@sa... */ @@ -64,6 +64,7 @@ int _sysio_mknod(struct pnode *pno, mode_t mode, dev_t dev) { + int err; if (pno->p_base->pb_ino) return -EEXIST; @@ -77,6 +78,11 @@ _sysio_mknod(struct pnode *pno, mode_t m if (IS_RDONLY(pno)) return -EROFS; + + err = _sysio_permitted(pno->p_parent, W_OK); + if (err) + return err; + return PNOP_MKNOD(pno, mode, dev); } @@ -100,15 +106,18 @@ PREPEND(__, SYSIO_INTERFACE_NAME(xmknod) mode &= ~(_sysio_umask & 0777); /* apply umask */ INTENT_INIT(&intent, INT_CREAT, &mode, NULL); - err = _sysio_namei(_sysio_cwd, path, ND_NEGOK, &intent, &pno); + err = + _sysio_namei(_sysio_cwd, + path, + ND_NEGOK|ND_WANTPARENT, + &intent, + &pno); if (err) goto out; - err = _sysio_permitted(pno->p_parent, W_OK); - if (err) - goto error; err = _sysio_mknod(pno, mode, *dev); error: + P_PUT(pno->p_parent); P_PUT(pno); out: SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, xmknod, "%d", 0); Index: open.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/open.c,v retrieving revision 1.34 retrieving revision 1.35 diff -u -w -b -B -p -r1.34 -r1.35 --- open.c 6 Dec 2008 18:22:27 -0000 1.34 +++ open.c 4 Aug 2009 15:01:24 -0000 1.35 @@ -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-2007 Sandia Corporation. + * Cplant(TM) Copyright 1998-2009 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 @@ -36,7 +36,7 @@ * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 - * Albuquerque, NM 87185-1110 + * Albuquerque, NM 87185-1319 * * le...@sa... */ @@ -140,9 +140,11 @@ SYSIO_INTERFACE_NAME(open)(const char *p va_list ap; /* - * Set ndflags to indicate return of negative alias is OK. + * Set ndflags to indicate return of negative alias is OK and, + * since this is a create, we'll want a lock on the parent + * directory as well. */ - ndflags |= ND_NEGOK; + ndflags |= ND_NEGOK|ND_WANTPARENT; /* * Will need mode too. @@ -177,6 +179,7 @@ SYSIO_INTERFACE_NAME(open)(const char *p * Ask for the open/creat. */ rtn = _sysio_open(pno, flags, mode); + P_PUT(pno->p_parent); if (rtn) goto error; /* Index: rename.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rename.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -w -b -B -p -r1.16 -r1.17 --- rename.c 28 Jan 2009 16:13:19 -0000 1.16 +++ rename.c 4 Aug 2009 15:01:24 -0000 1.17 @@ -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-2007 Sandia Corporation. + * Cplant(TM) Copyright 1998-2009 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 @@ -160,15 +160,14 @@ SYSIO_INTERFACE_NAME(rename)(const char err = _sysio_namei(_sysio_cwd, oldpath, - ND_NOFOLLOW, + ND_NOFOLLOW|ND_WANTPARENT, &intent, &old); if (err) { old = NULL; break; } - P_REF(old); - P_PUT(old); + /* * Resolve newpath to a path node. */ @@ -176,25 +175,25 @@ SYSIO_INTERFACE_NAME(rename)(const char err = _sysio_namei(_sysio_cwd, newpath, - ND_NOFOLLOW | ND_NEGOK, + ND_NOFOLLOW|ND_NEGOK|ND_WANTPARENT, &intent, &new); if (err) { new = NULL; break; } - P_REF(new); - P_PUT(new); - _sysio_p_get2(old, new); err = _sysio_p_rename(old, new); - P_PUT(old); - P_PUT(new); } while (0); - if (new) - P_RELE(new); - if (old) - P_RELE(old); + if (new) { + P_PUT(new->p_parent); + P_PUT(new); + } + if (old) { + P_PUT(old->p_parent); + P_PUT(old); + } + SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, rename, "%d", 0); } Index: rmdir.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/rmdir.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -w -b -B -p -r1.24 -r1.25 --- rmdir.c 28 Jan 2009 16:13:19 -0000 1.24 +++ rmdir.c 4 Aug 2009 15:01:24 -0000 1.25 @@ -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-2007 Sandia Corporation. + * Cplant(TM) Copyright 1998-2009 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 @@ -36,7 +36,7 @@ * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 - * Albuquerque, NM 87185-1110 + * Albuquerque, NM 87185-1319 * * le...@sa... */ @@ -68,6 +68,9 @@ _sysio_p_rmdir(struct pnode *pno) return -ENOENT; /* huh? */ if (!S_ISDIR(pno->p_base->pb_ino->i_stbuf.st_mode)) return -ENOTDIR; + err = _sysio_permitted(pno->p_parent, W_OK); + if (err) + return err; /* * Don't allow unlink of a root or a mount point. */ @@ -98,20 +101,24 @@ SYSIO_INTERFACE_NAME(rmdir)(const char * SYSIO_INTERFACE_ENTER(rmdir, "%s", path); do { INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); - err = _sysio_namei(_sysio_cwd, path, 0, &intent, &pno); + err = + _sysio_namei(_sysio_cwd, + path, + ND_WANTPARENT, + &intent, + &pno); if (err) { pno = NULL; break; } - err = _sysio_permitted(pno->p_parent, W_OK); - if (err) - break; err = _sysio_p_rmdir(pno); if (err) break; } while (0); - if (pno) + if (pno) { + P_PUT(pno->p_parent); P_PUT(pno); + } SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, rmdir, "%d", 0); } Index: symlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/symlink.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -w -b -B -p -r1.21 -r1.22 --- symlink.c 28 Jan 2009 16:13:19 -0000 1.21 +++ symlink.c 4 Aug 2009 15:01:24 -0000 1.22 @@ -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-2007 Sandia Corporation. + * Cplant(TM) Copyright 1998-2009 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 @@ -36,7 +36,7 @@ * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 - * Albuquerque, NM 87185-1110 + * Albuquerque, NM 87185-1319 * * le...@sa... */ @@ -63,6 +63,9 @@ _sysio_p_symlink(const char *oldpath, st if (new->p_base->pb_ino) return -EEXIST; + err = _sysio_permitted(new->p_parent, W_OK); + if (err) + return err; if (IS_RDONLY(new->p_parent)) return -EROFS; return PNOP_SYMLINK(new, oldpath); @@ -80,22 +83,21 @@ SYSIO_INTERFACE_NAME(symlink)(const char err = 0; pno = NULL; do { - INTENT_INIT(&intent, INT_CREAT, NULL, NULL); + INTENT_INIT(&intent, INT_CREAT|INT_UPDPARENT, NULL, NULL); err = _sysio_namei(_sysio_cwd, newpath, - ND_NOFOLLOW|ND_NEGOK, + ND_NOFOLLOW|ND_NEGOK|ND_WANTPARENT, &intent, &pno); if (err) break; - err = _sysio_permitted(pno->p_parent, W_OK); - if (err) - break; err = _sysio_p_symlink(oldpath, pno); } while (0); - if (pno) + if (pno) { + P_PUT(pno->p_parent); P_PUT(pno); + } SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, symlink, "%d", 0); } Index: unlink.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/unlink.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -w -b -B -p -r1.22 -r1.23 --- unlink.c 28 Jan 2009 16:13:19 -0000 1.22 +++ unlink.c 4 Aug 2009 15:01:24 -0000 1.23 @@ -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-2007 Sandia Corporation. + * Cplant(TM) Copyright 1998-2009 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 @@ -36,7 +36,7 @@ * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 - * Albuquerque, NM 87185-1110 + * Albuquerque, NM 87185-1319 * * le...@sa... */ @@ -94,7 +94,11 @@ SYSIO_INTERFACE_NAME(unlink)(const char do { INTENT_INIT(&intent, INT_UPDPARENT, NULL, NULL); err = - _sysio_namei(_sysio_cwd, path, ND_NOFOLLOW, &intent, &pno); + _sysio_namei(_sysio_cwd, + path, + ND_NOFOLLOW|ND_WANTPARENT, + &intent, + &pno); if (err) { pno = NULL; break; @@ -106,8 +110,10 @@ SYSIO_INTERFACE_NAME(unlink)(const char if (err) break; } while (0); - if (pno) + if (pno) { + P_PUT(pno->p_parent); P_PUT(pno); + } SYSIO_INTERFACE_RETURN(err ? -1 : 0, err, unlink, "%d", 0); } |
From: Lee W. <lw...@us...> - 2009-08-04 14:19:11
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18445/src Modified Files: namei.c Log Message: The namei family now takes the ND_WANTPARENT flag as well. This new flag causes a lock to be taken on the parent of the returned pnode when the return indicates success. Updated copyright date and contact. Index: namei.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/namei.c,v retrieving revision 1.34 retrieving revision 1.35 diff -u -w -b -B -p -r1.34 -r1.35 --- namei.c 4 Feb 2009 19:17:42 -0000 1.34 +++ namei.c 4 Aug 2009 14:19:00 -0000 1.35 @@ -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-2007 Sandia Corporation. + * Cplant(TM) Copyright 1998-2009 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 @@ -36,7 +36,7 @@ * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 - * Albuquerque, NM 87185-1110 + * Albuquerque, NM 87185-1319 * * le...@sa... */ @@ -211,6 +211,7 @@ _sysio_path_walk(struct pnode *parent, s const char *path; struct qstr this, next; struct inode *ino; + int done; /* * NULL path? @@ -282,6 +283,7 @@ _sysio_path_walk(struct pnode *parent, s path = next.name; parent = NULL; err = 0; + done = 0; /* * Derecurse the path tree-walk. @@ -294,6 +296,11 @@ _sysio_path_walk(struct pnode *parent, s ssize_t cc; struct nameidata nameidata; + if (parent) { + P_PUT(parent); + parent = NULL; + } + if (nd->nd_slicnt >= MAX_SYMLINK) { err = -ELOOP; break; @@ -334,6 +341,10 @@ _sysio_path_walk(struct pnode *parent, s break; P_PUT(nd->nd_pno); nd->nd_pno = nameidata.nd_pno; + if (nd->nd_flags & ND_WANTPARENT) { + parent = nd->nd_pno->p_parent; + assert(P_ISLOCKED(parent) && parent->p_ref); + } ino = nd->nd_pno->p_base->pb_ino; } #ifdef AUTOMOUNT_FILE_NAME @@ -403,6 +414,10 @@ _sysio_path_walk(struct pnode *parent, s * Must go back top and retry with this * new pnode as parent. */ + if (parent) { + P_PUT(parent); + parent = NULL; + } continue; } err = 0; /* it never happened */ @@ -428,6 +443,8 @@ _sysio_path_walk(struct pnode *parent, s } nd->nd_path = this.name + this.len; _sysio_next_component(nd->nd_path, &next); + if (parent) + P_PUT(parent); parent = nd->nd_pno; nd->nd_pno = NULL; @@ -484,7 +501,7 @@ _sysio_path_walk(struct pnode *parent, s !next.len && (nd->nd_flags & ND_NEGOK)) err = 0; - break; + done = 1; } path = NULL; /* Stop that! */ /* @@ -499,14 +516,15 @@ _sysio_path_walk(struct pnode *parent, s * to include the path again. */ path = nd->nd_path; - } - /* - * Finished with the current parent. + * Also, the parent isn't really the parent. */ P_PUT(parent); parent = NULL; } + if (done) + break; + } /* * Trailing separators cause us to break from the loop with @@ -524,12 +542,19 @@ _sysio_path_walk(struct pnode *parent, s err = -ENOTDIR; } + if (parent) { + if (err || !(nd->nd_flags & ND_WANTPARENT)) { /* - * Put the parent if present. Either we have a dup of the original - * parent or an intermediate reference. + * Put the parent if present. Either we have a dup of + * the original parent or an intermediate reference. */ - if (parent) P_PUT(parent); + parent = NULL; + } + } else if (!err && (nd->nd_flags & ND_WANTPARENT)) { + parent = nd->nd_pno->p_parent; + P_GET(parent); + } /* * On error, we will want to drop the current |
From: Lee W. <lw...@us...> - 2009-08-04 14:19:10
|
Update of /cvsroot/libsysio/libsysio/include In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18445/include Modified Files: inode.h Log Message: The namei family now takes the ND_WANTPARENT flag as well. This new flag causes a lock to be taken on the parent of the returned pnode when the return indicates success. Updated copyright date and contact. Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.57 retrieving revision 1.58 diff -u -w -b -B -p -r1.57 -r1.58 --- inode.h 4 Aug 2009 05:46:24 -0000 1.57 +++ inode.h 4 Aug 2009 14:19:01 -0000 1.58 @@ -703,6 +703,7 @@ struct nameidata { #define ND_NEGOK 0x02 /* last missing is ok */ #define ND_NOPERMCHECK 0x04 /* don't check perms */ #define ND_NXMNT 0x08 /* don't cross mounts */ +#define ND_WANTPARENT 0x0a /* want parent too */ #ifdef AUTOMOUNT_FILE_NAME #define _ND_INIT_AUTOMOUNT(nd) ((nd)->nd_amcnt = 0) |
From: Lee W. <lw...@us...> - 2009-08-04 06:04:08
|
Update of /cvsroot/libsysio/libsysio/misc In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv12485 Modified Files: fhi.c Log Message: In fhi_link, added a check to make sure the new pnode was not already associated. Index: fhi.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/misc/fhi.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -b -B -p -r1.4 -r1.5 --- fhi.c 3 Aug 2009 23:18:52 -0000 1.4 +++ fhi.c 4 Aug 2009 06:03:58 -0000 1.5 @@ -889,6 +889,10 @@ SYSIO_INTERFACE_NAME(fhi_link)(struct fi &new); if (err) break; + if (new->p_base->pb_ino) { + err = -EEXIST; + break; + } err = _sysio_p_link(old, new); } while (0); if (new) @@ -901,8 +905,6 @@ SYSIO_INTERFACE_NAME(fhi_link)(struct fi fhi_link, "%d", 0); - - return err; } int |