mirror of
https://github.com/troglobit/finit.git
synced 2026-10-08 00:24:17 +07:00
Support for fsck_mode=[auto,skip,force] + fsck_repair=[preen,no,yes]
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+39
@@ -62,6 +62,9 @@ static TAILQ_HEAD(, env_entry) env_list = TAILQ_HEAD_INITIALIZER(env_list);
|
||||
struct rlimit initial_rlimit[RLIMIT_NLIMITS];
|
||||
struct rlimit global_rlimit[RLIMIT_NLIMITS];
|
||||
|
||||
char *fsck_mode = "";
|
||||
char *fsck_repair = "-p";
|
||||
|
||||
char cgroup_current[16]; /* cgroup.NAME sets current cgroup for a set of services */
|
||||
|
||||
struct conf_change {
|
||||
@@ -149,6 +152,37 @@ static void parse_finit_opts(char *opt)
|
||||
}
|
||||
}
|
||||
|
||||
static void parse_fsck_opts(char *opt)
|
||||
{
|
||||
char *arg;
|
||||
|
||||
arg = strchr(opt, '=');
|
||||
if (arg)
|
||||
*arg++ = 0;
|
||||
|
||||
if (string_compare(opt, "mode")) {
|
||||
if (!strcmp(arg, "skip"))
|
||||
fsck_mode = NULL;
|
||||
if (!strcmp(arg, "auto"))
|
||||
fsck_mode = "";
|
||||
if (!strcmp(arg, "force"))
|
||||
fsck_mode = "-f";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (string_compare(opt, "repair")) {
|
||||
if (!strcmp(arg, "no"))
|
||||
fsck_repair = "-n";
|
||||
if (!strcmp(arg, "preen"))
|
||||
fsck_repair = "-p";
|
||||
if (!strcmp(arg, "yes"))
|
||||
fsck_repair = "-y";
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* When runlevel (single integer) is given on the command line,
|
||||
* it overrides the runlevel in finit.conf and the built-in
|
||||
@@ -183,6 +217,11 @@ static void parse_arg(char *arg)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strncmp(arg, "fsck.", 5)) {
|
||||
parse_fsck_opts(&arg[5]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string_compare(arg, "rescue") || string_compare(arg, "recover")) {
|
||||
rescue = 1;
|
||||
return;
|
||||
|
||||
+4
-1
@@ -259,7 +259,7 @@ static int fsck(int pass)
|
||||
#ifdef FSCK_FIX
|
||||
snprintf(cmd, sizeof(cmd), "fsck -yf %s", dev);
|
||||
#else
|
||||
snprintf(cmd, sizeof(cmd), "fsck -a %s", dev);
|
||||
snprintf(cmd, sizeof(cmd), "fsck %s %s %s", fsck_mode, fsck_repair, dev);
|
||||
#endif
|
||||
dbg("Running pass %d fsck command %s", pass, cmd);
|
||||
fsck_rc = run_interactive(cmd, "Checking filesystem %s", dev);
|
||||
@@ -286,6 +286,9 @@ static int fsck_all(void)
|
||||
#ifndef FAST_BOOT
|
||||
int pass;
|
||||
|
||||
if (!fsck_mode)
|
||||
return 0;
|
||||
|
||||
for (pass = 1; pass < 10; pass++) {
|
||||
rc = fsck(pass);
|
||||
if (rc)
|
||||
|
||||
@@ -36,6 +36,8 @@ extern char *finit_conf;
|
||||
extern char *finit_rcsd;
|
||||
extern svc_t *wdog;
|
||||
extern int service_interval;
|
||||
extern char *fsck_mode;
|
||||
extern char *fsck_repair;
|
||||
|
||||
int api_init (uev_ctx_t *ctx);
|
||||
int api_exit (void);
|
||||
|
||||
Reference in New Issue
Block a user