mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-13 20:00:08 +01:00
Move device_block_adjust() check lower in code.
This commit is contained in:
committed by
Milan Broz
parent
675cf7ef59
commit
5c0ad86f19
@@ -1156,8 +1156,6 @@ int LUKS1_activate(struct crypt_device *cd,
|
|||||||
struct volume_key *vk,
|
struct volume_key *vk,
|
||||||
uint32_t flags)
|
uint32_t flags)
|
||||||
{
|
{
|
||||||
int r;
|
|
||||||
enum devcheck device_check;
|
|
||||||
struct crypt_dm_active_device dmd = {
|
struct crypt_dm_active_device dmd = {
|
||||||
.target = DM_CRYPT,
|
.target = DM_CRYPT,
|
||||||
.uuid = crypt_get_uuid(cd),
|
.uuid = crypt_get_uuid(cd),
|
||||||
@@ -1173,19 +1171,7 @@ int LUKS1_activate(struct crypt_device *cd,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (dmd.flags & CRYPT_ACTIVATE_SHARED)
|
return create_or_reload_device(cd, name, CRYPT_LUKS1, &dmd);
|
||||||
device_check = DEV_SHARED;
|
|
||||||
else
|
|
||||||
device_check = DEV_EXCL;
|
|
||||||
|
|
||||||
r = device_block_adjust(cd, dmd.data_device, device_check,
|
|
||||||
dmd.u.crypt.offset, &dmd.size, &dmd.flags);
|
|
||||||
if (r)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
r = create_or_reload_device(cd, name, CRYPT_LUKS1, &dmd);
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LUKS_wipe_header_areas(struct luks_phdr *hdr,
|
int LUKS_wipe_header_areas(struct luks_phdr *hdr,
|
||||||
|
|||||||
@@ -1860,7 +1860,6 @@ int LUKS2_activate(struct crypt_device *cd,
|
|||||||
uint32_t flags)
|
uint32_t flags)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
enum devcheck device_check;
|
|
||||||
struct luks2_hdr *hdr = crypt_get_hdr(cd, CRYPT_LUKS2);
|
struct luks2_hdr *hdr = crypt_get_hdr(cd, CRYPT_LUKS2);
|
||||||
struct crypt_dm_active_device dmdi, dmd = {
|
struct crypt_dm_active_device dmdi, dmd = {
|
||||||
.target = DM_CRYPT,
|
.target = DM_CRYPT,
|
||||||
@@ -1888,11 +1887,6 @@ int LUKS2_activate(struct crypt_device *cd,
|
|||||||
|
|
||||||
dmd.flags |= flags;
|
dmd.flags |= flags;
|
||||||
|
|
||||||
if (dmd.flags & CRYPT_ACTIVATE_SHARED)
|
|
||||||
device_check = DEV_SHARED;
|
|
||||||
else
|
|
||||||
device_check = DEV_EXCL;
|
|
||||||
|
|
||||||
if (dmd.u.crypt.tag_size) {
|
if (dmd.u.crypt.tag_size) {
|
||||||
if (!LUKS2_integrity_compatible(hdr)) {
|
if (!LUKS2_integrity_compatible(hdr)) {
|
||||||
log_err(cd, "Unsupported device integrity configuration.");
|
log_err(cd, "Unsupported device integrity configuration.");
|
||||||
@@ -1913,11 +1907,7 @@ int LUKS2_activate(struct crypt_device *cd,
|
|||||||
return create_or_reload_device_with_integrity(cd, name, CRYPT_LUKS2, &dmd, &dmdi);
|
return create_or_reload_device_with_integrity(cd, name, CRYPT_LUKS2, &dmd, &dmdi);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: move down to create_or_reload */
|
return create_or_reload_device(cd, name, CRYPT_LUKS2, &dmd);
|
||||||
r = device_block_adjust(cd, dmd.data_device, device_check,
|
|
||||||
dmd.u.crypt.offset, &dmd.size, &dmd.flags);
|
|
||||||
|
|
||||||
return r ?: create_or_reload_device(cd, name, CRYPT_LUKS2, &dmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LUKS2_unmet_requirements(struct crypt_device *cd, struct luks2_hdr *hdr, uint32_t reqs_mask, int quiet)
|
int LUKS2_unmet_requirements(struct crypt_device *cd, struct luks2_hdr *hdr, uint32_t reqs_mask, int quiet)
|
||||||
|
|||||||
16
lib/setup.c
16
lib/setup.c
@@ -483,8 +483,6 @@ int PLAIN_activate(struct crypt_device *cd,
|
|||||||
uint64_t size,
|
uint64_t size,
|
||||||
uint32_t flags)
|
uint32_t flags)
|
||||||
{
|
{
|
||||||
int r;
|
|
||||||
enum devcheck device_check;
|
|
||||||
struct crypt_dm_active_device dmd = {
|
struct crypt_dm_active_device dmd = {
|
||||||
.target = DM_CRYPT,
|
.target = DM_CRYPT,
|
||||||
.size = size,
|
.size = size,
|
||||||
@@ -499,22 +497,10 @@ int PLAIN_activate(struct crypt_device *cd,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (dmd.flags & CRYPT_ACTIVATE_SHARED)
|
|
||||||
device_check = DEV_SHARED;
|
|
||||||
else
|
|
||||||
device_check = DEV_EXCL;
|
|
||||||
|
|
||||||
r = device_block_adjust(cd, dmd.data_device, device_check,
|
|
||||||
dmd.u.crypt.offset, &dmd.size, &dmd.flags);
|
|
||||||
if (r)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
log_dbg(cd, "Trying to activate PLAIN device %s using cipher %s.",
|
log_dbg(cd, "Trying to activate PLAIN device %s using cipher %s.",
|
||||||
name, dmd.u.crypt.cipher);
|
name, dmd.u.crypt.cipher);
|
||||||
|
|
||||||
r = create_or_reload_device(cd, name, CRYPT_PLAIN, &dmd);
|
return create_or_reload_device(cd, name, CRYPT_PLAIN, &dmd);
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int crypt_confirm(struct crypt_device *cd, const char *msg)
|
int crypt_confirm(struct crypt_device *cd, const char *msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user