namei.c (f419a2e3b64def707e1384ee38abb77f99af5f6d) | namei.c (2d8f30380ab8c706f4e0a8f1aaa22b5886e9ac8a) |
---|---|
1/* 2 * linux/fs/namei.c 3 * 4 * Copyright (C) 1991, 1992 Linus Torvalds 5 */ 6 7/* 8 * Some corrections by tytso. --- 1320 unchanged lines hidden (view full) --- 1329 struct qstr this; 1330 1331 err = __lookup_one_len(name, &this, base, strlen(name)); 1332 if (err) 1333 return ERR_PTR(err); 1334 return __lookup_hash(&this, base, NULL); 1335} 1336 | 1/* 2 * linux/fs/namei.c 3 * 4 * Copyright (C) 1991, 1992 Linus Torvalds 5 */ 6 7/* 8 * Some corrections by tytso. --- 1320 unchanged lines hidden (view full) --- 1329 struct qstr this; 1330 1331 err = __lookup_one_len(name, &this, base, strlen(name)); 1332 if (err) 1333 return ERR_PTR(err); 1334 return __lookup_hash(&this, base, NULL); 1335} 1336 |
1337int __user_walk_fd(int dfd, const char __user *name, unsigned flags, 1338 struct nameidata *nd) | 1337int user_path_at(int dfd, const char __user *name, unsigned flags, 1338 struct path *path) |
1339{ | 1339{ |
1340 struct nameidata nd; |
|
1340 char *tmp = getname(name); 1341 int err = PTR_ERR(tmp); | 1341 char *tmp = getname(name); 1342 int err = PTR_ERR(tmp); |
1342 | |
1343 if (!IS_ERR(tmp)) { | 1343 if (!IS_ERR(tmp)) { |
1344 err = do_path_lookup(dfd, tmp, flags, nd); | 1344 1345 BUG_ON(flags & LOOKUP_PARENT); 1346 1347 err = do_path_lookup(dfd, tmp, flags, &nd); |
1345 putname(tmp); | 1348 putname(tmp); |
1349 if (!err) 1350 *path = nd.path; |
|
1346 } 1347 return err; 1348} 1349 | 1351 } 1352 return err; 1353} 1354 |
1350int __user_walk(const char __user *name, unsigned flags, struct nameidata *nd) 1351{ 1352 return __user_walk_fd(AT_FDCWD, name, flags, nd); 1353} 1354 | |
1355/* 1356 * It's inline, so penalty for filesystems that don't use sticky bit is 1357 * minimal. 1358 */ 1359static inline int check_sticky(struct inode *dir, struct inode *inode) 1360{ 1361 if (!(dir->i_mode & S_ISVTX)) 1362 return 0; --- 1078 unchanged lines hidden (view full) --- 2441 * with linux 2.0, and to avoid hard-linking to directories 2442 * and other special files. --ADM 2443 */ 2444asmlinkage long sys_linkat(int olddfd, const char __user *oldname, 2445 int newdfd, const char __user *newname, 2446 int flags) 2447{ 2448 struct dentry *new_dentry; | 1355/* 1356 * It's inline, so penalty for filesystems that don't use sticky bit is 1357 * minimal. 1358 */ 1359static inline int check_sticky(struct inode *dir, struct inode *inode) 1360{ 1361 if (!(dir->i_mode & S_ISVTX)) 1362 return 0; --- 1078 unchanged lines hidden (view full) --- 2441 * with linux 2.0, and to avoid hard-linking to directories 2442 * and other special files. --ADM 2443 */ 2444asmlinkage long sys_linkat(int olddfd, const char __user *oldname, 2445 int newdfd, const char __user *newname, 2446 int flags) 2447{ 2448 struct dentry *new_dentry; |
2449 struct nameidata nd, old_nd; | 2449 struct nameidata nd; 2450 struct path old_path; |
2450 int error; 2451 char * to; 2452 2453 if ((flags & ~AT_SYMLINK_FOLLOW) != 0) 2454 return -EINVAL; 2455 2456 to = getname(newname); 2457 if (IS_ERR(to)) 2458 return PTR_ERR(to); 2459 | 2451 int error; 2452 char * to; 2453 2454 if ((flags & ~AT_SYMLINK_FOLLOW) != 0) 2455 return -EINVAL; 2456 2457 to = getname(newname); 2458 if (IS_ERR(to)) 2459 return PTR_ERR(to); 2460 |
2460 error = __user_walk_fd(olddfd, oldname, 2461 flags & AT_SYMLINK_FOLLOW ? LOOKUP_FOLLOW : 0, 2462 &old_nd); | 2461 error = user_path_at(olddfd, oldname, 2462 flags & AT_SYMLINK_FOLLOW ? LOOKUP_FOLLOW : 0, 2463 &old_path); |
2463 if (error) 2464 goto exit; 2465 error = do_path_lookup(newdfd, to, LOOKUP_PARENT, &nd); 2466 if (error) 2467 goto out; 2468 error = -EXDEV; | 2464 if (error) 2465 goto exit; 2466 error = do_path_lookup(newdfd, to, LOOKUP_PARENT, &nd); 2467 if (error) 2468 goto out; 2469 error = -EXDEV; |
2469 if (old_nd.path.mnt != nd.path.mnt) | 2470 if (old_path.mnt != nd.path.mnt) |
2470 goto out_release; 2471 new_dentry = lookup_create(&nd, 0); 2472 error = PTR_ERR(new_dentry); 2473 if (IS_ERR(new_dentry)) 2474 goto out_unlock; 2475 error = mnt_want_write(nd.path.mnt); 2476 if (error) 2477 goto out_dput; | 2471 goto out_release; 2472 new_dentry = lookup_create(&nd, 0); 2473 error = PTR_ERR(new_dentry); 2474 if (IS_ERR(new_dentry)) 2475 goto out_unlock; 2476 error = mnt_want_write(nd.path.mnt); 2477 if (error) 2478 goto out_dput; |
2478 error = vfs_link(old_nd.path.dentry, nd.path.dentry->d_inode, new_dentry); | 2479 error = vfs_link(old_path.dentry, nd.path.dentry->d_inode, new_dentry); |
2479 mnt_drop_write(nd.path.mnt); 2480out_dput: 2481 dput(new_dentry); 2482out_unlock: 2483 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 2484out_release: 2485 path_put(&nd.path); 2486out: | 2480 mnt_drop_write(nd.path.mnt); 2481out_dput: 2482 dput(new_dentry); 2483out_unlock: 2484 mutex_unlock(&nd.path.dentry->d_inode->i_mutex); 2485out_release: 2486 path_put(&nd.path); 2487out: |
2487 path_put(&old_nd.path); | 2488 path_put(&old_path); |
2488exit: 2489 putname(to); 2490 2491 return error; 2492} 2493 2494asmlinkage long sys_link(const char __user *oldname, const char __user *newname) 2495{ --- 376 unchanged lines hidden (view full) --- 2872} 2873 2874const struct inode_operations page_symlink_inode_operations = { 2875 .readlink = generic_readlink, 2876 .follow_link = page_follow_link_light, 2877 .put_link = page_put_link, 2878}; 2879 | 2489exit: 2490 putname(to); 2491 2492 return error; 2493} 2494 2495asmlinkage long sys_link(const char __user *oldname, const char __user *newname) 2496{ --- 376 unchanged lines hidden (view full) --- 2873} 2874 2875const struct inode_operations page_symlink_inode_operations = { 2876 .readlink = generic_readlink, 2877 .follow_link = page_follow_link_light, 2878 .put_link = page_put_link, 2879}; 2880 |
2880EXPORT_SYMBOL(__user_walk); 2881EXPORT_SYMBOL(__user_walk_fd); | 2881EXPORT_SYMBOL(user_path_at); |
2882EXPORT_SYMBOL(follow_down); 2883EXPORT_SYMBOL(follow_up); 2884EXPORT_SYMBOL(get_write_access); /* binfmt_aout */ 2885EXPORT_SYMBOL(getname); 2886EXPORT_SYMBOL(lock_rename); 2887EXPORT_SYMBOL(lookup_one_len); 2888EXPORT_SYMBOL(page_follow_link_light); 2889EXPORT_SYMBOL(page_put_link); --- 23 unchanged lines hidden --- | 2882EXPORT_SYMBOL(follow_down); 2883EXPORT_SYMBOL(follow_up); 2884EXPORT_SYMBOL(get_write_access); /* binfmt_aout */ 2885EXPORT_SYMBOL(getname); 2886EXPORT_SYMBOL(lock_rename); 2887EXPORT_SYMBOL(lookup_one_len); 2888EXPORT_SYMBOL(page_follow_link_light); 2889EXPORT_SYMBOL(page_put_link); --- 23 unchanged lines hidden --- |