Commit f81a0bffa116ea22149aa7cfb0b4ee09096d9d92

Authored by Christoph Hellwig
Committed by David S. Miller
1 parent 2fdba6b085

[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>

Showing 2 changed files with 4 additions and 25 deletions Side-by-side Diff

... ... @@ -1580,6 +1580,7 @@
1580 1580 fail:
1581 1581 return dentry;
1582 1582 }
  1583 +EXPORT_SYMBOL_GPL(lookup_create);
1583 1584  
1584 1585 int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
1585 1586 {
... ... @@ -770,34 +770,13 @@
770 770 err = path_lookup(sunaddr->sun_path, LOOKUP_PARENT, &nd);
771 771 if (err)
772 772 goto out_mknod_parent;
773   - /*
774   - * Yucky last component or no last component at all?
775   - * (foo/., foo/.., /////)
776   - */
777   - err = -EEXIST;
778   - if (nd.last_type != LAST_NORM)
779   - goto out_mknod;
780   - /*
781   - * Lock the directory.
782   - */
783   - down(&nd.dentry->d_inode->i_sem);
784   - /*
785   - * Do the final lookup.
786   - */
787   - dentry = lookup_hash(&nd.last, nd.dentry);
  773 +
  774 + dentry = lookup_create(&nd, 0);
788 775 err = PTR_ERR(dentry);
789 776 if (IS_ERR(dentry))
790 777 goto out_mknod_unlock;
791   - err = -ENOENT;
  778 +
792 779 /*
793   - * Special case - lookup gave negative, but... we had foo/bar/
794   - * From the vfs_mknod() POV we just have a negative dentry -
795   - * all is fine. Let's be bastards - you had / on the end, you've
796   - * been asking for (non-existent) directory. -ENOENT for you.
797   - */
798   - if (nd.last.name[nd.last.len] && !dentry->d_inode)
799   - goto out_mknod_dput;
800   - /*
801 780 * All right, let's create it.
802 781 */
803 782 mode = S_IFSOCK |
... ... @@ -845,7 +824,6 @@
845 824 dput(dentry);
846 825 out_mknod_unlock:
847 826 up(&nd.dentry->d_inode->i_sem);
848   -out_mknod:
849 827 path_release(&nd);
850 828 out_mknod_parent:
851 829 if (err==-EEXIST)