[Libsysio-commit] HEAD: libsysio/src chdir.c inode.c mount.c
Brought to you by:
lward
|
From: Lee W. <lw...@us...> - 2003-08-26 15:54:04
|
Update of /cvsroot/libsysio/libsysio/src
In directory sc8-pr-cvs1:/tmp/cvs-serv10929/src
Modified Files:
chdir.c inode.c mount.c
Log Message:
Fixed the bug in get{c}wd where names of sub-mounts were ommitted from the
returned string.
Path alias nodes now have their parent pointing at the parent of the
bottom-most, covered node. No need to look for mount-point crossing when
ascending the tree.
Index: chdir.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/chdir.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -b -B -p -r1.4 -r1.5
--- chdir.c 14 Aug 2003 18:39:33 -0000 1.4
+++ chdir.c 26 Aug 2003 15:53:59 -0000 1.5
@@ -98,62 +98,6 @@ chdir(const char *path)
return 0;
}
-char *
-getwd(char *buf)
-{
- size_t len, n;
- struct pnode *tmp;
- char *cp;
-
- /*
- * First pass: Traverse to the root of the sub-tree, remembering
- * lengths.
- */
- len = 0;
- tmp = _sysio_cwd;
- do {
- n = tmp->p_base->pb_name.len;
- len += tmp->p_base->pb_name.len;
- if (n)
- len++;
- tmp = tmp->p_parent;
- /*
- * Traverse mount points.
- */
- while (tmp->p_mount->mnt_root == tmp &&
- tmp != tmp->p_mount->mnt_covers)
- tmp = tmp->p_mount->mnt_root;
- } while (tmp != tmp->p_parent);
- if (!len)
- len++;
- /*
- * Fill in the path buffer -- Backwards, since we're starting
- * from the end.
- */
- cp = buf;
- *cp = PATH_SEPARATOR;
- cp += len;
- *cp = '\0'; /* NUL term */
- tmp = _sysio_cwd;
- do {
- cp -= tmp->p_base->pb_name.len;
- n = tmp->p_base->pb_name.len;
- if (n) {
- (void )strncpy(cp, tmp->p_base->pb_name.name, n);
- *--cp = PATH_SEPARATOR;
- }
- tmp = tmp->p_parent;
- /*
- * Traverse mount points.
- */
- while (tmp->p_mount->mnt_root == tmp &&
- tmp != tmp->p_mount->mnt_covers)
- tmp = tmp->p_mount->mnt_root;
- } while (tmp != tmp->p_parent);
-
- return buf;
-}
-
/*
* Return path tracked by the path ancestor chain.
*
@@ -178,12 +122,6 @@ _sysio_p_path(struct pnode *pno, char **
n = 0;
do {
/*
- * Traverse back through mounts.
- */
- while (pno->p_mount->mnt_root == pno &&
- pno != pno->p_mount->mnt_covers)
- pno = pno->p_mount->mnt_root;
- /*
* Add length of this component to running sum and
* account for this vertex.
*/
@@ -217,12 +155,6 @@ _sysio_p_path(struct pnode *pno, char **
*cp = '\0'; /* NUL terminate */
do {
/*
- * Traverse back through mounts.
- */
- while (pno->p_mount->mnt_root == pno &&
- pno != pno->p_mount->mnt_covers)
- pno = pno->p_mount->mnt_root;
- /*
* Add component and separator.
*/
cp -= pno->p_base->pb_name.len;
@@ -257,3 +189,14 @@ __getcwd(char *buf, size_t size)
}
#endif
+#ifdef PATH_MAX
+char *
+getwd(char *buf)
+{
+
+ if (!buf)
+ return -EFAULT;
+
+ return getcwd(buf, PATH_MAX);
+}
+#endif
Index: inode.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -b -B -p -r1.8 -r1.9
--- inode.c 25 Jul 2003 14:45:34 -0000 1.8
+++ inode.c 26 Aug 2003 15:53:59 -0000 1.9
@@ -497,43 +497,19 @@ _sysio_p_gone(struct pnode *pno)
int
_sysio_p_validate(struct pnode *pno, struct intent *intnt, const char *path)
{
- struct pnode *parent;
- int err;
struct inode *ino;
+ struct pnode_base *rootpb;
+ int err;
- err = 0;
-
- /*
- * Make sure we can use the parent. We don't validate that
- * unless we have to. Beware of this! It's assuming the caller
- * recently revalidated. Namei will do this for instance.
- */
- parent = pno->p_parent;
- if (!parent->p_base->pb_ino) {
- err = _sysio_p_validate(parent, NULL, NULL);
- if (err) {
+ ino = pno->p_base->pb_ino;
/*
- * I really, really want to smash the association
- * of the passed path node with it's i-node. Can't
- * do it, though, since at least one FS driver can
- * still accomplish IO accesses to the currently
- * held i-node. For now, the driver needs to
- * record that the i-node has become (semi) invalid
- * and return appropriate errors itself.
- *
- * We *might* be able to do this, now, with the
- * recent changes to the open file table. Must check
- * on it. It is so annoying to have these half
- * dead i-nodes hanging around.
+ * An invalid pnode will not have an associated inode. We'll use
+ * the FS root inode, then -- It *must* be valid.
*/
- return err;
- }
- }
-
- ino = pno->p_base->pb_ino;
- if (!err)
+ rootpb = pno->p_mount->mnt_root->p_base;
+ assert(rootpb->pb_ino);
err =
- parent->p_base->pb_ino->i_ops.inop_lookup(pno,
+ rootpb->pb_ino->i_ops.inop_lookup(pno,
&ino,
intnt,
path);
Index: mount.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/src/mount.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -b -B -p -r1.6 -r1.7
--- mount.c 26 Aug 2003 13:17:20 -0000 1.6
+++ mount.c 26 Aug 2003 15:53:59 -0000 1.7
@@ -106,8 +106,8 @@ _sysio_do_mount(struct filesys *fs,
struct inode *ino;
/*
- * It's really poor form to allow the new root to be
- * descendant of the pnode being covered.the one being covered.
+ * It's really poor form to allow the new root to be a
+ * descendant of the pnode being covered.
*/
if (tocover) {
struct pnode_base *pb;
@@ -142,7 +142,8 @@ _sysio_do_mount(struct filesys *fs,
/*
* Get alias for the new root.
*/
- mnt->mnt_root = _sysio_p_new_alias(NULL, rootpb, mnt);
+ mnt->mnt_root =
+ _sysio_p_new_alias(tocover ? tocover->p_parent : NULL, rootpb, mnt);
if (!mnt->mnt_root) {
err = -ENOMEM;
goto error;
|