fsck.c revision 91077af69e4eb5f7631e25a2bc5ae8e3c9c08178
da6747c2419b9cea8b5e2c576a30a5de999a8ab3vboxsync/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
24df09922f68ca6b53d3b8052e589d3b790f7c17vboxsync This file is part of systemd.
da6747c2419b9cea8b5e2c576a30a5de999a8ab3vboxsync Copyright 2010 Lennart Poettering
da6747c2419b9cea8b5e2c576a30a5de999a8ab3vboxsync Copyright 2014 Holger Hans Peter Freyther
6be66de4257f4f564e35f7b8ee57a282e3cf3e96vboxsync systemd is free software; you can redistribute it and/or modify it
da6747c2419b9cea8b5e2c576a30a5de999a8ab3vboxsync under the terms of the GNU Lesser General Public License as published by
6be66de4257f4f564e35f7b8ee57a282e3cf3e96vboxsync the Free Software Foundation; either version 2.1 of the License, or
6be66de4257f4f564e35f7b8ee57a282e3cf3e96vboxsync (at your option) any later version.
24df09922f68ca6b53d3b8052e589d3b790f7c17vboxsync systemd is distributed in the hope that it will be useful, but
24df09922f68ca6b53d3b8052e589d3b790f7c17vboxsync WITHOUT ANY WARRANTY; without even the implied warranty of
24df09922f68ca6b53d3b8052e589d3b790f7c17vboxsync MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
da6747c2419b9cea8b5e2c576a30a5de999a8ab3vboxsync Lesser General Public License for more details.
6be66de4257f4f564e35f7b8ee57a282e3cf3e96vboxsync You should have received a copy of the GNU Lesser General Public License
6be66de4257f4f564e35f7b8ee57a282e3cf3e96vboxsync along with systemd; If not, see <http://www.gnu.org/licenses/>.
24df09922f68ca6b53d3b8052e589d3b790f7c17vboxsync/* exit codes as defined in fsck(8) */
da6747c2419b9cea8b5e2c576a30a5de999a8ab3vboxsyncstatic bool arg_skip = false;
da6747c2419b9cea8b5e2c576a30a5de999a8ab3vboxsyncstatic bool arg_force = false;
da6747c2419b9cea8b5e2c576a30a5de999a8ab3vboxsyncstatic bool arg_show_progress = false;
da6747c2419b9cea8b5e2c576a30a5de999a8ab3vboxsync _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
24df09922f68ca6b53d3b8052e589d3b790f7c17vboxsync if (r < 0) {
24df09922f68ca6b53d3b8052e589d3b790f7c17vboxsync log_error_errno(r, "Failed to get D-Bus connection: %m");
6be66de4257f4f564e35f7b8ee57a282e3cf3e96vboxsync log_info("Running request %s/start/replace", target);
da6747c2419b9cea8b5e2c576a30a5de999a8ab3vboxsync /* Start these units only if we can replace base.target with it */
da6747c2419b9cea8b5e2c576a30a5de999a8ab3vboxsync "org.freedesktop.systemd1.Manager",
da6747c2419b9cea8b5e2c576a30a5de999a8ab3vboxsync "StartUnitReplace",
5b802b5e11fed6e163afca32e9118d2599d312fbvboxsync /* Don't print a warning if we aren't called during startup */
5b802b5e11fed6e163afca32e9118d2599d312fbvboxsync if (r < 0 && !sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_JOB))
5b802b5e11fed6e163afca32e9118d2599d312fbvboxsync log_error("Failed to start unit: %s", bus_error_message(&error, r));
5b802b5e11fed6e163afca32e9118d2599d312fbvboxsyncstatic int parse_proc_cmdline_item(const char *key, const char *value) {
939ffd583b0105c9cfab3570932faa41e0ccd563vboxsync log_warning("Invalid fsck.mode= parameter '%s'. Ignoring.", value);
#ifdef HAVE_SYSV_COMPAT
arg_skip = true;
arg_force = true;
static void test_files(void) {
#ifdef HAVE_SYSV_COMPAT
log_error("Please pass 'fsck.mode=skip' on the kernel command line rather than creating /fastboot on the root file system.");
arg_skip = true;
log_error("Please pass 'fsck.mode=force' on the kernel command line rather than creating /forcefsck on the root file system.");
arg_force = true;
static const int pass_table[] = {
if (pass <= 0)
bool locked = false;
int clear = 0, r;
if (fd < 0)
return -errno;
if (!console)
return -ENOMEM;
int pass, m;
usec_t t;
if (ferror(f))
else if (feof(f))
r = -EBADMSG;
if (!locked) {
locked = true;
last = t;
if (m > clear)
clear = m;
if (clear > 0) {
for (j = 0; j < (unsigned) clear; j++)
static int fsck_progress_socket(void) {
int fd, r;
if (fd < 0)
return fd;
bool root_directory;
return EXIT_FAILURE;
log_open();
test_files();
goto finish;
goto finish;
r = -EINVAL;
goto finish;
goto finish;
root_directory = false;
goto finish;
goto finish;
goto finish;
goto finish;
goto finish;
root_directory = true;
if (r == -ENOENT) {
goto finish;
if (arg_show_progress) {
goto finish;
if (pid < 0) {
goto finish;
if (pid == 0) {
if (progress_socket >= 0) {
dash_c[0] = 0;
* udevd, see https://bugs.freedesktop.org/show_bug.cgi?id=79576#c5
if (!root_directory)
if (arg_force)
goto finish;
r = -EINVAL;
if (status.si_code == CLD_EXITED && (status.si_status & FSCK_SYSTEM_SHOULD_REBOOT) && root_directory)
else if (status.si_code == CLD_EXITED && (status.si_status & (FSCK_SYSTEM_SHOULD_REBOOT | FSCK_ERRORS_LEFT_UNCORRECTED)))