Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 2953
b: refs/heads/master
c: c663e5d
h: refs/heads/master
i:
  2951: eec2f51
v: v3
  • Loading branch information
Christoph Hellwig authored and Linus Torvalds committed Jun 23, 2005
1 parent b757c44 commit 4096dea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 70f09f1fdf38cd7fca39913978d18cf998ab2c80
refs/heads/master: c663e5d80ebec426916ad2aa5400c7ec99aa572e
20 changes: 18 additions & 2 deletions trunk/fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1577,19 +1577,35 @@ int open_namei(const char * pathname, int flag, int mode, struct nameidata *nd)
*
* 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;
Expand Down

0 comments on commit 4096dea

Please sign in to comment.