Root was a child of itself, removed that relationship.

Root is only a parent of itself, it shouldn't show up in its children.
This commit is contained in:
Bahadir Balban
2008-04-16 00:20:59 +01:00
parent ab588c279b
commit e722ee0115
3 changed files with 8 additions and 9 deletions

View File

@@ -46,10 +46,8 @@ struct vnode *generic_vnode_lookup(struct vnode *thisnode,
struct vnode *found;
int err;
printf("looking up: %s\n", component);
/* Does this path component match with any of this vnode's dentries? */
list_for_each_entry(d, &thisnode->dentries, vref) {
printf("comparing dentry %s with %s\n", d->name, component);
if (d->ops.compare(d, component)) {
/* Is this a directory? */
if (vfs_isdir(thisnode)) {

View File

@@ -136,8 +136,12 @@ int memfs_init_rootdir(struct superblock *sb)
return -ENOMEM;
/*
* Initialise it.
* NOTE: On root, parent is itself.
* Initialise root dentry.
*
* NOTE: Root's parent is itself.
* Here's how it looks like in structures:
* root's parent is root. But root's child is not root.
*
* NOTE: Root has no name. This helps since splitpath
* cuts out the '/' and "" is left for root name search.
*/
@@ -149,9 +153,6 @@ int memfs_init_rootdir(struct superblock *sb)
/* Associate dentry with its vnode */
list_add(&d->vref, &d->vnode->dentries);
/* Associate dentry with its parent */
list_add(&d->child, &d->children);
/* Add both vnode and dentry to their flat caches */
list_add(&d->cache_list, &dentry_cache);
list_add(&v->cache_list, &vnode_cache);

View File

@@ -48,7 +48,7 @@ void print_vnode(struct vnode *v)
{
struct dentry *d, *c;
printf("Vnode name:\n");
printf("Vnode names:\n");
list_for_each_entry(d, &v->dentries, vref) {
printf("%s\n", d->name);
printf("Children dentries:\n");
@@ -79,7 +79,7 @@ int vfs_create(struct tcb *task, struct pathdata *pdata, unsigned int mode)
if ((err = vparent->ops.mknod(vparent, nodename, mode)) < 0)
return err;
// print_vnode(vparent);
print_vnode(vparent);
return 0;
}