Add suport for filtering only LUKS signatures.

This commit is contained in:
Ondrej Kozina
2022-04-07 16:22:56 +02:00
committed by Milan Broz
parent 8c350b65a3
commit 412de7dc25
2 changed files with 24 additions and 4 deletions

View File

@@ -19,6 +19,7 @@
*/
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -135,16 +136,34 @@ int blk_init_by_fd(struct blkid_handle **h, int fd)
return r;
}
int blk_superblocks_filter_luks(struct blkid_handle *h)
{
int r = -ENOTSUP;
#ifdef HAVE_BLKID
static int blk_superblocks_luks(struct blkid_handle *h, bool enable)
{
char luks[] = "crypto_LUKS";
char *luks_filter[] = {
luks,
NULL
};
r = blkid_probe_filter_superblocks_type(h->pr, BLKID_FLTR_NOTIN, luks_filter);
return blkid_probe_filter_superblocks_type(h->pr,
enable ? BLKID_FLTR_ONLYIN : BLKID_FLTR_NOTIN,
luks_filter);
}
#endif
int blk_superblocks_filter_luks(struct blkid_handle *h)
{
int r = -ENOTSUP;
#ifdef HAVE_BLKID
r = blk_superblocks_luks(h, false);
#endif
return r;
}
int blk_superblocks_only_luks(struct blkid_handle *h)
{
int r = -ENOTSUP;
#ifdef HAVE_BLKID
r = blk_superblocks_luks(h, true);
#endif
return r;
}

View File

@@ -44,6 +44,7 @@ void blk_set_chains_for_full_print(struct blkid_handle *h);
void blk_set_chains_for_fast_detection(struct blkid_handle *h);
int blk_superblocks_filter_luks(struct blkid_handle *h);
int blk_superblocks_only_luks(struct blkid_handle *h);
blk_probe_status blk_safeprobe(struct blkid_handle *h);