Add LUKS2 error message hint when device too small.

If we format LUKS2 device with parameters unsuitable
for current metadata device size we usually fail during header areas
wipe. It was not clear what the reason actually was.
This commit is contained in:
Ondrej Kozina
2019-07-11 15:06:30 +02:00
parent b0e224a9f8
commit 431bc87f85

View File

@@ -1809,6 +1809,8 @@ static int _crypt_format_luks2(struct crypt_device *cd,
if (r < 0) {
log_err(cd, _("Cannot wipe header on device %s."),
mdata_device_path(cd));
if (dev_size < LUKS2_hdr_and_areas_size(cd->u.luks2.hdr.jobj))
log_err(cd, _("Device %s is too small."), device_path(crypt_metadata_device(cd)));
goto out;
}