summaryrefslogtreecommitdiffstats
path: root/fs/jffs2/super.c
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2012-04-10 22:22:35 +0100
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-05-13 22:51:29 -0500
commit8da8ba2ea6ad52ea8558384f38586b0c1a516e9d (patch)
treed11d632886c481758b51cd5b9129dc0a5b94c7bd /fs/jffs2/super.c
parent886bd33da7cfb1f6c7f3396f7146278ed02e76a7 (diff)
downloadlinux-8da8ba2ea6ad52ea8558384f38586b0c1a516e9d.tar.bz2
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)
if (opts->override_compr)
seq_printf(s, ",compr=%s", jffs2_compr_name(opts->compr));
+ if (opts->rp_size)
+ seq_printf(s, ",rp_size=%u", opts->rp_size / 1024);
return 0;
}
@@ -171,15 +173,18 @@ static const struct export_operations jffs2_export_ops = {
* JFFS2 mount options.
*
* Opt_override_compr: override default compressor
+ * Opt_rp_size: size of reserved pool in KiB
* Opt_err: just end of array marker
*/
enum {
Opt_override_compr,
+ Opt_rp_size,
Opt_err,
};
static const match_table_t tokens = {
{Opt_override_compr, "compr=%s"},
+ {Opt_rp_size, "rp_size=%u"},
{Opt_err, NULL},
};
@@ -187,6 +192,7 @@ static int jffs2_parse_options(struct jffs2_sb_info *c, char *data)
{
substring_t args[MAX_OPT_ARGS];
char *p, *name;
+ unsigned int opt;
if (!data)
return 0;
@@ -224,6 +230,17 @@ static int jffs2_parse_options(struct jffs2_sb_info *c, char *data)
kfree(name);
c->mount_opts.override_compr = true;
break;
+ case Opt_rp_size:
+ if (match_int(&args[0], &opt))
+ return -EINVAL;
+ opt *= 1024;
+ if (opt > c->mtd->size) {
+ pr_warn("Too large reserve pool specified, max "
+ "is %llu KB\n", c->mtd->size / 1024);
+ return -EINVAL;
+ }
+ c->mount_opts.rp_size = opt;
+ break;
default:
pr_err("Error: unrecognized mount option '%s' or missing value\n",
p);