mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-15 12:50:06 +01:00
Support --device-size option for plain devices.
This commit is contained in:
committed by
Milan Broz
parent
bef46c950d
commit
452467661e
@@ -220,8 +220,8 @@ Opens (creates a mapping with) <name> backed by device <device>.
|
||||
|
||||
\fB<options>\fR can be [\-\-hash, \-\-cipher, \-\-verify-passphrase,
|
||||
\-\-sector\-size, \-\-key-file, \-\-keyfile-offset, \-\-key-size,
|
||||
\-\-offset, \-\-skip, \-\-size, \-\-readonly, \-\-shared, \-\-allow\-discards,
|
||||
\-\-refresh]
|
||||
\-\-offset, \-\-skip, \-\-device\-size, \-\-size, \-\-readonly,
|
||||
\-\-shared, \-\-allow\-discards, \-\-refresh]
|
||||
|
||||
Example: 'cryptsetup open \-\-type plain /dev/sda10 e1' maps the raw
|
||||
encrypted device /dev/sda10 to the mapped (decrypted) device
|
||||
|
||||
@@ -145,7 +145,6 @@ static int action_open_plain(void)
|
||||
.hash = ARG_SET(OPT_HASH_ID) ? ARG_STR(OPT_HASH_ID) : DEFAULT_PLAIN_HASH,
|
||||
.skip = ARG_UINT64(OPT_SKIP_ID),
|
||||
.offset = ARG_UINT64(OPT_OFFSET_ID),
|
||||
.size = ARG_UINT64(OPT_SIZE_ID),
|
||||
.sector_size = ARG_UINT32(OPT_SECTOR_SIZE_ID) ?: SECTOR_SIZE
|
||||
};
|
||||
char *password = NULL;
|
||||
@@ -230,6 +229,11 @@ static int action_open_plain(void)
|
||||
pmode = cipher_mode;
|
||||
}
|
||||
|
||||
if (ARG_SET(OPT_DEVICE_SIZE_ID))
|
||||
params.size = ARG_UINT64(OPT_DEVICE_SIZE_ID) / SECTOR_SIZE;
|
||||
else if (ARG_SET(OPT_SIZE_ID))
|
||||
params.size = ARG_UINT64(OPT_SIZE_ID);
|
||||
|
||||
r = crypt_format(cd, CRYPT_PLAIN,
|
||||
pcipher, pmode,
|
||||
NULL, NULL,
|
||||
@@ -2738,6 +2742,9 @@ static const char * verify_open(void)
|
||||
(strncmp(device_type, "luks", 4) && strcmp(device_type, "tcrypt") && strcmp(device_type, "bitlk"))))
|
||||
return _("Option --test-passphrase is allowed only for open of LUKS, TCRYPT and BITLK devices.");
|
||||
|
||||
if (ARG_SET(OPT_DEVICE_SIZE_ID) && ARG_SET(OPT_SIZE_ID))
|
||||
return _("Options --device-size and --size cannot be combined.");
|
||||
|
||||
/* "open --type tcrypt" and "tcryptDump" checks are identical */
|
||||
return verify_tcryptdump();
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
#define OPT_ALIGN_PAYLOAD_ACTIONS { FORMAT_ACTION, REENCRYPT_ACTION }
|
||||
#define OPT_ALLOW_DISCARDS_ACTIONS { OPEN_ACTION }
|
||||
#define OPT_DEFERRED_ACTIONS { CLOSE_ACTION }
|
||||
#define OPT_DEVICE_SIZE_ACTIONS { RESIZE_ACTION, REENCRYPT_ACTION }
|
||||
#define OPT_DEVICE_SIZE_ACTIONS { OPEN_ACTION, RESIZE_ACTION, REENCRYPT_ACTION }
|
||||
#define OPT_DISABLE_VERACRYPT_ACTIONS { OPEN_ACTION, TCRYPTDUMP_ACTION }
|
||||
#define OPT_HOTZONE_SIZE_ACTIONS { REENCRYPT_ACTION }
|
||||
#define OPT_INTEGRITY_ACTIONS { FORMAT_ACTION, REENCRYPT_ACTION }
|
||||
|
||||
@@ -277,7 +277,8 @@ exp_fail reencrypt DEV --reduce-device-size 64m --device-size 100g
|
||||
# exp_fail open DEV --encrypt
|
||||
# exp_fail open DEV NAME --device-size 32m
|
||||
# exp_fail open DEV NAME --size 100
|
||||
exp_fail open DEV NAME --device-size 32m --type plain
|
||||
exp_pass open DEV NAME --device-size 32m --type plain
|
||||
exp_fail open DEV NAME --device-size $((32*1024*1024+1)) --type plain
|
||||
exp_pass open DEV NAME --size 100 --type plain
|
||||
exp_fail open DEV NAME --size 100 --device-size $((512*100)) --type plain
|
||||
exp_fail reencrypt DEV --device-size $((32*1024*1024+1))
|
||||
|
||||
Reference in New Issue
Block a user