]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sysext: use LO_FLAGS_PARTSCAN when opening image
authorLuca Boccassi <luca.boccassi@microsoft.com>
Wed, 19 Jan 2022 00:27:45 +0000 (00:27 +0000)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 19 Jan 2022 07:54:50 +0000 (08:54 +0100)
Jan 17 12:34:59 myguest1 (sd-sysext)[486]: Device '/var/lib/extensions/myext.raw' is loopback block device with partition scanning turned off, please turn it on.

Fixes https://github.com/systemd/systemd/issues/22146

src/sysext/sysext.c

index 5abf1bb418389223c82ab5e05730cae5e8cb1511..60789e0f2c19d725061be923477ea71efa4a6709 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <fcntl.h>
 #include <getopt.h>
+#include <linux/loop.h>
 #include <sys/mount.h>
 #include <unistd.h>
 
@@ -529,7 +530,11 @@ static int merge_subprocess(Hashmap *images, const char *workspace) {
                         if (verity_settings.data_path)
                                 flags |= DISSECT_IMAGE_NO_PARTITION_TABLE;
 
-                        r = loop_device_make_by_path(img->path, O_RDONLY, 0, &d);
+                        r = loop_device_make_by_path(
+                                        img->path,
+                                        O_RDONLY,
+                                        FLAGS_SET(flags, DISSECT_IMAGE_NO_PARTITION_TABLE) ? 0 : LO_FLAGS_PARTSCAN,
+                                        &d);
                         if (r < 0)
                                 return log_error_errno(r, "Failed to set up loopback device for %s: %m", img->path);