Re: [PATCH 1/1] fs: add 4th case to do_path_lookup

From: Christoph Hellwig
Date: Fri May 04 2007 - 03:28:05 EST


sorry, I proposed Jeff a reply long ago but haven't done yet.

On Fri, May 04, 2007 at 12:02:00AM -0700, Andrew Morton wrote:
> > @@ -1125,6 +1125,10 @@ static int fastcall do_path_lookup(int dfd, const char *name,
> > nd->mnt = mntget(fs->rootmnt);
> > nd->dentry = dget(fs->root);
> > read_unlock(&fs->lock);
> > + } else if (flags & LOOKUP_ONE) {
> > + /* nd->mnt and nd->dentry already set, just grab references */
> > + mntget(nd->mnt);
> > + dget(nd->dentry);
> > } else if (dfd == AT_FDCWD) {
> > read_lock(&fs->lock);
> > nd->mnt = mntget(fs->pwdmnt);
>
> Well the patch passes my too-small-to-care-about test ;)
>
> Unless someone objects I'd suggest that you add it to the unionfs tree.

The code is obviously correct. There is one little thing that bothers
me, and that's that nd was purely an output paramter to path_lookup and
do_path_lookup, and no it's an input paramter for the least used case.
It might make sense to just a simple helper ala:



static int path_component_lookup(struct dentry *dentry, struct vfsmount *mnt,
const char *name, unsigned int flags, struct nameidata *nd)
{
int retval;

nd->last_type = LAST_ROOT;
nd->flags = flags;
nd->mnt = mntget(mnt);
nd->dentry = dget(dentry);
nd->depth = 0;

retval = path_walk(name, nd);
if (unlikely(!retval && !audit_dummy_context() &&
nd->dentry && nd->dentry->d_inode))
audit_inode(name, nd->dentry->d_inode);

return retval;

}

instead.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/