static int _init_by_name_verity(struct crypt_device *cd, const char *name)
{
	struct crypt_dm_active_device dmd;
	struct dm_target *tgt = &dmd.segment;
	int r;

	r = dm_query_device(cd, name,
				DM_ACTIVE_DEVICE |
				DM_ACTIVE_VERITY_HASH_DEVICE |
				DM_ACTIVE_VERITY_ROOT_HASH |
				DM_ACTIVE_VERITY_PARAMS, &dmd);
	if (r < 0)
		return r;
	if (!single_segment(&dmd) || tgt->type != DM_VERITY) {
		log_dbg(cd, "Unsupported device table detected in %s.", name);
		r = -EINVAL;
		goto out;
	}
	if (r > 0)
		r = 0;

	if (isVERITY(cd->type)) {
		cd->u.verity.uuid = NULL; // FIXME
		cd->u.verity.hdr.flags = CRYPT_VERITY_NO_HEADER; //FIXME
		cd->u.verity.hdr.data_size = tgt->u.verity.vp->data_size;
		cd->u.verity.root_hash_size = tgt->u.verity.root_hash_size;
		MOVE_REF(cd->u.verity.hdr.hash_name, tgt->u.verity.vp->hash_name);
		cd->u.verity.hdr.data_device = NULL;
		cd->u.verity.hdr.hash_device = NULL;
		cd->u.verity.hdr.data_block_size = tgt->u.verity.vp->data_block_size;
		cd->u.verity.hdr.hash_block_size = tgt->u.verity.vp->hash_block_size;
		cd->u.verity.hdr.hash_area_offset = tgt->u.verity.hash_offset;
		cd->u.verity.hdr.fec_area_offset = tgt->u.verity.fec_offset;
		cd->u.verity.hdr.hash_type = tgt->u.verity.vp->hash_type;
		cd->u.verity.hdr.flags = tgt->u.verity.vp->flags;
		cd->u.verity.hdr.salt_size = tgt->u.verity.vp->salt_size;
		MOVE_REF(cd->u.verity.hdr.salt, tgt->u.verity.vp->salt);
		MOVE_REF(cd->u.verity.hdr.fec_device, tgt->u.verity.vp->fec_device);
		cd->u.verity.hdr.fec_roots = tgt->u.verity.vp->fec_roots;
		MOVE_REF(cd->u.verity.fec_device, tgt->u.verity.fec_device);
		MOVE_REF(cd->metadata_device, tgt->u.verity.hash_device);
		MOVE_REF(cd->u.verity.root_hash, tgt->u.verity.root_hash);
	}
out:
	dm_targets_free(cd, &dmd);
	return r;
}
static int _init_by_name_verity(struct crypt_device *cd, const char *name)
{
	struct crypt_dm_active_device dmd;
	struct dm_target *tgt = &dmd.segment;
	int r;

	r = dm_query_device(cd, name,
				DM_ACTIVE_DEVICE |
				DM_ACTIVE_VERITY_HASH_DEVICE |
				DM_ACTIVE_VERITY_ROOT_HASH |
				DM_ACTIVE_VERITY_PARAMS, &dmd);
	if (r < 0)
		return r;
	if (!single_segment(&dmd) || tgt->type != DM_VERITY) {
		log_dbg(cd, "Unsupported device table detected in %s.", name);
		r = -EINVAL;
		goto out;
	}
	if (r > 0)
		r = 0;

	if (isVERITY(cd->type)) {
		cd->u.verity.uuid = NULL;  
		cd->u.verity.hdr.flags = CRYPT_VERITY_NO_HEADER;  
		cd->u.verity.hdr.data_size = tgt->u.verity.vp->data_size;
		cd->u.verity.root_hash_size = tgt->u.verity.root_hash_size;
		MOVE_REF(cd->u.verity.hdr.hash_name, tgt->u.verity.vp->hash_name);
		cd->u.verity.hdr.data_device = NULL;
		cd->u.verity.hdr.hash_device = NULL;
		cd->u.verity.hdr.data_block_size = tgt->u.verity.vp->data_block_size;
		cd->u.verity.hdr.hash_block_size = tgt->u.verity.vp->hash_block_size;
		cd->u.verity.hdr.hash_area_offset = tgt->u.verity.hash_offset;
		cd->u.verity.hdr.fec_area_offset = tgt->u.verity.fec_offset;
		cd->u.verity.hdr.hash_type = tgt->u.verity.vp->hash_type;
		cd->u.verity.hdr.flags = tgt->u.verity.vp->flags;
		cd->u.verity.hdr.salt_size = tgt->u.verity.vp->salt_size;
		MOVE_REF(cd->u.verity.hdr.salt, tgt->u.verity.vp->salt);
		MOVE_REF(cd->u.verity.hdr.fec_device, tgt->u.verity.vp->fec_device);
		cd->u.verity.hdr.fec_roots = tgt->u.verity.vp->fec_roots;
		MOVE_REF(cd->u.verity.fec_device, tgt->u.verity.fec_device);
		MOVE_REF(cd->metadata_device, tgt->u.verity.hash_device);
		MOVE_REF(cd->u.verity.root_hash, tgt->u.verity.root_hash);
	}
out:
	dm_targets_free(cd, &dmd);
	return r;
}