Re: [PATCH] VFS: filename_create(): fix incorrect intent.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 30 Mar 2022, David Disseldorp wrote:
> Hi Neil,
> 
> I gave this a spin and was wondering why xfstests wouldn't start with
> this change...
> 
> On Mon, 28 Mar 2022 11:56:48 +1100, NeilBrown wrote:
> ...
> > 
> > diff --git a/fs/namei.c b/fs/namei.c
> > index 3f1829b3ab5b..3ffb42e56a8e 100644
> > --- a/fs/namei.c
> > +++ b/fs/namei.c
> > @@ -3676,7 +3676,6 @@ static struct dentry *filename_create(int dfd, struct filename *name,
> >  	int type;
> >  	int err2;
> >  	int error;
> > -	bool is_dir = (lookup_flags & LOOKUP_DIRECTORY);
> >  
> >  	/*
> >  	 * Note that only LOOKUP_REVAL and LOOKUP_DIRECTORY matter here. Any
> > @@ -3698,9 +3697,11 @@ static struct dentry *filename_create(int dfd, struct filename *name,
> >  	/* don't fail immediately if it's r/o, at least try to report other errors */
> >  	err2 = mnt_want_write(path->mnt);
> >  	/*
> > -	 * Do the final lookup.
> > +	 * Do the final lookup.  Request 'create' only if there is no trailing
> > +	 * '/', or if directory is requested.
> >  	 */
> > -	lookup_flags |= LOOKUP_CREATE | LOOKUP_EXCL;
> > +	if (!last.name[last.len] || (lookup_flags & LOOKUP_DIRECTORY))
> > +		lookup_flags |= LOOKUP_CREATE | LOOKUP_EXCL;
> 
> This doesn't look right, as any LOOKUP_DIRECTORY flag gets dropped via
> the prior "lookup_flags &= LOOKUP_REVAL;".

Arg.. thanks for testing - I clearly should have tested more broadly.

I could leave the "is_dir" variable there I guess.
Or maybe the masking statement should be 
    lookup_flags &= LOOKUP_REVAL | LOOKUP_DIRECTORY;
as that is a better match for the comment.

Thanks,
NeilBrown




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux