aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2015-05-13 18:35:41 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-07-21 13:10:01 -0400
commit28dd1f346b2f0fc2ab8285046ed0bd91e9b808d3 (patch)
tree7c2a4337b103067684f0345283d19c8e8e62afb2
parent9924f6e89823a41bfd272ab759636276b9f9ee9c (diff)
sysfs: Create mountpoints with sysfs_create_mount_point
commit f9bb48825a6b5d02f4cabcc78967c75db903dcdc upstream. This allows for better documentation in the code and it allows for a simpler and fully correct version of fs_fully_visible to be written. The mount points converted and their filesystems are: /sys/hypervisor/s390/ s390_hypfs /sys/kernel/config/ configfs /sys/kernel/debug/ debugfs /sys/firmware/efi/efivars/ efivarfs /sys/fs/fuse/connections/ fusectl /sys/fs/pstore/ pstore /sys/kernel/tracing/ tracefs /sys/fs/cgroup/ cgroup /sys/kernel/security/ securityfs /sys/fs/selinux/ selinuxfs /sys/fs/smackfs/ smackfs Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/s390/hypfs/inode.c12
-rw-r--r--drivers/firmware/efi/efi.c6
-rw-r--r--fs/configfs/mount.c10
-rw-r--r--fs/debugfs/inode.c11
-rw-r--r--fs/fuse/inode.c9
-rw-r--r--fs/pstore/inode.c12
-rw-r--r--fs/tracefs/inode.c6
-rw-r--r--kernel/cgroup.c10
-rw-r--r--security/inode.c10
-rw-r--r--security/selinux/selinuxfs.c11
-rw-r--r--security/smack/smackfs.c8
11 files changed, 40 insertions, 65 deletions
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index d3f896a35b98..2eeb0a0f506d 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -456,8 +456,6 @@ static const struct super_operations hypfs_s_ops = {
456 .show_options = hypfs_show_options, 456 .show_options = hypfs_show_options,
457}; 457};
458 458
459static struct kobject *s390_kobj;
460
461static int __init hypfs_init(void) 459static int __init hypfs_init(void)
462{ 460{
463 int rc; 461 int rc;
@@ -481,18 +479,16 @@ static int __init hypfs_init(void)
481 rc = -ENODATA; 479 rc = -ENODATA;
482 goto fail_hypfs_sprp_exit; 480 goto fail_hypfs_sprp_exit;
483 } 481 }
484 s390_kobj = kobject_create_and_add("s390", hypervisor_kobj); 482 rc = sysfs_create_mount_point(hypervisor_kobj, "s390");
485 if (!s390_kobj) { 483 if (rc)
486 rc = -ENOMEM;
487 goto fail_hypfs_diag0c_exit; 484 goto fail_hypfs_diag0c_exit;
488 }
489 rc = register_filesystem(&hypfs_type); 485 rc = register_filesystem(&hypfs_type);
490 if (rc) 486 if (rc)
491 goto fail_filesystem; 487 goto fail_filesystem;
492 return 0; 488 return 0;
493 489
494fail_filesystem: 490fail_filesystem:
495 kobject_put(s390_kobj); 491 sysfs_remove_mount_point(hypervisor_kobj, "s390");
496fail_hypfs_diag0c_exit: 492fail_hypfs_diag0c_exit:
497 hypfs_diag0c_exit(); 493 hypfs_diag0c_exit();
498fail_hypfs_sprp_exit: 494fail_hypfs_sprp_exit:
@@ -510,7 +506,7 @@ fail_dbfs_exit:
510static void __exit hypfs_exit(void) 506static void __exit hypfs_exit(void)
511{ 507{
512 unregister_filesystem(&hypfs_type); 508 unregister_filesystem(&hypfs_type);
513 kobject_put(s390_kobj); 509 sysfs_remove_mount_point(hypervisor_kobj, "s390");
514 hypfs_diag0c_exit(); 510 hypfs_diag0c_exit();
515 hypfs_sprp_exit(); 511 hypfs_sprp_exit();
516 hypfs_vm_exit(); 512 hypfs_vm_exit();
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 3061bb8629dc..e14363d12690 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -65,7 +65,6 @@ static int __init parse_efi_cmdline(char *str)
65early_param("efi", parse_efi_cmdline); 65early_param("efi", parse_efi_cmdline);
66 66
67static struct kobject *efi_kobj; 67static struct kobject *efi_kobj;
68static struct kobject *efivars_kobj;
69 68
70/* 69/*
71 * Let's not leave out systab information that snuck into 70 * Let's not leave out systab information that snuck into
@@ -212,10 +211,9 @@ static int __init efisubsys_init(void)
212 goto err_remove_group; 211 goto err_remove_group;
213 212
214 /* and the standard mountpoint for efivarfs */ 213 /* and the standard mountpoint for efivarfs */
215 efivars_kobj = kobject_create_and_add("efivars", efi_kobj); 214 error = sysfs_create_mount_point(efi_kobj, "efivars");
216 if (!efivars_kobj) { 215 if (error) {
217 pr_err("efivars: Subsystem registration failed.\n"); 216 pr_err("efivars: Subsystem registration failed.\n");
218 error = -ENOMEM;
219 goto err_remove_group; 217 goto err_remove_group;
220 } 218 }
221 219
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index 537356742091..a8f3b589a2df 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -129,8 +129,6 @@ void configfs_release_fs(void)
129} 129}
130 130
131 131
132static struct kobject *config_kobj;
133
134static int __init configfs_init(void) 132static int __init configfs_init(void)
135{ 133{
136 int err = -ENOMEM; 134 int err = -ENOMEM;
@@ -141,8 +139,8 @@ static int __init configfs_init(void)
141 if (!configfs_dir_cachep) 139 if (!configfs_dir_cachep)
142 goto out; 140 goto out;
143 141
144 config_kobj = kobject_create_and_add("config", kernel_kobj); 142 err = sysfs_create_mount_point(kernel_kobj, "config");
145 if (!config_kobj) 143 if (err)
146 goto out2; 144 goto out2;
147 145
148 err = register_filesystem(&configfs_fs_type); 146 err = register_filesystem(&configfs_fs_type);
@@ -152,7 +150,7 @@ static int __init configfs_init(void)
152 return 0; 150 return 0;
153out3: 151out3:
154 pr_err("Unable to register filesystem!\n"); 152 pr_err("Unable to register filesystem!\n");
155 kobject_put(config_kobj); 153 sysfs_remove_mount_point(kernel_kobj, "config");
156out2: 154out2:
157 kmem_cache_destroy(configfs_dir_cachep); 155 kmem_cache_destroy(configfs_dir_cachep);
158 configfs_dir_cachep = NULL; 156 configfs_dir_cachep = NULL;
@@ -163,7 +161,7 @@ out:
163static void __exit configfs_exit(void) 161static void __exit configfs_exit(void)
164{ 162{
165 unregister_filesystem(&configfs_fs_type); 163 unregister_filesystem(&configfs_fs_type);
166 kobject_put(config_kobj); 164 sysfs_remove_mount_point(kernel_kobj, "config");
167 kmem_cache_destroy(configfs_dir_cachep); 165 kmem_cache_destroy(configfs_dir_cachep);
168 configfs_dir_cachep = NULL; 166 configfs_dir_cachep = NULL;
169} 167}
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index c1e7ffb0dab6..12756040ca20 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -716,20 +716,17 @@ bool debugfs_initialized(void)
716} 716}
717EXPORT_SYMBOL_GPL(debugfs_initialized); 717EXPORT_SYMBOL_GPL(debugfs_initialized);
718 718
719
720static struct kobject *debug_kobj;
721
722static int __init debugfs_init(void) 719static int __init debugfs_init(void)
723{ 720{
724 int retval; 721 int retval;
725 722
726 debug_kobj = kobject_create_and_add("debug", kernel_kobj); 723 retval = sysfs_create_mount_point(kernel_kobj, "debug");
727 if (!debug_kobj) 724 if (retval)
728 return -EINVAL; 725 return retval;
729 726
730 retval = register_filesystem(&debug_fs_type); 727 retval = register_filesystem(&debug_fs_type);
731 if (retval) 728 if (retval)
732 kobject_put(debug_kobj); 729 sysfs_remove_mount_point(kernel_kobj, "debug");
733 else 730 else
734 debugfs_registered = true; 731 debugfs_registered = true;
735 732
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 082ac1c97f39..18dacf9ed8ff 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1238,7 +1238,6 @@ static void fuse_fs_cleanup(void)
1238} 1238}
1239 1239
1240static struct kobject *fuse_kobj; 1240static struct kobject *fuse_kobj;
1241static struct kobject *connections_kobj;
1242 1241
1243static int fuse_sysfs_init(void) 1242static int fuse_sysfs_init(void)
1244{ 1243{
@@ -1250,11 +1249,9 @@ static int fuse_sysfs_init(void)
1250 goto out_err; 1249 goto out_err;
1251 } 1250 }
1252 1251
1253 connections_kobj = kobject_create_and_add("connections", fuse_kobj); 1252 err = sysfs_create_mount_point(fuse_kobj, "connections");
1254 if (!connections_kobj) { 1253 if (err)
1255 err = -ENOMEM;
1256 goto out_fuse_unregister; 1254 goto out_fuse_unregister;
1257 }
1258 1255
1259 return 0; 1256 return 0;
1260 1257
@@ -1266,7 +1263,7 @@ static int fuse_sysfs_init(void)
1266 1263
1267static void fuse_sysfs_cleanup(void) 1264static void fuse_sysfs_cleanup(void)
1268{ 1265{
1269 kobject_put(connections_kobj); 1266 sysfs_remove_mount_point(fuse_kobj, "connections");
1270 kobject_put(fuse_kobj); 1267 kobject_put(fuse_kobj);
1271} 1268}
1272 1269
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index dc43b5f29305..3adcc4669fac 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -461,22 +461,18 @@ static struct file_system_type pstore_fs_type = {
461 .kill_sb = pstore_kill_sb, 461 .kill_sb = pstore_kill_sb,
462}; 462};
463 463
464static struct kobject *pstore_kobj;
465
466static int __init init_pstore_fs(void) 464static int __init init_pstore_fs(void)
467{ 465{
468 int err = 0; 466 int err;
469 467
470 /* Create a convenient mount point for people to access pstore */ 468 /* Create a convenient mount point for people to access pstore */
471 pstore_kobj = kobject_create_and_add("pstore", fs_kobj); 469 err = sysfs_create_mount_point(fs_kobj, "pstore");
472 if (!pstore_kobj) { 470 if (err)
473 err = -ENOMEM;
474 goto out; 471 goto out;
475 }
476 472
477 err = register_filesystem(&pstore_fs_type); 473 err = register_filesystem(&pstore_fs_type);
478 if (err < 0) 474 if (err < 0)
479 kobject_put(pstore_kobj); 475 sysfs_remove_mount_point(fs_kobj, "pstore");
480 476
481out: 477out:
482 return err; 478 return err;
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index d92bdf3b079a..a43df11a163f 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -631,14 +631,12 @@ bool tracefs_initialized(void)
631 return tracefs_registered; 631 return tracefs_registered;
632} 632}
633 633
634static struct kobject *trace_kobj;
635
636static int __init tracefs_init(void) 634static int __init tracefs_init(void)
637{ 635{
638 int retval; 636 int retval;
639 637
640 trace_kobj = kobject_create_and_add("tracing", kernel_kobj); 638 retval = sysfs_create_mount_point(kernel_kobj, "tracing");
641 if (!trace_kobj) 639 if (retval)
642 return -EINVAL; 640 return -EINVAL;
643 641
644 retval = register_filesystem(&trace_fs_type); 642 retval = register_filesystem(&trace_fs_type);
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 469dd547770c..e8a5491be756 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1924,8 +1924,6 @@ static struct file_system_type cgroup_fs_type = {
1924 .kill_sb = cgroup_kill_sb, 1924 .kill_sb = cgroup_kill_sb,
1925}; 1925};
1926 1926
1927static struct kobject *cgroup_kobj;
1928
1929/** 1927/**
1930 * task_cgroup_path - cgroup path of a task in the first cgroup hierarchy 1928 * task_cgroup_path - cgroup path of a task in the first cgroup hierarchy
1931 * @task: target task 1929 * @task: target task
@@ -5044,13 +5042,13 @@ int __init cgroup_init(void)
5044 ss->bind(init_css_set.subsys[ssid]); 5042 ss->bind(init_css_set.subsys[ssid]);
5045 } 5043 }
5046 5044
5047 cgroup_kobj = kobject_create_and_add("cgroup", fs_kobj); 5045 err = sysfs_create_mount_point(fs_kobj, "cgroup");
5048 if (!cgroup_kobj) 5046 if (err)
5049 return -ENOMEM; 5047 return err;
5050 5048
5051 err = register_filesystem(&cgroup_fs_type); 5049 err = register_filesystem(&cgroup_fs_type);
5052 if (err < 0) { 5050 if (err < 0) {
5053 kobject_put(cgroup_kobj); 5051 sysfs_remove_mount_point(fs_kobj, "cgroup");
5054 return err; 5052 return err;
5055 } 5053 }
5056 5054
diff --git a/security/inode.c b/security/inode.c
index 91503b79c5f8..0e37e4fba8fa 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -215,19 +215,17 @@ void securityfs_remove(struct dentry *dentry)
215} 215}
216EXPORT_SYMBOL_GPL(securityfs_remove); 216EXPORT_SYMBOL_GPL(securityfs_remove);
217 217
218static struct kobject *security_kobj;
219
220static int __init securityfs_init(void) 218static int __init securityfs_init(void)
221{ 219{
222 int retval; 220 int retval;
223 221
224 security_kobj = kobject_create_and_add("security", kernel_kobj); 222 retval = sysfs_create_mount_point(kernel_kobj, "security");
225 if (!security_kobj) 223 if (retval)
226 return -EINVAL; 224 return retval;
227 225
228 retval = register_filesystem(&fs_type); 226 retval = register_filesystem(&fs_type);
229 if (retval) 227 if (retval)
230 kobject_put(security_kobj); 228 sysfs_remove_mount_point(kernel_kobj, "security");
231 return retval; 229 return retval;
232} 230}
233 231
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index d2787cca1fcb..3d2201413028 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1853,7 +1853,6 @@ static struct file_system_type sel_fs_type = {
1853}; 1853};
1854 1854
1855struct vfsmount *selinuxfs_mount; 1855struct vfsmount *selinuxfs_mount;
1856static struct kobject *selinuxfs_kobj;
1857 1856
1858static int __init init_sel_fs(void) 1857static int __init init_sel_fs(void)
1859{ 1858{
@@ -1862,13 +1861,13 @@ static int __init init_sel_fs(void)
1862 if (!selinux_enabled) 1861 if (!selinux_enabled)
1863 return 0; 1862 return 0;
1864 1863
1865 selinuxfs_kobj = kobject_create_and_add("selinux", fs_kobj); 1864 err = sysfs_create_mount_point(fs_kobj, "selinux");
1866 if (!selinuxfs_kobj) 1865 if (err)
1867 return -ENOMEM; 1866 return err;
1868 1867
1869 err = register_filesystem(&sel_fs_type); 1868 err = register_filesystem(&sel_fs_type);
1870 if (err) { 1869 if (err) {
1871 kobject_put(selinuxfs_kobj); 1870 sysfs_remove_mount_point(fs_kobj, "selinux");
1872 return err; 1871 return err;
1873 } 1872 }
1874 1873
@@ -1887,7 +1886,7 @@ __initcall(init_sel_fs);
1887#ifdef CONFIG_SECURITY_SELINUX_DISABLE 1886#ifdef CONFIG_SECURITY_SELINUX_DISABLE
1888void exit_sel_fs(void) 1887void exit_sel_fs(void)
1889{ 1888{
1890 kobject_put(selinuxfs_kobj); 1889 sysfs_remove_mount_point(fs_kobj, "selinux");
1891 kern_unmount(selinuxfs_mount); 1890 kern_unmount(selinuxfs_mount);
1892 unregister_filesystem(&sel_fs_type); 1891 unregister_filesystem(&sel_fs_type);
1893} 1892}
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index d9682985349e..ac4cac7c661a 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -2241,16 +2241,16 @@ static const struct file_operations smk_revoke_subj_ops = {
2241 .llseek = generic_file_llseek, 2241 .llseek = generic_file_llseek,
2242}; 2242};
2243 2243
2244static struct kset *smackfs_kset;
2245/** 2244/**
2246 * smk_init_sysfs - initialize /sys/fs/smackfs 2245 * smk_init_sysfs - initialize /sys/fs/smackfs
2247 * 2246 *
2248 */ 2247 */
2249static int smk_init_sysfs(void) 2248static int smk_init_sysfs(void)
2250{ 2249{
2251 smackfs_kset = kset_create_and_add("smackfs", NULL, fs_kobj); 2250 int err;
2252 if (!smackfs_kset) 2251 err = sysfs_create_mount_point(fs_kobj, "smackfs");
2253 return -ENOMEM; 2252 if (err)
2253 return err;
2254 return 0; 2254 return 0;
2255} 2255}
2256 2256