hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/fs/openpromfs/inode.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /* inode.c: /proc/openprom handling routines
23 *
34 * Copyright (C) 1996-1999 Jakub Jelinek (jakub@redhat.com)
....@@ -8,6 +9,7 @@
89 #include <linux/types.h>
910 #include <linux/string.h>
1011 #include <linux/fs.h>
12
+#include <linux/fs_context.h>
1113 #include <linux/init.h>
1214 #include <linux/slab.h>
1315 #include <linux/seq_file.h>
....@@ -199,10 +201,11 @@
199201
200202 child = dp->child;
201203 while (child) {
202
- int n = strlen(child->path_component_name);
204
+ const char *node_name = kbasename(child->full_name);
205
+ int n = strlen(node_name);
203206
204207 if (len == n &&
205
- !strncmp(child->path_component_name, name, len)) {
208
+ !strncmp(node_name, name, len)) {
206209 ent_type = op_inode_node;
207210 ent_data.node = child;
208211 ino = child->unique_id;
....@@ -245,7 +248,7 @@
245248 set_nlink(inode, 2);
246249 break;
247250 case op_inode_prop:
248
- if (!strcmp(dp->name, "options") && (len == 17) &&
251
+ if (of_node_name_eq(dp, "options") && (len == 17) &&
249252 !strncmp (name, "security-password", 17))
250253 inode->i_mode = S_IFREG | S_IRUSR | S_IWUSR;
251254 else
....@@ -293,8 +296,8 @@
293296 }
294297 while (child) {
295298 if (!dir_emit(ctx,
296
- child->path_component_name,
297
- strlen(child->path_component_name),
299
+ kbasename(child->full_name),
300
+ strlen(kbasename(child->full_name)),
298301 child->unique_id, DT_DIR))
299302 goto out;
300303
....@@ -335,15 +338,9 @@
335338 return &oi->vfs_inode;
336339 }
337340
338
-static void openprom_i_callback(struct rcu_head *head)
341
+static void openprom_free_inode(struct inode *inode)
339342 {
340
- struct inode *inode = container_of(head, struct inode, i_rcu);
341343 kmem_cache_free(op_inode_cachep, OP_I(inode));
342
-}
343
-
344
-static void openprom_destroy_inode(struct inode *inode)
345
-{
346
- call_rcu(&inode->i_rcu, openprom_i_callback);
347344 }
348345
349346 static struct inode *openprom_iget(struct super_block *sb, ino_t ino)
....@@ -374,12 +371,12 @@
374371
375372 static const struct super_operations openprom_sops = {
376373 .alloc_inode = openprom_alloc_inode,
377
- .destroy_inode = openprom_destroy_inode,
374
+ .free_inode = openprom_free_inode,
378375 .statfs = simple_statfs,
379376 .remount_fs = openprom_remount,
380377 };
381378
382
-static int openprom_fill_super(struct super_block *s, void *data, int silent)
379
+static int openprom_fill_super(struct super_block *s, struct fs_context *fc)
383380 {
384381 struct inode *root_inode;
385382 struct op_inode_info *oi;
....@@ -413,16 +410,25 @@
413410 return ret;
414411 }
415412
416
-static struct dentry *openprom_mount(struct file_system_type *fs_type,
417
- int flags, const char *dev_name, void *data)
413
+static int openpromfs_get_tree(struct fs_context *fc)
418414 {
419
- return mount_single(fs_type, flags, data, openprom_fill_super);
415
+ return get_tree_single(fc, openprom_fill_super);
416
+}
417
+
418
+static const struct fs_context_operations openpromfs_context_ops = {
419
+ .get_tree = openpromfs_get_tree,
420
+};
421
+
422
+static int openpromfs_init_fs_context(struct fs_context *fc)
423
+{
424
+ fc->ops = &openpromfs_context_ops;
425
+ return 0;
420426 }
421427
422428 static struct file_system_type openprom_fs_type = {
423429 .owner = THIS_MODULE,
424430 .name = "openpromfs",
425
- .mount = openprom_mount,
431
+ .init_fs_context = openpromfs_init_fs_context,
426432 .kill_sb = kill_anon_super,
427433 };
428434 MODULE_ALIAS_FS("openpromfs");