Mark all sizes in status and dump output in the correct units.

NOTE: This is possibly an incompatible change as it changes text output.

Since the support of --sector-size option, the description "sectors"
became ambiguous as it usually means 512-byte sectors (device-mapper unit).

Major confusion occurs when the sector size is 4096 bytes while units display
is in 512-bytes.

Unfortunately, there is no clear compatible way, so this patch adds
[512-byte units] marker and also additional byte size value.

All other fields that display units are changed to use the "[units]" format.

The integrity format is also unified with the common style with ':' as a separator.

Fixes: #884.
This commit is contained in:
Milan Broz
2024-12-02 16:11:43 +01:00
parent ea39aecba3
commit f8788f347e
11 changed files with 82 additions and 75 deletions

View File

@@ -742,7 +742,7 @@ int BITLK_dump(struct crypt_device *cd, struct device *device, struct bitlk_meta
log_std(cd, "Description: \t%s\n", params->description);
log_std(cd, "Cipher name: \t%s\n", params->cipher);
log_std(cd, "Cipher mode: \t%s\n", params->cipher_mode);
log_std(cd, "Cipher key: \t%u bits\n", params->key_size);
log_std(cd, "Cipher key: \t%u [bits]\n", params->key_size);
log_std(cd, "\n");

View File

@@ -83,23 +83,26 @@ int INTEGRITY_read_sb(struct crypt_device *cd,
int INTEGRITY_dump(struct crypt_device *cd, struct device *device, uint64_t offset)
{
struct superblock sb;
uint64_t sector_size;
int r;
r = INTEGRITY_read_superblock(cd, device, offset, &sb);
if (r)
return r;
log_std(cd, "Info for integrity device %s.\n", device_path(device));
log_std(cd, "superblock_version %d\n", (unsigned)sb.version);
log_std(cd, "log2_interleave_sectors %d\n", sb.log2_interleave_sectors);
log_std(cd, "integrity_tag_size %u\n", sb.integrity_tag_size);
log_std(cd, "journal_sections %u\n", sb.journal_sections);
log_std(cd, "provided_data_sectors %" PRIu64 "\n", sb.provided_data_sectors);
log_std(cd, "sector_size %u\n", SECTOR_SIZE << sb.log2_sectors_per_block);
sector_size = SECTOR_SIZE << sb.log2_sectors_per_block;
log_std(cd, "INTEGRITY header information for %s.\n", device_path(device));
log_std(cd, "version: %d\n", (unsigned)sb.version);
log_std(cd, "tag size: %u [bytes]\n", sb.integrity_tag_size);
log_std(cd, "sector size: %" PRIu64 " [bytes]\n", sector_size);
log_std(cd, "data size: %" PRIu64 " [512-byte units] (%" PRIu64 " [bytes])\n",
sb.provided_data_sectors, sb.provided_data_sectors * SECTOR_SIZE);
if (sb.version >= SB_VERSION_2 && (sb.flags & SB_FLAG_RECALCULATING))
log_std(cd, "recalc_sector %" PRIu64 "\n", sb.recalc_sector);
log_std(cd, "log2_blocks_per_bitmap %u\n", sb.log2_blocks_per_bitmap_bit);
log_std(cd, "flags %s%s%s%s%s\n",
log_std(cd, "recalculate sector: %" PRIu64 "\n", sb.recalc_sector);
log_std(cd, "journal sections: %u\n", sb.journal_sections);
log_std(cd, "log2 interleave sectors: %d\n", sb.log2_interleave_sectors);
log_std(cd, "log2 blocks per bitmap: %u\n", sb.log2_blocks_per_bitmap_bit);
log_std(cd, "flags: %s%s%s%s%s\n",
sb.flags & SB_FLAG_HAVE_JOURNAL_MAC ? "have_journal_mac " : "",
sb.flags & SB_FLAG_RECALCULATING ? "recalculating " : "",
sb.flags & SB_FLAG_DIRTY_BITMAP ? "dirty_bitmap " : "",

View File

@@ -411,13 +411,13 @@ int VERITY_dump(struct crypt_device *cd,
verity_blocks += rs_blocks;
}
log_std(cd, "VERITY header information for %s\n", device_path(crypt_metadata_device(cd)));
log_std(cd, "VERITY header information for %s.\n", device_path(crypt_metadata_device(cd)));
log_std(cd, "UUID: \t%s\n", crypt_get_uuid(cd) ?: "");
log_std(cd, "Hash type: \t%u\n", verity_hdr->hash_type);
log_std(cd, "Data blocks: \t%" PRIu64 "\n", verity_hdr->data_size);
log_std(cd, "Data block size: \t%u\n", verity_hdr->data_block_size);
log_std(cd, "Data block size: \t%u [bytes]\n", verity_hdr->data_block_size);
log_std(cd, "Hash blocks: \t%" PRIu64 "\n", hash_blocks);
log_std(cd, "Hash block size: \t%u\n", verity_hdr->hash_block_size);
log_std(cd, "Hash block size: \t%u [bytes]\n", verity_hdr->hash_block_size);
log_std(cd, "Hash algorithm: \t%s\n", verity_hdr->hash_name);
if (fec_device && fec_blocks) {
log_std(cd, "FEC RS roots: \t%" PRIu32 "\n", verity_hdr->fec_roots);

View File

@@ -1016,6 +1016,7 @@ static int action_status(void)
char *backing_file;
const char *device;
int path = 0, r = 0, hw_enc;
uint64_t sector_size;
/* perhaps a path, not a dm device name */
if (strchr(action_argv[0], '/'))
@@ -1072,36 +1073,37 @@ static int action_status(void)
if (hw_enc == CRYPT_SW_ONLY) {
log_std(" cipher: %s-%s\n", crypt_get_cipher(cd), crypt_get_cipher_mode(cd));
log_std(" keysize: %d bits\n", crypt_get_volume_key_size(cd) * 8);
log_std(" keysize: %d [bits]\n", crypt_get_volume_key_size(cd) * 8);
log_std(" key location: %s\n", (cad.flags & CRYPT_ACTIVATE_KEYRING_KEY) ? "keyring" : "dm-crypt");
} else if (hw_enc == CRYPT_OPAL_HW_ONLY) {
log_std(" encryption: HW OPAL only\n");
log_std(" OPAL keysize: %d bits\n", crypt_get_hw_encryption_key_size(cd) * 8);
log_std(" OPAL keysize: %d [bits]\n", crypt_get_hw_encryption_key_size(cd) * 8);
} else if (hw_enc == CRYPT_SW_AND_OPAL_HW) {
log_std(" encryption: dm-crypt over HW OPAL\n");
log_std(" OPAL keysize: %d bits\n", crypt_get_hw_encryption_key_size(cd) * 8);
log_std(" OPAL keysize: %d [bits]\n", crypt_get_hw_encryption_key_size(cd) * 8);
log_std(" cipher: %s-%s\n", crypt_get_cipher(cd), crypt_get_cipher_mode(cd));
log_std(" keysize: %d bits\n", (crypt_get_volume_key_size(cd) - crypt_get_hw_encryption_key_size(cd)) * 8);
log_std(" keysize: %d [bits]\n", (crypt_get_volume_key_size(cd) - crypt_get_hw_encryption_key_size(cd)) * 8);
log_std(" key location: %s\n", (cad.flags & CRYPT_ACTIVATE_KEYRING_KEY) ? "keyring" : "dm-crypt");
}
if (ip.integrity)
log_std(" integrity: %s\n", ip.integrity);
if (ip.integrity_key_size)
log_std(" integrity keysize: %d bits\n", ip.integrity_key_size * 8);
log_std(" integrity keysize: %d [bits]\n", ip.integrity_key_size * 8);
if (ip.tag_size)
log_std(" integrity tag size: %u bytes\n", ip.tag_size);
log_std(" integrity tag size: %u [bytes]\n", ip.tag_size);
device = crypt_get_device_name(cd);
log_std(" device: %s\n", device);
if ((backing_file = crypt_loop_backing_file(device))) {
log_std(" loop: %s\n", backing_file);
free(backing_file);
}
log_std(" sector size: %d\n", crypt_get_sector_size(cd));
log_std(" offset: %" PRIu64 " sectors\n", cad.offset);
log_std(" size: %" PRIu64 " sectors\n", cad.size);
sector_size = (uint64_t)crypt_get_sector_size(cd) ?: SECTOR_SIZE;
log_std(" sector size: %d [bytes]\n", sector_size);
log_std(" offset: %" PRIu64 " [512-byte units] (%" PRIu64 " [bytes])\n", cad.offset, cad.offset * sector_size);
log_std(" size: %" PRIu64 " [512-byte units] (%" PRIu64 " [bytes])\n", cad.size, cad.size * sector_size);
if (cad.iv_offset)
log_std(" skipped: %" PRIu64 " sectors\n", cad.iv_offset);
log_std(" skipped: %" PRIu64 " [512-byte units]\n", cad.iv_offset);
log_std(" mode: %s%s\n", cad.flags & CRYPT_ACTIVATE_READONLY ?
"readonly" : "read/write",
(cad.flags & CRYPT_ACTIVATE_SUSPENDED) ? " (suspended)" : "");

View File

@@ -413,6 +413,7 @@ static int action_status(void)
char *backing_file;
const char *device, *metadata_device;
int path = 0, r = 0;
uint64_t sector_size;
/* perhaps a path, not a dm device name */
if (strchr(action_argv[0], '/'))
@@ -454,7 +455,7 @@ static int action_status(void)
if (r < 0)
goto out;
log_std(" tag size: %u\n", ip.tag_size);
log_std(" tag size: %u [bytes]\n", ip.tag_size);
log_std(" integrity: %s\n", ip.integrity ?: "(none)");
device = crypt_get_device_name(cd);
metadata_device = crypt_get_metadata_device_name(cd);
@@ -470,9 +471,10 @@ static int action_status(void)
free(backing_file);
}
}
log_std(" sector size: %u bytes\n", crypt_get_sector_size(cd));
sector_size = (uint64_t)crypt_get_sector_size(cd) ?: SECTOR_SIZE;
log_std(" sector size: %" PRIu64 " [bytes]\n", sector_size);
log_std(" interleave sectors: %u\n", ip.interleave_sectors);
log_std(" size: %" PRIu64 " sectors\n", cad.size);
log_std(" size: %" PRIu64 " [512-byte units] (%" PRIu64 " [bytes])\n", cad.size, cad.size * sector_size);
log_std(" mode: %s%s\n",
cad.flags & CRYPT_ACTIVATE_READONLY ? "readonly" : "read/write",
cad.flags & CRYPT_ACTIVATE_RECOVERY ? " recovery" : "");
@@ -480,13 +482,13 @@ static int action_status(void)
crypt_get_active_integrity_failures(cd, action_argv[0]));
if (cad.flags & CRYPT_ACTIVATE_NO_JOURNAL_BITMAP) {
log_std(" bitmap 512-byte sectors per bit: %u\n", ip.journal_watermark);
log_std(" bitmap flush interval: %u ms\n", ip.journal_commit_time);
log_std(" bitmap flush interval: %u [ms]\n", ip.journal_commit_time);
} if (cad.flags & CRYPT_ACTIVATE_NO_JOURNAL) {
log_std(" journal: not active\n");
} else {
log_std(" journal size: %" PRIu64 " bytes\n", ip.journal_size);
log_std(" journal size: %" PRIu64 " [bytes]\n", ip.journal_size);
log_std(" journal watermark: %u%%\n", ip.journal_watermark);
log_std(" journal commit time: %u ms\n", ip.journal_commit_time);
log_std(" journal commit time: %u [ms]\n", ip.journal_commit_time);
if (ip.journal_integrity)
log_std(" journal integrity MAC: %s\n", ip.journal_integrity);
if (ip.journal_crypt)

View File

@@ -377,8 +377,8 @@ static int action_status(void)
vp.flags & CRYPT_VERITY_ROOT_HASH_SIGNATURE ? " (with signature)" : "");
log_std(" hash type: %u\n", vp.hash_type);
log_std(" data block: %u\n", vp.data_block_size);
log_std(" hash block: %u\n", vp.hash_block_size);
log_std(" data block: %u [bytes]\n", vp.data_block_size);
log_std(" hash block: %u [bytes]\n", vp.hash_block_size);
log_std(" hash name: %s\n", vp.hash_name);
log_std(" salt: ");
if (vp.salt_size)
@@ -392,7 +392,7 @@ static int action_status(void)
log_std(" data loop: %s\n", backing_file);
free(backing_file);
}
log_std(" size: %" PRIu64 " sectors\n", cad.size);
log_std(" size: %" PRIu64 " [512-byte units] (%" PRIu64 " [bytes])\n", cad.size, cad.size * (uint64_t)SECTOR_SIZE);
log_std(" mode: %s\n", cad.flags & CRYPT_ACTIVATE_READONLY ?
"readonly" : "read/write");
@@ -401,8 +401,8 @@ static int action_status(void)
log_std(" hash loop: %s\n", backing_file);
free(backing_file);
}
log_std(" hash offset: %" PRIu64 " sectors\n",
vp.hash_area_offset * vp.hash_block_size / 512);
log_std(" hash offset: %" PRIu64 " [512-byte units] (%" PRIu64 " [bytes])\n",
vp.hash_area_offset * vp.hash_block_size / SECTOR_SIZE, vp.hash_area_offset * vp.hash_block_size);
if (vp.fec_device) {
log_std(" FEC device: %s\n", vp.fec_device);
@@ -410,8 +410,8 @@ static int action_status(void)
log_std(" FEC loop: %s\n", backing_file);
free(backing_file);
}
log_std(" FEC offset: %" PRIu64 " sectors\n",
vp.fec_area_offset * vp.hash_block_size / 512);
log_std(" FEC offset: %" PRIu64 " [512-byte units] (%" PRIu64 " [bytes])\n",
vp.fec_area_offset * vp.hash_block_size / SECTOR_SIZE, vp.fec_area_offset * vp.hash_block_size);
log_std(" FEC roots: %u\n", vp.fec_roots);
}

