8 #define KMSG_COMPONENT "hypfs"
9 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
11 #include <linux/types.h>
12 #include <linux/errno.h>
16 #include <linux/slab.h>
18 #include <linux/time.h>
21 #include <linux/module.h>
27 #define HYPFS_MAGIC 0x687970
46 static struct dentry *hypfs_last_dentry;
61 dentry->
d_fsdata = hypfs_last_dentry;
62 hypfs_last_dentry = dentry;
67 return dentry->
d_inode && !d_unhashed(dentry);
76 if (hypfs_positive(dentry)) {
87 static void hypfs_delete_tree(
struct dentry *root)
89 while (hypfs_last_dentry) {
90 struct dentry *next_dentry;
91 next_dentry = hypfs_last_dentry->
d_fsdata;
92 hypfs_remove(hypfs_last_dentry);
93 hypfs_last_dentry = next_dentry;
114 static void hypfs_evict_inode(
struct inode *
inode)
122 char *
data = filp->
f_path.dentry->d_inode->i_private;
134 fs_info = inode->
i_sb->s_fs_info;
148 unsigned long nr_segs, loff_t
offset)
171 unsigned long nr_segs, loff_t offset)
176 size_t count = iov_length(iov, nr_segs);
178 sb = iocb->
ki_filp->f_path.dentry->d_inode->i_sb;
195 hypfs_delete_tree(sb->
s_root);
201 pr_err(
"Updating the hypfs tree failed\n");
202 hypfs_delete_tree(sb->
s_root);
205 hypfs_update_update(sb);
212 static int hypfs_release(
struct inode *inode,
struct file *filp)
235 while ((str =
strsep(&options,
",")) !=
NULL) {
261 pr_err(
"%s is not a valid mount option\n", str);
268 static int hypfs_show_options(
struct seq_file *
s,
struct dentry *root)
277 static int hypfs_fill_super(
struct super_block *sb,
void *data,
int silent)
279 struct inode *root_inode;
280 struct dentry *root_dentry;
294 sb->
s_op = &hypfs_s_ops;
295 if (hypfs_parse_options(data, sb))
297 root_inode = hypfs_make_inode(sb,
S_IFDIR | 0755);
311 sbi->
update_file = hypfs_create_update_file(sb, root_dentry);
314 hypfs_update_update(sb);
315 pr_info(
"Hypervisor filesystem mounted\n");
320 const char *devname,
void *data)
322 return mount_single(fst, flags, data, hypfs_fill_super);
325 static void hypfs_kill_super(
struct super_block *sb)
330 hypfs_delete_tree(sb->
s_root);
338 static struct dentry *hypfs_create_file(
struct super_block *sb,
339 struct dentry *parent,
const char *
name,
342 struct dentry *dentry;
347 if (IS_ERR(dentry)) {
348 dentry = ERR_PTR(-
ENOMEM);
351 inode = hypfs_make_inode(sb, mode);
354 dentry = ERR_PTR(-
ENOMEM);
358 inode->
i_fop = &hypfs_file_ops;
380 struct dentry *dentry;
385 hypfs_add_dentry(dentry);
389 static struct dentry *hypfs_create_update_file(
struct super_block *sb,
392 struct dentry *dentry;
394 dentry = hypfs_create_file(sb, dir,
"update",
NULL,
409 struct dentry *dentry;
417 if (IS_ERR(dentry)) {
421 hypfs_add_dentry(dentry);
426 const char *name,
char *
string)
429 struct dentry *dentry;
434 sprintf(buffer,
"%s\n",
string);
437 if (IS_ERR(dentry)) {
441 hypfs_add_dentry(dentry);
447 .release = hypfs_release,
450 .aio_read = hypfs_aio_read,
451 .aio_write = hypfs_aio_write,
457 .name =
"s390_hypfs",
458 .mount = hypfs_mount,
459 .kill_sb = hypfs_kill_super
464 .evict_inode = hypfs_evict_inode,
465 .show_options = hypfs_show_options,
468 static struct kobject *s390_kobj;
470 static int __init hypfs_init(
void)
483 goto fail_hypfs_diag_exit;
488 goto fail_hypfs_vm_exit;
492 goto fail_filesystem;
499 fail_hypfs_diag_exit:
503 pr_err(
"Initialization of hypfs failed with rc=%i\n", rc);
507 static void __exit hypfs_exit(
void)