4 * Copyright (C) 1998 Peter J. Braam
5 * Copyright (C) 2000 Stelias Computing, Inc.
6 * Copyright (C) 2000 Red Hat, Inc.
7 * Copyright (C) 2000 Mountain View Data, Inc.
9 * Author: Peter J. Braam <braam@mountainviewdata.com>
11 #define DEBUG_SUBSYSTEM S_SNAP
13 #include <linux/module.h>
14 #include <linux/kmod.h>
15 #include <linux/init.h>
17 #include <linux/slab.h>
18 #include <linux/string.h>
19 #include <linux/loop.h>
20 //#include <linux/jbd.h>
21 //#include <linux/ext3_fs.h>
22 #include <linux/errno.h>
23 #include "smfs_internal.h"
25 /* Find the options for the clone. These consist of a cache device
26 and an index in the snaptable associated with that device.
28 static char *smfs_options(char *options, char **devstr, char **namestr)
30 struct option *opt_value = NULL;
33 while (!(get_opt(&opt_value, &pos))) {
34 if (!strcmp(opt_value->opt, "dev")) {
36 *devstr = opt_value->value;
37 } else if (!strcmp(opt_value->opt, "type")) {
39 *namestr = opt_value->value;
46 extern struct super_operations smfs_super_ops;
48 static struct super_block *sm_mount_cache(struct super_block *sb,
57 struct super_block *sb,
61 struct smfs_inode_info *smi;
62 struct smfs_super_info *smb;
63 struct dentry *bottom_root;
64 struct inode *root_inode = NULL;
65 struct super_block *cache_sb;
66 char *devstr = NULL, *typestr = NULL;
73 CDEBUG(D_SUPER, "mount opts: %s\n", data ? (char *)data : "(none)");
76 /* read and validate options */
77 cache_data = smfs_options(data, &devstr, &typestr);
79 CERROR("invalid mount option %s\n", (char*)data);
80 GOTO(out_err, err=-EINVAL);
82 if (!typestr || !devstr) {
83 CERROR("mount options name and dev mandatory\n");
84 GOTO(out_err, err=-EINVAL);
87 cache_sb = sm_mount_cache(sb, devstr, typestr);
89 CERROR("Can not mount %s as %s\n", devstr, typestr);
90 GOTO(out_err, err=-EINVAL);
92 /* set up the super block */
94 smb->smsi_sb = cache_sb;
95 sb->s_op = &smfs_super_ops;
97 bottom_root = dget(cache_sb->s_root);
99 CERROR("bottom not mounted\n");
100 GOTO(out_err, err=-ENOENT);
103 root_ino = bottom_root->d_inode->i_ino;
104 smi = I2SMI(root_inode);
105 /*FIXME Intialize smi here*/
107 CDEBUG(D_SUPER, "readinode %p, root ino %ld, root inode at %p\n",
108 sb->s_op->read_inode, root_ino, root_inode);
110 sb->s_root = d_alloc_root(bottom_root->d_inode);
113 GOTO(out_err, err=-EINVAL);
116 CDEBUG(D_SUPER, "sb %lx, &sb->u.generic_sbp: %lx\n",
117 (ulong) sb, (ulong) &sb->u.generic_sbp);
126 static DECLARE_FSTYPE(smfs_type, "smfs", smfs_read_super, 0);
132 err = register_filesystem(&smfs_type);
134 CERROR("smfs: failed in register Storage Management filesystem!\n");
139 int cleanup_smfs(void)
144 err = unregister_filesystem(&smfs_type);
146 CERROR("smfs: failed to unregister Storage Management filesystem!\n");