super.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #include <linux/kernel.h>
  10. #include <linux/errno.h>
  11. #include <linux/module.h>
  12. #include <linux/fs.h>
  13. #include <linux/magic.h>
  14. #include "xenfs.h"
  15. #include <asm/xen/hypervisor.h>
  16. MODULE_DESCRIPTION("Xen filesystem");
  17. MODULE_LICENSE("GPL");
  18. static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
  19. {
  20. static struct tree_descr xenfs_files[] = {
  21. [2] = {"xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR},
  22. {""},
  23. };
  24. return simple_fill_super(sb, XENFS_SUPER_MAGIC, xenfs_files);
  25. }
  26. static int xenfs_get_sb(struct file_system_type *fs_type,
  27. int flags, const char *dev_name,
  28. void *data, struct vfsmount *mnt)
  29. {
  30. return get_sb_single(fs_type, flags, data, xenfs_fill_super, mnt);
  31. }
  32. static struct file_system_type xenfs_type = {
  33. .owner = THIS_MODULE,
  34. .name = "xenfs",
  35. .get_sb = xenfs_get_sb,
  36. .kill_sb = kill_litter_super,
  37. };
  38. static int __init xenfs_init(void)
  39. {
  40. if (xen_pv_domain())
  41. return register_filesystem(&xenfs_type);
  42. printk(KERN_INFO "XENFS: not registering filesystem on non-xen platform\n");
  43. return 0;
  44. }
  45. static void __exit xenfs_exit(void)
  46. {
  47. if (xen_pv_domain())
  48. unregister_filesystem(&xenfs_type);
  49. }
  50. module_init(xenfs_init);
  51. module_exit(xenfs_exit);