mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-13 03:40:05 +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,
|
||||
uint32_t flags)
|
||||
{
|
||||
int r;
|
||||
enum devcheck device_check;
|
||||
struct crypt_dm_active_device dmd = {
|
||||
.target = DM_CRYPT,
|
||||
.uuid = crypt_get_uuid(cd),
|
||||
@@ -1173,19 +1171,7 @@ int LUKS1_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;
|
||||
|
||||
r = create_or_reload_device(cd, name, CRYPT_LUKS1, &dmd);
|
||||
|
||||
return r;
|
||||
return create_or_reload_device(cd, name, CRYPT_LUKS1, &dmd);
|
||||
}
|
||||
|
||||
int LUKS_wipe_header_areas(struct luks_phdr *hdr,
|
||||
|
||||
@@ -1860,7 +1860,6 @@ int LUKS2_activate(struct crypt_device *cd,
|
||||
uint32_t flags)
|
||||
{
|
||||
int r;
|
||||
enum devcheck device_check;
|
||||
struct luks2_hdr *hdr = crypt_get_hdr(cd, CRYPT_LUKS2);
|
||||
struct crypt_dm_active_device dmdi, dmd = {
|
||||
.target = DM_CRYPT,
|
||||
@@ -1888,11 +1887,6 @@ int LUKS2_activate(struct crypt_device *cd,
|
||||
|
||||
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 (!LUKS2_integrity_compatible(hdr)) {
|
||||
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);
|
||||
}
|
||||
|
||||
/* TODO: move down to create_or_reload */
|
||||
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);
|
||||
return 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)
|
||||
|
||||
16
lib/setup.c
16
lib/setup.c
@@ -483,8 +483,6 @@ int PLAIN_activate(struct crypt_device *cd,
|
||||
uint64_t size,
|
||||
uint32_t flags)
|
||||
{
|
||||
int r;
|
||||
enum devcheck device_check;
|
||||
struct crypt_dm_active_device dmd = {
|
||||
.target = DM_CRYPT,
|
||||
.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.",
|
||||
name, dmd.u.crypt.cipher);
|
||||
|
||||
r = create_or_reload_device(cd, name, CRYPT_PLAIN, &dmd);
|
||||
|
||||
return r;
|
||||
return create_or_reload_device(cd, name, CRYPT_PLAIN, &dmd);
|
||||
}
|
||||
|
||||
int crypt_confirm(struct crypt_device *cd, const char *msg)
|
||||
|
||||
Reference in New Issue
Block a user