linux/drivers/xen/xenfs/super.c
<<
>>
Prefs
   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
  16#include "xenfs.h"
  17
  18#include <asm/xen/hypervisor.h>
  19
  20MODULE_DESCRIPTION("Xen filesystem");
  21MODULE_LICENSE("GPL");
  22
  23static ssize_t capabilities_read(struct file *file, char __user *buf,
  24                                 size_t size, loff_t *off)
  25{
  26        char *tmp = "";
  27
  28        if (xen_initial_domain())
  29                tmp = "control_d\n";
  30
  31        return simple_read_from_buffer(buf, size, off, tmp, strlen(tmp));
  32}
  33
  34static const struct file_operations capabilities_file_ops = {
  35        .read = capabilities_read,
  36};
  37
  38static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
  39{
  40        static struct tree_descr xenfs_files[] = {
  41                [1] = {},
  42                { "xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR },
  43                { "capabilities", &capabilities_file_ops, S_IRUGO },
  44                {""},
  45        };
  46
  47        return simple_fill_super(sb, XENFS_SUPER_MAGIC, xenfs_files);
  48}
  49
  50static int xenfs_get_sb(struct file_system_type *fs_type,
  51                        int flags, const char *dev_name,
  52                        void *data, struct vfsmount *mnt)
  53{
  54        return get_sb_single(fs_type, flags, data, xenfs_fill_super, mnt);
  55}
  56
  57static struct file_system_type xenfs_type = {
  58        .owner =        THIS_MODULE,
  59        .name =         "xenfs",
  60        .get_sb =       xenfs_get_sb,
  61        .kill_sb =      kill_litter_super,
  62};
  63
  64static int __init xenfs_init(void)
  65{
  66        if (xen_pv_domain())
  67                return register_filesystem(&xenfs_type);
  68
  69        printk(KERN_INFO "XENFS: not registering filesystem on non-xen platform\n");
  70        return 0;
  71}
  72
  73static void __exit xenfs_exit(void)
  74{
  75        if (xen_pv_domain())
  76                unregister_filesystem(&xenfs_type);
  77}
  78
  79module_init(xenfs_init);
  80module_exit(xenfs_exit);
  81
  82