#include "unit-name.h"
#include "virt.h"
-typedef enum GptAutoRoot {
- GPT_AUTO_ROOT_UNSPECIFIED, /* no root= specified */
- GPT_AUTO_ROOT_OFF, /* root= set to something else */
- GPT_AUTO_ROOT_ON, /* root= set explicitly to "gpt-auto" */
- GPT_AUTO_ROOT_FORCE, /* root= set explicitly to "gpt-auto-force" → ignores factory reset mode */
-} GptAutoRoot;
-
static const char *arg_dest = NULL;
static bool arg_enabled = true;
-static GptAutoRoot arg_auto_root = GPT_AUTO_ROOT_UNSPECIFIED;
+static GptAutoRoot arg_auto_root = _GPT_AUTO_ROOT_INVALID;
static bool arg_swap_enabled = true;
static char *arg_root_fstype = NULL;
static char *arg_root_options = NULL;
return 0;
/* Neither explicitly enabled nor disabled? Then decide based on the EFI partition variables to be set */
- if (arg_auto_root == GPT_AUTO_ROOT_UNSPECIFIED) {
+ if (arg_auto_root < 0) {
if (!is_efi_boot()) {
log_debug("Not an EFI boot, not creating root mount.");
return 0;
/* Disable root disk logic if there's a root= value specified (unless it happens to be
* "gpt-auto" or "gpt-auto-force") */
- if (streq(value, "gpt-auto")) {
- arg_auto_root = GPT_AUTO_ROOT_ON;
- log_debug("Enabling root partition auto-detection (respecting factory reset mode), root= is explicitly set to 'gpt-auto'.");
- } else if (streq(value, "gpt-auto-force")) {
- arg_auto_root = GPT_AUTO_ROOT_FORCE;
- log_debug("Enabling root partition auto-detection (ignoring factory reset mode), root= is explicitly set to 'gpt-auto-force'.");
- } else {
- arg_auto_root = GPT_AUTO_ROOT_OFF;
- log_debug("Disabling root partition auto-detection, root= is neither unset, nor set to 'gpt-auto' or 'gpt-auto-force'.");
- }
+ arg_auto_root = parse_gpt_auto_root(value);
+ assert(arg_auto_root >= 0);
} else if (streq(key, "roothash")) {
return (cached = (u > 0));
}
+
+GptAutoRoot parse_gpt_auto_root(const char *value) {
+ assert(value);
+
+ /* Parses the 'gpt-auto'/'gpt-auto-root' parameters to root= */
+
+ if (streq(value, "gpt-auto")) {
+ log_debug("Enabling root partition auto-detection (respecting factory reset mode), root= is explicitly set to 'gpt-auto'.");
+ return GPT_AUTO_ROOT_ON;
+ }
+
+ if (streq(value, "gpt-auto-force")) {
+ log_debug("Enabling root partition auto-detection (ignoring factory reset mode), root= is explicitly set to 'gpt-auto-force'.");
+ return GPT_AUTO_ROOT_FORCE;
+ }
+
+ log_debug("Disabling root partition auto-detection, root= is neither unset, nor set to 'gpt-auto' or 'gpt-auto-force'.");
+ return GPT_AUTO_ROOT_OFF;
+}
#include <stdio.h>
+#include "errno-list.h"
#include "macro.h"
#include "main-func.h"
argv[argc == 4 ? 3 : 1]), \
exit_failure_if_negative, \
exit_failure_if_negative)
+
+typedef enum GptAutoRoot {
+ GPT_AUTO_ROOT_OFF = 0, /* root= set to something else */
+ GPT_AUTO_ROOT_ON, /* root= set explicitly to "gpt-auto" */
+ GPT_AUTO_ROOT_FORCE, /* root= set explicitly to "gpt-auto-force" → ignores factory reset mode */
+ _GPT_AUTO_ROOT_MAX,
+ _GPT_AUTO_ROOT_INVALID = -EINVAL,
+} GptAutoRoot;
+
+GptAutoRoot parse_gpt_auto_root(const char *value);