tree 941317d6f91fe2bd0cb605692230b65686ca13e0
parent 6897089c5f7989603ccb9c696050470ba1dbd262
author Kay Sievers <[EMAIL PROTECTED]> Tue, 19 Apr 2005 11:57:32 -0700
committer Greg KH <[EMAIL PROTECTED]> Tue, 19 Apr 2005 11:57:32 -0700
[PATCH] sysfs: add sysfs_chmod_file()
sysfs: allow changing the permissions for already created attributes
Signed-off-by: Kay Sievers <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
sysfs/file.c | 35 +++++++++++++++++++++++++++++++++++
linux/sysfs.h | 7 +++++++
2 files changed, 42 insertions(+)
Index: fs/sysfs/file.c
===================================================================
--- 858c77a9aefc2f7b7b2c310b07e243d19a78e148/fs/sysfs/file.c (mode:100644
sha1:352f966a1174681f0c1e6a5801942b16d8df7d40)
+++ 941317d6f91fe2bd0cb605692230b65686ca13e0/fs/sysfs/file.c (mode:100644
sha1:da25aeb0e062093c242778d38b95bafe2a168c81)
@@ -428,6 +428,41 @@
/**
+ * sysfs_chmod_file - update the modified mode value on an object attribute.
+ * @kobj: object we're acting for.
+ * @attr: attribute descriptor.
+ * @mode: file permissions.
+ *
+ */
+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;
+ int res = -ENOENT;
+
+ down(&dir->d_inode->i_sem);
+ victim = sysfs_get_dentry(dir, 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;
+ }
+ }
+ up(&dir->d_inode->i_sem);
+
+ return res;
+}
+EXPORT_SYMBOL_GPL(sysfs_chmod_file);
+
+
+/**
* sysfs_remove_file - remove an object attribute.
* @kobj: object we're acting for.
* @attr: attribute descriptor.
Index: include/linux/sysfs.h
===================================================================
--- 858c77a9aefc2f7b7b2c310b07e243d19a78e148/include/linux/sysfs.h
(mode:100644 sha1:6f502ff7902a03bf880b2d4155ca146ae6d4654a)
+++ 941317d6f91fe2bd0cb605692230b65686ca13e0/include/linux/sysfs.h
(mode:100644 sha1:38b58b30814a304ddcd803ea10595fb35880a41c)
@@ -99,6 +99,9 @@
extern int
sysfs_update_file(struct kobject *, const struct attribute *);
+extern int
+sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode);
+
extern void
sysfs_remove_file(struct kobject *, const struct attribute *);
@@ -140,6 +143,10 @@
{
return 0;
}
+static inline int sysfs_chmod_file(struct kobject *kobj, struct attribute
*attr, mode_t mode)
+{
+ return 0;
+}
static inline void sysfs_remove_file(struct kobject * k, const struct
attribute * a)
{
-
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