diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2012-06-05 09:10:13 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-14 08:32:59 -0400 |
commit | b6183df7b294997a748eeb9991daa126986ead12 (patch) | |
tree | 7ddfc09b76beabfd7f69b6da7b60a65cbfe9c8d6 /fs | |
parent | 37d7fffc9cafe75ded8a840fa30ba625f99ed7ae (diff) |
vfs: do_last(): separate O_CREAT specific code
Check O_CREAT on the slow lookup paths where necessary. This allows the rest to
be shared with plain open.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/namei.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/fs/namei.c b/fs/namei.c index 68742e3cb98d..12ed29712b4e 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -2274,22 +2274,23 @@ static struct file *do_last(struct nameidata *nd, struct path *path, | |||
2274 | inode = path->dentry->d_inode; | 2274 | inode = path->dentry->d_inode; |
2275 | } | 2275 | } |
2276 | goto finish_lookup; | 2276 | goto finish_lookup; |
2277 | } | 2277 | } else { |
2278 | 2278 | /* create side of things */ | |
2279 | /* create side of things */ | 2279 | /* |
2280 | /* | 2280 | * This will *only* deal with leaving RCU mode - LOOKUP_JUMPED |
2281 | * This will *only* deal with leaving RCU mode - LOOKUP_JUMPED has been | 2281 | * has been cleared when we got to the last component we are |
2282 | * cleared when we got to the last component we are about to look up | 2282 | * about to look up |
2283 | */ | 2283 | */ |
2284 | error = complete_walk(nd); | 2284 | error = complete_walk(nd); |
2285 | if (error) | 2285 | if (error) |
2286 | return ERR_PTR(error); | 2286 | return ERR_PTR(error); |
2287 | 2287 | ||
2288 | audit_inode(pathname, dir); | 2288 | audit_inode(pathname, dir); |
2289 | error = -EISDIR; | 2289 | error = -EISDIR; |
2290 | /* trailing slashes? */ | 2290 | /* trailing slashes? */ |
2291 | if (nd->last.name[nd->last.len]) | 2291 | if (nd->last.name[nd->last.len]) |
2292 | goto exit; | 2292 | goto exit; |
2293 | } | ||
2293 | 2294 | ||
2294 | retry_lookup: | 2295 | retry_lookup: |
2295 | mutex_lock(&dir->d_inode->i_mutex); | 2296 | mutex_lock(&dir->d_inode->i_mutex); |
@@ -2305,7 +2306,7 @@ retry_lookup: | |||
2305 | path->mnt = nd->path.mnt; | 2306 | path->mnt = nd->path.mnt; |
2306 | 2307 | ||
2307 | /* Negative dentry, just create the file */ | 2308 | /* Negative dentry, just create the file */ |
2308 | if (!dentry->d_inode) { | 2309 | if (!dentry->d_inode && (open_flag & O_CREAT)) { |
2309 | umode_t mode = op->mode; | 2310 | umode_t mode = op->mode; |
2310 | if (!IS_POSIXACL(dir->d_inode)) | 2311 | if (!IS_POSIXACL(dir->d_inode)) |
2311 | mode &= ~current_umask(); | 2312 | mode &= ~current_umask(); |