]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/quotacheck/quotacheck.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 This file is part of systemd.
5 Copyright 2010 Lennart Poettering
7 systemd is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
12 systemd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 #include <sys/prctl.h>
27 #include "proc-cmdline.h"
28 #include "process-util.h"
29 #include "signal-util.h"
30 #include "string-util.h"
33 static bool arg_skip
= false;
34 static bool arg_force
= false;
36 static int parse_proc_cmdline_item(const char *key
, const char *value
, void *data
) {
38 if (streq(key
, "quotacheck.mode")) {
40 if (proc_cmdline_value_missing(key
, value
))
43 if (streq(value
, "auto"))
44 arg_force
= arg_skip
= false;
45 else if (streq(value
, "force"))
47 else if (streq(value
, "skip"))
50 log_warning("Invalid quotacheck.mode= parameter '%s'. Ignoring.", value
);
54 else if (streq(key
, "forcequotacheck") && !value
) {
55 log_warning("Please use 'quotacheck.mode=force' rather than 'forcequotacheck' on the kernel command line.");
63 static void test_files(void) {
66 if (access("/forcequotacheck", F_OK
) >= 0) {
67 log_error("Please pass 'quotacheck.mode=force' on the kernel command line rather than creating /forcequotacheck on the root file system.");
73 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_AUTO
);
90 log_parse_environment();
95 r
= proc_cmdline_parse(parse_proc_cmdline_item
, NULL
, 0);
97 log_warning_errno(r
, "Failed to parse kernel command line, ignoring: %m");
105 if (access("/run/systemd/quotacheck", F_OK
) < 0)
111 r
= log_error_errno(errno
, "fork(): %m");
118 (void) reset_all_signal_handlers();
119 (void) reset_signal_mask();
120 assert_se(prctl(PR_SET_PDEATHSIG
, SIGTERM
) == 0);
122 execv(cmdline
[0], (char**) cmdline
);
123 _exit(1); /* Operational error */
126 r
= wait_for_terminate_and_warn("quotacheck", pid
, true);
129 return r
< 0 ? EXIT_FAILURE
: EXIT_SUCCESS
;