Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 306
b: refs/heads/master
c: 31e5abe
h: refs/heads/master
v: v3
  • Loading branch information
Kay Sievers authored and Greg KH committed Apr 19, 2005
1 parent 1930c11 commit 6adb35e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6897089c5f7989603ccb9c696050470ba1dbd262
refs/heads/master: 31e5abe9a6dab1ed3a5c30352bdb001353146318
35 changes: 35 additions & 0 deletions trunk/fs/sysfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,41 @@ int sysfs_update_file(struct kobject * kobj, const struct attribute * attr)
}


/**
* 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.
Expand Down
7 changes: 7 additions & 0 deletions trunk/include/linux/sysfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ sysfs_create_file(struct kobject *, const struct attribute *);
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 *);

Expand Down Expand Up @@ -140,6 +143,10 @@ static inline int sysfs_update_file(struct kobject * k, const struct attribute *
{
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)
{
Expand Down

0 comments on commit 6adb35e

Please sign in to comment.