From maneesh@in.ibm.com Tue Jul 12 08:53:09 2005
Date: Tue, 12 Jul 2005 17:58:13 +0530
From: Maneesh Soni <maneesh@in.ibm.com>
To: gregkh@suse.de
Subject: sysfs: fix sysfs_chmod_file
Message-ID: <20050712122813.GB5971@in.ibm.com>

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>


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

--- gregkh-2.6.orig/fs/sysfs/file.c	2005-07-13 09:45:07.000000000 -0700
+++ gregkh-2.6/fs/sysfs/file.c	2005-07-27 17:09:24.000000000 -0700
@@ -437,8 +437,8 @@
 {
 	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 @@
 	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);
 
