int create_or_reload_device_with_integrity(struct crypt_device *cd, const char *name,
		     const char *type, struct crypt_dm_active_device *dmd,
		     struct crypt_dm_active_device *dmdi)
{
	int r;
	const char *iname = NULL;
	char *ipath = NULL;

	if (!type || !name || !dmd || !dmdi)
		return -EINVAL;

	if (asprintf(&ipath, "%s/%s_dif", dm_get_dir(), name) < 0)
		return -ENOMEM;
	iname = ipath + strlen(dm_get_dir()) + 1;

	/* drop CRYPT_ACTIVATE_REFRESH flag if any device is inactive */
	r = check_devices(cd, name, iname, &dmd->flags);
	if (r)
		goto out;

	if (dmd->flags & CRYPT_ACTIVATE_REFRESH)
		r = _reload_device_with_integrity(cd, name, iname, ipath, dmd, dmdi);
	else
		r = _create_device_with_integrity(cd, type, name, iname, ipath, dmd, dmdi);
out:
	free(ipath);

	return r;
}
int create_or_reload_device_with_integrity(struct crypt_device *cd, const char *name,
		     const char *type, struct crypt_dm_active_device *dmd,
		     struct crypt_dm_active_device *dmdi)
{
	int r;
	const char *iname = NULL;
	char *ipath = NULL;

	if (!type || !name || !dmd || !dmdi)
		return -EINVAL;

	if (asprintf(&ipath, "%s/%s_dif", dm_get_dir(), name) < 0)
		return -ENOMEM;
	iname = ipath + strlen(dm_get_dir()) + 1;

	 
	r = check_devices(cd, name, iname, &dmd->flags);
	if (r)
		goto out;

	if (dmd->flags & CRYPT_ACTIVATE_REFRESH)
		r = _reload_device_with_integrity(cd, name, iname, ipath, dmd, dmdi);
	else
		r = _create_device_with_integrity(cd, type, name, iname, ipath, dmd, dmdi);
out:
	free(ipath);

	return r;
}