+2011-01-29 Milan Broz <mbroz@redhat.com>
+ * Fix mapping removal if device disappeared but node still exists.
+
2011-01-25 Milan Broz <mbroz@redhat.com>
* Add loop-AES handling (loopaesOpen and loopaesClose commands).
(requires kernel 2.6.38 and above)
if (r < 0)
goto out;
+ *cd = NULL;
+ r = crypt_init(cd, device);
+
/* Underlying device disappeared but mapping still active */
- if (!device)
+ if (!device || r == -ENOTBLK)
log_verbose(NULL, _("Underlying device for crypt device %s disappeared.\n"),
name);
- *cd = NULL;
- r = crypt_init(cd, device);
+ /* Underlying device is not readable but crypt mapping exists */
+ if (r == -ENOTBLK) {
+ free(device);
+ device = NULL;
+ r = crypt_init(cd, NULL);
+ }
+
if (r < 0)
goto out;
/* Try to read first sector */
s = read_blockwise(devfd, buf, sizeof(buf));
if (s < 0 || s != sizeof(buf)) {
- log_err(cd, _("Cannot read device %s.\n"), device);
+ log_verbose(cd, _("Cannot read device %s.\n"), device);
r = 0;
}
echo "key0" | $CRYPTSETUP luksDump $LOOPDEV --dump-master-key | grep -q "MK dump:" || fail
$CRYPTSETUP luksDump -q $LOOPDEV --dump-master-key -d $KEY1 | grep -q "MK dump:" || fail
+prepare "[22] remove disappeared device" wipe
+dmsetup create $DEV_NAME --table "0 5000 linear $LOOPDEV 2" || fail
+echo "key0" | $CRYPTSETUP -q -i 0 luksFormat /dev/mapper/$DEV_NAME || fail
+echo "key0" | $CRYPTSETUP -q luksOpen /dev/mapper/$DEV_NAME $DEV_NAME2 || fail
+# underlying device now returns error but node is still present
+dmsetup load $DEV_NAME --table "0 5000 error" || fail
+dmsetup resume $DEV_NAME || fail
+$CRYPTSETUP -q luksClose $DEV_NAME2 || fail
+dmsetup remove $DEV_NAME || fail
+
remove_mapping
exit 0