]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect-image: make verity_partition() actually fail when all attempts of activation... 24703/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 16 Sep 2022 20:11:43 +0000 (05:11 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 16 Sep 2022 20:18:25 +0000 (05:18 +0900)
src/shared/dissect-image.c

index d6a2ab99ce134189e241b9f441028192ffb68a35..274c33c35e4b49eeff7d79c0c34b6e8e91bd9aff 100644 (file)
@@ -2021,17 +2021,19 @@ static int verity_partition(
                         }
                 }
                 if (r >= 0)
-                        break;
+                        goto success;
 
                 /* Device is being opened by another process, but it has not finished yet, yield for 2ms */
                 (void) usleep(2 * USEC_PER_MSEC);
         }
 
-        /* An existing verity device was reported by libcryptsetup/libdevmapper, but we can't use it at this time.
-         * Fall back to activating it with a unique device name. */
-        if (r < 0 && FLAGS_SET(flags, DISSECT_IMAGE_VERITY_SHARE))
+        /* All trials failed. Let's try to activate with a unique name. */
+        if (FLAGS_SET(flags, DISSECT_IMAGE_VERITY_SHARE))
                 return verity_partition(designator, m, v, verity, flags & ~DISSECT_IMAGE_VERITY_SHARE, d);
 
+        return log_debug_errno(SYNTHETIC_ERRNO(EBUSY), "All attempts to activate verity device %s failed.", name);
+
+success:
         /* Everything looks good and we'll be able to mount the device, so deferred remove will be re-enabled at that point. */
         restore_deferred_remove = mfree(restore_deferred_remove);