Skip to content

Commit c38c5a7

Browse files
ubifs: Allow setting assert action as mount parameter
Expose our three options to userspace. Signed-off-by: Richard Weinberger <[email protected]>
1 parent 2e52eb7 commit c38c5a7

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

fs/ubifs/misc.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,14 @@ void ubifs_warn(const struct ubifs_info *c, const char *fmt, ...)
5656

5757
va_end(args);
5858
}
59+
60+
static char *assert_names[] = {
61+
[ASSACT_REPORT] = "report",
62+
[ASSACT_RO] = "read-only",
63+
[ASSACT_PANIC] = "panic",
64+
};
65+
66+
const char *ubifs_assert_action_name(struct ubifs_info *c)
67+
{
68+
return assert_names[c->assert_action];
69+
}

fs/ubifs/misc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,6 @@ static inline int ubifs_next_log_lnum(const struct ubifs_info *c, int lnum)
287287
return lnum;
288288
}
289289

290+
const char *ubifs_assert_action_name(struct ubifs_info *c);
291+
290292
#endif /* __UBIFS_MISC_H__ */

fs/ubifs/super.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ static int ubifs_show_options(struct seq_file *s, struct dentry *root)
445445
ubifs_compr_name(c, c->mount_opts.compr_type));
446446
}
447447

448+
seq_printf(s, ",assert=%s", ubifs_assert_action_name(c));
448449
seq_printf(s, ",ubi=%d,vol=%d", c->vi.ubi_num, c->vi.vol_id);
449450

450451
return 0;
@@ -922,6 +923,7 @@ static int check_volume_empty(struct ubifs_info *c)
922923
* Opt_chk_data_crc: check CRCs when reading data nodes
923924
* Opt_no_chk_data_crc: do not check CRCs when reading data nodes
924925
* Opt_override_compr: override default compressor
926+
* Opt_assert: set ubifs_assert() action
925927
* Opt_err: just end of array marker
926928
*/
927929
enum {
@@ -932,6 +934,7 @@ enum {
932934
Opt_chk_data_crc,
933935
Opt_no_chk_data_crc,
934936
Opt_override_compr,
937+
Opt_assert,
935938
Opt_ignore,
936939
Opt_err,
937940
};
@@ -946,6 +949,7 @@ static const match_table_t tokens = {
946949
{Opt_override_compr, "compr=%s"},
947950
{Opt_ignore, "ubi=%s"},
948951
{Opt_ignore, "vol=%s"},
952+
{Opt_assert, "assert=%s"},
949953
{Opt_err, NULL},
950954
};
951955

@@ -1046,6 +1050,26 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options,
10461050
c->default_compr = c->mount_opts.compr_type;
10471051
break;
10481052
}
1053+
case Opt_assert:
1054+
{
1055+
char *act = match_strdup(&args[0]);
1056+
1057+
if (!act)
1058+
return -ENOMEM;
1059+
if (!strcmp(act, "report"))
1060+
c->assert_action = ASSACT_REPORT;
1061+
else if (!strcmp(act, "read-only"))
1062+
c->assert_action = ASSACT_RO;
1063+
else if (!strcmp(act, "panic"))
1064+
c->assert_action = ASSACT_PANIC;
1065+
else {
1066+
ubifs_err(c, "unknown assert action \"%s\"", act);
1067+
kfree(act);
1068+
return -EINVAL;
1069+
}
1070+
kfree(act);
1071+
break;
1072+
}
10491073
case Opt_ignore:
10501074
break;
10511075
default:

0 commit comments

Comments
 (0)