fsck.c revision b65205466248531d52f9d6dba16195864b023d4a
fccd44ec3a7abd305b558d39f54b5ef223f00b68Kay Sievers/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
fccd44ec3a7abd305b558d39f54b5ef223f00b68Kay Sievers This file is part of systemd.
fccd44ec3a7abd305b558d39f54b5ef223f00b68Kay Sievers Copyright 2010 Lennart Poettering
fccd44ec3a7abd305b558d39f54b5ef223f00b68Kay Sievers systemd is free software; you can redistribute it and/or modify it
fccd44ec3a7abd305b558d39f54b5ef223f00b68Kay Sievers under the terms of the GNU Lesser General Public License as published by
fccd44ec3a7abd305b558d39f54b5ef223f00b68Kay Sievers the Free Software Foundation; either version 2.1 of the License, or
fccd44ec3a7abd305b558d39f54b5ef223f00b68Kay Sievers (at your option) any later version.
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 "sd-bus.h"
#include "libudev.h"
#include "util.h"
#include "special.h"
#include "bus-util.h"
#include "bus-error.h"
#include "bus-errors.h"
#include "fileio.h"
#include "udev-util.h"
static bool arg_skip = false;
static bool arg_force = false;
static bool arg_show_progress = false;
/* Start these units only if we can replace base.target with it */
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
&error,
NULL,
static int parse_proc_cmdline(void) {
char *w, *state;
size_t l;
arg_force = true;
arg_skip = true;
#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;
arg_show_progress = true;
static const int pass_table[] = {
if (pass <= 0)
bool locked = false;
int clear = 0;
return -errno;
if (!console)
return -ENOMEM;
while (!feof(f)) {
int pass, m;
usec_t t;
if (!locked) {
locked = true;
last = t;
if (m > clear)
clear = m;
if (clear > 0) {
for (j = 0; j < (unsigned) clear; j++)
int i = 0, r = EXIT_FAILURE, q;
bool root_directory;
return EXIT_FAILURE;
log_open();
test_files();
if (!udev) {
log_oom();
return EXIT_FAILURE;
root_directory = false;
return EXIT_FAILURE;
if (!udev_device) {
return EXIT_FAILURE;
return EXIT_FAILURE;
return EXIT_SUCCESS;
return EXIT_SUCCESS;
if (!udev_device) {
return EXIT_FAILURE;
if (!device) {
return EXIT_FAILURE;
root_directory = true;
if (type) {
return EXIT_SUCCESS;
if (arg_show_progress)
return EXIT_FAILURE;
if (!root_directory)
if (arg_force)
if (pid < 0) {
goto finish;
} else if (pid == 0) {
if (progress_pipe[0] >= 0)
if (progress_pipe[0] >= 0) {
goto finish;
r = EXIT_SUCCESS;
r = EXIT_SUCCESS;