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