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