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 #include <linux/kernel.h>
11 #include <linux/errno.h>
12 #include <linux/module.h>
14 #include <linux/magic.h>
19 #include "../privcmd.h"
20 #include "../xenbus/xenbus_comms.h"
22 #include <asm/xen/hypervisor.h>
24 MODULE_DESCRIPTION("Xen filesystem");
25 MODULE_LICENSE("GPL");
27 static ssize_t
capabilities_read(struct file
*file
, char __user
*buf
,
28 size_t size
, loff_t
*off
)
32 if (xen_initial_domain())
35 return simple_read_from_buffer(buf
, size
, off
, tmp
, strlen(tmp
));
38 static const struct file_operations capabilities_file_ops
= {
39 .read
= capabilities_read
,
40 .llseek
= default_llseek
,
43 static int xenfs_fill_super(struct super_block
*sb
, void *data
, int silent
)
45 static struct tree_descr xenfs_files
[] = {
46 [2] = { "xenbus", &xen_xenbus_fops
, S_IRUSR
|S_IWUSR
},
47 { "capabilities", &capabilities_file_ops
, S_IRUGO
},
48 { "privcmd", &xen_privcmd_fops
, S_IRUSR
|S_IWUSR
},
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
},
61 return simple_fill_super(sb
, XENFS_SUPER_MAGIC
,
62 xen_initial_domain() ? xenfs_init_files
: xenfs_files
);
65 static struct dentry
*xenfs_mount(struct file_system_type
*fs_type
,
66 int flags
, const char *dev_name
,
69 return mount_single(fs_type
, flags
, data
, xenfs_fill_super
);
72 static struct file_system_type xenfs_type
= {
76 .kill_sb
= kill_litter_super
,
78 MODULE_ALIAS_FS("xenfs");
80 static int __init
xenfs_init(void)
83 return register_filesystem(&xenfs_type
);
85 printk(KERN_INFO
"XENFS: not registering filesystem on non-xen platform\n");
89 static void __exit
xenfs_exit(void)
92 unregister_filesystem(&xenfs_type
);
95 module_init(xenfs_init
);
96 module_exit(xenfs_exit
);