From ea5642c0ea537ef3c9da946d4f26a8f597b68622 Mon Sep 17 00:00:00 2001 From: Iurii Konovalenko Date: Thu, 19 Mar 2015 13:55:44 +0200 Subject: [PATCH] arm: xen: hack to make xen files unregular Change-Id: I0bc32867ca12dad78aa5f532a9c606fab9a3d1db Signed-off-by: Iurii Konovalenko --- drivers/xen/xenfs/super.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c index 06092e0..1f7e74c 100644 --- a/drivers/xen/xenfs/super.c +++ b/drivers/xen/xenfs/super.c @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -42,6 +43,74 @@ static const struct file_operations capabilities_file_ops = { .llseek = default_llseek, }; +static const struct super_operations xen_simple_super_operations = { + .statfs = simple_statfs, +}; + +static int xen_simple_fill_super(struct super_block *s, unsigned long magic, + struct tree_descr *files) +{ +struct inode *inode; +struct dentry *root; +struct dentry *dentry; +int i; + +s->s_blocksize = PAGE_CACHE_SIZE; +s->s_blocksize_bits = PAGE_CACHE_SHIFT; +s->s_magic = magic; +s->s_op = &xen_simple_super_operations; +s->s_time_gran = 1; + +inode = new_inode(s); +if (!inode) + return -ENOMEM; +/* +* because the root inode is 1, the files array must not contain an +* entry at index 1 +*/ +inode->i_ino = 1; +inode->i_mode = S_IFDIR | 0755; +inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; +inode->i_op = &simple_dir_inode_operations; +inode->i_fop = &simple_dir_operations; +set_nlink(inode, 2); +root = d_make_root(inode); +if (!root) + return -ENOMEM; +for (i = 0; !files->name || files->name[0]; i++, files++) { + if (!files->name) + continue; + + /* warn if it tries to conflict with the root inode */ + if (unlikely(i == 1)) + printk(KERN_WARNING "%s: %s passed in a files array" + "with an index of 1!\n", __func__, + s->s_type->name); + + dentry = d_alloc_name(root, files->name); + if (!dentry) + goto out; + inode = new_inode(s); + if (!inode) { + dput(dentry); + goto out; + } + inode->i_mode = files->mode; + inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + inode->i_fop = files->ops; + inode->i_ino = i; + d_add(dentry, inode); +} +s->s_root = root; +return 0; +out: +d_genocide(root); +shrink_dcache_parent(root); +dput(root); +return -ENOMEM; +} + + static int xenfs_fill_super(struct super_block *sb, void *data, int silent) { static struct tree_descr xenfs_files[] = { @@ -60,7 +129,7 @@ static int xenfs_fill_super(struct super_block *sb, void *data, int silent) {""}, }; - return simple_fill_super(sb, XENFS_SUPER_MAGIC, + return xen_simple_fill_super(sb, XENFS_SUPER_MAGIC, xen_initial_domain() ? xenfs_init_files : xenfs_files); } -- 1.9.1