mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-18 22:30:07 +01:00
Allow --reduce-device-size and --device-size in encrypt action.
Fixes: #822
This commit is contained in:
@@ -680,13 +680,15 @@ static int encrypt_luks2_init(struct crypt_device **cd, const char *data_device,
|
||||
}
|
||||
}
|
||||
|
||||
/* The --reduce-device-size has to be at least twice the size of first moved segment (LUKS2
|
||||
* data offset) */
|
||||
if (!ARG_SET(OPT_HEADER_ID) && ARG_UINT64(OPT_OFFSET_ID) &&
|
||||
data_shift && (ARG_UINT64(OPT_OFFSET_ID) > (uint64_t)(imaxabs(data_shift) / (2 * SECTOR_SIZE)))) {
|
||||
log_err(_("Requested data offset must be less than or equal to half of --reduce-device-size parameter."));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* TODO: ask user to confirm. It's useless to do data device reduction and than use smaller value */
|
||||
/* It's useless to do data device reduction and than use smaller value */
|
||||
if (!ARG_SET(OPT_HEADER_ID) && ARG_UINT64(OPT_OFFSET_ID) &&
|
||||
data_shift && (ARG_UINT64(OPT_OFFSET_ID) < (uint64_t)(imaxabs(data_shift) / (2 * SECTOR_SIZE)))) {
|
||||
data_shift = -(ARG_UINT64(OPT_OFFSET_ID) * 2 * SECTOR_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user