From: Yu Watanabe Date: Tue, 6 Sep 2022 01:58:26 +0000 (+0900) Subject: dissect-image: use loop backing file or device node as name of the image X-Git-Tag: v252-rc1~236^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=64dd3a245f0964b8a15923da68b77e932a40536b;p=thirdparty%2Fsystemd.git dissect-image: use loop backing file or device node as name of the image Note, currently, for each call of dissect_loop_device_and_warn(), the specified name is equivalent to the path passed to loop_device_make_by_path(). Hence, this should not change the current behavios. --- diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c index 22872d803cf..b075222ec56 100644 --- a/src/dissect/dissect.c +++ b/src/dissect/dissect.c @@ -946,7 +946,6 @@ static int run(int argc, char *argv[]) { return log_error_errno(r, "Failed to set up loopback device for %s: %m", arg_image); r = dissect_loop_device_and_warn( - arg_image, d, &arg_verity_settings, NULL, diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 50c7f78f1c2..7c703acf9ce 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -5754,7 +5754,6 @@ static int run(int argc, char *argv[]) { } r = dissect_loop_device_and_warn( - arg_image, loop, &arg_verity_settings, NULL, diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index fce05bcfbd1..b5c963656b8 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -2806,20 +2806,19 @@ finish: } int dissect_loop_device_and_warn( - const char *name, const LoopDevice *loop, const VeritySettings *verity, const MountOptions *mount_options, DissectImageFlags flags, DissectedImage **ret) { + const char *name; int r; assert(loop); assert(loop->fd >= 0); - if (!name) - name = ASSERT_PTR(loop->node); + name = ASSERT_PTR(loop->backing_file ?: loop->node); r = dissect_loop_device(loop, verity, mount_options, flags, ret); switch (r) { @@ -2974,7 +2973,7 @@ int mount_image_privately_interactively( if (r < 0) return log_error_errno(r, "Failed to set up loopback device for %s: %m", image); - r = dissect_loop_device_and_warn(image, d, &verity, NULL, flags, &dissected_image); + r = dissect_loop_device_and_warn(d, &verity, NULL, flags, &dissected_image); if (r < 0) return r; diff --git a/src/shared/dissect-image.h b/src/shared/dissect-image.h index c8d2e6de8fa..39af311833d 100644 --- a/src/shared/dissect-image.h +++ b/src/shared/dissect-image.h @@ -265,9 +265,9 @@ int dissect_image( DissectedImage **ret); static inline int dissect_loop_device(const LoopDevice *loop, const VeritySettings *verity, const MountOptions *mount_options, DissectImageFlags flags, DissectedImage **ret) { assert(loop); - return dissect_image(loop->fd, loop->backing_file, verity, mount_options, loop->diskseq, loop->uevent_seqnum_not_before, loop->timestamp_not_before, flags, ret); + return dissect_image(loop->fd, loop->backing_file ?: loop->node, verity, mount_options, loop->diskseq, loop->uevent_seqnum_not_before, loop->timestamp_not_before, flags, ret); } -int dissect_loop_device_and_warn(const char *name, const LoopDevice *loop, const VeritySettings *verity, const MountOptions *mount_options, DissectImageFlags flags, DissectedImage **ret); +int dissect_loop_device_and_warn(const LoopDevice *loop, const VeritySettings *verity, const MountOptions *mount_options, DissectImageFlags flags, DissectedImage **ret); DissectedImage* dissected_image_unref(DissectedImage *m); DEFINE_TRIVIAL_CLEANUP_FUNC(DissectedImage*, dissected_image_unref); diff --git a/src/sysext/sysext.c b/src/sysext/sysext.c index 93ddc73b462..e45fa61640c 100644 --- a/src/sysext/sysext.c +++ b/src/sysext/sysext.c @@ -540,7 +540,6 @@ static int merge_subprocess(Hashmap *images, const char *workspace) { return log_error_errno(r, "Failed to set up loopback device for %s: %m", img->path); r = dissect_loop_device_and_warn( - img->path, d, &verity_settings, NULL,