mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-13 20:00:08 +01:00
Minor code cleanup.
This commit is contained in:
committed by
Milan Broz
parent
f18cd7ae81
commit
3e7dedaf99
@@ -970,13 +970,16 @@ int LUKS2_hdr_read(struct crypt_device *cd, struct luks2_hdr *hdr, int repair)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LUKS2_hdr_write_force(struct crypt_device *cd, struct luks2_hdr *hdr)
|
static int hdr_cleanup_and_validate(struct crypt_device *cd, struct luks2_hdr *hdr)
|
||||||
{
|
{
|
||||||
/* NOTE: is called before LUKS2 validation routines */
|
|
||||||
/* erase unused digests (no assigned keyslot or segment) */
|
|
||||||
LUKS2_digests_erase_unused(cd, hdr);
|
LUKS2_digests_erase_unused(cd, hdr);
|
||||||
|
|
||||||
if (LUKS2_hdr_validate(cd, hdr->jobj, hdr->hdr_size - LUKS2_HDR_BIN_LEN))
|
return LUKS2_hdr_validate(cd, hdr->jobj, hdr->hdr_size - LUKS2_HDR_BIN_LEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
int LUKS2_hdr_write_force(struct crypt_device *cd, struct luks2_hdr *hdr)
|
||||||
|
{
|
||||||
|
if (hdr_cleanup_and_validate(cd, hdr))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
return LUKS2_disk_hdr_write(cd, hdr, crypt_metadata_device(cd), false);
|
return LUKS2_disk_hdr_write(cd, hdr, crypt_metadata_device(cd), false);
|
||||||
@@ -984,11 +987,7 @@ int LUKS2_hdr_write_force(struct crypt_device *cd, struct luks2_hdr *hdr)
|
|||||||
|
|
||||||
int LUKS2_hdr_write(struct crypt_device *cd, struct luks2_hdr *hdr)
|
int LUKS2_hdr_write(struct crypt_device *cd, struct luks2_hdr *hdr)
|
||||||
{
|
{
|
||||||
/* NOTE: is called before LUKS2 validation routines */
|
if (hdr_cleanup_and_validate(cd, hdr))
|
||||||
/* erase unused digests (no assigned keyslot or segment) */
|
|
||||||
LUKS2_digests_erase_unused(cd, hdr);
|
|
||||||
|
|
||||||
if (LUKS2_hdr_validate(cd, hdr->jobj, hdr->hdr_size - LUKS2_HDR_BIN_LEN))
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
return LUKS2_disk_hdr_write(cd, hdr, crypt_metadata_device(cd), true);
|
return LUKS2_disk_hdr_write(cd, hdr, crypt_metadata_device(cd), true);
|
||||||
|
|||||||
Reference in New Issue
Block a user