From: Yu Watanabe Date: Fri, 16 Sep 2022 20:11:43 +0000 (+0900) Subject: dissect-image: make verity_partition() actually fail when all attempts of activation... X-Git-Tag: v252-rc1~165^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F24703%2Fhead;p=thirdparty%2Fsystemd.git dissect-image: make verity_partition() actually fail when all attempts of activation failed --- diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index d6a2ab99ce1..274c33c35e4 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -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);