diff options
| author | Miklos Szeredi <mszeredi@suse.cz> | 2012-05-21 11:30:14 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-06-01 12:12:00 -0400 |
| commit | 5f5daac12a4cef568d1269be0215fec0667193c1 (patch) | |
| tree | fd580ca7c35d607fd9267499193ec1a93b656cc1 | |
| parent | d7fdd7f6e1afbffda03aeacb90039c092e8cacf8 (diff) | |
vfs: do_last() common post lookup
Now the post lookup code can be shared between O_CREAT and plain opens since
they are essentially the same.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| -rw-r--r-- | fs/namei.c | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/fs/namei.c b/fs/namei.c index 125386c250bb..998d5316921a 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
| @@ -2249,37 +2249,7 @@ static struct file *do_last(struct nameidata *nd, struct path *path, | |||
| 2249 | 2249 | ||
| 2250 | inode = path->dentry->d_inode; | 2250 | inode = path->dentry->d_inode; |
| 2251 | } | 2251 | } |
| 2252 | error = -ENOENT; | 2252 | goto finish_lookup; |
| 2253 | if (!inode) { | ||
| 2254 | path_to_nameidata(path, nd); | ||
| 2255 | goto exit; | ||
| 2256 | } | ||
| 2257 | |||
| 2258 | if (should_follow_link(inode, !symlink_ok)) { | ||
| 2259 | if (nd->flags & LOOKUP_RCU) { | ||
| 2260 | if (unlikely(unlazy_walk(nd, path->dentry))) { | ||
| 2261 | error = -ECHILD; | ||
| 2262 | goto exit; | ||
| 2263 | } | ||
| 2264 | } | ||
| 2265 | BUG_ON(inode != path->dentry->d_inode); | ||
| 2266 | return NULL; | ||
| 2267 | } | ||
| 2268 | path_to_nameidata(path, nd); | ||
| 2269 | nd->inode = inode; | ||
| 2270 | |||
| 2271 | /* sayonara */ | ||
| 2272 | error = complete_walk(nd); | ||
| 2273 | if (error) | ||
| 2274 | return ERR_PTR(error); | ||
| 2275 | |||
| 2276 | error = -ENOTDIR; | ||
| 2277 | if (nd->flags & LOOKUP_DIRECTORY) { | ||
| 2278 | if (!nd->inode->i_op->lookup) | ||
| 2279 | goto exit; | ||
| 2280 | } | ||
| 2281 | audit_inode(pathname, nd->path.dentry); | ||
| 2282 | goto ok; | ||
| 2283 | } | 2253 | } |
| 2284 | 2254 | ||
| 2285 | /* create side of things */ | 2255 | /* create side of things */ |
| @@ -2360,6 +2330,8 @@ static struct file *do_last(struct nameidata *nd, struct path *path, | |||
| 2360 | 2330 | ||
| 2361 | BUG_ON(nd->flags & LOOKUP_RCU); | 2331 | BUG_ON(nd->flags & LOOKUP_RCU); |
| 2362 | inode = path->dentry->d_inode; | 2332 | inode = path->dentry->d_inode; |
| 2333 | finish_lookup: | ||
| 2334 | /* we _can_ be in RCU mode here */ | ||
| 2363 | error = -ENOENT; | 2335 | error = -ENOENT; |
| 2364 | if (!inode) { | 2336 | if (!inode) { |
| 2365 | path_to_nameidata(path, nd); | 2337 | path_to_nameidata(path, nd); |
