aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/super.c
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2012-04-10 17:22:35 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-05-13 23:51:29 -0400
commit8da8ba2ea6ad52ea8558384f38586b0c1a516e9d (patch)
treed11d632886c481758b51cd5b9129dc0a5b94c7bd /fs/jffs2/super.c
parent886bd33da7cfb1f6c7f3396f7146278ed02e76a7 (diff)
JFFS2: Add parameter to reserve disk space for root
Add a new rp_size= parameter which creates a "reserved pool" of disk space which can only be used by root. Other users are not permitted to write to disk when the available space is less than the pool size. Based on original code by Artem Bityutskiy in https://dev.laptop.org/ticket/5317 [dwmw2: use capable(CAP_SYS_RESOURCE) not uid/gid check, fix debug prints] Signed-off-by: Daniel Drake <dsd@laptop.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'fs/jffs2/super.c')
-rw-r--r--fs/jffs2/super.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index f9916f312bd8..66d44560f75d 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -105,6 +105,8 @@ static int jffs2_show_options(struct seq_file *s, struct dentry *root)
105 105
106 if (opts->override_compr) 106 if (opts->override_compr)
107 seq_printf(s, ",compr=%s", jffs2_compr_name(opts->compr)); 107 seq_printf(s, ",compr=%s", jffs2_compr_name(opts->compr));
108 if (opts->rp_size)
109 seq_printf(s, ",rp_size=%u", opts->rp_size / 1024);
108 110
109 return 0; 111 return 0;
110} 112}
@@ -171,15 +173,18 @@ static const struct export_operations jffs2_export_ops = {
171 * JFFS2 mount options. 173 * JFFS2 mount options.
172 * 174 *
173 * Opt_override_compr: override default compressor 175 * Opt_override_compr: override default compressor
176 * Opt_rp_size: size of reserved pool in KiB
174 * Opt_err: just end of array marker 177 * Opt_err: just end of array marker
175 */ 178 */
176enum { 179enum {
177 Opt_override_compr, 180 Opt_override_compr,
181 Opt_rp_size,
178 Opt_err, 182 Opt_err,
179}; 183};
180 184
181static const match_table_t tokens = { 185static const match_table_t tokens = {
182 {Opt_override_compr, "compr=%s"}, 186 {Opt_override_compr, "compr=%s"},
187 {Opt_rp_size, "rp_size=%u"},
183 {Opt_err, NULL}, 188 {Opt_err, NULL},
184}; 189};
185 190
@@ -187,6 +192,7 @@ static int jffs2_parse_options(struct jffs2_sb_info *c, char *data)
187{ 192{
188 substring_t args[MAX_OPT_ARGS]; 193 substring_t args[MAX_OPT_ARGS];
189 char *p, *name; 194 char *p, *name;
195 unsigned int opt;
190 196
191 if (!data) 197 if (!data)
192 return 0; 198 return 0;
@@ -224,6 +230,17 @@ static int jffs2_parse_options(struct jffs2_sb_info *c, char *data)
224 kfree(name); 230 kfree(name);
225 c->mount_opts.override_compr = true; 231 c->mount_opts.override_compr = true;
226 break; 232 break;
233 case Opt_rp_size:
234 if (match_int(&args[0], &opt))
235 return -EINVAL;
236 opt *= 1024;
237 if (opt > c->mtd->size) {
238 pr_warn("Too large reserve pool specified, max "
239 "is %llu KB\n", c->mtd->size / 1024);
240 return -EINVAL;
241 }
242 c->mount_opts.rp_size = opt;
243 break;
227 default: 244 default:
228 pr_err("Error: unrecognized mount option '%s' or missing value\n", 245 pr_err("Error: unrecognized mount option '%s' or missing value\n",
229 p); 246 p);