aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-09-20 03:05:10 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-10-12 17:51:09 -0400
commitf88123eaf953f13a0c597dde54745d28f81236de (patch)
treed737f3d4a79055d9d6c8ab5df0c564ea6a89ec8a
parent181b2e4be1603ce3ccace8322047a548f29f4b20 (diff)
sysfs: fix sysfs_chmod_file() such that it updates sd->s_mode too
sysfs_chmod_file() looked and updated only inode of the target file. Dentry and inode are reclaimable and the update mode data will go away when the inode is reclaimed. This patch makes sysfs_chmod_file() update sd->s_mode too such that the change is permanent. Signed-off-by: Tejun Heo <htejun@gmail.com> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--fs/sysfs/file.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index ff93c92164b3..9fdf8dae0dcd 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -521,10 +521,19 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode)
521 } 521 }
522 522
523 inode = victim->d_inode; 523 inode = victim->d_inode;
524
524 mutex_lock(&inode->i_mutex); 525 mutex_lock(&inode->i_mutex);
526
525 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); 527 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
526 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; 528 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
527 rc = notify_change(victim, &newattrs); 529 rc = notify_change(victim, &newattrs);
530
531 if (rc == 0) {
532 mutex_lock(&sysfs_mutex);
533 victim_sd->s_mode = newattrs.ia_mode;
534 mutex_unlock(&sysfs_mutex);
535 }
536
528 mutex_unlock(&inode->i_mutex); 537 mutex_unlock(&inode->i_mutex);
529 out: 538 out:
530 dput(victim); 539 dput(victim);