fsck.c revision 1de4d79bf554946f486adf56ed765c5335816f15
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <libudev.h>
#include "util.h"
#include "dbus-common.h"
#include "special.h"
#include "bus-errors.h"
static bool arg_skip = false;
static bool arg_force = false;
goto finish;
}
if (isolate)
mode = "isolate";
else
mode = "replace";
if (!(m = dbus_message_new_method_call("org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "StartUnitReplace"))) {
log_error("Could not allocate message.");
goto finish;
}
/* Start these units only if we can replace base.target with it */
if (!dbus_message_append_args(m,
log_error("Could not attach target and flag information to message.");
goto finish;
}
/* Don't print a waring if we aren't called during
* startup */
goto finish;
}
if (m)
if (reply)
if (bus) {
}
}
static int parse_proc_cmdline(void) {
int r;
size_t l;
return 0;
}
if (strneq(w, "fsck.mode=auto", l))
else if (strneq(w, "fsck.mode=force", l))
arg_force = true;
else if (strneq(w, "fsck.mode=skip", l))
arg_skip = true;
else if (startswith(w, "fsck.mode"))
log_warning("Invalid fsck.mode= parameter. Ignoring.");
#if defined(TARGET_FEDORA) || defined(TARGET_MANDRIVA)
else if (strneq(w, "fastboot", l))
arg_skip = true;
else if (strneq(w, "forcefsck", l))
arg_force = true;
#endif
}
return 0;
}
static void test_files(void) {
arg_skip = true;
arg_force = true;
}
const char *cmdline[8];
int i = 0, r = EXIT_FAILURE, q;
const char *device;
bool root_directory;
if (argc > 2) {
log_error("This program expects one or no arguments.");
return EXIT_FAILURE;
}
log_open();
test_files();
return 0;
if (argc > 1) {
root_directory = false;
} else {
/* Find root device */
log_error("Failed to stat() the root directory: %m");
goto finish;
}
/* Virtual root devices don't need an fsck */
return 0;
/* check if we are already writable */
log_info("Root directory is writable, skipping check.");
return 0;
}
log_error("Out of memory");
goto finish;
}
log_error("Failed to detect root device.");
goto finish;
}
log_error("Failed to detect device node of root directory.");
goto finish;
}
root_directory = true;
}
cmdline[i++] = "-a";
cmdline[i++] = "-T";
cmdline[i++] = "-l";
if (!root_directory)
cmdline[i++] = "-M";
if (arg_force)
cmdline[i++] = "-f";
log_error("fork(): %m");
goto finish;
} else if (pid == 0) {
/* Child */
}
goto finish;
}
else
log_error("fsck failed due to unknown reason.");
/* System should be rebooted. */
start_target(SPECIAL_REBOOT_TARGET, false);
/* Some other problem */
start_target(SPECIAL_EMERGENCY_TARGET, true);
else {
r = EXIT_SUCCESS;
log_warning("Ignoring error.");
}
} else
r = EXIT_SUCCESS;
touch("/dev/.systemd/quotacheck");
if (udev_device)
if (udev)
return r;
}