Commit bc062b1b authored by Maneesh Soni's avatar Maneesh Soni Committed by Linus Torvalds

[PATCH] sysfs: fix sysfs_chmod_file

o sysfs_chmod_file() must update the new iattr field in sysfs_dirent else
  the mode change will not be persistent in case of inode evacuation from
  cache.
Signed-off-by: default avatarManeesh Soni <maneesh@in.ibm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 30d07a22
...@@ -437,8 +437,8 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) ...@@ -437,8 +437,8 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode)
{ {
struct dentry *dir = kobj->dentry; struct dentry *dir = kobj->dentry;
struct dentry *victim; struct dentry *victim;
struct sysfs_dirent *sd; struct inode * inode;
umode_t umode = (mode & S_IALLUGO) | S_IFREG; struct iattr newattrs;
int res = -ENOENT; int res = -ENOENT;
down(&dir->d_inode->i_sem); down(&dir->d_inode->i_sem);
...@@ -446,13 +446,15 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) ...@@ -446,13 +446,15 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode)
if (!IS_ERR(victim)) { if (!IS_ERR(victim)) {
if (victim->d_inode && if (victim->d_inode &&
(victim->d_parent->d_inode == dir->d_inode)) { (victim->d_parent->d_inode == dir->d_inode)) {
sd = victim->d_fsdata; inode = victim->d_inode;
attr->mode = mode; down(&inode->i_sem);
sd->s_mode = umode; newattrs.ia_mode = (mode & S_IALLUGO) |
victim->d_inode->i_mode = umode; (inode->i_mode & ~S_IALLUGO);
dput(victim); newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
res = 0; res = notify_change(victim, &newattrs);
up(&inode->i_sem);
} }
dput(victim);
} }
up(&dir->d_inode->i_sem); up(&dir->d_inode->i_sem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment