aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-06-27 16:53:43 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-20 01:44:12 -0400
commited75e95de574c99575e5f3e1d9ca59ea8c12a9cb (patch)
tree9b79ea8f3b30f2589d2edf773307bdc6528ef3e3 /fs
parent5da4e689449ad99ab31cf2208d99eddfce0498ba (diff)
kill lookup_create()
folded into the only caller (kern_path_create()) Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/namei.c54
1 files changed, 18 insertions, 36 deletions
diff --git a/fs/namei.c b/fs/namei.c
index b292eb03d9d2..b45a039216c7 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2258,35 +2258,29 @@ struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt,
2258 return file; 2258 return file;
2259} 2259}
2260 2260
2261/** 2261struct dentry *kern_path_create(int dfd, const char *pathname, struct path *path, int is_dir)
2262 * lookup_create - lookup a dentry, creating it if it doesn't exist
2263 * @nd: nameidata info
2264 * @is_dir: directory flag
2265 *
2266 * Simple function to lookup and return a dentry and create it
2267 * if it doesn't exist. Is SMP-safe.
2268 *
2269 * Returns with nd->path.dentry->d_inode->i_mutex locked.
2270 */
2271struct dentry *lookup_create(struct nameidata *nd, int is_dir)
2272{ 2262{
2273 struct dentry *dentry = ERR_PTR(-EEXIST); 2263 struct dentry *dentry = ERR_PTR(-EEXIST);
2264 struct nameidata nd;
2265 int error = do_path_lookup(dfd, pathname, LOOKUP_PARENT, &nd);
2266 if (error)
2267 return ERR_PTR(error);
2274 2268
2275 mutex_lock_nested(&nd->path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
2276 /* 2269 /*
2277 * Yucky last component or no last component at all? 2270 * Yucky last component or no last component at all?
2278 * (foo/., foo/.., /////) 2271 * (foo/., foo/.., /////)
2279 */ 2272 */
2280 if (nd->last_type != LAST_NORM) 2273 if (nd.last_type != LAST_NORM)
2281 goto fail; 2274 goto out;
2282 nd->flags &= ~LOOKUP_PARENT; 2275 nd.flags &= ~LOOKUP_PARENT;
2283 nd->flags |= LOOKUP_CREATE | LOOKUP_EXCL; 2276 nd.flags |= LOOKUP_CREATE | LOOKUP_EXCL;
2284 nd->intent.open.flags = O_EXCL; 2277 nd.intent.open.flags = O_EXCL;
2285 2278
2286 /* 2279 /*
2287 * Do the final lookup. 2280 * Do the final lookup.
2288 */ 2281 */
2289 dentry = lookup_hash(nd); 2282 mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
2283 dentry = lookup_hash(&nd);
2290 if (IS_ERR(dentry)) 2284 if (IS_ERR(dentry))
2291 goto fail; 2285 goto fail;
2292 2286
@@ -2298,34 +2292,22 @@ struct dentry *lookup_create(struct nameidata *nd, int is_dir)
2298 * all is fine. Let's be bastards - you had / on the end, you've 2292 * all is fine. Let's be bastards - you had / on the end, you've
2299 * been asking for (non-existent) directory. -ENOENT for you. 2293 * been asking for (non-existent) directory. -ENOENT for you.
2300 */ 2294 */
2301 if (unlikely(!is_dir && nd->last.name[nd->last.len])) { 2295 if (unlikely(!is_dir && nd.last.name[nd.last.len])) {
2302 dput(dentry); 2296 dput(dentry);
2303 dentry = ERR_PTR(-ENOENT); 2297 dentry = ERR_PTR(-ENOENT);
2298 goto fail;
2304 } 2299 }
2300 *path = nd.path;
2305 return dentry; 2301 return dentry;
2306eexist: 2302eexist:
2307 dput(dentry); 2303 dput(dentry);
2308 dentry = ERR_PTR(-EEXIST); 2304 dentry = ERR_PTR(-EEXIST);
2309fail: 2305fail:
2306 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2307out:
2308 path_put(&nd.path);
2310 return dentry; 2309 return dentry;
2311} 2310}
2312EXPORT_SYMBOL_GPL(lookup_create);
2313
2314struct dentry *kern_path_create(int dfd, const char *pathname, struct path *path, int is_dir)
2315{
2316 struct nameidata nd;
2317 struct dentry *res;
2318 int error = do_path_lookup(dfd, pathname, LOOKUP_PARENT, &nd);
2319 if (error)
2320 return ERR_PTR(error);
2321 res = lookup_create(&nd, is_dir);
2322 if (IS_ERR(res)) {
2323 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2324 path_put(&nd.path);
2325 }
2326 *path = nd.path;
2327 return res;
2328}
2329EXPORT_SYMBOL(kern_path_create); 2311EXPORT_SYMBOL(kern_path_create);
2330 2312
2331struct dentry *user_path_create(int dfd, const char __user *pathname, struct path *path, int is_dir) 2313struct dentry *user_path_create(int dfd, const char __user *pathname, struct path *path, int is_dir)