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 General Public License as published by
10 the Free Software Foundation; either version 2 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 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
30 static bool arg_skip = false;
31 static bool arg_force = false;
33 static int parse_proc_cmdline(void) {
34 char *line, *w, *state;
38 if (detect_container(NULL) > 0)
41 if ((r = read_one_line_file("/proc/cmdline", &line)) < 0) {
42 log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
46 FOREACH_WORD_QUOTED(w, l, line, state) {
48 if (strneq(w, "quotacheck.mode=auto", l))
49 arg_force = arg_skip = false;
50 else if (strneq(w, "quotacheck.mode=force", l))
52 else if (strneq(w, "quotacheck.mode=skip", l))
54 else if (startswith(w, "quotacheck.mode"))
55 log_warning("Invalid quotacheck.mode= parameter. Ignoring.");
56 #if defined(TARGET_FEDORA) || defined(TARGET_MANDRIVA)
57 else if (strneq(w, "forcequotacheck", l))
66 static void test_files(void) {
67 #if defined(TARGET_FEDORA) || defined(TARGET_MANDRIVA)
68 /* This exists only on Fedora or Mandriva */
69 if (access("/forcequotacheck", F_OK) >= 0)
74 int main(int argc, char *argv[]) {
75 static const char * const cmdline[] = {
85 log_error("This program takes no arguments.");
89 log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
90 log_parse_environment();
100 if (access("/run/systemd/quotacheck", F_OK) < 0)
104 if ((pid = fork()) < 0) {
105 log_error("fork(): %m");
107 } else if (pid == 0) {
109 execv(cmdline[0], (char**) cmdline);
110 _exit(1); /* Operational error */
113 r = wait_for_terminate_and_warn("quotacheck", pid) == 0 ? EXIT_SUCCESS : EXIT_FAILURE;