tree 57dceb8371d0e83e7772b3deeb4a9e8dd2ae6b03
parent 30d07a22a19329c89628a2057b0120245c482c9e
author Maneesh Soni <[EMAIL PROTECTED]> Sat, 30 Jul 2005 02:13:35 -0700
committer Linus Torvalds <[EMAIL PROTECTED]> Sat, 30 Jul 2005 03:12:49 -0700

[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: Maneesh Soni <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>

 fs/sysfs/file.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -437,8 +437,8 @@ int sysfs_chmod_file(struct kobject *kob
 {
        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);
@@ -446,13 +446,15 @@ int sysfs_chmod_file(struct kobject *kob
        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);
 
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to