use lookup_create in af_unix
Subsystems (4)
PATCH 1/1 use lookup_create in af_unix
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.
fs/namei.c (mode:100644) renamed from fs/namei.c (mode:100644 sha1:defe6781e003c208fc0a4b6e92bcf1dc2a0465de) +1 -0
@@ -1580,6 +1580,7 @@ fail: return dentry; } +EXPORT_SYMBOL_GPL(lookup_create); int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) {
net/unix/af_unix.c (mode:100644) renamed from net/unix/af_unix.c (mode:100644 sha1:c478fc8db7768428580d23381856fa53fa31add2) +3 -25
@@ -770,33 +770,12 @@ err = path_lookup(sunaddr->sun_path, LOOKUP_PARENT, &nd); if (err) goto out_mknod_parent; - /* - * Yucky last component or no last component at all? - * (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); + + dentry = lookup_create(&nd, 0); err = PTR_ERR(dentry); if (IS_ERR(dentry)) 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. */
@@ -845,7 +824,6 @@ dput(dentry); out_mknod_unlock: up(&nd.dentry->d_inode->i_sem); -out_mknod: path_release(&nd); out_mknod_parent: if (err==-EEXIST)
David S. Miller
maintainerFrom: Christoph Hellwig <[email protected]>
Date: Thu, 12 May 2005 12:23:36 +0200
Quoted 7 lines
currently it opencodes it, but that's in the way of chaning the
lookup_hashinterface.I'd prefer to disallow modular
af_unixover exportinglookup_create, but I'll leave that to you.Signed-off-by Christoph Hellwig <[email protected]>
This patch looks fine. Applied, thanks Chirstophe.
Maybe someone should add to the comments above these fs/namei.c functions that they will return with the semaphore held even in error cases.
Quoted 3 lines · David S. Miller
Maybe someone should add to the comments above these
fs/namei.cfunctions that they will return with the semaphore held even in error cases.
I sent a patch to Andrew that adds this comment and various others that were in af_unix.c to lookup_create.
David S. Miller
maintainerFrom: Christoph Hellwig <[email protected]>
Date: Thu, 19 May 2005 21:30:06 +0200
Quoted 2 lines
I sent a patch to Andrew that adds this comment and various others that were in
af_unix.ctolookup_create.
That's great, thanks a lot.