diff options
author | Lachlan McIlroy <lachlan@redback.melbourne.sgi.com> | 2008-02-17 21:51:42 -0500 |
---|---|---|
committer | Lachlan McIlroy <lachlan@redback.melbourne.sgi.com> | 2008-02-17 21:51:42 -0500 |
commit | c58310bf4933986513020fa90b4190c7492995ae (patch) | |
tree | 143f2c7578d02ebef5db8fc57ae69e951ae0e2ee /fs/open.c | |
parent | 269cdfaf769f5cd831284cc831790c7c5038040f (diff) | |
parent | 1309d4e68497184d2fd87e892ddf14076c2bda98 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 into for-linus
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 66 |
1 files changed, 31 insertions, 35 deletions
@@ -127,10 +127,10 @@ 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_put(&nd.path); |
134 | } | 134 | } |
135 | return error; | 135 | return error; |
136 | } | 136 | } |
@@ -146,10 +146,10 @@ 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_put(&nd.path); |
153 | } | 153 | } |
154 | return error; | 154 | return error; |
155 | } | 155 | } |
@@ -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,13 +271,13 @@ 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: |
278 | put_write_access(inode); | 278 | put_write_access(inode); |
279 | dput_and_out: | 279 | dput_and_out: |
280 | path_release(&nd); | 280 | path_put(&nd.path); |
281 | out: | 281 | out: |
282 | return error; | 282 | return error; |
283 | } | 283 | } |
@@ -455,14 +455,14 @@ 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: |
465 | path_release(&nd); | 465 | path_put(&nd.path); |
466 | out: | 466 | out: |
467 | current->fsuid = old_fsuid; | 467 | current->fsuid = old_fsuid; |
468 | current->fsgid = old_fsgid; | 468 | current->fsgid = old_fsgid; |
@@ -490,10 +490,10 @@ 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); |
494 | 494 | ||
495 | dput_and_out: | 495 | dput_and_out: |
496 | path_release(&nd); | 496 | path_put(&nd.path); |
497 | out: | 497 | out: |
498 | return error; | 498 | return error; |
499 | } | 499 | } |
@@ -501,9 +501,7 @@ out: | |||
501 | asmlinkage long sys_fchdir(unsigned int fd) | 501 | asmlinkage long sys_fchdir(unsigned int fd) |
502 | { | 502 | { |
503 | struct file *file; | 503 | struct file *file; |
504 | struct dentry *dentry; | ||
505 | struct inode *inode; | 504 | struct inode *inode; |
506 | struct vfsmount *mnt; | ||
507 | int error; | 505 | int error; |
508 | 506 | ||
509 | error = -EBADF; | 507 | error = -EBADF; |
@@ -511,9 +509,7 @@ asmlinkage long sys_fchdir(unsigned int fd) | |||
511 | if (!file) | 509 | if (!file) |
512 | goto out; | 510 | goto out; |
513 | 511 | ||
514 | dentry = file->f_path.dentry; | 512 | inode = file->f_path.dentry->d_inode; |
515 | mnt = file->f_path.mnt; | ||
516 | inode = dentry->d_inode; | ||
517 | 513 | ||
518 | error = -ENOTDIR; | 514 | error = -ENOTDIR; |
519 | if (!S_ISDIR(inode->i_mode)) | 515 | if (!S_ISDIR(inode->i_mode)) |
@@ -521,7 +517,7 @@ asmlinkage long sys_fchdir(unsigned int fd) | |||
521 | 517 | ||
522 | error = file_permission(file, MAY_EXEC); | 518 | error = file_permission(file, MAY_EXEC); |
523 | if (!error) | 519 | if (!error) |
524 | set_fs_pwd(current->fs, mnt, dentry); | 520 | set_fs_pwd(current->fs, &file->f_path); |
525 | out_putf: | 521 | out_putf: |
526 | fput(file); | 522 | fput(file); |
527 | out: | 523 | out: |
@@ -545,11 +541,11 @@ asmlinkage long sys_chroot(const char __user * filename) | |||
545 | if (!capable(CAP_SYS_CHROOT)) | 541 | if (!capable(CAP_SYS_CHROOT)) |
546 | goto dput_and_out; | 542 | goto dput_and_out; |
547 | 543 | ||
548 | set_fs_root(current->fs, nd.mnt, nd.dentry); | 544 | set_fs_root(current->fs, &nd.path); |
549 | set_fs_altroot(); | 545 | set_fs_altroot(); |
550 | error = 0; | 546 | error = 0; |
551 | dput_and_out: | 547 | dput_and_out: |
552 | path_release(&nd); | 548 | path_put(&nd.path); |
553 | out: | 549 | out: |
554 | return error; | 550 | return error; |
555 | } | 551 | } |
@@ -602,7 +598,7 @@ asmlinkage long sys_fchmodat(int dfd, const char __user *filename, | |||
602 | error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd); | 598 | error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd); |
603 | if (error) | 599 | if (error) |
604 | goto out; | 600 | goto out; |
605 | inode = nd.dentry->d_inode; | 601 | inode = nd.path.dentry->d_inode; |
606 | 602 | ||
607 | error = -EROFS; | 603 | error = -EROFS; |
608 | if (IS_RDONLY(inode)) | 604 | if (IS_RDONLY(inode)) |
@@ -617,11 +613,11 @@ asmlinkage long sys_fchmodat(int dfd, const char __user *filename, | |||
617 | mode = inode->i_mode; | 613 | mode = inode->i_mode; |
618 | newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); | 614 | newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); |
619 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; | 615 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; |
620 | error = notify_change(nd.dentry, &newattrs); | 616 | error = notify_change(nd.path.dentry, &newattrs); |
621 | mutex_unlock(&inode->i_mutex); | 617 | mutex_unlock(&inode->i_mutex); |
622 | 618 | ||
623 | dput_and_out: | 619 | dput_and_out: |
624 | path_release(&nd); | 620 | path_put(&nd.path); |
625 | out: | 621 | out: |
626 | return error; | 622 | return error; |
627 | } | 623 | } |
@@ -675,8 +671,8 @@ asmlinkage long sys_chown(const char __user * filename, uid_t user, gid_t group) | |||
675 | error = user_path_walk(filename, &nd); | 671 | error = user_path_walk(filename, &nd); |
676 | if (error) | 672 | if (error) |
677 | goto out; | 673 | goto out; |
678 | error = chown_common(nd.dentry, user, group); | 674 | error = chown_common(nd.path.dentry, user, group); |
679 | path_release(&nd); | 675 | path_put(&nd.path); |
680 | out: | 676 | out: |
681 | return error; | 677 | return error; |
682 | } | 678 | } |
@@ -695,8 +691,8 @@ asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user, | |||
695 | error = __user_walk_fd(dfd, filename, follow, &nd); | 691 | error = __user_walk_fd(dfd, filename, follow, &nd); |
696 | if (error) | 692 | if (error) |
697 | goto out; | 693 | goto out; |
698 | error = chown_common(nd.dentry, user, group); | 694 | error = chown_common(nd.path.dentry, user, group); |
699 | path_release(&nd); | 695 | path_put(&nd.path); |
700 | out: | 696 | out: |
701 | return error; | 697 | return error; |
702 | } | 698 | } |
@@ -709,8 +705,8 @@ asmlinkage long sys_lchown(const char __user * filename, uid_t user, gid_t group | |||
709 | error = user_path_walk_link(filename, &nd); | 705 | error = user_path_walk_link(filename, &nd); |
710 | if (error) | 706 | if (error) |
711 | goto out; | 707 | goto out; |
712 | error = chown_common(nd.dentry, user, group); | 708 | error = chown_common(nd.path.dentry, user, group); |
713 | path_release(&nd); | 709 | path_put(&nd.path); |
714 | out: | 710 | out: |
715 | return error; | 711 | return error; |
716 | } | 712 | } |
@@ -863,7 +859,7 @@ struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry | |||
863 | goto out; | 859 | goto out; |
864 | if (IS_ERR(dentry)) | 860 | if (IS_ERR(dentry)) |
865 | goto out_err; | 861 | goto out_err; |
866 | nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->mnt), | 862 | nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->path.mnt), |
867 | nd->intent.open.flags - 1, | 863 | nd->intent.open.flags - 1, |
868 | nd->intent.open.file, | 864 | nd->intent.open.file, |
869 | open); | 865 | open); |
@@ -891,9 +887,10 @@ struct file *nameidata_to_filp(struct nameidata *nd, int flags) | |||
891 | filp = nd->intent.open.file; | 887 | filp = nd->intent.open.file; |
892 | /* Has the filesystem initialised the file for us? */ | 888 | /* Has the filesystem initialised the file for us? */ |
893 | if (filp->f_path.dentry == NULL) | 889 | if (filp->f_path.dentry == NULL) |
894 | filp = __dentry_open(nd->dentry, nd->mnt, flags, filp, NULL); | 890 | filp = __dentry_open(nd->path.dentry, nd->path.mnt, flags, filp, |
891 | NULL); | ||
895 | else | 892 | else |
896 | path_release(nd); | 893 | path_put(&nd->path); |
897 | return filp; | 894 | return filp; |
898 | } | 895 | } |
899 | 896 | ||
@@ -991,7 +988,7 @@ static void __put_unused_fd(struct files_struct *files, unsigned int fd) | |||
991 | files->next_fd = fd; | 988 | files->next_fd = fd; |
992 | } | 989 | } |
993 | 990 | ||
994 | void fastcall put_unused_fd(unsigned int fd) | 991 | void put_unused_fd(unsigned int fd) |
995 | { | 992 | { |
996 | struct files_struct *files = current->files; | 993 | struct files_struct *files = current->files; |
997 | spin_lock(&files->file_lock); | 994 | spin_lock(&files->file_lock); |
@@ -1014,7 +1011,7 @@ EXPORT_SYMBOL(put_unused_fd); | |||
1014 | * will follow. | 1011 | * will follow. |
1015 | */ | 1012 | */ |
1016 | 1013 | ||
1017 | void fastcall fd_install(unsigned int fd, struct file * file) | 1014 | void fd_install(unsigned int fd, struct file *file) |
1018 | { | 1015 | { |
1019 | struct files_struct *files = current->files; | 1016 | struct files_struct *files = current->files; |
1020 | struct fdtable *fdt; | 1017 | struct fdtable *fdt; |
@@ -1061,7 +1058,6 @@ asmlinkage long sys_open(const char __user *filename, int flags, int mode) | |||
1061 | prevent_tail_call(ret); | 1058 | prevent_tail_call(ret); |
1062 | return ret; | 1059 | return ret; |
1063 | } | 1060 | } |
1064 | EXPORT_UNUSED_SYMBOL_GPL(sys_open); /* To be deleted for 2.6.25 */ | ||
1065 | 1061 | ||
1066 | asmlinkage long sys_openat(int dfd, const char __user *filename, int flags, | 1062 | asmlinkage long sys_openat(int dfd, const char __user *filename, int flags, |
1067 | int mode) | 1063 | int mode) |