]>
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
11 #include <sys/prctl.h>
14 #include "proc-cmdline.h"
15 #include "process-util.h"
16 #include "signal-util.h"
17 #include "string-util.h"
20 static bool arg_skip
= false;
21 static bool arg_force
= false;
23 static int parse_proc_cmdline_item(const char *key
, const char *value
, void *data
) {
25 if (streq(key
, "quotacheck.mode")) {
27 if (proc_cmdline_value_missing(key
, value
))
30 if (streq(value
, "auto"))
31 arg_force
= arg_skip
= false;
32 else if (streq(value
, "force"))
34 else if (streq(value
, "skip"))
37 log_warning("Invalid quotacheck.mode= parameter '%s'. Ignoring.", value
);
41 else if (streq(key
, "forcequotacheck") && !value
) {
42 log_warning("Please use 'quotacheck.mode=force' rather than 'forcequotacheck' on the kernel command line.");
50 static void test_files(void) {
53 if (access("/forcequotacheck", F_OK
) >= 0) {
54 log_error("Please pass 'quotacheck.mode=force' on the kernel command line rather than creating /forcequotacheck on the root file system.");
60 int main(int argc
, char *argv
[]) {
64 log_error("This program takes no arguments.");
68 log_set_target(LOG_TARGET_AUTO
);
69 log_parse_environment();
74 r
= proc_cmdline_parse(parse_proc_cmdline_item
, NULL
, 0);
76 log_warning_errno(r
, "Failed to parse kernel command line, ignoring: %m");
84 if (access("/run/systemd/quotacheck", F_OK
) < 0)
88 r
= safe_fork("(quotacheck)", FORK_RESET_SIGNALS
|FORK_DEATHSIG
|FORK_LOG
|FORK_WAIT
, NULL
);
92 static const char * const cmdline
[] = {
100 execv(cmdline
[0], (char**) cmdline
);
101 _exit(EXIT_FAILURE
); /* Operational error */
105 return r
< 0 ? EXIT_FAILURE
: EXIT_SUCCESS
;