From: Scott James Remnant Date: Mon, 26 Oct 2009 12:49:17 +0000 (+0100) Subject: libblkid: return first detected crypto device X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=048c62915fd76c3ed47afe2dde2a9b297fad9a81;p=util-linux libblkid: return first detected crypto device Crypto devices may sometimes have multiple additional prober matches, however just like RAID, there's no danger of activating the wrong one since special help is needed to activate the block device before it can be used. Thus modify blkid_do_safeprobe() to break out of the loop when a crypto device is detected, as it does already for RAID. Signed-off-by: Scott James Remnant Signed-off-by: Karel Zak --- diff --git a/shlibs/blkid/src/superblocks/superblocks.c b/shlibs/blkid/src/superblocks/superblocks.c index fe66d5af..6fb2be3a 100644 --- a/shlibs/blkid/src/superblocks/superblocks.c +++ b/shlibs/blkid/src/superblocks/superblocks.c @@ -93,6 +93,7 @@ static const struct blkid_idinfo *idinfos[] = &highpoint37x_idinfo, &adraid_idinfo, &jmraid_idinfo, + &lvm2_idinfo, &lvm1_idinfo, &snapcow_idinfo, @@ -388,9 +389,9 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn) * (cannot be used in while()) and checks for ambivalen results (more * filesystems on the device) -- in such case returns -2. * - * The function does not check for filesystems when a RAID signature is - * detected. The function also does not check for collision between RAIDs. The - * first detected RAID is returned. + * The function does not check for filesystems when a RAID or crypto signature + * is detected. The function also does not check for collision between RAIDs + * and crypto devices. The first detected RAID or crypto device is returned. */ static int superblocks_safeprobe(blkid_probe pr, struct blkid_chain *chn) { @@ -409,7 +410,7 @@ static int superblocks_safeprobe(blkid_probe pr, struct blkid_chain *chn) } count++; - if (idinfos[chn->idx]->usage & BLKID_USAGE_RAID) + if (idinfos[chn->idx]->usage & (BLKID_USAGE_RAID | BLKID_USAGE_CRYPTO)) break; if (!(idinfos[chn->idx]->flags & BLKID_IDINFO_TOLERANT)) intol++;