]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/quotacheck/quotacheck.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
10 #include "proc-cmdline.h"
11 #include "process-util.h"
12 #include "signal-util.h"
13 #include "string-util.h"
16 static bool arg_skip
= false;
17 static bool arg_force
= false;
19 static int parse_proc_cmdline_item(const char *key
, const char *value
, void *data
) {
21 if (streq(key
, "quotacheck.mode")) {
23 if (proc_cmdline_value_missing(key
, value
))
26 if (streq(value
, "auto"))
27 arg_force
= arg_skip
= false;
28 else if (streq(value
, "force"))
30 else if (streq(value
, "skip"))
33 log_warning("Invalid quotacheck.mode= parameter '%s'. Ignoring.", value
);
37 else if (streq(key
, "forcequotacheck") && !value
) {
38 log_warning("Please use 'quotacheck.mode=force' rather than 'forcequotacheck' on the kernel command line.");
46 static void test_files(void) {
49 if (access("/forcequotacheck", F_OK
) >= 0) {
50 log_error("Please pass 'quotacheck.mode=force' on the kernel command line rather than creating /forcequotacheck on the root file system.");
56 static int run(int argc
, char *argv
[]) {
62 return log_error_errno(SYNTHETIC_ERRNO(EINVAL
),
63 "This program takes no arguments.");
67 r
= proc_cmdline_parse(parse_proc_cmdline_item
, NULL
, 0);
69 log_warning_errno(r
, "Failed to parse kernel command line, ignoring: %m");
77 if (access("/run/systemd/quotacheck", F_OK
) < 0)
81 r
= safe_fork("(quotacheck)", FORK_RESET_SIGNALS
|FORK_DEATHSIG
|FORK_RLIMIT_NOFILE_SAFE
|FORK_WAIT
|FORK_LOG
, NULL
);
85 static const char * const cmdline
[] = {
93 execv(cmdline
[0], (char**) cmdline
);
94 _exit(EXIT_FAILURE
); /* Operational error */
100 DEFINE_MAIN_FUNCTION(run
);