hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/configfs/mount.c
....@@ -1,22 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* -*- mode: c; c-basic-offset: 8; -*-
23 * vim: noexpandtab sw=8 ts=8 sts=0:
34 *
45 * mount.c - operations for initializing and mounting configfs.
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public
8
- * License as published by the Free Software Foundation; either
9
- * version 2 of the License, or (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- * General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public
17
- * License along with this program; if not, write to the
18
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
- * Boston, MA 021110-1307, USA.
206 *
217 * Based on sysfs:
228 * sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel
....@@ -27,6 +13,7 @@
2713 #include <linux/fs.h>
2814 #include <linux/module.h>
2915 #include <linux/mount.h>
16
+#include <linux/fs_context.h>
3017 #include <linux/pagemap.h>
3118 #include <linux/init.h>
3219 #include <linux/slab.h>
....@@ -41,9 +28,18 @@
4128 struct kmem_cache *configfs_dir_cachep;
4229 static int configfs_mnt_count = 0;
4330
31
+
32
+static void configfs_free_inode(struct inode *inode)
33
+{
34
+ if (S_ISLNK(inode->i_mode))
35
+ kfree(inode->i_link);
36
+ free_inode_nonrcu(inode);
37
+}
38
+
4439 static const struct super_operations configfs_ops = {
4540 .statfs = simple_statfs,
4641 .drop_inode = generic_delete_inode,
42
+ .free_inode = configfs_free_inode,
4743 };
4844
4945 static struct config_group configfs_root_group = {
....@@ -66,7 +62,7 @@
6662 .s_iattr = NULL,
6763 };
6864
69
-static int configfs_fill_super(struct super_block *sb, void *data, int silent)
65
+static int configfs_fill_super(struct super_block *sb, struct fs_context *fc)
7066 {
7167 struct inode *inode;
7268 struct dentry *root;
....@@ -102,16 +98,25 @@
10298 return 0;
10399 }
104100
105
-static struct dentry *configfs_do_mount(struct file_system_type *fs_type,
106
- int flags, const char *dev_name, void *data)
101
+static int configfs_get_tree(struct fs_context *fc)
107102 {
108
- return mount_single(fs_type, flags, data, configfs_fill_super);
103
+ return get_tree_single(fc, configfs_fill_super);
104
+}
105
+
106
+static const struct fs_context_operations configfs_context_ops = {
107
+ .get_tree = configfs_get_tree,
108
+};
109
+
110
+static int configfs_init_fs_context(struct fs_context *fc)
111
+{
112
+ fc->ops = &configfs_context_ops;
113
+ return 0;
109114 }
110115
111116 static struct file_system_type configfs_fs_type = {
112117 .owner = THIS_MODULE,
113118 .name = "configfs",
114
- .mount = configfs_do_mount,
119
+ .init_fs_context = configfs_init_fs_context,
115120 .kill_sb = kill_litter_super,
116121 };
117122 MODULE_ALIAS_FS("configfs");
....@@ -168,6 +173,7 @@
168173
169174 MODULE_AUTHOR("Oracle");
170175 MODULE_LICENSE("GPL");
176
+MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
171177 MODULE_VERSION("0.0.2");
172178 MODULE_DESCRIPTION("Simple RAM filesystem for user driven kernel subsystem configuration.");
173179