Commit b6183df7b294997a748eeb9991daa126986ead12
Committed by
Al Viro
1 parent
37d7fffc9c
Exists in
master
and in
20 other branches
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>
Showing 1 changed file with 17 additions and 16 deletions Side-by-side Diff
fs/namei.c
... | ... | @@ -2274,23 +2274,24 @@ |
2274 | 2274 | inode = path->dentry->d_inode; |
2275 | 2275 | } |
2276 | 2276 | goto finish_lookup; |
2277 | + } else { | |
2278 | + /* create side of things */ | |
2279 | + /* | |
2280 | + * This will *only* deal with leaving RCU mode - LOOKUP_JUMPED | |
2281 | + * has been cleared when we got to the last component we are | |
2282 | + * about to look up | |
2283 | + */ | |
2284 | + error = complete_walk(nd); | |
2285 | + if (error) | |
2286 | + return ERR_PTR(error); | |
2287 | + | |
2288 | + audit_inode(pathname, dir); | |
2289 | + error = -EISDIR; | |
2290 | + /* trailing slashes? */ | |
2291 | + if (nd->last.name[nd->last.len]) | |
2292 | + goto exit; | |
2277 | 2293 | } |
2278 | 2294 | |
2279 | - /* create side of things */ | |
2280 | - /* | |
2281 | - * This will *only* deal with leaving RCU mode - LOOKUP_JUMPED has been | |
2282 | - * cleared when we got to the last component we are about to look up | |
2283 | - */ | |
2284 | - error = complete_walk(nd); | |
2285 | - if (error) | |
2286 | - return ERR_PTR(error); | |
2287 | - | |
2288 | - audit_inode(pathname, dir); | |
2289 | - error = -EISDIR; | |
2290 | - /* trailing slashes? */ | |
2291 | - if (nd->last.name[nd->last.len]) | |
2292 | - goto exit; | |
2293 | - | |
2294 | 2295 | retry_lookup: |
2295 | 2296 | mutex_lock(&dir->d_inode->i_mutex); |
2296 | 2297 | |
... | ... | @@ -2305,7 +2306,7 @@ |
2305 | 2306 | path->mnt = nd->path.mnt; |
2306 | 2307 | |
2307 | 2308 | /* Negative dentry, just create the file */ |
2308 | - if (!dentry->d_inode) { | |
2309 | + if (!dentry->d_inode && (open_flag & O_CREAT)) { | |
2309 | 2310 | umode_t mode = op->mode; |
2310 | 2311 | if (!IS_POSIXACL(dir->d_inode)) |
2311 | 2312 | mode &= ~current_umask(); |