]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/xen/xenfs/super.c
userns: Stop oopsing in key_change_session_keyring
[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
10#include <linux/kernel.h>
11#include <linux/errno.h>
12#include <linux/module.h>
13#include <linux/fs.h>
14#include <linux/magic.h>
15
1ccbf534
JF
16#include <xen/xen.h>
17
1107ba88 18#include "xenfs.h"
d8414d3c 19#include "../privcmd.h"
2fb3683e 20#include "../xenbus/xenbus_comms.h"
1107ba88
AZ
21
22#include <asm/xen/hypervisor.h>
23
24MODULE_DESCRIPTION("Xen filesystem");
25MODULE_LICENSE("GPL");
26
818fd206
JF
27static ssize_t capabilities_read(struct file *file, char __user *buf,
28 size_t size, loff_t *off)
29{
30 char *tmp = "";
31
32 if (xen_initial_domain())
33 tmp = "control_d\n";
34
35 return simple_read_from_buffer(buf, size, off, tmp, strlen(tmp));
36}
37
38static const struct file_operations capabilities_file_ops = {
39 .read = capabilities_read,
6038f373 40 .llseek = default_llseek,
818fd206
JF
41};
42
1107ba88
AZ
43static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
44{
45 static struct tree_descr xenfs_files[] = {
78c3e473 46 [2] = { "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR },
818fd206 47 { "capabilities", &capabilities_file_ops, S_IRUGO },
d8414d3c 48 { "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR },
1107ba88
AZ
49 {""},
50 };
51
78c3e473
AV
52 static struct tree_descr xenfs_init_files[] = {
53 [2] = { "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR },
54 { "capabilities", &capabilities_file_ops, S_IRUGO },
55 { "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR },
56 { "xsd_kva", &xsd_kva_file_ops, S_IRUSR|S_IWUSR},
57 { "xsd_port", &xsd_port_file_ops, S_IRUSR|S_IWUSR},
58 {""},
59 };
1107ba88 60
78c3e473
AV
61 return simple_fill_super(sb, XENFS_SUPER_MAGIC,
62 xen_initial_domain() ? xenfs_init_files : xenfs_files);
1107ba88
AZ
63}
64
fe61f1d7
JF
65static struct dentry *xenfs_mount(struct file_system_type *fs_type,
66 int flags, const char *dev_name,
67 void *data)
1107ba88 68{
fc14f2fe 69 return mount_single(fs_type, flags, data, xenfs_fill_super);
1107ba88
AZ
70}
71
72static struct file_system_type xenfs_type = {
73 .owner = THIS_MODULE,
74 .name = "xenfs",
fc14f2fe 75 .mount = xenfs_mount,
1107ba88
AZ
76 .kill_sb = kill_litter_super,
77};
78
79static int __init xenfs_init(void)
80{
9045d47e
JF
81 if (xen_domain())
82 return register_filesystem(&xenfs_type);
1107ba88 83
9045d47e
JF
84 printk(KERN_INFO "XENFS: not registering filesystem on non-xen platform\n");
85 return 0;
1107ba88
AZ
86}
87
88static void __exit xenfs_exit(void)
89{
43df95c4 90 if (xen_domain())
1107ba88
AZ
91 unregister_filesystem(&xenfs_type);
92}
93
94module_init(xenfs_init);
95module_exit(xenfs_exit);
96