Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kernfs: move the last knowledge of sysfs out from kernfs

There is still one residue of sysfs remaining: the sb_magic
SYSFS_MAGIC. However this should be kernfs user specific,
so this patch moves it out. Kerrnfs user should specify their
magic number while mouting.

Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jianyu Zhan and committed by
Linus Torvalds
c9482a5b cae61ba3

+20 -12
+6 -5
fs/kernfs/mount.c
··· 62 62 return NULL; 63 63 } 64 64 65 - static int kernfs_fill_super(struct super_block *sb) 65 + static int kernfs_fill_super(struct super_block *sb, unsigned long magic) 66 66 { 67 67 struct kernfs_super_info *info = kernfs_info(sb); 68 68 struct inode *inode; ··· 70 70 71 71 sb->s_blocksize = PAGE_CACHE_SIZE; 72 72 sb->s_blocksize_bits = PAGE_CACHE_SHIFT; 73 - sb->s_magic = SYSFS_MAGIC; 73 + sb->s_magic = magic; 74 74 sb->s_op = &kernfs_sops; 75 75 sb->s_time_gran = 1; 76 76 ··· 131 131 * @fs_type: file_system_type of the fs being mounted 132 132 * @flags: mount flags specified for the mount 133 133 * @root: kernfs_root of the hierarchy being mounted 134 + * @magic: file system specific magic number 134 135 * @new_sb_created: tell the caller if we allocated a new superblock 135 136 * @ns: optional namespace tag of the mount 136 137 * ··· 143 142 * The return value can be passed to the vfs layer verbatim. 144 143 */ 145 144 struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, 146 - struct kernfs_root *root, bool *new_sb_created, 147 - const void *ns) 145 + struct kernfs_root *root, unsigned long magic, 146 + bool *new_sb_created, const void *ns) 148 147 { 149 148 struct super_block *sb; 150 149 struct kernfs_super_info *info; ··· 167 166 *new_sb_created = !sb->s_root; 168 167 169 168 if (!sb->s_root) { 170 - error = kernfs_fill_super(sb); 169 + error = kernfs_fill_super(sb, magic); 171 170 if (error) { 172 171 deactivate_locked_super(sb); 173 172 return ERR_PTR(error);
+3 -1
fs/sysfs/mount.c
··· 13 13 #define DEBUG 14 14 15 15 #include <linux/fs.h> 16 + #include <linux/magic.h> 16 17 #include <linux/mount.h> 17 18 #include <linux/init.h> 18 19 #include <linux/user_namespace.h> ··· 39 38 } 40 39 41 40 ns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET); 42 - root = kernfs_mount_ns(fs_type, flags, sysfs_root, &new_sb, ns); 41 + root = kernfs_mount_ns(fs_type, flags, sysfs_root, 42 + SYSFS_MAGIC, &new_sb, ns); 43 43 if (IS_ERR(root) || !new_sb) 44 44 kobj_ns_drop(KOBJ_NS_TYPE_NET, ns); 45 45 return root;
+8 -5
include/linux/kernfs.h
··· 297 297 298 298 const void *kernfs_super_ns(struct super_block *sb); 299 299 struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, 300 - struct kernfs_root *root, bool *new_sb_created, 301 - const void *ns); 300 + struct kernfs_root *root, unsigned long magic, 301 + bool *new_sb_created, const void *ns); 302 302 void kernfs_kill_sb(struct super_block *sb); 303 303 304 304 void kernfs_init(void); ··· 391 391 392 392 static inline struct dentry * 393 393 kernfs_mount_ns(struct file_system_type *fs_type, int flags, 394 - struct kernfs_root *root, bool *new_sb_created, const void *ns) 394 + struct kernfs_root *root, unsigned long magic, 395 + bool *new_sb_created, const void *ns) 395 396 { return ERR_PTR(-ENOSYS); } 396 397 397 398 static inline void kernfs_kill_sb(struct super_block *sb) { } ··· 450 449 451 450 static inline struct dentry * 452 451 kernfs_mount(struct file_system_type *fs_type, int flags, 453 - struct kernfs_root *root, bool *new_sb_created) 452 + struct kernfs_root *root, unsigned long magic, 453 + bool *new_sb_created) 454 454 { 455 - return kernfs_mount_ns(fs_type, flags, root, new_sb_created, NULL); 455 + return kernfs_mount_ns(fs_type, flags, root, 456 + magic, new_sb_created, NULL); 456 457 } 457 458 458 459 #endif /* __LINUX_KERNFS_H */
+3 -1
kernel/cgroup.c
··· 33 33 #include <linux/init_task.h> 34 34 #include <linux/kernel.h> 35 35 #include <linux/list.h> 36 + #include <linux/magic.h> 36 37 #include <linux/mm.h> 37 38 #include <linux/mutex.h> 38 39 #include <linux/mount.h> ··· 1605 1604 if (ret) 1606 1605 return ERR_PTR(ret); 1607 1606 1608 - dentry = kernfs_mount(fs_type, flags, root->kf_root, &new_sb); 1607 + dentry = kernfs_mount(fs_type, flags, root->kf_root, 1608 + CGROUP_SUPER_MAGIC, &new_sb); 1609 1609 if (IS_ERR(dentry) || !new_sb) 1610 1610 cgroup_put(&root->cgrp); 1611 1611 return dentry;