Blame view

drivers/xen/xenfs/super.c 1.89 KB
1107ba885   Alex Zeffertt   xen: add xenfs to...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  /*
   *  xenfs.c - a filesystem for passing info between the a domain and
   *  the hypervisor.
   *
   * 2008-10-07  Alex Zeffertt    Replaced /proc/xen/xenbus with xenfs filesystem
   *                              and /proc/xen compatibility mount point.
   *                              Turned xenfs into a loadable module.
   */
  
  #include <linux/kernel.h>
  #include <linux/errno.h>
  #include <linux/module.h>
  #include <linux/fs.h>
  #include <linux/magic.h>
1ccbf5344   Jeremy Fitzhardinge   xen: move Xen-tes...
15
  #include <xen/xen.h>
1107ba885   Alex Zeffertt   xen: add xenfs to...
16
17
18
19
20
21
  #include "xenfs.h"
  
  #include <asm/xen/hypervisor.h>
  
  MODULE_DESCRIPTION("Xen filesystem");
  MODULE_LICENSE("GPL");
818fd2067   Jeremy Fitzhardinge   xen: add "capabil...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  static ssize_t capabilities_read(struct file *file, char __user *buf,
  				 size_t size, loff_t *off)
  {
  	char *tmp = "";
  
  	if (xen_initial_domain())
  		tmp = "control_d
  ";
  
  	return simple_read_from_buffer(buf, size, off, tmp, strlen(tmp));
  }
  
  static const struct file_operations capabilities_file_ops = {
  	.read = capabilities_read,
  };
1107ba885   Alex Zeffertt   xen: add xenfs to...
37
38
39
  static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
  {
  	static struct tree_descr xenfs_files[] = {
818fd2067   Jeremy Fitzhardinge   xen: add "capabil...
40
41
42
  		[1] = {},
  		{ "xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR },
  		{ "capabilities", &capabilities_file_ops, S_IRUGO },
1107ba885   Alex Zeffertt   xen: add xenfs to...
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  		{""},
  	};
  
  	return simple_fill_super(sb, XENFS_SUPER_MAGIC, xenfs_files);
  }
  
  static int xenfs_get_sb(struct file_system_type *fs_type,
  			int flags, const char *dev_name,
  			void *data, struct vfsmount *mnt)
  {
  	return get_sb_single(fs_type, flags, data, xenfs_fill_super, mnt);
  }
  
  static struct file_system_type xenfs_type = {
  	.owner =	THIS_MODULE,
  	.name =		"xenfs",
  	.get_sb =	xenfs_get_sb,
  	.kill_sb =	kill_litter_super,
  };
  
  static int __init xenfs_init(void)
  {
43df95c44   Jeremy Fitzhardinge   xenfs: enable for...
65
  	if (xen_domain())
1107ba885   Alex Zeffertt   xen: add xenfs to...
66
67
68
69
70
71
72
73
74
  		return register_filesystem(&xenfs_type);
  
  	printk(KERN_INFO "XENFS: not registering filesystem on non-xen platform
  ");
  	return 0;
  }
  
  static void __exit xenfs_exit(void)
  {
43df95c44   Jeremy Fitzhardinge   xenfs: enable for...
75
  	if (xen_domain())
1107ba885   Alex Zeffertt   xen: add xenfs to...
76
77
78
79
80
  		unregister_filesystem(&xenfs_type);
  }
  
  module_init(xenfs_init);
  module_exit(xenfs_exit);