diff options
author | Jan Blunck <jblunck@suse.de> | 2008-02-14 22:34:32 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-15 00:13:33 -0500 |
commit | 4ac9137858e08a19f29feac4e1f4df7c268b0ba5 (patch) | |
tree | f5b5d84fd12fcc2b0ba0e7ce1a79ff381ad8f5dd /fs/open.c | |
parent | c5e725f33b733a77de622e91b6ba5645fcf070be (diff) |
Embed a struct path into struct nameidata instead of nd->{dentry,mnt}
This is the central patch of a cleanup series. In most cases there is no good
reason why someone would want to use a dentry for itself. This series reflects
that fact and embeds a struct path into nameidata.
Together with the other patches of this series
- it enforced the correct order of getting/releasing the reference count on
<dentry,vfsmount> pairs
- it prepares the VFS for stacking support since it is essential to have a
struct path in every place where the stack can be traversed
- it reduces the overall code size:
without patch series:
text data bss dec hex filename
5321639 858418 715768 6895825 6938d1 vmlinux
with patch series:
text data bss dec hex filename
5320026 858418 715768 6894212 693284 vmlinux
This patch:
Switch from nd->{dentry,mnt} to nd->path.{dentry,mnt} everywhere.
[akpm@linux-foundation.org: coding-style fixes]
[akpm@linux-foundation.org: fix cifs]
[akpm@linux-foundation.org: fix smack]
Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Acked-by: Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 31 |
1 files changed, 16 insertions, 15 deletions
@@ -127,7 +127,7 @@ asmlinkage long sys_statfs(const char __user * path, struct statfs __user * buf) | |||
127 | error = user_path_walk(path, &nd); | 127 | error = user_path_walk(path, &nd); |
128 | if (!error) { | 128 | if (!error) { |
129 | struct statfs tmp; | 129 | struct statfs tmp; |
130 | error = vfs_statfs_native(nd.dentry, &tmp); | 130 | error = vfs_statfs_native(nd.path.dentry, &tmp); |
131 | if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) | 131 | if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) |
132 | error = -EFAULT; | 132 | error = -EFAULT; |
133 | path_release(&nd); | 133 | path_release(&nd); |
@@ -146,7 +146,7 @@ asmlinkage long sys_statfs64(const char __user *path, size_t sz, struct statfs64 | |||
146 | error = user_path_walk(path, &nd); | 146 | error = user_path_walk(path, &nd); |
147 | if (!error) { | 147 | if (!error) { |
148 | struct statfs64 tmp; | 148 | struct statfs64 tmp; |
149 | error = vfs_statfs64(nd.dentry, &tmp); | 149 | error = vfs_statfs64(nd.path.dentry, &tmp); |
150 | if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) | 150 | if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) |
151 | error = -EFAULT; | 151 | error = -EFAULT; |
152 | path_release(&nd); | 152 | path_release(&nd); |
@@ -233,7 +233,7 @@ static long do_sys_truncate(const char __user * path, loff_t length) | |||
233 | error = user_path_walk(path, &nd); | 233 | error = user_path_walk(path, &nd); |
234 | if (error) | 234 | if (error) |
235 | goto out; | 235 | goto out; |
236 | inode = nd.dentry->d_inode; | 236 | inode = nd.path.dentry->d_inode; |
237 | 237 | ||
238 | /* For directories it's -EISDIR, for other non-regulars - -EINVAL */ | 238 | /* For directories it's -EISDIR, for other non-regulars - -EINVAL */ |
239 | error = -EISDIR; | 239 | error = -EISDIR; |
@@ -271,7 +271,7 @@ static long do_sys_truncate(const char __user * path, loff_t length) | |||
271 | error = locks_verify_truncate(inode, NULL, length); | 271 | error = locks_verify_truncate(inode, NULL, length); |
272 | if (!error) { | 272 | if (!error) { |
273 | DQUOT_INIT(inode); | 273 | DQUOT_INIT(inode); |
274 | error = do_truncate(nd.dentry, length, 0, NULL); | 274 | error = do_truncate(nd.path.dentry, length, 0, NULL); |
275 | } | 275 | } |
276 | 276 | ||
277 | put_write_and_out: | 277 | put_write_and_out: |
@@ -455,10 +455,10 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode) | |||
455 | res = vfs_permission(&nd, mode); | 455 | res = vfs_permission(&nd, mode); |
456 | /* SuS v2 requires we report a read only fs too */ | 456 | /* SuS v2 requires we report a read only fs too */ |
457 | if(res || !(mode & S_IWOTH) || | 457 | if(res || !(mode & S_IWOTH) || |
458 | special_file(nd.dentry->d_inode->i_mode)) | 458 | special_file(nd.path.dentry->d_inode->i_mode)) |
459 | goto out_path_release; | 459 | goto out_path_release; |
460 | 460 | ||
461 | if(IS_RDONLY(nd.dentry->d_inode)) | 461 | if(IS_RDONLY(nd.path.dentry->d_inode)) |
462 | res = -EROFS; | 462 | res = -EROFS; |
463 | 463 | ||
464 | out_path_release: | 464 | out_path_release: |
@@ -490,7 +490,7 @@ asmlinkage long sys_chdir(const char __user * filename) | |||
490 | if (error) | 490 | if (error) |
491 | goto dput_and_out; | 491 | goto dput_and_out; |
492 | 492 | ||
493 | set_fs_pwd(current->fs, nd.mnt, nd.dentry); | 493 | set_fs_pwd(current->fs, nd.path.mnt, nd.path.dentry); |
494 | 494 | ||
495 | dput_and_out: | 495 | dput_and_out: |
496 | path_release(&nd); | 496 | path_release(&nd); |
@@ -545,7 +545,7 @@ asmlinkage long sys_chroot(const char __user * filename) | |||
545 | if (!capable(CAP_SYS_CHROOT)) | 545 | if (!capable(CAP_SYS_CHROOT)) |
546 | goto dput_and_out; | 546 | goto dput_and_out; |
547 | 547 | ||
548 | set_fs_root(current->fs, nd.mnt, nd.dentry); | 548 | set_fs_root(current->fs, nd.path.mnt, nd.path.dentry); |
549 | set_fs_altroot(); | 549 | set_fs_altroot(); |
550 | error = 0; | 550 | error = 0; |
551 | dput_and_out: | 551 | dput_and_out: |
@@ -602,7 +602,7 @@ asmlinkage long sys_fchmodat(int dfd, const char __user *filename, | |||
602 | error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd); | 602 | error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd); |
603 | if (error) | 603 | if (error) |
604 | goto out; | 604 | goto out; |
605 | inode = nd.dentry->d_inode; | 605 | inode = nd.path.dentry->d_inode; |
606 | 606 | ||
607 | error = -EROFS; | 607 | error = -EROFS; |
608 | if (IS_RDONLY(inode)) | 608 | if (IS_RDONLY(inode)) |
@@ -617,7 +617,7 @@ asmlinkage long sys_fchmodat(int dfd, const char __user *filename, | |||
617 | mode = inode->i_mode; | 617 | mode = inode->i_mode; |
618 | newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); | 618 | newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); |
619 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; | 619 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; |
620 | error = notify_change(nd.dentry, &newattrs); | 620 | error = notify_change(nd.path.dentry, &newattrs); |
621 | mutex_unlock(&inode->i_mutex); | 621 | mutex_unlock(&inode->i_mutex); |
622 | 622 | ||
623 | dput_and_out: | 623 | dput_and_out: |
@@ -675,7 +675,7 @@ asmlinkage long sys_chown(const char __user * filename, uid_t user, gid_t group) | |||
675 | error = user_path_walk(filename, &nd); | 675 | error = user_path_walk(filename, &nd); |
676 | if (error) | 676 | if (error) |
677 | goto out; | 677 | goto out; |
678 | error = chown_common(nd.dentry, user, group); | 678 | error = chown_common(nd.path.dentry, user, group); |
679 | path_release(&nd); | 679 | path_release(&nd); |
680 | out: | 680 | out: |
681 | return error; | 681 | return error; |
@@ -695,7 +695,7 @@ asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user, | |||
695 | error = __user_walk_fd(dfd, filename, follow, &nd); | 695 | error = __user_walk_fd(dfd, filename, follow, &nd); |
696 | if (error) | 696 | if (error) |
697 | goto out; | 697 | goto out; |
698 | error = chown_common(nd.dentry, user, group); | 698 | error = chown_common(nd.path.dentry, user, group); |
699 | path_release(&nd); | 699 | path_release(&nd); |
700 | out: | 700 | out: |
701 | return error; | 701 | return error; |
@@ -709,7 +709,7 @@ asmlinkage long sys_lchown(const char __user * filename, uid_t user, gid_t group | |||
709 | error = user_path_walk_link(filename, &nd); | 709 | error = user_path_walk_link(filename, &nd); |
710 | if (error) | 710 | if (error) |
711 | goto out; | 711 | goto out; |
712 | error = chown_common(nd.dentry, user, group); | 712 | error = chown_common(nd.path.dentry, user, group); |
713 | path_release(&nd); | 713 | path_release(&nd); |
714 | out: | 714 | out: |
715 | return error; | 715 | return error; |
@@ -863,7 +863,7 @@ struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry | |||
863 | goto out; | 863 | goto out; |
864 | if (IS_ERR(dentry)) | 864 | if (IS_ERR(dentry)) |
865 | goto out_err; | 865 | goto out_err; |
866 | nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->mnt), | 866 | nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->path.mnt), |
867 | nd->intent.open.flags - 1, | 867 | nd->intent.open.flags - 1, |
868 | nd->intent.open.file, | 868 | nd->intent.open.file, |
869 | open); | 869 | open); |
@@ -891,7 +891,8 @@ struct file *nameidata_to_filp(struct nameidata *nd, int flags) | |||
891 | filp = nd->intent.open.file; | 891 | filp = nd->intent.open.file; |
892 | /* Has the filesystem initialised the file for us? */ | 892 | /* Has the filesystem initialised the file for us? */ |
893 | if (filp->f_path.dentry == NULL) | 893 | if (filp->f_path.dentry == NULL) |
894 | filp = __dentry_open(nd->dentry, nd->mnt, flags, filp, NULL); | 894 | filp = __dentry_open(nd->path.dentry, nd->path.mnt, flags, filp, |
895 | NULL); | ||
895 | else | 896 | else |
896 | path_release(nd); | 897 | path_release(nd); |
897 | return filp; | 898 | return filp; |