| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* -*- mode: c; c-basic-offset: 8; -*- |
|---|
| 2 | 3 | * vim: noexpandtab sw=8 ts=8 sts=0: |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * 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. |
|---|
| 20 | 6 | * |
|---|
| 21 | 7 | * Based on sysfs: |
|---|
| 22 | 8 | * sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel |
|---|
| .. | .. |
|---|
| 27 | 13 | #include <linux/fs.h> |
|---|
| 28 | 14 | #include <linux/module.h> |
|---|
| 29 | 15 | #include <linux/mount.h> |
|---|
| 16 | +#include <linux/fs_context.h> |
|---|
| 30 | 17 | #include <linux/pagemap.h> |
|---|
| 31 | 18 | #include <linux/init.h> |
|---|
| 32 | 19 | #include <linux/slab.h> |
|---|
| .. | .. |
|---|
| 41 | 28 | struct kmem_cache *configfs_dir_cachep; |
|---|
| 42 | 29 | static int configfs_mnt_count = 0; |
|---|
| 43 | 30 | |
|---|
| 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 | + |
|---|
| 44 | 39 | static const struct super_operations configfs_ops = { |
|---|
| 45 | 40 | .statfs = simple_statfs, |
|---|
| 46 | 41 | .drop_inode = generic_delete_inode, |
|---|
| 42 | + .free_inode = configfs_free_inode, |
|---|
| 47 | 43 | }; |
|---|
| 48 | 44 | |
|---|
| 49 | 45 | static struct config_group configfs_root_group = { |
|---|
| .. | .. |
|---|
| 66 | 62 | .s_iattr = NULL, |
|---|
| 67 | 63 | }; |
|---|
| 68 | 64 | |
|---|
| 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) |
|---|
| 70 | 66 | { |
|---|
| 71 | 67 | struct inode *inode; |
|---|
| 72 | 68 | struct dentry *root; |
|---|
| .. | .. |
|---|
| 102 | 98 | return 0; |
|---|
| 103 | 99 | } |
|---|
| 104 | 100 | |
|---|
| 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) |
|---|
| 107 | 102 | { |
|---|
| 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; |
|---|
| 109 | 114 | } |
|---|
| 110 | 115 | |
|---|
| 111 | 116 | static struct file_system_type configfs_fs_type = { |
|---|
| 112 | 117 | .owner = THIS_MODULE, |
|---|
| 113 | 118 | .name = "configfs", |
|---|
| 114 | | - .mount = configfs_do_mount, |
|---|
| 119 | + .init_fs_context = configfs_init_fs_context, |
|---|
| 115 | 120 | .kill_sb = kill_litter_super, |
|---|
| 116 | 121 | }; |
|---|
| 117 | 122 | MODULE_ALIAS_FS("configfs"); |
|---|
| .. | .. |
|---|
| 168 | 173 | |
|---|
| 169 | 174 | MODULE_AUTHOR("Oracle"); |
|---|
| 170 | 175 | MODULE_LICENSE("GPL"); |
|---|
| 176 | +MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver); |
|---|
| 171 | 177 | MODULE_VERSION("0.0.2"); |
|---|
| 172 | 178 | MODULE_DESCRIPTION("Simple RAM filesystem for user driven kernel subsystem configuration."); |
|---|
| 173 | 179 | |
|---|