]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/quotacheck/quotacheck.c
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / quotacheck / quotacheck.c
index dc2911e4e8b2558b8f779462838eb8f95be5ef60..ec5be21a34d5ea4a04fafff10a0be43752191247 100644 (file)
@@ -1,5 +1,4 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
 #include <sys/prctl.h>
 #include <unistd.h>
 
+#include "proc-cmdline.h"
 #include "process-util.h"
 #include "signal-util.h"
 #include "string-util.h"
 #include "util.h"
-#include "proc-cmdline.h"
 
 static bool arg_skip = false;
 static bool arg_force = false;
 
-static int parse_proc_cmdline_item(const char *key, const char *value) {
+static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
 
-        if (streq(key, "quotacheck.mode") && value) {
+        if (streq(key, "quotacheck.mode")) {
+
+                if (proc_cmdline_value_missing(key, value))
+                        return 0;
 
                 if (streq(value, "auto"))
                         arg_force = arg_skip = false;
@@ -48,7 +50,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value) {
                         log_warning("Invalid quotacheck.mode= parameter '%s'. Ignoring.", value);
         }
 
-#ifdef HAVE_SYSV_COMPAT
+#if HAVE_SYSV_COMPAT
         else if (streq(key, "forcequotacheck") && !value) {
                 log_warning("Please use 'quotacheck.mode=force' rather than 'forcequotacheck' on the kernel command line.");
                 arg_force = true;
@@ -60,7 +62,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value) {
 
 static void test_files(void) {
 
-#ifdef HAVE_SYSV_COMPAT
+#if HAVE_SYSV_COMPAT
         if (access("/forcequotacheck", F_OK) >= 0) {
                 log_error("Please pass 'quotacheck.mode=force' on the kernel command line rather than creating /forcequotacheck on the root file system.");
                 arg_force = true;
@@ -90,7 +92,7 @@ int main(int argc, char *argv[]) {
 
         umask(0022);
 
-        r = parse_proc_cmdline(parse_proc_cmdline_item);
+        r = proc_cmdline_parse(parse_proc_cmdline_item, NULL, 0);
         if (r < 0)
                 log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
 
@@ -106,9 +108,10 @@ int main(int argc, char *argv[]) {
 
         pid = fork();
         if (pid < 0) {
-                log_error_errno(errno, "fork(): %m");
-                return EXIT_FAILURE;
-        } else if (pid == 0) {
+                r = log_error_errno(errno, "fork(): %m");
+                goto finish;
+        }
+        if (pid == 0) {
 
                 /* Child */
 
@@ -122,5 +125,6 @@ int main(int argc, char *argv[]) {
 
         r = wait_for_terminate_and_warn("quotacheck", pid, true);
 
+finish:
         return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }