]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/quotacheck/quotacheck.c
a87b0866cd3a1f32153e2871ed4b5af8ca539245
2 This file is part of systemd.
4 Copyright 2010 Lennart Poettering
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 #include <sys/prctl.h>
26 #include "proc-cmdline.h"
27 #include "process-util.h"
28 #include "signal-util.h"
29 #include "string-util.h"
32 static bool arg_skip
= false;
33 static bool arg_force
= false;
35 static int parse_proc_cmdline_item(const char *key
, const char *value
, void *data
) {
37 if (streq(key
, "quotacheck.mode") && value
) {
39 if (streq(value
, "auto"))
40 arg_force
= arg_skip
= false;
41 else if (streq(value
, "force"))
43 else if (streq(value
, "skip"))
46 log_warning("Invalid quotacheck.mode= parameter '%s'. Ignoring.", value
);
49 #ifdef HAVE_SYSV_COMPAT
50 else if (streq(key
, "forcequotacheck") && !value
) {
51 log_warning("Please use 'quotacheck.mode=force' rather than 'forcequotacheck' on the kernel command line.");
59 static void test_files(void) {
61 #ifdef HAVE_SYSV_COMPAT
62 if (access("/forcequotacheck", F_OK
) >= 0) {
63 log_error("Please pass 'quotacheck.mode=force' on the kernel command line rather than creating /forcequotacheck on the root file system.");
69 int main(int argc
, char *argv
[]) {
71 static const char * const cmdline
[] = {
81 log_error("This program takes no arguments.");
85 log_set_target(LOG_TARGET_AUTO
);
86 log_parse_environment();
91 r
= parse_proc_cmdline(parse_proc_cmdline_item
, NULL
);
93 log_warning_errno(r
, "Failed to parse kernel command line, ignoring: %m");
101 if (access("/run/systemd/quotacheck", F_OK
) < 0)
107 log_error_errno(errno
, "fork(): %m");
109 } else if (pid
== 0) {
113 (void) reset_all_signal_handlers();
114 (void) reset_signal_mask();
115 assert_se(prctl(PR_SET_PDEATHSIG
, SIGTERM
) == 0);
117 execv(cmdline
[0], (char**) cmdline
);
118 _exit(1); /* Operational error */
121 r
= wait_for_terminate_and_warn("quotacheck", pid
, true);
123 return r
< 0 ? EXIT_FAILURE
: EXIT_SUCCESS
;