linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] sysfs: fix sysfs_chmod_file
@ 2005-07-12 12:28 Maneesh Soni
  2005-07-12 12:29 ` [PATCH 2/2] sysfs: fix sysfs_setattr Maneesh Soni
  0 siblings, 1 reply; 2+ messages in thread
From: Maneesh Soni @ 2005-07-12 12:28 UTC (permalink / raw)
  To: gregkh; +Cc: LKML

Hi Greg,

Please include this patch and the following one for sysfs. This is needed
after the introduction of sysfs setattr functionality.


Thanks
Maneesh



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>
---

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

diff -puN fs/sysfs/file.c~fix-sysfs_chmod_file fs/sysfs/file.c
--- linux-2.6.13-rc2/fs/sysfs/file.c~fix-sysfs_chmod_file	2005-07-12 11:43:26.799678624 +0530
+++ linux-2.6.13-rc2-maneesh/fs/sysfs/file.c	2005-07-12 11:44:09.213230784 +0530
@@ -440,8 +440,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);
@@ -449,13 +449,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);
 
_
-- 
Maneesh Soni
Linux Technology Center, 
IBM India Software Labs,
Bangalore, India
email: maneesh@in.ibm.com
Phone: 91-80-25044990

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2] sysfs: fix sysfs_setattr
  2005-07-12 12:28 [PATCH 1/2] sysfs: fix sysfs_chmod_file Maneesh Soni
@ 2005-07-12 12:29 ` Maneesh Soni
  0 siblings, 0 replies; 2+ messages in thread
From: Maneesh Soni @ 2005-07-12 12:29 UTC (permalink / raw)
  To: gregkh; +Cc: LKML




o sysfs_dirent's s_mode field should also be updated in sysfs_setattr(), else
  there could be inconsistency in the two fields. s_mode is used while
  ->readdir so as not to bring in the inode to cache.

Signed-off-by: Maneesh Soni <maneesh@in.ibm.com>
---

 linux-2.6.13-rc2-maneesh/fs/sysfs/inode.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

diff -puN fs/sysfs/inode.c~fix-sysfs_setattr-update-s_mode fs/sysfs/inode.c
--- linux-2.6.13-rc2/fs/sysfs/inode.c~fix-sysfs_setattr-update-s_mode	2005-07-12 11:24:56.341493928 +0530
+++ linux-2.6.13-rc2-maneesh/fs/sysfs/inode.c	2005-07-12 11:24:56.347493016 +0530
@@ -85,7 +85,7 @@ int sysfs_setattr(struct dentry * dentry
 
 		if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
 			mode &= ~S_ISGID;
-		sd_iattr->ia_mode = mode;
+		sd_iattr->ia_mode = sd->s_mode = mode;
 	}
 
 	return error;
_
-- 
Maneesh Soni
Linux Technology Center, 
IBM India Software Labs,
Bangalore, India
email: maneesh@in.ibm.com
Phone: 91-80-25044990

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-07-12 12:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-12 12:28 [PATCH 1/2] sysfs: fix sysfs_chmod_file Maneesh Soni
2005-07-12 12:29 ` [PATCH 2/2] sysfs: fix sysfs_setattr Maneesh Soni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).