Skip to content

Commit c4cff1e

Browse files
committed
Merge tag 'vfs-6.15-rc1.mount.api' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs mount API updates from Christian Brauner: "This converts the remaining pseudo filesystems to the new mount api. The sysv conversion is a bit gratuitous because we remove sysv in another pull request. But if we have to revert the removal we at least will have it converted to the new mount api already" * tag 'vfs-6.15-rc1.mount.api' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: sysv: convert sysv to use the new mount api vfs: remove some unused old mount api code devtmpfs: replace ->mount with ->get_tree in public instance vfs: Convert devpts to use the new mount API pstore: convert to the new mount API
2 parents 3514818 + 00dac02 commit c4cff1e

7 files changed

Lines changed: 287 additions & 271 deletions

File tree

drivers/base/devtmpfs.c

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,6 @@ __setup("devtmpfs.mount=", mount_param);
6363

6464
static struct vfsmount *mnt;
6565

66-
static struct dentry *public_dev_mount(struct file_system_type *fs_type, int flags,
67-
const char *dev_name, void *data)
68-
{
69-
struct super_block *s = mnt->mnt_sb;
70-
int err;
71-
72-
atomic_inc(&s->s_active);
73-
down_write(&s->s_umount);
74-
err = reconfigure_single(s, flags, data);
75-
if (err < 0) {
76-
deactivate_locked_super(s);
77-
return ERR_PTR(err);
78-
}
79-
return dget(s->s_root);
80-
}
81-
8266
static struct file_system_type internal_fs_type = {
8367
.name = "devtmpfs",
8468
#ifdef CONFIG_TMPFS
@@ -89,9 +73,40 @@ static struct file_system_type internal_fs_type = {
8973
.kill_sb = kill_litter_super,
9074
};
9175

76+
/* Simply take a ref on the existing mount */
77+
static int devtmpfs_get_tree(struct fs_context *fc)
78+
{
79+
struct super_block *sb = mnt->mnt_sb;
80+
81+
atomic_inc(&sb->s_active);
82+
down_write(&sb->s_umount);
83+
fc->root = dget(sb->s_root);
84+
return 0;
85+
}
86+
87+
/* Ops are filled in during init depending on underlying shmem or ramfs type */
88+
struct fs_context_operations devtmpfs_context_ops = {};
89+
90+
/* Call the underlying initialization and set to our ops */
91+
static int devtmpfs_init_fs_context(struct fs_context *fc)
92+
{
93+
int ret;
94+
#ifdef CONFIG_TMPFS
95+
ret = shmem_init_fs_context(fc);
96+
#else
97+
ret = ramfs_init_fs_context(fc);
98+
#endif
99+
if (ret < 0)
100+
return ret;
101+
102+
fc->ops = &devtmpfs_context_ops;
103+
104+
return 0;
105+
}
106+
92107
static struct file_system_type dev_fs_type = {
93108
.name = "devtmpfs",
94-
.mount = public_dev_mount,
109+
.init_fs_context = devtmpfs_init_fs_context,
95110
};
96111

97112
static int devtmpfs_submit_req(struct req *req, const char *tmp)
@@ -442,6 +457,31 @@ static int __ref devtmpfsd(void *p)
442457
return 0;
443458
}
444459

460+
/*
461+
* Get the underlying (shmem/ramfs) context ops to build ours
462+
*/
463+
static int devtmpfs_configure_context(void)
464+
{
465+
struct fs_context *fc;
466+
467+
fc = fs_context_for_reconfigure(mnt->mnt_root, mnt->mnt_sb->s_flags,
468+
MS_RMT_MASK);
469+
if (IS_ERR(fc))
470+
return PTR_ERR(fc);
471+
472+
/* Set up devtmpfs_context_ops based on underlying type */
473+
devtmpfs_context_ops.free = fc->ops->free;
474+
devtmpfs_context_ops.dup = fc->ops->dup;
475+
devtmpfs_context_ops.parse_param = fc->ops->parse_param;
476+
devtmpfs_context_ops.parse_monolithic = fc->ops->parse_monolithic;
477+
devtmpfs_context_ops.get_tree = &devtmpfs_get_tree;
478+
devtmpfs_context_ops.reconfigure = fc->ops->reconfigure;
479+
480+
put_fs_context(fc);
481+
482+
return 0;
483+
}
484+
445485
/*
446486
* Create devtmpfs instance, driver-core devices will add their device
447487
* nodes here.
@@ -456,6 +496,13 @@ int __init devtmpfs_init(void)
456496
pr_err("unable to create devtmpfs %ld\n", PTR_ERR(mnt));
457497
return PTR_ERR(mnt);
458498
}
499+
500+
err = devtmpfs_configure_context();
501+
if (err) {
502+
pr_err("unable to configure devtmpfs type %d\n", err);
503+
return err;
504+
}
505+
459506
err = register_filesystem(&dev_fs_type);
460507
if (err) {
461508
pr_err("unable to register devtmpfs type %d\n", err);

0 commit comments

Comments
 (0)