Skip to content

Commit

Permalink
[PATCH] sysfs: fix sysfs_chmod_file
Browse files Browse the repository at this point in the history
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: Maneesh Soni <maneesh@in.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Maneesh Soni authored and Linus Torvalds committed Jul 29, 2005
1 parent 30d07a2 commit bc062b1
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions fs/sysfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,22 +437,24 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode)
{
struct dentry *dir = kobj->dentry;
struct dentry *victim;
struct sysfs_dirent *sd;
umode_t umode = (mode & S_IALLUGO) | S_IFREG;
struct inode * inode;
struct iattr newattrs;
int res = -ENOENT;

down(&dir->d_inode->i_sem);
victim = lookup_one_len(attr->name, dir, strlen(attr->name));
if (!IS_ERR(victim)) {
if (victim->d_inode &&
(victim->d_parent->d_inode == dir->d_inode)) {
sd = victim->d_fsdata;
attr->mode = mode;
sd->s_mode = umode;
victim->d_inode->i_mode = umode;
dput(victim);
res = 0;
inode = victim->d_inode;
down(&inode->i_sem);
newattrs.ia_mode = (mode & S_IALLUGO) |
(inode->i_mode & ~S_IALLUGO);
newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
res = notify_change(victim, &newattrs);
up(&inode->i_sem);
}
dput(victim);
}
up(&dir->d_inode->i_sem);

Expand Down

0 comments on commit bc062b1

Please sign in to comment.