aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2005-12-31 16:33:33 -0500
committerTheodore Ts'o <tytso@mit.edu>2005-12-31 16:33:33 -0500
commit8fd98bba213bbcc93e43993aaf41e7dec19a1b61 (patch)
tree321c9153e4de28a1fc97af7d75985f0680eae7c5
parent5582275fe06d6f4d0679d0a1a28d069769da8b41 (diff)
downloade2fsprogs-8fd98bba213bbcc93e43993aaf41e7dec19a1b61.tar.gz
e2fsprogs-8fd98bba213bbcc93e43993aaf41e7dec19a1b61.tar.xz
e2fsprogs-8fd98bba213bbcc93e43993aaf41e7dec19a1b61.zip
Add e2fsck problem handling to be configurable
Add the ability for the e2fsck configuration file to override the behaviour of e2fsck when a particular filesystem problem is encountered. This allows reconnecting an inode to lost+found to not stop the boot sequence, if a system administrator really badly wants this behaviour for some specialized reason, for example. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--e2fsck/ChangeLog8
-rw-r--r--e2fsck/problem.c41
-rw-r--r--e2fsck/problemP.h3
3 files changed, 48 insertions, 4 deletions
diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index 951ff73f..29a907e8 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -1,5 +1,13 @@
2005-12-31 Theodore Ts'o <tytso@mit.edu>
+ * problem.c (fix_problem), problemP.h: Add the ability for the
+ e2fsck configuration file to override the behaviour of
+ e2fsck when a particular filesystem problem is
+ encountered. This allows reconnecting an inode to
+ lost+found to not stop the boot sequence, if a system
+ administrator really badly wants this behaviour for some
+ specialized reason, for example.
+
* unix.c (main): If the e2fsck configuration file sets the
allow_cancellation option to be true, then if the
filesystem does not have any known problems, and was known
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 7d70f568..a25cc088 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -98,7 +98,7 @@ static const char *preen_msg[] = {
"", /* 20 */
};
-static const struct e2fsck_problem problem_table[] = {
+static struct e2fsck_problem problem_table[] = {
/* Pre-Pass 1 errors */
@@ -1497,7 +1497,7 @@ static struct latch_descr pr_latch_info[] = {
{ -1, 0, 0 },
};
-static const struct e2fsck_problem *find_problem(problem_t code)
+static struct e2fsck_problem *find_problem(problem_t code)
{
int i;
@@ -1564,10 +1564,24 @@ void clear_problem_context(struct problem_context *ctx)
ctx->group = -1;
}
+static void reconfigure_bool(e2fsck_t ctx, struct e2fsck_problem *ptr,
+ const char *key, int mask, const char *name)
+{
+ int bool;
+
+ bool = (ptr->flags & mask);
+ profile_get_boolean(ctx->profile, "problems", key, name, bool, &bool);
+ if (bool)
+ ptr->flags |= mask;
+ else
+ ptr->flags &= ~mask;
+}
+
+
int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
{
ext2_filsys fs = ctx->fs;
- const struct e2fsck_problem *ptr;
+ struct e2fsck_problem *ptr;
struct latch_descr *ldesc = 0;
const char *message;
int def_yn, answer, ans;
@@ -1579,6 +1593,27 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
printf(_("Unhandled error code (0x%x)!\n"), code);
return 0;
}
+ if (!(ptr->flags & PR_CONFIG)) {
+ char key[9], *new_desc;
+
+ sprintf(key, "0x%06x", code);
+
+ profile_get_string(ctx->profile, "problems", key,
+ "description", 0, &new_desc);
+ if (new_desc)
+ ptr->e2p_description = new_desc;
+
+ reconfigure_bool(ctx, ptr, key, PR_PREEN_OK, "preen_ok");
+ reconfigure_bool(ctx, ptr, key, PR_NO_OK, "no_ok");
+ reconfigure_bool(ctx, ptr, key, PR_NO_DEFAULT, "no_default");
+ reconfigure_bool(ctx, ptr, key, PR_MSG_ONLY, "print_message_only");
+ reconfigure_bool(ctx, ptr, key, PR_PREEN_NOMSG, "preen_nomessage");
+ reconfigure_bool(ctx, ptr, key, PR_NOCOLLATE, "no_collate");
+ reconfigure_bool(ctx, ptr, key, PR_NO_NOMSG, "no_nomsg");
+ reconfigure_bool(ctx, ptr, key, PR_PREEN_NOHDR, "preen_noheader");
+
+ ptr->flags |= PR_CONFIG;
+ }
def_yn = 1;
if ((ptr->flags & PR_NO_DEFAULT) ||
((ptr->flags & PR_PREEN_NO) && (ctx->options & E2F_OPT_PREEN)) ||
diff --git a/e2fsck/problemP.h b/e2fsck/problemP.h
index 329056b9..21264fa7 100644
--- a/e2fsck/problemP.h
+++ b/e2fsck/problemP.h
@@ -39,4 +39,5 @@ struct latch_descr {
#define PR_NO_NOMSG 0x010000 /* Don't print a message if e2fsck -n */
#define PR_PREEN_NO 0x020000 /* Use No as an answer if preening */
#define PR_PREEN_NOHDR 0x040000 /* Don't print the preen header */
-
+#define PR_CONFIG 0x080000 /* This problem has been customized
+ from the config file */