View File

@@ -555,23 +555,23 @@ $CRYPTSETUP luksDump $LOOPDEV | grep -q "Key Slot 1: DISABLED" || fail
prepare "[19] create & status & resize" wipe
echo $PWD1 | $CRYPTSETUP create $DEV_NAME $LOOPDEV --hash xxx --cipher aes-cbc-essiv:sha256 --key-size 256 2>/dev/null && fail
echo $PWD1 | $CRYPTSETUP create $DEV_NAME $LOOPDEV $PLAIN_OPT --offset 3 --skip 4 --readonly || fail
$CRYPTSETUP -q status $DEV_NAME | grep "offset:" | grep -q "3 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "skipped:" | grep -q "4 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "offset:" | grep -q "3 \[512-byte units\]" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "skipped:" | grep -q "4 \[512-byte units\]" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "mode:" | grep -q "readonly" || fail
$CRYPTSETUP -q resize $DEV_NAME --size 100 || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 \[512-byte units\]" || fail
$CRYPTSETUP -q resize $DEV_NAME || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "19997 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "19997 \[512-byte units\]" || fail
$CRYPTSETUP -q resize $DEV_NAME --device-size 1M || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "2048 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "2048 \[512-byte units\]" || fail
$CRYPTSETUP -q resize $DEV_NAME --device-size 512k --size 1023 >/dev/null 2>&1 && fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "2048 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "2048 \[512-byte units\]" || fail
$CRYPTSETUP -q resize $DEV_NAME --device-size 513 >/dev/null 2>&1 && fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "2048 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "2048 \[512-byte units\]" || fail
# Resize underlying loop device as well
truncate -s 16M $IMG || fail
$CRYPTSETUP -q resize $DEV_NAME || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "32765 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "32765 \[512-byte units\]" || fail
$CRYPTSETUP -q remove $DEV_NAME || fail
$CRYPTSETUP -q status $DEV_NAME >/dev/null && fail
echo $PWD1 | $CRYPTSETUP create $DEV_NAME $PLAIN_OPT $LOOPDEV || fail
@@ -579,18 +579,18 @@ $CRYPTSETUP -q remove $DEV_NAME || fail
echo $PWD1 | $CRYPTSETUP -q create $DEV_NAME $PLAIN_OPT $LOOPDEV || fail
$CRYPTSETUP -q remove $DEV_NAME || fail
echo $PWD1 | $CRYPTSETUP -q create $DEV_NAME $PLAIN_OPT --size 100 $LOOPDEV || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 \[512-byte units\]" || fail
$CRYPTSETUP -q remove $DEV_NAME || fail
# 4k sector resize (if kernel supports it)
echo $PWD1 | $CRYPTSETUP -q open --type plain $PLAIN_OPT $LOOPDEV $DEV_NAME --sector-size 4096 --size 8 >/dev/null 2>&1
if [ $? -eq 0 ] ; then
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "8 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "8 \[512-byte units\]" || fail
$CRYPTSETUP -q resize $DEV_NAME --size 16 || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "16 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "16 \[512-byte units\]" || fail
$CRYPTSETUP -q resize $DEV_NAME --size 9 2>/dev/null && fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "16 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "16 \[512-byte units\]" || fail
$CRYPTSETUP -q resize $DEV_NAME --device-size 4608 2>/dev/null && fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "16 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "16 \[512-byte units\]" || fail
$CRYPTSETUP -q remove $DEV_NAME || fail
fi
# Resize not aligned to logical block size
@@ -806,9 +806,9 @@ echo $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV --h
echo $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV-missing --header $HEADER_IMG $DEV_NAME 2>/dev/null && fail
echo $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV --header $HEADER_IMG $DEV_NAME || fail
$CRYPTSETUP -q resize $DEV_NAME --size 100 --header $HEADER_IMG || fail
$CRYPTSETUP -q status $DEV_NAME --header $HEADER_IMG | grep "size:" | grep -q "100 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME --header $HEADER_IMG | grep "size:" | grep -q "100 \[512-byte units\]" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "type:" | grep -q "n/a" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 \[512-byte units\]" || fail
$CRYPTSETUP luksSuspend $DEV_NAME --header $HEADER_IMG || fail
echo $PWD1 | $CRYPTSETUP luksResume $DEV_NAME --header $HEADER_IMG || fail
$CRYPTSETUP luksSuspend $DEV_NAME || fail

