Rework detection of DM target flags.

Because there are already 3 targets used, the current detection
based only on dm-crypt is not sufficient.

Add new definition of dm_flags that allows separate target version detect.

Note: we do not want to load targets explicitly; instead, we repeats
detection after operation that could trigger target load.

If dm_flags() call fails, then the target is not yet loaded.
This commit is contained in:
Milan Broz
2017-06-01 09:15:05 +02:00
parent 82f7cae22c
commit 40a9178c7f
5 changed files with 169 additions and 108 deletions

View File

@@ -241,6 +241,7 @@ int VERITY_activate(struct crypt_device *cd,
uint32_t activation_flags)
{
struct crypt_dm_active_device dmd;
uint32_t dmv_flags;
int r;
log_dbg("Trying to activate VERITY device %s using hash %s.",
@@ -289,7 +290,7 @@ int VERITY_activate(struct crypt_device *cd,
}
r = dm_create_device(cd, name, CRYPT_VERITY, &dmd, 0);
if (r < 0 && !(dm_flags() & DM_VERITY_SUPPORTED)) {
if (r < 0 && !dm_flags(DM_VERITY, &dmv_flags) && !(dmv_flags & DM_VERITY_SUPPORTED)) {
log_err(cd, _("Kernel doesn't support dm-verity mapping.\n"));
return -ENOTSUP;
}