diff options
Diffstat (limited to 'fs/pstore/inode.c')
-rw-r--r-- | fs/pstore/inode.c | 76 |
1 files changed, 53 insertions, 23 deletions
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index 08342232cb1c..977ed2723845 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/string.h> | 27 | #include <linux/string.h> |
28 | #include <linux/mount.h> | 28 | #include <linux/mount.h> |
29 | #include <linux/ramfs.h> | 29 | #include <linux/ramfs.h> |
30 | #include <linux/parser.h> | ||
30 | #include <linux/sched.h> | 31 | #include <linux/sched.h> |
31 | #include <linux/magic.h> | 32 | #include <linux/magic.h> |
32 | #include <linux/pstore.h> | 33 | #include <linux/pstore.h> |
@@ -73,11 +74,16 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry) | |||
73 | struct pstore_private *p = dentry->d_inode->i_private; | 74 | struct pstore_private *p = dentry->d_inode->i_private; |
74 | 75 | ||
75 | p->erase(p->id); | 76 | p->erase(p->id); |
76 | kfree(p); | ||
77 | 77 | ||
78 | return simple_unlink(dir, dentry); | 78 | return simple_unlink(dir, dentry); |
79 | } | 79 | } |
80 | 80 | ||
81 | static void pstore_evict_inode(struct inode *inode) | ||
82 | { | ||
83 | end_writeback(inode); | ||
84 | kfree(inode->i_private); | ||
85 | } | ||
86 | |||
81 | static const struct inode_operations pstore_dir_inode_operations = { | 87 | static const struct inode_operations pstore_dir_inode_operations = { |
82 | .lookup = simple_lookup, | 88 | .lookup = simple_lookup, |
83 | .unlink = pstore_unlink, | 89 | .unlink = pstore_unlink, |
@@ -107,9 +113,52 @@ static struct inode *pstore_get_inode(struct super_block *sb, | |||
107 | return inode; | 113 | return inode; |
108 | } | 114 | } |
109 | 115 | ||
116 | enum { | ||
117 | Opt_kmsg_bytes, Opt_err | ||
118 | }; | ||
119 | |||
120 | static const match_table_t tokens = { | ||
121 | {Opt_kmsg_bytes, "kmsg_bytes=%u"}, | ||
122 | {Opt_err, NULL} | ||
123 | }; | ||
124 | |||
125 | static void parse_options(char *options) | ||
126 | { | ||
127 | char *p; | ||
128 | substring_t args[MAX_OPT_ARGS]; | ||
129 | int option; | ||
130 | |||
131 | if (!options) | ||
132 | return; | ||
133 | |||
134 | while ((p = strsep(&options, ",")) != NULL) { | ||
135 | int token; | ||
136 | |||
137 | if (!*p) | ||
138 | continue; | ||
139 | |||
140 | token = match_token(p, tokens, args); | ||
141 | switch (token) { | ||
142 | case Opt_kmsg_bytes: | ||
143 | if (!match_int(&args[0], &option)) | ||
144 | pstore_set_kmsg_bytes(option); | ||
145 | break; | ||
146 | } | ||
147 | } | ||
148 | } | ||
149 | |||
150 | static int pstore_remount(struct super_block *sb, int *flags, char *data) | ||
151 | { | ||
152 | parse_options(data); | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
110 | static const struct super_operations pstore_ops = { | 157 | static const struct super_operations pstore_ops = { |
111 | .statfs = simple_statfs, | 158 | .statfs = simple_statfs, |
112 | .drop_inode = generic_delete_inode, | 159 | .drop_inode = generic_delete_inode, |
160 | .evict_inode = pstore_evict_inode, | ||
161 | .remount_fs = pstore_remount, | ||
113 | .show_options = generic_show_options, | 162 | .show_options = generic_show_options, |
114 | }; | 163 | }; |
115 | 164 | ||
@@ -209,6 +258,8 @@ int pstore_fill_super(struct super_block *sb, void *data, int silent) | |||
209 | sb->s_op = &pstore_ops; | 258 | sb->s_op = &pstore_ops; |
210 | sb->s_time_gran = 1; | 259 | sb->s_time_gran = 1; |
211 | 260 | ||
261 | parse_options(data); | ||
262 | |||
212 | inode = pstore_get_inode(sb, NULL, S_IFDIR | 0755, 0); | 263 | inode = pstore_get_inode(sb, NULL, S_IFDIR | 0755, 0); |
213 | if (!inode) { | 264 | if (!inode) { |
214 | err = -ENOMEM; | 265 | err = -ENOMEM; |
@@ -252,28 +303,7 @@ static struct file_system_type pstore_fs_type = { | |||
252 | 303 | ||
253 | static int __init init_pstore_fs(void) | 304 | static int __init init_pstore_fs(void) |
254 | { | 305 | { |
255 | int rc = 0; | 306 | return register_filesystem(&pstore_fs_type); |
256 | struct kobject *pstorefs_kobj; | ||
257 | |||
258 | pstorefs_kobj = kobject_create_and_add("pstore", fs_kobj); | ||
259 | if (!pstorefs_kobj) { | ||
260 | rc = -ENOMEM; | ||
261 | goto done; | ||
262 | } | ||
263 | |||
264 | rc = sysfs_create_file(pstorefs_kobj, &pstore_kmsg_bytes_attr.attr); | ||
265 | if (rc) | ||
266 | goto done1; | ||
267 | |||
268 | rc = register_filesystem(&pstore_fs_type); | ||
269 | if (rc == 0) | ||
270 | goto done; | ||
271 | |||
272 | sysfs_remove_file(pstorefs_kobj, &pstore_kmsg_bytes_attr.attr); | ||
273 | done1: | ||
274 | kobject_put(pstorefs_kobj); | ||
275 | done: | ||
276 | return rc; | ||
277 | } | 307 | } |
278 | module_init(init_pstore_fs) | 308 | module_init(init_pstore_fs) |
279 | 309 | ||