]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/quotacheck/quotacheck.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
11 #include "main-func.h"
12 #include "proc-cmdline.h"
13 #include "process-util.h"
14 #include "signal-util.h"
15 #include "string-util.h"
17 static bool arg_skip
= false;
18 static bool arg_force
= false;
20 static int parse_proc_cmdline_item(const char *key
, const char *value
, void *data
) {
22 if (streq(key
, "quotacheck.mode")) {
24 if (proc_cmdline_value_missing(key
, value
))
27 if (streq(value
, "auto"))
28 arg_force
= arg_skip
= false;
29 else if (streq(value
, "force"))
31 else if (streq(value
, "skip"))
34 log_warning("Invalid quotacheck.mode= parameter '%s'. Ignoring.", value
);
38 else if (streq(key
, "forcequotacheck") && !value
) {
39 log_warning("Please use 'quotacheck.mode=force' rather than 'forcequotacheck' on the kernel command line.");
47 static void test_files(void) {
50 if (access("/forcequotacheck", F_OK
) >= 0) {
51 log_error("Please pass 'quotacheck.mode=force' on the kernel command line rather than creating /forcequotacheck on the root file system.");
57 static int run(int argc
, char *argv
[]) {
63 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
64 "This program takes no arguments.");
68 r
= proc_cmdline_parse(parse_proc_cmdline_item
, NULL
, 0);
70 log_warning_errno(r
, "Failed to parse kernel command line, ignoring: %m");
78 if (access("/run/systemd/quotacheck", F_OK
) < 0)
82 r
= safe_fork("(quotacheck)", FORK_RESET_SIGNALS
|FORK_DEATHSIG
|FORK_RLIMIT_NOFILE_SAFE
|FORK_WAIT
|FORK_LOG
, NULL
);
86 static const char * const cmdline
[] = {
94 execv(cmdline
[0], (char**) cmdline
);
95 _exit(EXIT_FAILURE
); /* Operational error */
101 DEFINE_MAIN_FUNCTION(run
);