]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect-image: use loop backing file or device node as name of the image
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 6 Sep 2022 01:58:26 +0000 (10:58 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 7 Sep 2022 11:45:24 +0000 (20:45 +0900)
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.

src/dissect/dissect.c
src/nspawn/nspawn.c
src/shared/dissect-image.c
src/shared/dissect-image.h
src/sysext/sysext.c

index 22872d803cf19fdad24a2dea759f8fb6e5fc3bfa..b075222ec5622a9bb389596548429abcbb7e389e 100644 (file)
@@ -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,
index 50c7f78f1c2af8b36e2122f87889b4fc7306c611..7c703acf9ce462ca758a74ecc2b9dd5709ff8d1a 100644 (file)
@@ -5754,7 +5754,6 @@ static int run(int argc, char *argv[]) {
                 }
 
                 r = dissect_loop_device_and_warn(
-                                arg_image,
                                 loop,
                                 &arg_verity_settings,
                                 NULL,
index fce05bcfbd14cee008d72ae1bd179dd043aef04c..b5c963656b8a059bdd375b3f2b8ea299e1dc52bd 100644 (file)
@@ -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;
 
index c8d2e6de8fa623d51f561f90ecab6f6c58de88a7..39af311833da47e7f7977a8148dbe60104a310a4 100644 (file)
@@ -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);
index 93ddc73b4624431011ec5aaa5b75f01dc433f8fd..e45fa61640c90f8fc371019c8c6ba6d73d15c6cd 100644 (file)
@@ -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,