X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fsystemd.git;a=blobdiff_plain;f=src%2Ffsck%2Ffsck.c;h=cd39161f10f0a99f868a60d8a10eb970e2e699b9;hp=7415be1529b7464b548d784d427ff24e21b38aaf;hb=349cc4a507c4d84fcadf61f42159ea6412717896;hpb=6bedfcbb2970e06a4d3280c8fb62083d252ede73 diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c index 7415be1529b..cd39161f10f 100644 --- a/src/fsck/fsck.c +++ b/src/fsck/fsck.c @@ -1,5 +1,3 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - /*** This file is part of systemd. @@ -20,29 +18,33 @@ along with systemd; If not, see . ***/ -#include -#include #include -#include #include +#include +#include #include -#include #include +#include +#include #include "sd-bus.h" #include "sd-device.h" +#include "alloc-util.h" #include "bus-common-errors.h" #include "bus-error.h" #include "bus-util.h" #include "device-util.h" #include "fd-util.h" +#include "fs-util.h" #include "parse-util.h" #include "path-util.h" +#include "proc-cmdline.h" #include "process-util.h" #include "signal-util.h" #include "socket-util.h" #include "special.h" +#include "stdio-util.h" #include "util.h" /* exit codes as defined in fsck(8) */ @@ -63,8 +65,8 @@ static bool arg_show_progress = false; static const char *arg_repair = "-a"; static void start_target(const char *target, const char *mode) { - _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; - _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL; + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; int r; assert(target); @@ -92,12 +94,15 @@ static void start_target(const char *target, const char *mode) { log_error("Failed to start unit: %s", bus_error_message(&error, r)); } -static int parse_proc_cmdline_item(const char *key, const char *value) { +static int parse_proc_cmdline_item(const char *key, const char *value, void *data) { int r; assert(key); - if (streq(key, "fsck.mode") && value) { + if (streq(key, "fsck.mode")) { + + if (proc_cmdline_value_missing(key, value)) + return 0; if (streq(value, "auto")) arg_force = arg_skip = false; @@ -108,7 +113,10 @@ static int parse_proc_cmdline_item(const char *key, const char *value) { else log_warning("Invalid fsck.mode= parameter '%s'. Ignoring.", value); - } else if (streq(key, "fsck.repair") && value) { + } else if (streq(key, "fsck.repair")) { + + if (proc_cmdline_value_missing(key, value)) + return 0; if (streq(value, "preen")) arg_repair = "-a"; @@ -123,7 +131,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value) { } } -#ifdef HAVE_SYSV_COMPAT +#if HAVE_SYSV_COMPAT else if (streq(key, "fastboot") && !value) { log_warning("Please pass 'fsck.mode=skip' rather than 'fastboot' on the kernel command line."); arg_skip = true; @@ -139,7 +147,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value) { static void test_files(void) { -#ifdef HAVE_SYSV_COMPAT +#if HAVE_SYSV_COMPAT if (access("/fastboot", F_OK) >= 0) { log_error("Please pass 'fsck.mode=skip' on the kernel command line rather than creating /fastboot on the root file system."); arg_skip = true; @@ -260,8 +268,8 @@ static int fsck_progress_socket(void) { if (fd < 0) return log_warning_errno(errno, "socket(): %m"); - if (connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path)) < 0) { - r = log_full_errno(errno == ECONNREFUSED || errno == ENOENT ? LOG_DEBUG : LOG_WARNING, + if (connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0) { + r = log_full_errno(IN_SET(errno, ECONNREFUSED, ENOENT) ? LOG_DEBUG : LOG_WARNING, errno, "Failed to connect to progress socket %s, ignoring: %m", sa.un.sun_path); safe_close(fd); return r; @@ -272,7 +280,7 @@ static int fsck_progress_socket(void) { int main(int argc, char *argv[]) { _cleanup_close_pair_ int progress_pipe[2] = { -1, -1 }; - _cleanup_device_unref_ sd_device *dev = NULL; + _cleanup_(sd_device_unrefp) sd_device *dev = NULL; const char *device, *type; bool root_directory; siginfo_t status; @@ -291,7 +299,7 @@ int main(int argc, char *argv[]) { umask(0022); - r = parse_proc_cmdline(parse_proc_cmdline_item); + r = proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_STRIP_RD_PREFIX); if (r < 0) log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");