diff options
author | Luck, Tony <tony.luck@intel.com> | 2011-03-18 18:33:43 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-21 16:50:05 -0400 |
commit | 366f7e7a79b19bd8c4e8f55fdf12b81538d1a7a4 (patch) | |
tree | 0c43335ab9e91ca895fdec82d1327cec16dcb645 /fs/pstore/inode.c | |
parent | 10effcb548c170d59ea1d2152f2ee0ad45ce4c9d (diff) |
pstore: use mount option instead sysfs to tweak kmsg_bytes
/sys/fs is a somewhat strange way to tweak what could more
obviously be tuned with a mount option.
Suggested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/pstore/inode.c')
-rw-r--r-- | fs/pstore/inode.c | 68 |
1 files changed, 46 insertions, 22 deletions
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index f777f2902c49..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> |
@@ -112,10 +113,52 @@ static struct inode *pstore_get_inode(struct super_block *sb, | |||
112 | return inode; | 113 | return inode; |
113 | } | 114 | } |
114 | 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 | |||
115 | static const struct super_operations pstore_ops = { | 157 | static const struct super_operations pstore_ops = { |
116 | .statfs = simple_statfs, | 158 | .statfs = simple_statfs, |
117 | .drop_inode = generic_delete_inode, | 159 | .drop_inode = generic_delete_inode, |
118 | .evict_inode = pstore_evict_inode, | 160 | .evict_inode = pstore_evict_inode, |
161 | .remount_fs = pstore_remount, | ||
119 | .show_options = generic_show_options, | 162 | .show_options = generic_show_options, |
120 | }; | 163 | }; |
121 | 164 | ||
@@ -215,6 +258,8 @@ int pstore_fill_super(struct super_block *sb, void *data, int silent) | |||
215 | sb->s_op = &pstore_ops; | 258 | sb->s_op = &pstore_ops; |
216 | sb->s_time_gran = 1; | 259 | sb->s_time_gran = 1; |
217 | 260 | ||
261 | parse_options(data); | ||
262 | |||
218 | inode = pstore_get_inode(sb, NULL, S_IFDIR | 0755, 0); | 263 | inode = pstore_get_inode(sb, NULL, S_IFDIR | 0755, 0); |
219 | if (!inode) { | 264 | if (!inode) { |
220 | err = -ENOMEM; | 265 | err = -ENOMEM; |
@@ -258,28 +303,7 @@ static struct file_system_type pstore_fs_type = { | |||
258 | 303 | ||
259 | static int __init init_pstore_fs(void) | 304 | static int __init init_pstore_fs(void) |
260 | { | 305 | { |
261 | int rc = 0; | 306 | return register_filesystem(&pstore_fs_type); |
262 | struct kobject *pstorefs_kobj; | ||
263 | |||
264 | pstorefs_kobj = kobject_create_and_add("pstore", fs_kobj); | ||
265 | if (!pstorefs_kobj) { | ||
266 | rc = -ENOMEM; | ||
267 | goto done; | ||
268 | } | ||
269 | |||
270 | rc = sysfs_create_file(pstorefs_kobj, &pstore_kmsg_bytes_attr.attr); | ||
271 | if (rc) | ||
272 | goto done1; | ||
273 | |||
274 | rc = register_filesystem(&pstore_fs_type); | ||
275 | if (rc == 0) | ||
276 | goto done; | ||
277 | |||
278 | sysfs_remove_file(pstorefs_kobj, &pstore_kmsg_bytes_attr.attr); | ||
279 | done1: | ||
280 | kobject_put(pstorefs_kobj); | ||
281 | done: | ||
282 | return rc; | ||
283 | } | 307 | } |
284 | module_init(init_pstore_fs) | 308 | module_init(init_pstore_fs) |
285 | 309 | ||