mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-06 00:10:04 +01:00
Introduce SUBDEV internal device type.
LUKS2 and other device types allow stacking of dm devices underneath public top level device. The new type identifies clearly those private devices in respective device stack so that they can be easily removed while removing top level public device. Switch LUKS2 reencryption device stack to use SUBDEV type immmediately for hotzone and overlay devices. Other devices will follow in later releases.
This commit is contained in:
committed by
Milan Broz
parent
af62dbf3d3
commit
614f671b92
@@ -56,6 +56,8 @@
|
||||
#define LOG_MAX_LEN 4096
|
||||
#define MAX_DM_DEPS 32
|
||||
|
||||
#define CRYPT_SUBDEV "SUBDEV" /* prefix for sublayered devices underneath public crypt types */
|
||||
|
||||
#define at_least(a, b) ({ __typeof__(a) __at_least = (a); (__at_least >= (b))?__at_least:(b); })
|
||||
|
||||
#define MISALIGNED(a, b) ((a) & ((b) - 1))
|
||||
|
||||
@@ -2209,20 +2209,20 @@ int LUKS2_deactivate(struct crypt_device *cd, const char *name, struct luks2_hdr
|
||||
struct dm_target *tgt;
|
||||
crypt_status_info ci;
|
||||
struct crypt_dm_active_device dmdc;
|
||||
char **dep, uuid[37], deps_uuid_prefix[38], *deps[MAX_DM_DEPS+1] = { 0 };
|
||||
char **dep, uuid[37], deps_uuid_prefix[40], *deps[MAX_DM_DEPS+1] = { 0 };
|
||||
const char *namei = NULL;
|
||||
struct crypt_lock_handle *reencrypt_lock = NULL;
|
||||
|
||||
if (!dmd || !dmd->uuid)
|
||||
return -EINVAL;
|
||||
|
||||
r = snprintf(deps_uuid_prefix, sizeof(deps_uuid_prefix), "TEMP-%.32s", dmd->uuid + 6);
|
||||
if (r < 0 || (size_t)r != 37)
|
||||
r = snprintf(deps_uuid_prefix, sizeof(deps_uuid_prefix), CRYPT_SUBDEV "-%.32s", dmd->uuid + 6);
|
||||
if (r < 0 || (size_t)r != (sizeof(deps_uuid_prefix) - 1))
|
||||
return -EINVAL;
|
||||
|
||||
r = snprintf(uuid, sizeof(uuid), "%.8s-%.4s-%.4s-%.4s-%.12s",
|
||||
dmd->uuid + 6, dmd->uuid + 14, dmd->uuid + 18, dmd->uuid + 22, dmd->uuid + 26);
|
||||
if (r < 0 || (size_t)r != 36)
|
||||
if (r < 0 || (size_t)r != (sizeof(uuid) - 1))
|
||||
return -EINVAL;
|
||||
|
||||
/* uuid mismatch with metadata (if available) */
|
||||
|
||||
@@ -1877,7 +1877,7 @@ static int reenc_replace_device(struct crypt_device *cd, const char *target, con
|
||||
r = dm_resume_device(cd, target, dmflags | act2dmflags(dmd_source.flags));
|
||||
}
|
||||
} else
|
||||
r = dm_create_device(cd, target, "TEMP", &dmd_source);
|
||||
r = dm_create_device(cd, target, CRYPT_SUBDEV, &dmd_source);
|
||||
err:
|
||||
dm_targets_free(cd, &dmd_source);
|
||||
dm_targets_free(cd, &dmd_target);
|
||||
@@ -1954,7 +1954,7 @@ static int reenc_activate_hotzone_device(struct crypt_device *cd, const char *na
|
||||
if (r)
|
||||
goto err;
|
||||
|
||||
r = dm_create_device(cd, name, "TEMP", &dmd);
|
||||
r = dm_create_device(cd, name, CRYPT_SUBDEV, &dmd);
|
||||
err:
|
||||
dm_targets_free(cd, &dmd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user