]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/xen/xenfs/super.c
Merge branches 'for-4.11/upstream-fixes', 'for-4.12/accutouch', 'for-4.12/cp2112...
[mirror_ubuntu-artful-kernel.git] / drivers / xen / xenfs / super.c
CommitLineData
1107ba88
AZ
1/*
2 * xenfs.c - a filesystem for passing info between the a domain and
3 * the hypervisor.
4 *
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.
8 */
9
283c0972
JP
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
1107ba88
AZ
12#include <linux/kernel.h>
13#include <linux/errno.h>
14#include <linux/module.h>
15#include <linux/fs.h>
16#include <linux/magic.h>
17
1ccbf534 18#include <xen/xen.h>
332f791d 19#include <xen/xenbus.h>
1ccbf534 20
1107ba88 21#include "xenfs.h"
d8414d3c 22#include "../privcmd.h"
1107ba88
AZ
23
24#include <asm/xen/hypervisor.h>
25
26MODULE_DESCRIPTION("Xen filesystem");
27MODULE_LICENSE("GPL");
28
818fd206
JF
29static ssize_t capabilities_read(struct file *file, char __user *buf,
30 size_t size, loff_t *off)
31{
32 char *tmp = "";
33
34 if (xen_initial_domain())
35 tmp = "control_d\n";
36
37 return simple_read_from_buffer(buf, size, off, tmp, strlen(tmp));
38}
39
40static const struct file_operations capabilities_file_ops = {
41 .read = capabilities_read,
6038f373 42 .llseek = default_llseek,
818fd206
JF
43};
44
1107ba88
AZ
45static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
46{
47 static struct tree_descr xenfs_files[] = {
78c3e473 48 [2] = { "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR },
818fd206 49 { "capabilities", &capabilities_file_ops, S_IRUGO },
d8414d3c 50 { "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR },
1107ba88
AZ
51 {""},
52 };
53
78c3e473
AV
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},
a11f4f0a
BO
60#ifdef CONFIG_XEN_SYMS
61 { "xensyms", &xensyms_ops, S_IRUSR},
62#endif
78c3e473
AV
63 {""},
64 };
1107ba88 65
78c3e473
AV
66 return simple_fill_super(sb, XENFS_SUPER_MAGIC,
67 xen_initial_domain() ? xenfs_init_files : xenfs_files);
1107ba88
AZ
68}
69
fe61f1d7
JF
70static struct dentry *xenfs_mount(struct file_system_type *fs_type,
71 int flags, const char *dev_name,
72 void *data)
1107ba88 73{
fc14f2fe 74 return mount_single(fs_type, flags, data, xenfs_fill_super);
1107ba88
AZ
75}
76
77static struct file_system_type xenfs_type = {
78 .owner = THIS_MODULE,
79 .name = "xenfs",
fc14f2fe 80 .mount = xenfs_mount,
1107ba88
AZ
81 .kill_sb = kill_litter_super,
82};
7f78e035 83MODULE_ALIAS_FS("xenfs");
1107ba88
AZ
84
85static int __init xenfs_init(void)
86{
9045d47e
JF
87 if (xen_domain())
88 return register_filesystem(&xenfs_type);
1107ba88 89
283c0972 90 pr_info("not registering filesystem on non-xen platform\n");
9045d47e 91 return 0;
1107ba88
AZ
92}
93
94static void __exit xenfs_exit(void)
95{
43df95c4 96 if (xen_domain())
1107ba88
AZ
97 unregister_filesystem(&xenfs_type);
98}
99
100module_init(xenfs_init);
101module_exit(xenfs_exit);
102