hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/security/inode.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * inode.c - securityfs
34 *
45 * Copyright (C) 2005 Greg Kroah-Hartman <gregkh@suse.de>
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public License version
8
- * 2 as published by the Free Software Foundation.
96 *
107 * Based on fs/debugfs/inode.c which had the following copyright notice:
118 * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
....@@ -13,8 +10,10 @@
1310 */
1411
1512 /* #define DEBUG */
16
-#include <linux/module.h>
13
+#include <linux/sysfs.h>
14
+#include <linux/kobject.h>
1715 #include <linux/fs.h>
16
+#include <linux/fs_context.h>
1817 #include <linux/mount.h>
1918 #include <linux/pagemap.h>
2019 #include <linux/init.h>
....@@ -26,25 +25,19 @@
2625 static struct vfsmount *mount;
2726 static int mount_count;
2827
29
-static void securityfs_i_callback(struct rcu_head *head)
28
+static void securityfs_free_inode(struct inode *inode)
3029 {
31
- struct inode *inode = container_of(head, struct inode, i_rcu);
3230 if (S_ISLNK(inode->i_mode))
3331 kfree(inode->i_link);
3432 free_inode_nonrcu(inode);
3533 }
3634
37
-static void securityfs_destroy_inode(struct inode *inode)
38
-{
39
- call_rcu(&inode->i_rcu, securityfs_i_callback);
40
-}
41
-
4235 static const struct super_operations securityfs_super_operations = {
4336 .statfs = simple_statfs,
44
- .destroy_inode = securityfs_destroy_inode,
37
+ .free_inode = securityfs_free_inode,
4538 };
4639
47
-static int fill_super(struct super_block *sb, void *data, int silent)
40
+static int securityfs_fill_super(struct super_block *sb, struct fs_context *fc)
4841 {
4942 static const struct tree_descr files[] = {{""}};
5043 int error;
....@@ -58,17 +51,25 @@
5851 return 0;
5952 }
6053
61
-static struct dentry *get_sb(struct file_system_type *fs_type,
62
- int flags, const char *dev_name,
63
- void *data)
54
+static int securityfs_get_tree(struct fs_context *fc)
6455 {
65
- return mount_single(fs_type, flags, data, fill_super);
56
+ return get_tree_single(fc, securityfs_fill_super);
57
+}
58
+
59
+static const struct fs_context_operations securityfs_context_ops = {
60
+ .get_tree = securityfs_get_tree,
61
+};
62
+
63
+static int securityfs_init_fs_context(struct fs_context *fc)
64
+{
65
+ fc->ops = &securityfs_context_ops;
66
+ return 0;
6667 }
6768
6869 static struct file_system_type fs_type = {
6970 .owner = THIS_MODULE,
7071 .name = "securityfs",
71
- .mount = get_sb,
72
+ .init_fs_context = securityfs_init_fs_context,
7273 .kill_sb = kill_litter_super,
7374 };
7475
....@@ -127,7 +128,7 @@
127128 dir = d_inode(parent);
128129
129130 inode_lock(dir);
130
- dentry = lookup_one_len2(name, mount, parent, strlen(name));
131
+ dentry = lookup_one_len(name, parent, strlen(name));
131132 if (IS_ERR(dentry))
132133 goto out;
133134
....@@ -346,7 +347,4 @@
346347 #endif
347348 return 0;
348349 }
349
-
350350 core_initcall(securityfs_init);
351
-MODULE_LICENSE("GPL");
352
-