From ab588c279b2632e189c75ef44d76720d1429fe4c Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Wed, 16 Apr 2008 00:04:54 +0100 Subject: [PATCH] Fixed the component-consumption-every-lookup problem. Now components only consumed on child lookup recursions. --- tasks/fs0/include/fs.h | 3 ++- tasks/fs0/include/vfs.h | 3 ++- tasks/fs0/src/lookup.c | 8 ++++---- tasks/fs0/src/vfs.c | 4 +++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tasks/fs0/include/fs.h b/tasks/fs0/include/fs.h index d60f685..d2403fa 100644 --- a/tasks/fs0/include/fs.h +++ b/tasks/fs0/include/fs.h @@ -46,7 +46,8 @@ struct file_ops { /* Operations that work on vnode fields and associations between vnodes */ struct vnode_ops { vnode_op_t create; - struct vnode *(*lookup)(struct vnode *root, struct pathdata *pdata); + struct vnode *(*lookup)(struct vnode *root, struct pathdata *pdata, + char *component); int (*readdir)(struct vnode *v); int (*filldir)(void *buf, struct vnode *v, int count); vnode_op_t link; diff --git a/tasks/fs0/include/vfs.h b/tasks/fs0/include/vfs.h index 2d24346..876181f 100644 --- a/tasks/fs0/include/vfs.h +++ b/tasks/fs0/include/vfs.h @@ -82,7 +82,8 @@ struct vfs_mountpoint { extern struct vfs_mountpoint vfs_root; int vfs_mount_root(struct superblock *sb); -struct vnode *generic_vnode_lookup(struct vnode *thisnode, struct pathdata *p); +struct vnode *generic_vnode_lookup(struct vnode *thisnode, struct pathdata *p, + char *component); struct vnode *vfs_lookup_bypath(struct pathdata *p); struct vnode *vfs_lookup_byvnum(struct superblock *sb, unsigned long vnum); diff --git a/tasks/fs0/src/lookup.c b/tasks/fs0/src/lookup.c index b23d384..489bf7a 100644 --- a/tasks/fs0/src/lookup.c +++ b/tasks/fs0/src/lookup.c @@ -20,10 +20,11 @@ struct vnode *lookup_dentry_children(struct dentry *parentdir, { struct dentry *childdir; struct vnode *v; + char *component = pathdata_next_component(pdata); list_for_each_entry(childdir, &parentdir->children, child) if (IS_ERR(v = childdir->vnode->ops.lookup(childdir->vnode, - pdata))) + pdata, component))) /* Means not found, continue search */ if ((int)v == -ENOENT) continue; @@ -38,14 +39,13 @@ struct vnode *lookup_dentry_children(struct dentry *parentdir, /* Lookup, recursive, assuming single-mountpoint */ struct vnode *generic_vnode_lookup(struct vnode *thisnode, - struct pathdata *pdata) + struct pathdata *pdata, + char *component) { - char *component; struct dentry *d; struct vnode *found; int err; - component = pathdata_next_component(pdata); 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) { diff --git a/tasks/fs0/src/vfs.c b/tasks/fs0/src/vfs.c index b9985b8..f2ea262 100644 --- a/tasks/fs0/src/vfs.c +++ b/tasks/fs0/src/vfs.c @@ -61,6 +61,7 @@ struct vnode *vfs_lookup_byvnum(struct superblock *sb, unsigned long vnum) struct vnode *vfs_lookup_bypath(struct pathdata *pdata) { struct vnode *vstart; + char *firstcomp; /* Do we start from root or curdir? */ if (pdata->root) @@ -72,7 +73,8 @@ struct vnode *vfs_lookup_bypath(struct pathdata *pdata) * This does vfs cache + fs lookup. */ BUG_ON(list_empty(&pdata->list)); - return vstart->ops.lookup(vstart, pdata); + firstcomp = pathdata_next_component(pdata); + return vstart->ops.lookup(vstart, pdata, firstcomp); } int vfs_mount_root(struct superblock *sb)