X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Ffsck%2Ffsck.c;h=cb2f5734ea069ddf11a0a9ddd17bfd44ce23ddb6;hp=b6691c96ff05845c4fb0624259b066933f82c983;hb=c343be283b7152554bac0c02493a4e1759c163f7;hpb=059cb3858acd038ff2cef10a3a99119bf71a8fc6 diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c index b6691c96f..cb2f5734e 100644 --- a/src/fsck/fsck.c +++ b/src/fsck/fsck.c @@ -4,6 +4,7 @@ This file is part of systemd. Copyright 2010 Lennart Poettering + Copyright 2014 Holger Hans Peter Freyther systemd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -37,10 +38,12 @@ #include "bus-errors.h" #include "fileio.h" #include "udev-util.h" +#include "path-util.h" static bool arg_skip = false; static bool arg_force = false; static bool arg_show_progress = false; +static const char *arg_repair = "-a"; static void start_target(const char *target) { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; @@ -84,6 +87,16 @@ static int parse_proc_cmdline_item(const char *key, const char *value) { arg_skip = true; else log_warning("Invalid fsck.mode= parameter. Ignoring."); + } else if (streq(key, "fsck.repair") && value) { + + if (streq(value, "preen")) + arg_repair = "-a"; + else if (streq(value, "yes")) + arg_repair = "-y"; + else if (streq(value, "no")) + arg_repair = "-n"; + else + log_warning("Invalid fsck.repair= parameter. Ignoring."); } else if (startswith(key, "fsck.")) log_warning("Invalid fsck parameter. Ignoring."); #ifdef HAVE_SYSV_COMPAT @@ -142,7 +155,7 @@ static int process_progress(int fd) { f = fdopen(fd, "r"); if (!f) { - close_nointr_nofail(fd); + safe_close(fd); return -errno; } @@ -285,14 +298,15 @@ int main(int argc, char *argv[]) { type = udev_device_get_property_value(udev_device, "ID_FS_TYPE"); if (type) { - const char *checker = strappenda("/sbin/fsck.", type); - r = access(checker, X_OK); + r = fsck_exists(type); if (r < 0) { - if (errno == ENOENT) { - log_info("%s doesn't exist, not checking file system.", checker); + if (r == -ENOENT) { + log_info("fsck.%s doesn't exist, not checking file system on %s", + type, device); return EXIT_SUCCESS; } else - log_warning("%s cannot be used: %m", checker); + log_warning("fsck.%s cannot be used for %s: %s", + type, device, strerror(-r)); } } @@ -303,9 +317,20 @@ int main(int argc, char *argv[]) { } cmdline[i++] = "/sbin/fsck"; - cmdline[i++] = "-a"; + cmdline[i++] = arg_repair; cmdline[i++] = "-T"; - cmdline[i++] = "-l"; + + /* + * Disable locking which conflict with udev's event + * ownershipi, until util-linux moves the flock + * synchronization file which prevents multiple fsck running + * on the same rotationg media, from the disk device + * node to a privately owned regular file. + * + * https://bugs.freedesktop.org/show_bug.cgi?id=79576#c5 + * + * cmdline[i++] = "-l"; + */ if (!root_directory) cmdline[i++] = "-M"; @@ -329,15 +354,12 @@ int main(int argc, char *argv[]) { } else if (pid == 0) { /* Child */ if (progress_pipe[0] >= 0) - close_nointr_nofail(progress_pipe[0]); + safe_close(progress_pipe[0]); execv(cmdline[0], (char**) cmdline); _exit(8); /* Operational error */ } - if (progress_pipe[1] >= 0) { - close_nointr_nofail(progress_pipe[1]); - progress_pipe[1] = -1; - } + progress_pipe[1] = safe_close(progress_pipe[1]); if (progress_pipe[0] >= 0) { process_progress(progress_pipe[0]); @@ -377,7 +399,7 @@ int main(int argc, char *argv[]) { touch("/run/systemd/quotacheck"); finish: - close_pipe(progress_pipe); + safe_close_pair(progress_pipe); return r; }