#include "main-func.h"
#include "proc-cmdline.h"
#include "process-util.h"
+#include "string-table.h"
#include "string-util.h"
-static bool arg_skip = false;
-static bool arg_force = false;
+typedef enum QuotaCheckMode {
+ QUOTA_CHECK_AUTO,
+ QUOTA_CHECK_FORCE,
+ QUOTA_CHECK_SKIP,
+ _QUOTA_CHECK_MODE_MAX,
+ _QUOTA_CHECK_MODE_INVALID = -EINVAL,
+} QuotaCheckMode;
+
+static QuotaCheckMode arg_mode = QUOTA_CHECK_AUTO;
+
+static const char * const quota_check_mode_table[_QUOTA_CHECK_MODE_MAX] = {
+ [QUOTA_CHECK_AUTO] = "auto",
+ [QUOTA_CHECK_FORCE] = "force",
+ [QUOTA_CHECK_SKIP] = "skip",
+};
+
+DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(quota_check_mode, QuotaCheckMode);
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
if (proc_cmdline_value_missing(key, value))
return 0;
- if (streq(value, "auto"))
- arg_force = arg_skip = false;
- else if (streq(value, "force"))
- arg_force = true;
- else if (streq(value, "skip"))
- arg_skip = true;
- else
- log_warning("Invalid quotacheck.mode= value, ignoring: %s", value);
+ arg_mode = quota_check_mode_from_string(value);
+ if (arg_mode < 0)
+ log_warning_errno(arg_mode, "Invalid quotacheck.mode= value, ignoring: %s", value);
} else if (streq(key, "forcequotacheck") && !value)
- arg_force = true;
+ arg_mode = QUOTA_CHECK_FORCE;
return 0;
}
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
- if (!arg_force) {
- if (arg_skip)
- return 0;
+ if (arg_mode == QUOTA_CHECK_SKIP)
+ return 0;
+ if (arg_mode == QUOTA_CHECK_AUTO) {
/* This is created by systemd-fsck when fsck detected and corrected errors. In normal
* operations quotacheck is not needed. */
if (access("/run/systemd/quotacheck", F_OK) < 0) {