Skip to content

Commit fac2622

Browse files
ebiedermgregkh
authored andcommitted
sysfs: Pass super_block to sysfs_get_inode
Currently sysfs_get_inode magically returns an inode on sysfs_sb. Make the super_block parameter explicit and the code becomes clearer. Acked-by: Tejun Heo <tj@kernel.org> Acked-by: Serge Hallyn <serue@us.ibm.com> Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 2354dcc commit fac2622

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

‎fs/sysfs/dir.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry,
645645
}
646646

647647
/* attach dentry and inode */
648-
inode = sysfs_get_inode(sd);
648+
inode = sysfs_get_inode(dir->i_sb, sd);
649649
if (!inode) {
650650
ret = ERR_PTR(-ENOMEM);
651651
goto out_unlock;

‎fs/sysfs/inode.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
283283

284284
/**
285285
* sysfs_get_inode - get inode for sysfs_dirent
286+
* @sb: super block
286287
* @sd: sysfs_dirent to allocate inode for
287288
*
288289
* Get inode for @sd. If such inode doesn't exist, a new inode
@@ -295,11 +296,11 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
295296
* RETURNS:
296297
* Pointer to allocated inode on success, NULL on failure.
297298
*/
298-
struct inode * sysfs_get_inode(struct sysfs_dirent *sd)
299+
struct inode * sysfs_get_inode(struct super_block *sb, struct sysfs_dirent *sd)
299300
{
300301
struct inode *inode;
301302

302-
inode = iget_locked(sysfs_sb, sd->s_ino);
303+
inode = iget_locked(sb, sd->s_ino);
303304
if (inode && (inode->i_state & I_NEW))
304305
sysfs_init_inode(sd, inode);
305306

‎fs/sysfs/mount.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
5454

5555
/* get root inode, initialize and unlock it */
5656
mutex_lock(&sysfs_mutex);
57-
inode = sysfs_get_inode(&sysfs_root);
57+
inode = sysfs_get_inode(sb, &sysfs_root);
5858
mutex_unlock(&sysfs_mutex);
5959
if (!inode) {
6060
pr_debug("sysfs: could not get root inode\n");

‎fs/sysfs/sysfs.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static inline void __sysfs_put(struct sysfs_dirent *sd)
172172
/*
173173
* inode.c
174174
*/
175-
struct inode *sysfs_get_inode(struct sysfs_dirent *sd);
175+
struct inode *sysfs_get_inode(struct super_block *sb, struct sysfs_dirent *sd);
176176
void sysfs_delete_inode(struct inode *inode);
177177
int sysfs_sd_setattr(struct sysfs_dirent *sd, struct iattr *iattr);
178178
int sysfs_permission(struct inode *inode, int mask);

0 commit comments

Comments
 (0)