2 * xenfs.c - a filesystem for passing info between the a domain and
5 * 2008-10-07 Alex Zeffertt Replaced /proc/xen/xenbus with xenfs filesystem
6 * and /proc/xen compatibility mount point.
7 * Turned xenfs into a loadable module.
10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12 #include <linux/kernel.h>
13 #include <linux/errno.h>
14 #include <linux/module.h>
16 #include <linux/magic.h>
21 #include "../privcmd.h"
22 #include "../xenbus/xenbus_comms.h"
24 #include <asm/xen/hypervisor.h>
26 MODULE_DESCRIPTION("Xen filesystem");
27 MODULE_LICENSE("GPL");
29 static ssize_t
capabilities_read(struct file
*file
, char __user
*buf
,
30 size_t size
, loff_t
*off
)
34 if (xen_initial_domain())
37 return simple_read_from_buffer(buf
, size
, off
, tmp
, strlen(tmp
));
40 static const struct file_operations capabilities_file_ops
= {
41 .read
= capabilities_read
,
42 .llseek
= default_llseek
,
45 static int xenfs_fill_super(struct super_block
*sb
, void *data
, int silent
)
47 static struct tree_descr xenfs_files
[] = {
48 [2] = { "xenbus", &xen_xenbus_fops
, S_IRUSR
|S_IWUSR
},
49 { "capabilities", &capabilities_file_ops
, S_IRUGO
},
50 { "privcmd", &xen_privcmd_fops
, S_IRUSR
|S_IWUSR
},
54 static struct tree_descr xenfs_init_files
[] = {
55 [2] = { "xenbus", &xen_xenbus_fops
, S_IRUSR
|S_IWUSR
},
56 { "capabilities", &capabilities_file_ops
, S_IRUGO
},
57 { "privcmd", &xen_privcmd_fops
, S_IRUSR
|S_IWUSR
},
58 { "xsd_kva", &xsd_kva_file_ops
, S_IRUSR
|S_IWUSR
},
59 { "xsd_port", &xsd_port_file_ops
, S_IRUSR
|S_IWUSR
},
63 return simple_fill_super(sb
, XENFS_SUPER_MAGIC
,
64 xen_initial_domain() ? xenfs_init_files
: xenfs_files
);
67 static struct dentry
*xenfs_mount(struct file_system_type
*fs_type
,
68 int flags
, const char *dev_name
,
71 return mount_single(fs_type
, flags
, data
, xenfs_fill_super
);
74 static struct file_system_type xenfs_type
= {
78 .kill_sb
= kill_litter_super
,
80 MODULE_ALIAS_FS("xenfs");
82 static int __init
xenfs_init(void)
85 return register_filesystem(&xenfs_type
);
87 pr_info("not registering filesystem on non-xen platform\n");
91 static void __exit
xenfs_exit(void)
94 unregister_filesystem(&xenfs_type
);
97 module_init(xenfs_init
);
98 module_exit(xenfs_exit
);