4 #define DEBUG_SUBSYSTEM S_SNAP
6 #include <linux/module.h>
7 #include <linux/kmod.h>
8 #include <linux/init.h>
10 #include <linux/slab.h>
11 #include <linux/string.h>
12 #include <linux/jbd.h>
13 #include <linux/ext3_fs.h>
14 #include <linux/snap.h>
15 #include <linux/errno.h>
16 #include "snapfs_internal.h"
19 static struct list_head option_list;
20 static char *options = NULL;
21 static char *opt_left = NULL;
23 int init_option(char *data)
25 INIT_LIST_HEAD(&option_list);
26 SNAP_ALLOC(options, strlen(data) + 1);
28 CERROR("Can not allocate memory \n");
31 memcpy(options, data, strlen(data));
39 struct option *option;
40 while (!list_empty(&option_list)) {
41 option = list_entry(option_list.next, struct option, list);
42 list_del(&option->list);
43 SNAP_FREE(option->opt, strlen(option->opt) + 1);
44 SNAP_FREE(option->value, strlen(option->value) + 1);
45 SNAP_FREE(option, sizeof(struct option));
47 SNAP_FREE(options, strlen(options) + 1);
50 int get_opt(struct option **option, char **pos)
52 char *name, *value, *left;
53 struct option *tmp_opt;
61 left = strchr(opt_left, '=');
63 if (left == opt_left || !left)
66 SNAP_ALLOC(tmp_opt, sizeof(struct option));
68 length = left - opt_left + 1;
69 SNAP_ALLOC(name, length);
71 memset(name, 0, length);
72 while (opt_left != left) *name++ = *opt_left++;
74 opt_left ++; /*after '='*/
76 left = strchr(opt_left, ',');
77 if (left == opt_left) {
78 SNAP_FREE(tmp_opt->opt, length);
79 SNAP_FREE(tmp_opt, sizeof(struct option));
84 left = opt_left + strlen(opt_left);
85 length = left - opt_left + 1;
86 SNAP_ALLOC(value, length);
87 tmp_opt->value = value;
88 memset(value, 0, length);
89 while (opt_left != left) *value++ = *opt_left++;
91 list_add(&tmp_opt->list, &option_list);
93 if (*opt_left == ',') opt_left ++; /*after ','*/