Force test to read device to detect corrupted blocks.

(If udev scanning is switched off, there is no real activity on device yet.)
This commit is contained in:
Milan Broz
2016-06-23 09:45:06 +02:00
parent 16fab74ab1
commit 4d3a501b83

View File

@@ -1772,6 +1772,8 @@ static void VerityTest(void)
/* hash fail */ /* hash fail */
root_hash[1] = ~root_hash[1]; root_hash[1] = ~root_hash[1];
OK_(crypt_activate_by_volume_key(cd, CDEVICE_1, root_hash, 32, CRYPT_ACTIVATE_READONLY)); OK_(crypt_activate_by_volume_key(cd, CDEVICE_1, root_hash, 32, CRYPT_ACTIVATE_READONLY));
/* Be sure there was some read activity to mark device corrupted. */
_system("blkid " DMDIR CDEVICE_1, 0);
OK_(crypt_get_active_device(cd, CDEVICE_1, &cad)); OK_(crypt_get_active_device(cd, CDEVICE_1, &cad));
EQ_(CRYPT_ACTIVATE_READONLY|CRYPT_ACTIVATE_CORRUPTED, cad.flags); EQ_(CRYPT_ACTIVATE_READONLY|CRYPT_ACTIVATE_CORRUPTED, cad.flags);
OK_(crypt_deactivate(cd, CDEVICE_1)); OK_(crypt_deactivate(cd, CDEVICE_1));
@@ -1780,6 +1782,7 @@ static void VerityTest(void)
/* data fail */ /* data fail */
OK_(crypt_set_data_device(cd, DEVICE_1)); OK_(crypt_set_data_device(cd, DEVICE_1));
OK_(crypt_activate_by_volume_key(cd, CDEVICE_1, root_hash, 32, CRYPT_ACTIVATE_READONLY)); OK_(crypt_activate_by_volume_key(cd, CDEVICE_1, root_hash, 32, CRYPT_ACTIVATE_READONLY));
_system("blkid " DMDIR CDEVICE_1, 0);
OK_(crypt_get_active_device(cd, CDEVICE_1, &cad)); OK_(crypt_get_active_device(cd, CDEVICE_1, &cad));
EQ_(CRYPT_ACTIVATE_READONLY|CRYPT_ACTIVATE_CORRUPTED, cad.flags); EQ_(CRYPT_ACTIVATE_READONLY|CRYPT_ACTIVATE_CORRUPTED, cad.flags);
OK_(crypt_deactivate(cd, CDEVICE_1)); OK_(crypt_deactivate(cd, CDEVICE_1));