mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 02:43:15 +01:00
Fixed the component-consumption-every-lookup problem.
Now components only consumed on child lookup recursions.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user