diff options
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 24 |
1 files changed, 2 insertions, 22 deletions
@@ -588,9 +588,6 @@ asmlinkage long sys_fchmod(unsigned int fd, mode_t mode) | |||
588 | err = mnt_want_write(file->f_path.mnt); | 588 | err = mnt_want_write(file->f_path.mnt); |
589 | if (err) | 589 | if (err) |
590 | goto out_putf; | 590 | goto out_putf; |
591 | err = -EPERM; | ||
592 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) | ||
593 | goto out_drop_write; | ||
594 | mutex_lock(&inode->i_mutex); | 591 | mutex_lock(&inode->i_mutex); |
595 | if (mode == (mode_t) -1) | 592 | if (mode == (mode_t) -1) |
596 | mode = inode->i_mode; | 593 | mode = inode->i_mode; |
@@ -598,8 +595,6 @@ asmlinkage long sys_fchmod(unsigned int fd, mode_t mode) | |||
598 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; | 595 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; |
599 | err = notify_change(dentry, &newattrs); | 596 | err = notify_change(dentry, &newattrs); |
600 | mutex_unlock(&inode->i_mutex); | 597 | mutex_unlock(&inode->i_mutex); |
601 | |||
602 | out_drop_write: | ||
603 | mnt_drop_write(file->f_path.mnt); | 598 | mnt_drop_write(file->f_path.mnt); |
604 | out_putf: | 599 | out_putf: |
605 | fput(file); | 600 | fput(file); |
@@ -623,11 +618,6 @@ asmlinkage long sys_fchmodat(int dfd, const char __user *filename, | |||
623 | error = mnt_want_write(nd.path.mnt); | 618 | error = mnt_want_write(nd.path.mnt); |
624 | if (error) | 619 | if (error) |
625 | goto dput_and_out; | 620 | goto dput_and_out; |
626 | |||
627 | error = -EPERM; | ||
628 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) | ||
629 | goto out_drop_write; | ||
630 | |||
631 | mutex_lock(&inode->i_mutex); | 621 | mutex_lock(&inode->i_mutex); |
632 | if (mode == (mode_t) -1) | 622 | if (mode == (mode_t) -1) |
633 | mode = inode->i_mode; | 623 | mode = inode->i_mode; |
@@ -635,8 +625,6 @@ asmlinkage long sys_fchmodat(int dfd, const char __user *filename, | |||
635 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; | 625 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; |
636 | error = notify_change(nd.path.dentry, &newattrs); | 626 | error = notify_change(nd.path.dentry, &newattrs); |
637 | mutex_unlock(&inode->i_mutex); | 627 | mutex_unlock(&inode->i_mutex); |
638 | |||
639 | out_drop_write: | ||
640 | mnt_drop_write(nd.path.mnt); | 628 | mnt_drop_write(nd.path.mnt); |
641 | dput_and_out: | 629 | dput_and_out: |
642 | path_put(&nd.path); | 630 | path_put(&nd.path); |
@@ -651,18 +639,10 @@ asmlinkage long sys_chmod(const char __user *filename, mode_t mode) | |||
651 | 639 | ||
652 | static int chown_common(struct dentry * dentry, uid_t user, gid_t group) | 640 | static int chown_common(struct dentry * dentry, uid_t user, gid_t group) |
653 | { | 641 | { |
654 | struct inode * inode; | 642 | struct inode *inode = dentry->d_inode; |
655 | int error; | 643 | int error; |
656 | struct iattr newattrs; | 644 | struct iattr newattrs; |
657 | 645 | ||
658 | error = -ENOENT; | ||
659 | if (!(inode = dentry->d_inode)) { | ||
660 | printk(KERN_ERR "chown_common: NULL inode\n"); | ||
661 | goto out; | ||
662 | } | ||
663 | error = -EPERM; | ||
664 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) | ||
665 | goto out; | ||
666 | newattrs.ia_valid = ATTR_CTIME; | 646 | newattrs.ia_valid = ATTR_CTIME; |
667 | if (user != (uid_t) -1) { | 647 | if (user != (uid_t) -1) { |
668 | newattrs.ia_valid |= ATTR_UID; | 648 | newattrs.ia_valid |= ATTR_UID; |
@@ -678,7 +658,7 @@ static int chown_common(struct dentry * dentry, uid_t user, gid_t group) | |||
678 | mutex_lock(&inode->i_mutex); | 658 | mutex_lock(&inode->i_mutex); |
679 | error = notify_change(dentry, &newattrs); | 659 | error = notify_change(dentry, &newattrs); |
680 | mutex_unlock(&inode->i_mutex); | 660 | mutex_unlock(&inode->i_mutex); |
681 | out: | 661 | |
682 | return error; | 662 | return error; |
683 | } | 663 | } |
684 | 664 | ||