[AF_UNIX]: Use lookup_create().
currently it opencodes it, but that's in the way of chaning the lookup_hash interface. I'd prefer to disallow modular af_unix over exporting lookup_create, but I'll leave that to you. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
2fdba6b085
commit
f81a0bffa1
2 changed files with 4 additions and 25 deletions
|
@ -1580,6 +1580,7 @@ struct dentry *lookup_create(struct nameidata *nd, int is_dir)
|
||||||
fail:
|
fail:
|
||||||
return dentry;
|
return dentry;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(lookup_create);
|
||||||
|
|
||||||
int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
|
int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
|
||||||
{
|
{
|
||||||
|
|
|
@ -770,33 +770,12 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
|
||||||
err = path_lookup(sunaddr->sun_path, LOOKUP_PARENT, &nd);
|
err = path_lookup(sunaddr->sun_path, LOOKUP_PARENT, &nd);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_mknod_parent;
|
goto out_mknod_parent;
|
||||||
/*
|
|
||||||
* Yucky last component or no last component at all?
|
dentry = lookup_create(&nd, 0);
|
||||||
* (foo/., foo/.., /////)
|
|
||||||
*/
|
|
||||||
err = -EEXIST;
|
|
||||||
if (nd.last_type != LAST_NORM)
|
|
||||||
goto out_mknod;
|
|
||||||
/*
|
|
||||||
* Lock the directory.
|
|
||||||
*/
|
|
||||||
down(&nd.dentry->d_inode->i_sem);
|
|
||||||
/*
|
|
||||||
* Do the final lookup.
|
|
||||||
*/
|
|
||||||
dentry = lookup_hash(&nd.last, nd.dentry);
|
|
||||||
err = PTR_ERR(dentry);
|
err = PTR_ERR(dentry);
|
||||||
if (IS_ERR(dentry))
|
if (IS_ERR(dentry))
|
||||||
goto out_mknod_unlock;
|
goto out_mknod_unlock;
|
||||||
err = -ENOENT;
|
|
||||||
/*
|
|
||||||
* Special case - lookup gave negative, but... we had foo/bar/
|
|
||||||
* From the vfs_mknod() POV we just have a negative dentry -
|
|
||||||
* all is fine. Let's be bastards - you had / on the end, you've
|
|
||||||
* been asking for (non-existent) directory. -ENOENT for you.
|
|
||||||
*/
|
|
||||||
if (nd.last.name[nd.last.len] && !dentry->d_inode)
|
|
||||||
goto out_mknod_dput;
|
|
||||||
/*
|
/*
|
||||||
* All right, let's create it.
|
* All right, let's create it.
|
||||||
*/
|
*/
|
||||||
|
@ -845,7 +824,6 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
|
||||||
dput(dentry);
|
dput(dentry);
|
||||||
out_mknod_unlock:
|
out_mknod_unlock:
|
||||||
up(&nd.dentry->d_inode->i_sem);
|
up(&nd.dentry->d_inode->i_sem);
|
||||||
out_mknod:
|
|
||||||
path_release(&nd);
|
path_release(&nd);
|
||||||
out_mknod_parent:
|
out_mknod_parent:
|
||||||
if (err==-EEXIST)
|
if (err==-EEXIST)
|
||||||
|
|
Loading…
Reference in a new issue