View File

@@ -769,31 +769,31 @@ if dm_crypt_keyring_support; then
load_key user $TEST_KEY_DESC2 $PWD1 "$TEST_KEYRING" || skip "Kernel keyring service is useless on this system, test skipped."
$CRYPTSETUP token add $LOOPDEV --key-description $TEST_KEY_DESC2 --token-id 1 || fail
$CRYPTSETUP -q resize --size 99 $DEV_NAME <&- || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "99 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "99 \[512-byte units\]" || fail
#replace kernel key with wrong pass
load_key user $TEST_KEY_DESC2 $PWD2 "$TEST_KEYRING" || skip "Kernel keyring service is useless on this system, test skipped."
# must fail due to --token-only
echo $PWD1 | $CRYPTSETUP -q resize --token-only --size 100 $DEV_NAME && fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 sectors" && fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 \[512-byte units\]" && fail
# resize with keyring description
load_key user $TEST_KEY_DESC1 $PWD1 "$TEST_KEYRING" || fail
$CRYPTSETUP -q resize --size 99 $DEV_NAME --key-description $TEST_KEY_DESC1 || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "99 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "99 \[512-byte units\]" || fail
fi
fi
echo $PWD1 | $CRYPTSETUP -q resize --size 100 $DEV_NAME || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 \[512-byte units\]" || fail
echo $PWD1 | $CRYPTSETUP -q resize --device-size 51200 $DEV_NAME || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 \[512-byte units\]" || fail
echo $PWD1 | $CRYPTSETUP -q resize --device-size 1M $DEV_NAME || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "2048 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "2048 \[512-byte units\]" || fail
echo $PWD1 | $CRYPTSETUP -q resize --device-size 512k --size 1024 $DEV_NAME > /dev/null 2>&1 && fail
echo $PWD1 | $CRYPTSETUP -q resize --device-size 4097 $DEV_NAME > /dev/null 2>&1 && fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "2048 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "2048 \[512-byte units\]" || fail
$CRYPTSETUP close $DEV_NAME || fail
echo $PWD1 | $CRYPTSETUP luksOpen --disable-keyring $LOOPDEV $DEV_NAME || fail
echo | $CRYPTSETUP -q resize --size 100 $DEV_NAME || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 \[512-byte units\]" || fail
$CRYPTSETUP close $DEV_NAME || fail
echo $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || fail
if dm_crypt_keyring_support; then
@@ -804,10 +804,10 @@ if dm_crypt_sector_size_support; then
echo $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --sector-size 4096 $LOOPDEV > /dev/null || fail
echo $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || fail
echo $PWD1 | $CRYPTSETUP -q resize --device-size 1M $DEV_NAME || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "2048 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "2048 \[512-byte units\]" || fail
echo $PWD1 | $CRYPTSETUP -q resize --device-size 2049s $DEV_NAME > /dev/null 2>&1 && fail
echo $PWD1 | $CRYPTSETUP -q resize --size 2049 $DEV_NAME > /dev/null 2>&1 && fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "2048 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "2048 \[512-byte units\]" || fail
fi
$CRYPTSETUP close $DEV_NAME || fail
# Resize not aligned to logical block size
@@ -1012,9 +1012,9 @@ echo $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --h
echo $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV-missing --header $HEADER_IMG $DEV_NAME 2>/dev/null && fail
echo $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV --header $HEADER_IMG $DEV_NAME || fail
echo $PWD1 | $CRYPTSETUP -q resize $DEV_NAME --size 100 --header $HEADER_IMG || fail
$CRYPTSETUP -q status $DEV_NAME --header $HEADER_IMG | grep "size:" | grep -q "100 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME --header $HEADER_IMG | grep "size:" | grep -q "100 \[512-byte units\]" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "type:" | grep -q "n/a" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "100 \[512-byte units\]" || fail
$CRYPTSETUP luksSuspend $DEV_NAME --header $HEADER_IMG || fail
echo $PWD1 | $CRYPTSETUP luksResume $DEV_NAME --header $HEADER_IMG || fail
$CRYPTSETUP luksSuspend $DEV_NAME || fail

