sysext: Move parsing mutable mode to a separate function

This commit is contained in:
Krzesimir Nowak
2024-03-25 08:14:36 +01:00
parent 5e3c08d375
commit 738eaf9697
+22 -10
View File
@@ -119,6 +119,24 @@ static const struct {
}
};
static int parse_mutable_mode(const char *p) {
int r;
assert(p);
if (streq(p, "auto"))
return MUTABLE_AUTO;
if (streq(p, "import"))
return MUTABLE_IMPORT;
r = parse_boolean(p);
if (r < 0)
return r;
return r ? MUTABLE_YES : MUTABLE_NO;
}
static int is_our_mount_point(
ImageClass image_class,
const char *p) {
@@ -2109,16 +2127,10 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_MUTABLE:
if (streq(optarg, "auto"))
arg_mutable = MUTABLE_AUTO;
else if (streq(optarg, "import"))
arg_mutable = MUTABLE_IMPORT;
else {
r = parse_boolean(optarg);
if (r < 0)
return log_error_errno(r, "Failed to parse argument to --mutable=: %s", optarg);
arg_mutable = r ? MUTABLE_YES : MUTABLE_NO;
}
r = parse_mutable_mode(optarg);
if (r < 0)
return log_error_errno(r, "Failed to parse argument to --mutable=: %s", optarg);
arg_mutable = r;
break;
case '?':