static int _compare_device_types(struct crypt_device *cd,
			       const struct crypt_dm_active_device *src,
			       const struct crypt_dm_active_device *tgt)
{
	if (!tgt->uuid) {
		log_dbg(cd, "Missing device uuid in target device.");
		return -EINVAL;
	}

	if (isLUKS2(cd->type) && !strncmp("INTEGRITY-", tgt->uuid, strlen("INTEGRITY-"))) {
		if (crypt_uuid_cmp(tgt->uuid, src->uuid)) {
			log_dbg(cd, "LUKS UUID mismatch.");
			return -EINVAL;
		}
	} else if (isLUKS(cd->type)) {
		if (!src->uuid || strncmp(cd->type, tgt->uuid, strlen(cd->type)) ||
		    crypt_uuid_cmp(tgt->uuid, src->uuid)) {
			log_dbg(cd, "LUKS UUID mismatch.");
			return -EINVAL;
		}
	} else if (isPLAIN(cd->type) || isLOOPAES(cd->type)) {
		if (strncmp(cd->type, tgt->uuid, strlen(cd->type))) {
			log_dbg(cd, "Unexpected uuid prefix %s in target device.", tgt->uuid);
			return -EINVAL;
		}
	} else {
		log_dbg(cd, "Unsupported device type %s for reload.", cd->type ?: "<empty>");
		return -ENOTSUP;
	}

	return 0;
}
static int _compare_device_types(struct crypt_device *cd,
			       const struct crypt_dm_active_device *src,
			       const struct crypt_dm_active_device *tgt)
{
	if (!tgt->uuid) {
		log_dbg(cd, "Missing device uuid in target device.");
		return -EINVAL;
	}

	if (isLUKS2(cd->type) && !strncmp("INTEGRITY-", tgt->uuid, strlen("INTEGRITY-"))) {
		if (crypt_uuid_cmp(tgt->uuid, src->uuid)) {
			log_dbg(cd, "LUKS UUID mismatch.");
			return -EINVAL;
		}
	} else if (isLUKS(cd->type)) {
		if (!src->uuid || strncmp(cd->type, tgt->uuid, strlen(cd->type)) ||
		    crypt_uuid_cmp(tgt->uuid, src->uuid)) {
			log_dbg(cd, "LUKS UUID mismatch.");
			return -EINVAL;
		}
	} else if (isPLAIN(cd->type) || isLOOPAES(cd->type)) {
		if (strncmp(cd->type, tgt->uuid, strlen(cd->type))) {
			log_dbg(cd, "Unexpected uuid prefix %s in target device.", tgt->uuid);
			return -EINVAL;
		}
	} else {
		log_dbg(cd, "Unsupported device type %s for reload.", cd->type ?: "<empty>");
		return -ENOTSUP;
	}

	return 0;
}