diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c index d7d64235010d..d02c451f6a4d 100644 --- a/drivers/xen/xenfs/super.c +++ b/drivers/xen/xenfs/super.c @@ -3,6 +3,11 @@ * xenfs.c - a filesystem for passing info between the a domain and * the hypervisor. * + * 2022-02-12 James Dingwall Introduce hide_deprecated module parameter to + * mask: + * - xenbus (deprecated in xen 4.6.0) + * - privcmd (deprecated in xen 4.7.0) + * * 2008-10-07 Alex Zeffertt Replaced /proc/xen/xenbus with xenfs filesystem * and /proc/xen compatibility mount point. * Turned xenfs into a loadable module. @@ -28,6 +33,13 @@ MODULE_DESCRIPTION("Xen filesystem"); MODULE_LICENSE("GPL"); +static bool __read_mostly hide_deprecated = 0; +module_param(hide_deprecated, bool, 0444); +MODULE_PARM_DESC(hide_deprecated, + "Allow deprecated files to be hidden in xenfs.\n"\ + " 0 - (default) show deprecated xenfs files."\ + " 1 - hide deprecated xenfs files [xenbus, privcmd].\n"); + static ssize_t capabilities_read(struct file *file, char __user *buf, size_t size, loff_t *off) { @@ -69,8 +81,32 @@ static int xenfs_fill_super(struct super_block *sb, struct fs_context *fc) xen_initial_domain() ? xenfs_init_files : xenfs_files); } +static int xenfs_fill_super_hide_deprecated(struct super_block *sb, struct fs_context *fc) +{ + static const struct tree_descr xenfs_files[] = { + [2] = { "capabilities", &capabilities_file_ops, S_IRUGO }, + {""}, + }; + + static const struct tree_descr xenfs_init_files[] = { + [2] = { "capabilities", &capabilities_file_ops, S_IRUGO }, + { "xsd_kva", &xsd_kva_file_ops, S_IRUSR|S_IWUSR}, + { "xsd_port", &xsd_port_file_ops, S_IRUSR|S_IWUSR}, +#ifdef CONFIG_XEN_SYMS + { "xensyms", &xensyms_ops, S_IRUSR}, +#endif + {""}, + }; + + return simple_fill_super(sb, XENFS_SUPER_MAGIC, + xen_initial_domain() ? xenfs_init_files : xenfs_files); +} + static int xenfs_get_tree(struct fs_context *fc) { + if(hide_deprecated) + return get_tree_single(fc, xenfs_fill_super_hide_deprecated); + return get_tree_single(fc, xenfs_fill_super); }