|
|
6717ab |
diff -up util-linux-2.23.2/disk-utils/fsck.c.kzak util-linux-2.23.2/disk-utils/fsck.c
|
|
|
6717ab |
--- util-linux-2.23.2/disk-utils/fsck.c.kzak 2014-03-25 12:52:33.429389852 +0100
|
|
|
6717ab |
+++ util-linux-2.23.2/disk-utils/fsck.c 2014-03-25 12:56:27.126804792 +0100
|
|
|
6717ab |
@@ -79,9 +79,7 @@ static const char *really_wanted[] = {
|
|
|
6717ab |
"ext4dev",
|
|
|
6717ab |
"jfs",
|
|
|
6717ab |
"reiserfs",
|
|
|
6717ab |
- "xiafs",
|
|
|
6717ab |
- "xfs",
|
|
|
6717ab |
- NULL
|
|
|
6717ab |
+ "xiafs"
|
|
|
6717ab |
};
|
|
|
6717ab |
|
|
|
6717ab |
/*
|
|
|
6717ab |
@@ -167,6 +165,19 @@ static int string_to_int(const char *s)
|
|
|
6717ab |
return (int) l;
|
|
|
6717ab |
}
|
|
|
6717ab |
|
|
|
6717ab |
+/* Do we really really want to check this fs? */
|
|
|
6717ab |
+static int fs_check_required(const char *type)
|
|
|
6717ab |
+{
|
|
|
6717ab |
+ size_t i;
|
|
|
6717ab |
+
|
|
|
6717ab |
+ for(i = 0; i < ARRAY_SIZE(really_wanted); i++) {
|
|
|
6717ab |
+ if (strcmp(type, really_wanted[i]) == 0)
|
|
|
6717ab |
+ return 1;
|
|
|
6717ab |
+ }
|
|
|
6717ab |
+
|
|
|
6717ab |
+ return 0;
|
|
|
6717ab |
+}
|
|
|
6717ab |
+
|
|
|
6717ab |
static int is_mounted(struct libmnt_fs *fs)
|
|
|
6717ab |
{
|
|
|
6717ab |
int rc;
|
|
|
6717ab |
@@ -546,17 +557,17 @@ static void print_stats(struct fsck_inst
|
|
|
6717ab |
* Execute a particular fsck program, and link it into the list of
|
|
|
6717ab |
* child processes we are waiting for.
|
|
|
6717ab |
*/
|
|
|
6717ab |
-static int execute(const char *type, struct libmnt_fs *fs, int interactive)
|
|
|
6717ab |
+static int execute(const char *progname, const char *progpath,
|
|
|
6717ab |
+ const char *type, struct libmnt_fs *fs, int interactive)
|
|
|
6717ab |
{
|
|
|
6717ab |
- char *s, *argv[80], prog[80];
|
|
|
6717ab |
+ char *argv[80];
|
|
|
6717ab |
int argc, i;
|
|
|
6717ab |
struct fsck_instance *inst, *p;
|
|
|
6717ab |
pid_t pid;
|
|
|
6717ab |
|
|
|
6717ab |
inst = xcalloc(1, sizeof(*inst));
|
|
|
6717ab |
|
|
|
6717ab |
- sprintf(prog, "fsck.%s", type);
|
|
|
6717ab |
- argv[0] = xstrdup(prog);
|
|
|
6717ab |
+ argv[0] = xstrdup(progname);
|
|
|
6717ab |
argc = 1;
|
|
|
6717ab |
|
|
|
6717ab |
for (i=0; i
|
|
|
6717ab |
@@ -583,19 +594,12 @@ static int execute(const char *type, str
|
|
|
6717ab |
argv[argc++] = xstrdup(fs_get_device(fs));
|
|
|
6717ab |
argv[argc] = 0;
|
|
|
6717ab |
|
|
|
6717ab |
- s = find_fsck(prog);
|
|
|
6717ab |
- if (s == NULL) {
|
|
|
6717ab |
- warnx(_("%s: not found"), prog);
|
|
|
6717ab |
- free(inst);
|
|
|
6717ab |
- return ENOENT;
|
|
|
6717ab |
- }
|
|
|
6717ab |
-
|
|
|
6717ab |
if (verbose || noexecute) {
|
|
|
6717ab |
const char *tgt = mnt_fs_get_target(fs);
|
|
|
6717ab |
|
|
|
6717ab |
if (!tgt)
|
|
|
6717ab |
tgt = fs_get_device(fs);
|
|
|
6717ab |
- printf("[%s (%d) -- %s] ", s, num_running, tgt);
|
|
|
6717ab |
+ printf("[%s (%d) -- %s] ", progpath, num_running, tgt);
|
|
|
6717ab |
for (i=0; i < argc; i++)
|
|
|
6717ab |
printf("%s ", argv[i]);
|
|
|
6717ab |
printf("\n");
|
|
|
6717ab |
@@ -617,15 +621,15 @@ static int execute(const char *type, str
|
|
|
6717ab |
} else if (pid == 0) {
|
|
|
6717ab |
if (!interactive)
|
|
|
6717ab |
close(0);
|
|
|
6717ab |
- execv(s, argv);
|
|
|
6717ab |
- err(FSCK_EX_ERROR, _("%s: execute failed"), s);
|
|
|
6717ab |
+ execv(progpath, argv);
|
|
|
6717ab |
+ err(FSCK_EX_ERROR, _("%s: execute failed"), progpath);
|
|
|
6717ab |
}
|
|
|
6717ab |
|
|
|
6717ab |
for (i=0; i < argc; i++)
|
|
|
6717ab |
free(argv[i]);
|
|
|
6717ab |
|
|
|
6717ab |
inst->pid = pid;
|
|
|
6717ab |
- inst->prog = xstrdup(prog);
|
|
|
6717ab |
+ inst->prog = xstrdup(progname);
|
|
|
6717ab |
inst->type = xstrdup(type);
|
|
|
6717ab |
gettimeofday(&inst->start_time, NULL);
|
|
|
6717ab |
inst->next = NULL;
|
|
|
6717ab |
@@ -822,6 +826,7 @@ static int wait_many(int flags)
|
|
|
6717ab |
*/
|
|
|
6717ab |
static int fsck_device(struct libmnt_fs *fs, int interactive)
|
|
|
6717ab |
{
|
|
|
6717ab |
+ char progname[80], *progpath;
|
|
|
6717ab |
const char *type;
|
|
|
6717ab |
int retval;
|
|
|
6717ab |
|
|
|
6717ab |
@@ -838,15 +843,27 @@ static int fsck_device(struct libmnt_fs
|
|
|
6717ab |
else
|
|
|
6717ab |
type = DEFAULT_FSTYPE;
|
|
|
6717ab |
|
|
|
6717ab |
+ sprintf(progname, "fsck.%s", type);
|
|
|
6717ab |
+ progpath = find_fsck(progname);
|
|
|
6717ab |
+ if (progpath == NULL) {
|
|
|
6717ab |
+ if (fs_check_required(type)) {
|
|
|
6717ab |
+ retval = ENOENT;
|
|
|
6717ab |
+ goto err;
|
|
|
6717ab |
+ }
|
|
|
6717ab |
+ return 0;
|
|
|
6717ab |
+ }
|
|
|
6717ab |
+
|
|
|
6717ab |
num_running++;
|
|
|
6717ab |
- retval = execute(type, fs, interactive);
|
|
|
6717ab |
+ retval = execute(progname, progpath, type, fs, interactive);
|
|
|
6717ab |
if (retval) {
|
|
|
6717ab |
- warnx(_("error %d while executing fsck.%s for %s"),
|
|
|
6717ab |
- retval, type, fs_get_device(fs));
|
|
|
6717ab |
num_running--;
|
|
|
6717ab |
- return FSCK_EX_ERROR;
|
|
|
6717ab |
+ goto err;
|
|
|
6717ab |
}
|
|
|
6717ab |
return 0;
|
|
|
6717ab |
+err:
|
|
|
6717ab |
+ warnx(_("error %d (%m) while executing fsck.%s for %s"),
|
|
|
6717ab |
+ retval, type, fs_get_device(fs));
|
|
|
6717ab |
+ return FSCK_EX_ERROR;
|
|
|
6717ab |
}
|
|
|
6717ab |
|
|
|
6717ab |
|
|
|
6717ab |
@@ -1014,8 +1031,7 @@ static int fs_ignored_type(struct libmnt
|
|
|
6717ab |
/* Check if we should ignore this filesystem. */
|
|
|
6717ab |
static int ignore(struct libmnt_fs *fs)
|
|
|
6717ab |
{
|
|
|
6717ab |
- const char **ip, *type;
|
|
|
6717ab |
- int wanted = 0;
|
|
|
6717ab |
+ const char *type;
|
|
|
6717ab |
|
|
|
6717ab |
/*
|
|
|
6717ab |
* If the pass number is 0, ignore it.
|
|
|
6717ab |
@@ -1070,16 +1086,11 @@ static int ignore(struct libmnt_fs *fs)
|
|
|
6717ab |
if (fs_ignored_type(fs))
|
|
|
6717ab |
return 1;
|
|
|
6717ab |
|
|
|
6717ab |
- /* Do we really really want to check this fs? */
|
|
|
6717ab |
- for(ip = really_wanted; *ip; ip++)
|
|
|
6717ab |
- if (strcmp(type, *ip) == 0) {
|
|
|
6717ab |
- wanted = 1;
|
|
|
6717ab |
- break;
|
|
|
6717ab |
- }
|
|
|
6717ab |
+
|
|
|
6717ab |
|
|
|
6717ab |
/* See if the <fsck.fs> program is available. */
|
|
|
6717ab |
if (find_fsck(type) == NULL) {
|
|
|
6717ab |
- if (wanted)
|
|
|
6717ab |
+ if (fs_check_required(type))
|
|
|
6717ab |
warnx(_("cannot check %s: fsck.%s not found"),
|
|
|
6717ab |
fs_get_device(fs), type);
|
|
|
6717ab |
return 1;
|
|
|
6717ab |
@@ -1557,7 +1568,6 @@ int main(int argc, char *argv[])
|
|
|
6717ab |
fs = add_dummy_fs(devices[i]);
|
|
|
6717ab |
else if (fs_ignored_type(fs))
|
|
|
6717ab |
continue;
|
|
|
6717ab |
-
|
|
|
6717ab |
if (ignore_mounted && is_mounted(fs))
|
|
|
6717ab |
continue;
|
|
|
6717ab |
status |= fsck_device(fs, interactive);
|