]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect: Go via service on ENOENT from loop_device_make() as well
authorDaan De Meyer <daan@amutable.com>
Sat, 21 Feb 2026 20:36:16 +0000 (21:36 +0100)
committerDaan De Meyer <daan@amutable.com>
Tue, 24 Feb 2026 17:29:37 +0000 (18:29 +0100)
ENOENT means /dev/loop-control isn't there which means we're in a
container and should go via mountfsd.

At the same time, reverse the check for fatal actions as almost all
actions can be done via mountfsd, only --attach needs the loop device.

src/dissect/dissect.c

index 250be1af3d140ba9690150d9e181e5bfca7a60c9..aafbd872ae7134863c8c963ade3037653e275b3c 100644 (file)
@@ -2178,10 +2178,10 @@ static int run(int argc, char *argv[]) {
                         else
                                 r = loop_device_make_by_path(arg_image, open_flags, /* sector_size= */ UINT32_MAX, loop_flags, LOCK_SH, &d);
                         if (r < 0) {
-                                if (!ERRNO_IS_PRIVILEGE(r) || !IN_SET(arg_action, ACTION_MOUNT, ACTION_UMOUNT, ACTION_WITH, ACTION_DISSECT, ACTION_LIST, ACTION_MTREE, ACTION_COPY_FROM, ACTION_COPY_TO, ACTION_SHIFT))
+                                if ((r != -ENOENT && !ERRNO_IS_PRIVILEGE(r)) || arg_action == ACTION_ATTACH)
                                         return log_error_errno(r, "Failed to set up loopback device for %s: %m", arg_image);
 
-                                log_debug_errno(r, "Lacking permissions to set up loopback block device for %s, using service: %m", arg_image);
+                                log_debug_errno(r, "Lacking permissions or missing /dev/loop-control to set up loopback block device for %s, using service: %m", arg_image);
                                 arg_via_service = true;
                         } else {
                                 if (arg_loop_ref) {