aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2018-07-12 07:01:59 -0400
committerRichard Weinberger <richard@nod.at>2018-08-14 18:25:21 -0400
commitc38c5a7f2e5056555c22e7603c2151b118f3a494 (patch)
tree3b1b99d7cf709d3c0196b2304383277d8d4dcb85
parent2e52eb74463f15c745d64948cedfaee722d6268c (diff)
ubifs: Allow setting assert action as mount parameter
Expose our three options to userspace. Signed-off-by: Richard Weinberger <richard@nod.at>
-rw-r--r--fs/ubifs/misc.c11
-rw-r--r--fs/ubifs/misc.h2
-rw-r--r--fs/ubifs/super.c24
3 files changed, 37 insertions, 0 deletions
diff --git a/fs/ubifs/misc.c b/fs/ubifs/misc.c
index 586fd5b578a7..cd23de0f211d 100644
--- a/fs/ubifs/misc.c
+++ b/fs/ubifs/misc.c
@@ -56,3 +56,14 @@ void ubifs_warn(const struct ubifs_info *c, const char *fmt, ...)
56 56
57 va_end(args); 57 va_end(args);
58} 58}
59
60static char *assert_names[] = {
61 [ASSACT_REPORT] = "report",
62 [ASSACT_RO] = "read-only",
63 [ASSACT_PANIC] = "panic",
64};
65
66const char *ubifs_assert_action_name(struct ubifs_info *c)
67{
68 return assert_names[c->assert_action];
69}
diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h
index f5d180c0c52e..21d35d7dd975 100644
--- a/fs/ubifs/misc.h
+++ b/fs/ubifs/misc.h
@@ -287,4 +287,6 @@ static inline int ubifs_next_log_lnum(const struct ubifs_info *c, int lnum)
287 return lnum; 287 return lnum;
288} 288}
289 289
290const char *ubifs_assert_action_name(struct ubifs_info *c);
291
290#endif /* __UBIFS_MISC_H__ */ 292#endif /* __UBIFS_MISC_H__ */
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index df73b0e1c2f7..c31e7b4f1e1c 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -445,6 +445,7 @@ static int ubifs_show_options(struct seq_file *s, struct dentry *root)
445 ubifs_compr_name(c, c->mount_opts.compr_type)); 445 ubifs_compr_name(c, c->mount_opts.compr_type));
446 } 446 }
447 447
448 seq_printf(s, ",assert=%s", ubifs_assert_action_name(c));
448 seq_printf(s, ",ubi=%d,vol=%d", c->vi.ubi_num, c->vi.vol_id); 449 seq_printf(s, ",ubi=%d,vol=%d", c->vi.ubi_num, c->vi.vol_id);
449 450
450 return 0; 451 return 0;
@@ -922,6 +923,7 @@ static int check_volume_empty(struct ubifs_info *c)
922 * Opt_chk_data_crc: check CRCs when reading data nodes 923 * Opt_chk_data_crc: check CRCs when reading data nodes
923 * Opt_no_chk_data_crc: do not check CRCs when reading data nodes 924 * Opt_no_chk_data_crc: do not check CRCs when reading data nodes
924 * Opt_override_compr: override default compressor 925 * Opt_override_compr: override default compressor
926 * Opt_assert: set ubifs_assert() action
925 * Opt_err: just end of array marker 927 * Opt_err: just end of array marker
926 */ 928 */
927enum { 929enum {
@@ -932,6 +934,7 @@ enum {
932 Opt_chk_data_crc, 934 Opt_chk_data_crc,
933 Opt_no_chk_data_crc, 935 Opt_no_chk_data_crc,
934 Opt_override_compr, 936 Opt_override_compr,
937 Opt_assert,
935 Opt_ignore, 938 Opt_ignore,
936 Opt_err, 939 Opt_err,
937}; 940};
@@ -946,6 +949,7 @@ static const match_table_t tokens = {
946 {Opt_override_compr, "compr=%s"}, 949 {Opt_override_compr, "compr=%s"},
947 {Opt_ignore, "ubi=%s"}, 950 {Opt_ignore, "ubi=%s"},
948 {Opt_ignore, "vol=%s"}, 951 {Opt_ignore, "vol=%s"},
952 {Opt_assert, "assert=%s"},
949 {Opt_err, NULL}, 953 {Opt_err, NULL},
950}; 954};
951 955
@@ -1046,6 +1050,26 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options,
1046 c->default_compr = c->mount_opts.compr_type; 1050 c->default_compr = c->mount_opts.compr_type;
1047 break; 1051 break;
1048 } 1052 }
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 }
1049 case Opt_ignore: 1073 case Opt_ignore:
1050 break; 1074 break;
1051 default: 1075 default: