| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * inode.c - securityfs |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * 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. |
|---|
| 9 | 6 | * |
|---|
| 10 | 7 | * Based on fs/debugfs/inode.c which had the following copyright notice: |
|---|
| 11 | 8 | * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com> |
|---|
| .. | .. |
|---|
| 13 | 10 | */ |
|---|
| 14 | 11 | |
|---|
| 15 | 12 | /* #define DEBUG */ |
|---|
| 16 | | -#include <linux/module.h> |
|---|
| 13 | +#include <linux/sysfs.h> |
|---|
| 14 | +#include <linux/kobject.h> |
|---|
| 17 | 15 | #include <linux/fs.h> |
|---|
| 16 | +#include <linux/fs_context.h> |
|---|
| 18 | 17 | #include <linux/mount.h> |
|---|
| 19 | 18 | #include <linux/pagemap.h> |
|---|
| 20 | 19 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 26 | 25 | static struct vfsmount *mount; |
|---|
| 27 | 26 | static int mount_count; |
|---|
| 28 | 27 | |
|---|
| 29 | | -static void securityfs_i_callback(struct rcu_head *head) |
|---|
| 28 | +static void securityfs_free_inode(struct inode *inode) |
|---|
| 30 | 29 | { |
|---|
| 31 | | - struct inode *inode = container_of(head, struct inode, i_rcu); |
|---|
| 32 | 30 | if (S_ISLNK(inode->i_mode)) |
|---|
| 33 | 31 | kfree(inode->i_link); |
|---|
| 34 | 32 | free_inode_nonrcu(inode); |
|---|
| 35 | 33 | } |
|---|
| 36 | 34 | |
|---|
| 37 | | -static void securityfs_destroy_inode(struct inode *inode) |
|---|
| 38 | | -{ |
|---|
| 39 | | - call_rcu(&inode->i_rcu, securityfs_i_callback); |
|---|
| 40 | | -} |
|---|
| 41 | | - |
|---|
| 42 | 35 | static const struct super_operations securityfs_super_operations = { |
|---|
| 43 | 36 | .statfs = simple_statfs, |
|---|
| 44 | | - .destroy_inode = securityfs_destroy_inode, |
|---|
| 37 | + .free_inode = securityfs_free_inode, |
|---|
| 45 | 38 | }; |
|---|
| 46 | 39 | |
|---|
| 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) |
|---|
| 48 | 41 | { |
|---|
| 49 | 42 | static const struct tree_descr files[] = {{""}}; |
|---|
| 50 | 43 | int error; |
|---|
| .. | .. |
|---|
| 58 | 51 | return 0; |
|---|
| 59 | 52 | } |
|---|
| 60 | 53 | |
|---|
| 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) |
|---|
| 64 | 55 | { |
|---|
| 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; |
|---|
| 66 | 67 | } |
|---|
| 67 | 68 | |
|---|
| 68 | 69 | static struct file_system_type fs_type = { |
|---|
| 69 | 70 | .owner = THIS_MODULE, |
|---|
| 70 | 71 | .name = "securityfs", |
|---|
| 71 | | - .mount = get_sb, |
|---|
| 72 | + .init_fs_context = securityfs_init_fs_context, |
|---|
| 72 | 73 | .kill_sb = kill_litter_super, |
|---|
| 73 | 74 | }; |
|---|
| 74 | 75 | |
|---|
| .. | .. |
|---|
| 127 | 128 | dir = d_inode(parent); |
|---|
| 128 | 129 | |
|---|
| 129 | 130 | inode_lock(dir); |
|---|
| 130 | | - dentry = lookup_one_len2(name, mount, parent, strlen(name)); |
|---|
| 131 | + dentry = lookup_one_len(name, parent, strlen(name)); |
|---|
| 131 | 132 | if (IS_ERR(dentry)) |
|---|
| 132 | 133 | goto out; |
|---|
| 133 | 134 | |
|---|
| .. | .. |
|---|
| 346 | 347 | #endif |
|---|
| 347 | 348 | return 0; |
|---|
| 348 | 349 | } |
|---|
| 349 | | - |
|---|
| 350 | 350 | core_initcall(securityfs_init); |
|---|
| 351 | | -MODULE_LICENSE("GPL"); |
|---|
| 352 | | - |
|---|