aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/xenfs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/xen/xenfs/super.c')
-rw-r--r--drivers/xen/xenfs/super.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c
index 78bfab0700ba..3cf7707217f2 100644
--- a/drivers/xen/xenfs/super.c
+++ b/drivers/xen/xenfs/super.c
@@ -22,6 +22,46 @@
22MODULE_DESCRIPTION("Xen filesystem"); 22MODULE_DESCRIPTION("Xen filesystem");
23MODULE_LICENSE("GPL"); 23MODULE_LICENSE("GPL");
24 24
25static struct inode *xenfs_make_inode(struct super_block *sb, int mode)
26{
27 struct inode *ret = new_inode(sb);
28
29 if (ret) {
30 ret->i_mode = mode;
31 ret->i_uid = ret->i_gid = 0;
32 ret->i_blocks = 0;
33 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
34 }
35 return ret;
36}
37
38static struct dentry *xenfs_create_file(struct super_block *sb,
39 struct dentry *parent,
40 const char *name,
41 const struct file_operations *fops,
42 void *data,
43 int mode)
44{
45 struct dentry *dentry;
46 struct inode *inode;
47
48 dentry = d_alloc_name(parent, name);
49 if (!dentry)
50 return NULL;
51
52 inode = xenfs_make_inode(sb, S_IFREG | mode);
53 if (!inode) {
54 dput(dentry);
55 return NULL;
56 }
57
58 inode->i_fop = fops;
59 inode->i_private = data;
60
61 d_add(dentry, inode);
62 return dentry;
63}
64
25static ssize_t capabilities_read(struct file *file, char __user *buf, 65static ssize_t capabilities_read(struct file *file, char __user *buf,
26 size_t size, loff_t *off) 66 size_t size, loff_t *off)
27{ 67{
@@ -45,8 +85,20 @@ static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
45 { "capabilities", &capabilities_file_ops, S_IRUGO }, 85 { "capabilities", &capabilities_file_ops, S_IRUGO },
46 {""}, 86 {""},
47 }; 87 };
88 int rc;
89
90 rc = simple_fill_super(sb, XENFS_SUPER_MAGIC, xenfs_files);
91 if (rc < 0)
92 return rc;
93
94 if (xen_initial_domain()) {
95 xenfs_create_file(sb, sb->s_root, "xsd_kva",
96 &xsd_kva_file_ops, NULL, S_IRUSR|S_IWUSR);
97 xenfs_create_file(sb, sb->s_root, "xsd_port",
98 &xsd_port_file_ops, NULL, S_IRUSR|S_IWUSR);
99 }
48 100
49 return simple_fill_super(sb, XENFS_SUPER_MAGIC, xenfs_files); 101 return rc;
50} 102}
51 103
52static int xenfs_get_sb(struct file_system_type *fs_type, 104static int xenfs_get_sb(struct file_system_type *fs_type,