summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2005-06-23 00:09:49 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-23 09:45:26 -0700
commitc663e5d80ebec426916ad2aa5400c7ec99aa572e (patch)
tree463dd4600525e536ed00579fa30bab9708c53824 /fs
parent70f09f1fdf38cd7fca39913978d18cf998ab2c80 (diff)
downloadop-kernel-dev-c663e5d80ebec426916ad2aa5400c7ec99aa572e.zip
op-kernel-dev-c663e5d80ebec426916ad2aa5400c7ec99aa572e.tar.gz
[PATCH] add some comments to lookup_create()
In a duplicate of lookup_create in the af_unix code Al commented what's going on nicely, so let's bring that over to lookup_create before the copy is going away (I'll send a patch soon) Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/namei.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/fs/namei.c b/fs/namei.c
index a7f7f44..fa8df81 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1577,19 +1577,35 @@ do_link:
*
* Simple function to lookup and return a dentry and create it
* if it doesn't exist. Is SMP-safe.
+ *
+ * Returns with nd->dentry->d_inode->i_sem locked.
*/
struct dentry *lookup_create(struct nameidata *nd, int is_dir)
{
- struct dentry *dentry;
+ struct dentry *dentry = ERR_PTR(-EEXIST);
down(&nd->dentry->d_inode->i_sem);
- dentry = ERR_PTR(-EEXIST);
+ /*
+ * Yucky last component or no last component at all?
+ * (foo/., foo/.., /////)
+ */
if (nd->last_type != LAST_NORM)
goto fail;
nd->flags &= ~LOOKUP_PARENT;
+
+ /*
+ * Do the final lookup.
+ */
dentry = lookup_hash(&nd->last, nd->dentry);
if (IS_ERR(dentry))
goto fail;
+
+ /*
+ * 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 (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
goto enoent;
return dentry;
OpenPOWER on IntegriCloud