summaryrefslogtreecommitdiffstats
path: root/src/sysupdate/sysupdate.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-11-30 18:43:18 +0100
committerLennart Poettering <lennart@poettering.net>2023-04-05 20:45:30 +0200
commit84be0c710d9d562f6d2cf986cc2a8ff4c98a138b (patch)
treeb374ebea1d604154fa0e004560f428c7f111352c /src/sysupdate/sysupdate.c
parentdissect: add image dissection policy framework (diff)
downloadsystemd-84be0c710d9d562f6d2cf986cc2a8ff4c98a138b.tar.xz
systemd-84be0c710d9d562f6d2cf986cc2a8ff4c98a138b.zip
tree-wide: hook up image dissection policy logic everywhere
Diffstat (limited to 'src/sysupdate/sysupdate.c')
-rw-r--r--src/sysupdate/sysupdate.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/sysupdate/sysupdate.c b/src/sysupdate/sysupdate.c
index 6cb09dae50..f62e193056 100644
--- a/src/sysupdate/sysupdate.c
+++ b/src/sysupdate/sysupdate.c
@@ -46,11 +46,13 @@ static char *arg_image = NULL;
static bool arg_reboot = false;
static char *arg_component = NULL;
static int arg_verify = -1;
+static ImagePolicy *arg_image_policy = NULL;
STATIC_DESTRUCTOR_REGISTER(arg_definitions, freep);
STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
STATIC_DESTRUCTOR_REGISTER(arg_image, freep);
STATIC_DESTRUCTOR_REGISTER(arg_component, freep);
+STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep);
typedef struct Context {
Transfer **transfers;
@@ -872,6 +874,7 @@ static int process_image(
r = mount_image_privately_interactively(
arg_image,
+ arg_image_policy,
(ro ? DISSECT_IMAGE_READ_ONLY : 0) |
DISSECT_IMAGE_FSCK |
DISSECT_IMAGE_MKDIR |
@@ -1022,7 +1025,7 @@ static int verb_pending_or_reboot(int argc, char **argv, void *userdata) {
if (arg_image || arg_root)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "The --root=/--image switches may not be combined with the '%s' operation.", argv[0]);
+ "The --root=/--image= switches may not be combined with the '%s' operation.", argv[0]);
r = context_make_offline(&context, NULL);
if (r < 0)
@@ -1205,8 +1208,10 @@ static int verb_help(int argc, char **argv, void *userdata) {
"\n%3$sOptions:%4$s\n"
" -C --component=NAME Select component to update\n"
" --definitions=DIR Find transfer definitions in specified directory\n"
- " --root=PATH Operate relative to root path\n"
- " --image=PATH Operate relative to image file\n"
+ " --root=PATH Operate on an alternate filesystem root\n"
+ " --image=PATH Operate on disk image as filesystem root\n"
+ " --image-policy=POLICY\n"
+ " Specify disk image dissection policy\n"
" -m --instances-max=INT How many instances to maintain\n"
" --sync=BOOL Controls whether to sync data to disk\n"
" --verify=BOOL Force signature verification on or off\n"
@@ -1238,6 +1243,7 @@ static int parse_argv(int argc, char *argv[]) {
ARG_IMAGE,
ARG_REBOOT,
ARG_VERIFY,
+ ARG_IMAGE_POLICY,
};
static const struct option options[] = {
@@ -1254,6 +1260,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "reboot", no_argument, NULL, ARG_REBOOT },
{ "component", required_argument, NULL, 'C' },
{ "verify", required_argument, NULL, ARG_VERIFY },
+ { "image-policy", required_argument, NULL, ARG_IMAGE_POLICY },
{}
};
@@ -1351,6 +1358,17 @@ static int parse_argv(int argc, char *argv[]) {
break;
}
+ case ARG_IMAGE_POLICY: {
+ _cleanup_(image_policy_freep) ImagePolicy *p = NULL;
+
+ r = image_policy_from_string(optarg, &p);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse image policy: %s", optarg);
+
+ image_policy_free(arg_image_policy);
+ arg_image_policy = TAKE_PTR(p);
+ break;
+ }
case '?':
return -EINVAL;