View File

@@ -97,7 +97,7 @@ status_check() # name value
dump_check() # name value
{
X=$($INTSETUP dump $DEV | grep "$1" | cut -d' ' -f 2)
X=$($INTSETUP dump $DEV | grep "$1" | sed 's/.*: //' | cut -d' ' -f 1)
if [ "$X" != "$2" ] ; then
echo "[dump FAIL]"
echo " Expecting $1:$2 got \"$X\"."
@@ -185,8 +185,8 @@ intformat() # alg alg_out tagsize outtagsize sector_size csum [keyfile keysize]
return
fi
dump_check "tag_size" $4
dump_check "sector_size" $5
dump_check "tag size" $4
dump_check "sector size" $5
echo -n "[ACTIVATE]"
$INTSETUP open $DEV $DEV_NAME --integrity $1 $KEY_PARAMS || fail "Cannot activate device."
if [ -n "$8" ]; then
@@ -194,9 +194,9 @@ intformat() # alg alg_out tagsize outtagsize sector_size csum [keyfile keysize]
[ -z "$KEY_HEX" ] && fail "Cannot decode key."
dmsetup table --showkeys $DEV_NAME | grep -q $KEY_HEX || fail "Key mismatch."
fi
status_check "tag size" $4
status_check "tag size" "$4 [bytes]"
status_check "integrity" $2
status_check "sector size" "$5 bytes"
status_check "sector size" "$5 [bytes]"
int_check_sum $1 $6 $7 $8
echo -n "[REMOVE]"
$INTSETUP close $DEV_NAME || fail "Cannot deactivate device."
@@ -279,7 +279,7 @@ int_journal() # 1 alg, 2 tagsize, 3 sector_size, 4 watermark, 5 commit_time, 6 j
dmsetup table --showkeys $DEV_NAME | grep -q $KEY_HEX || fail "Key mismatch."
status_check "journal watermark" "${4}%"
status_check "journal commit time" "${5} ms"
status_check "journal commit time" "${5} [ms]"
status_check "journal integrity MAC" $9
echo -n "[REMOVE]"
@@ -526,7 +526,7 @@ if [ -n "$DM_INTEGRITY_BITMAP" ] ; then
$INTSETUP format -q $DEV --integrity-bitmap-mode $DEV2 || fail "Cannot format device."
$INTSETUP open $DEV --integrity-bitmap-mode --bitmap-sectors-per-bit 65536 --bitmap-flush-time 5000 $DEV_NAME || fail "Cannot activate device."
$INTSETUP status $DEV_NAME | grep -q 'bitmap 512-byte sectors per bit: 65536' || fail
$INTSETUP status $DEV_NAME | grep -q 'bitmap flush interval: 5000 ms' || fail
$INTSETUP status $DEV_NAME | grep -q 'bitmap flush interval: 5000 \[ms\]' || fail
$INTSETUP close $DEV_NAME || fail "Cannot deactivate device."
echo "[OK]"
echo "Bitmap error detection tests:"
@@ -551,7 +551,7 @@ EOF
[ ! -b /dev/mapper/$DEV_NAME2 ] && fail
$INTSETUP format -q -s 512 --no-wipe /dev/mapper/$DEV_NAME2
$INTSETUP open /dev/mapper/$DEV_NAME2 $DEV_NAME || fail
D_SIZE=$($INTSETUP dump /dev/mapper/$DEV_NAME2 | grep provided_data_sectors | sed -e 's/.*provided_data_sectors\ \+//g')
D_SIZE=$($INTSETUP dump /dev/mapper/$DEV_NAME2 | grep "data size:" | cut -d' ' -f 3)
A_SIZE=$(blockdev --getsz /dev/mapper/$DEV_NAME)
# Compare strings (to avoid 64bit integers), not integers
[ -n "$A_SIZE" -a "$D_SIZE" != "$A_SIZE" ] && fail

View File

@@ -175,7 +175,7 @@ $CRYPTSETUP open --type plain $IMG $MAP --key-size=256 --cipher=aes-xts-plain64
dmsetup table --showkeys $MAP | grep -q ":32:encrypted:$KEYNAME" || fail
$CRYPTSETUP status $MAP | grep -q "key location: keyring" || fail
$CRYPTSETUP resize $MAP --size 100 || fail
$CRYPTSETUP status $MAP| grep "size:" | grep -q "100 sectors" || fail
$CRYPTSETUP status $MAP | grep "size:" | grep -q "100 \[512-byte units\]" || fail
$CRYPTSETUP resize $MAP || fail
$CRYPTSETUP close $MAP || fail
echo "[OK]"

View File

@@ -805,7 +805,7 @@ function reencrypt_online_fixed_size() {
echo $PWD1 | $CRYPTSETUP open $DEV $_hdr $DEV_NAME || fail
echo $PWD1 | $CRYPTSETUP resize $DEV_NAME $_hdr --size $2 || fail
echo $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV $_hdr --sector-size $1 --resilience $4 || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "$2 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "$2 \[512-byte units\]" || fail
$CRYPTSETUP close $DEV_NAME || fail
check_hash_head $PWD1 $2 $3 $7
wipe $PWD1 $7
@@ -816,7 +816,7 @@ function reencrypt_online_fixed_size() {
echo $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV $_hdr --sector-size $1 --init-only || fail
echo $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV $_hdr --device-size $(($2-_esz))s --resilience $4 2>/dev/null && fail
echo $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV $_hdr --device-size $2s --resilience $4 || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "$2 sectors" || fail
$CRYPTSETUP -q status $DEV_NAME | grep "size:" | grep -q "$2 \[512-byte units\]" || fail
$CRYPTSETUP close $DEV_NAME || fail
check_hash_head $PWD1 $2 $3 $7