diff options
Diffstat (limited to 'fs/sysfs/inode.c')
| -rw-r--r-- | fs/sysfs/inode.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c index 220b758523ae..a4a0a9419711 100644 --- a/fs/sysfs/inode.c +++ b/fs/sysfs/inode.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <linux/capability.h> | 18 | #include <linux/capability.h> |
| 19 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
| 20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
| 21 | #include <linux/slab.h> | ||
| 21 | #include <linux/xattr.h> | 22 | #include <linux/xattr.h> |
| 22 | #include <linux/security.h> | 23 | #include <linux/security.h> |
| 23 | #include "sysfs.h" | 24 | #include "sysfs.h" |
| @@ -81,24 +82,23 @@ int sysfs_sd_setattr(struct sysfs_dirent *sd, struct iattr * iattr) | |||
| 81 | if (!sd_attrs) | 82 | if (!sd_attrs) |
| 82 | return -ENOMEM; | 83 | return -ENOMEM; |
| 83 | sd->s_iattr = sd_attrs; | 84 | sd->s_iattr = sd_attrs; |
| 84 | } else { | 85 | } |
| 85 | /* attributes were changed at least once in past */ | 86 | /* attributes were changed at least once in past */ |
| 86 | iattrs = &sd_attrs->ia_iattr; | 87 | iattrs = &sd_attrs->ia_iattr; |
| 87 | 88 | ||
| 88 | if (ia_valid & ATTR_UID) | 89 | if (ia_valid & ATTR_UID) |
| 89 | iattrs->ia_uid = iattr->ia_uid; | 90 | iattrs->ia_uid = iattr->ia_uid; |
| 90 | if (ia_valid & ATTR_GID) | 91 | if (ia_valid & ATTR_GID) |
| 91 | iattrs->ia_gid = iattr->ia_gid; | 92 | iattrs->ia_gid = iattr->ia_gid; |
| 92 | if (ia_valid & ATTR_ATIME) | 93 | if (ia_valid & ATTR_ATIME) |
| 93 | iattrs->ia_atime = iattr->ia_atime; | 94 | iattrs->ia_atime = iattr->ia_atime; |
| 94 | if (ia_valid & ATTR_MTIME) | 95 | if (ia_valid & ATTR_MTIME) |
| 95 | iattrs->ia_mtime = iattr->ia_mtime; | 96 | iattrs->ia_mtime = iattr->ia_mtime; |
| 96 | if (ia_valid & ATTR_CTIME) | 97 | if (ia_valid & ATTR_CTIME) |
| 97 | iattrs->ia_ctime = iattr->ia_ctime; | 98 | iattrs->ia_ctime = iattr->ia_ctime; |
| 98 | if (ia_valid & ATTR_MODE) { | 99 | if (ia_valid & ATTR_MODE) { |
| 99 | umode_t mode = iattr->ia_mode; | 100 | umode_t mode = iattr->ia_mode; |
| 100 | iattrs->ia_mode = sd->s_mode = mode; | 101 | iattrs->ia_mode = sd->s_mode = mode; |
| 101 | } | ||
| 102 | } | 102 | } |
| 103 | return 0; | 103 | return 0; |
| 104 | } | 104 | } |
| @@ -112,20 +112,20 @@ int sysfs_setattr(struct dentry *dentry, struct iattr *iattr) | |||
| 112 | if (!sd) | 112 | if (!sd) |
| 113 | return -EINVAL; | 113 | return -EINVAL; |
| 114 | 114 | ||
| 115 | mutex_lock(&sysfs_mutex); | ||
| 115 | error = inode_change_ok(inode, iattr); | 116 | error = inode_change_ok(inode, iattr); |
| 116 | if (error) | 117 | if (error) |
| 117 | return error; | 118 | goto out; |
| 118 | 119 | ||
| 119 | iattr->ia_valid &= ~ATTR_SIZE; /* ignore size changes */ | 120 | iattr->ia_valid &= ~ATTR_SIZE; /* ignore size changes */ |
| 120 | 121 | ||
| 121 | error = inode_setattr(inode, iattr); | 122 | error = inode_setattr(inode, iattr); |
| 122 | if (error) | 123 | if (error) |
| 123 | return error; | 124 | goto out; |
| 124 | 125 | ||
| 125 | mutex_lock(&sysfs_mutex); | ||
| 126 | error = sysfs_sd_setattr(sd, iattr); | 126 | error = sysfs_sd_setattr(sd, iattr); |
| 127 | out: | ||
| 127 | mutex_unlock(&sysfs_mutex); | 128 | mutex_unlock(&sysfs_mutex); |
| 128 | |||
| 129 | return error; | 129 | return error; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| @@ -284,6 +284,7 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode) | |||
| 284 | 284 | ||
| 285 | /** | 285 | /** |
| 286 | * sysfs_get_inode - get inode for sysfs_dirent | 286 | * sysfs_get_inode - get inode for sysfs_dirent |
| 287 | * @sb: super block | ||
| 287 | * @sd: sysfs_dirent to allocate inode for | 288 | * @sd: sysfs_dirent to allocate inode for |
| 288 | * | 289 | * |
| 289 | * Get inode for @sd. If such inode doesn't exist, a new inode | 290 | * Get inode for @sd. If such inode doesn't exist, a new inode |
| @@ -296,11 +297,11 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode) | |||
| 296 | * RETURNS: | 297 | * RETURNS: |
| 297 | * Pointer to allocated inode on success, NULL on failure. | 298 | * Pointer to allocated inode on success, NULL on failure. |
| 298 | */ | 299 | */ |
| 299 | struct inode * sysfs_get_inode(struct sysfs_dirent *sd) | 300 | struct inode * sysfs_get_inode(struct super_block *sb, struct sysfs_dirent *sd) |
| 300 | { | 301 | { |
| 301 | struct inode *inode; | 302 | struct inode *inode; |
| 302 | 303 | ||
| 303 | inode = iget_locked(sysfs_sb, sd->s_ino); | 304 | inode = iget_locked(sb, sd->s_ino); |
| 304 | if (inode && (inode->i_state & I_NEW)) | 305 | if (inode && (inode->i_state & I_NEW)) |
| 305 | sysfs_init_inode(sd, inode); | 306 | sysfs_init_inode(sd, inode); |
| 306 | 307 | ||
