mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-10 02:10:01 +01:00
Fix mapping removal if device disappeared but node still exists.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@420 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
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)
|
||||
|
||||
14
lib/setup.c
14
lib/setup.c
@@ -1024,13 +1024,21 @@ int crypt_init_by_name(struct crypt_device **cd, const char *name)
|
||||
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;
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ int device_ready(struct crypt_device *cd, const char *device, int mode)
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -278,5 +278,15 @@ echo "bad" | $CRYPTSETUP luksDump $LOOPDEV --dump-master-key 2>/dev/null && fail
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user