1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
32 static bool arg_skip = false;
33 static bool arg_force = false;
35 static int parse_proc_cmdline(void) {
36 char *line, *w, *state;
40 if (detect_container(NULL) > 0)
43 if ((r = read_one_line_file("/proc/cmdline", &line)) < 0) {
44 log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
48 FOREACH_WORD_QUOTED(w, l, line, state) {
50 if (strneq(w, "quotacheck.mode=auto", l))
51 arg_force = arg_skip = false;
52 else if (strneq(w, "quotacheck.mode=force", l))
54 else if (strneq(w, "quotacheck.mode=skip", l))
56 else if (startswith(w, "quotacheck"))
57 log_warning("Invalid quotacheck parameter. Ignoring.");
58 #ifdef HAVE_SYSV_COMPAT
59 else if (strneq(w, "forcequotacheck", l)) {
60 log_error("Please use 'quotacheck.mode=force' rather than 'forcequotacheck' on the kernel command line.");
70 static void test_files(void) {
71 #ifdef HAVE_SYSV_COMPAT
72 if (access("/forcequotacheck", F_OK) >= 0) {
73 log_error("Please pass 'quotacheck.mode=force' on the kernel command line rather than creating /forcequotacheck on the root file system.");
79 int main(int argc, char *argv[]) {
80 static const char * const cmdline[] = {
90 log_error("This program takes no arguments.");
94 log_set_target(LOG_TARGET_AUTO);
95 log_parse_environment();
100 parse_proc_cmdline();
107 if (access("/run/systemd/quotacheck", F_OK) < 0)
111 if ((pid = fork()) < 0) {
112 log_error("fork(): %m");
114 } else if (pid == 0) {
116 execv(cmdline[0], (char**) cmdline);
117 _exit(1); /* Operational error */
120 r = wait_for_terminate_and_warn("quotacheck", pid) == 0 ? EXIT_SUCCESS : EXIT_FAILURE;