From b8889c0a214aeb3dd47bf1ab280fe5534b64d2aa Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Thu, 9 Feb 2023 01:21:07 +0000 Subject: [PATCH] libblkid: try LUKS2 first when probing If a device is locked with OPAL we'll get an I/O error when probing past the LUKS2 header. Try it first to avoid this issue. It is useful regardless, as when we find a LUKS superblock we stop there anyway, no need to check futher. Signed-off-by: Luca Boccassi --- libblkid/src/superblocks/superblocks.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c index c7789a15be..fb03927078 100644 --- a/libblkid/src/superblocks/superblocks.c +++ b/libblkid/src/superblocks/superblocks.c @@ -94,6 +94,11 @@ static int blkid_probe_set_usage(blkid_probe pr, int usage); */ static const struct blkid_idinfo *idinfos[] = { + /* In case the volume is locked with OPAL we are going to get + * an I/O error when reading past the LUKS header, so try it + * first. */ + &luks_idinfo, + /* RAIDs */ &linuxraid_idinfo, &ddfraid_idinfo, @@ -119,7 +124,6 @@ static const struct blkid_idinfo *idinfos[] = &snapcow_idinfo, &verity_hash_idinfo, &integrity_idinfo, - &luks_idinfo, &vmfs_volume_idinfo, &ubi_idinfo, &vdo_idinfo, -- 2.39.5