Add test for deferred removal.

Print more info in CLI command.
This commit is contained in:
Milan Broz
2017-06-24 10:32:48 +02:00
parent 3efa00d59a
commit 164bbdfcfc
2 changed files with 18 additions and 0 deletions

View File

@@ -422,6 +422,7 @@ out:
static int action_close(void)
{
struct crypt_device *cd = NULL;
crypt_status_info ci;
uint32_t flags = 0;
int r;
@@ -432,6 +433,13 @@ static int action_close(void)
if (r == 0)
r = crypt_deactivate_by_name(cd, action_argv[0], flags);
if (!r && opt_deferred_remove) {
ci = crypt_status(cd, action_argv[0]);
if (ci == CRYPT_ACTIVE || ci == CRYPT_BUSY)
log_std(_("Device %s is still active and scheduled for deferred removal.\n"),
action_argv[0]);
}
crypt_free(cd);
return r;
}

View File

@@ -595,5 +595,15 @@ $CRYPTSETUP luksErase -q $LOOPDEV || fail
$CRYPTSETUP luksDump $LOOPDEV | grep -q "Key Slot 1: DISABLED" || fail
$CRYPTSETUP luksDump $LOOPDEV | grep -q "Key Slot 5: DISABLED" || fail
prepare "[31] Deferred removal of device" wipe
echo $PWD1 | $CRYPTSETUP open --type plain $LOOPDEV $DEV_NAME || fail
echo $PWD2 | $CRYPTSETUP open --type plain /dev/mapper/$DEV_NAME $DEV_NAME2 || fail
$CRYPTSETUP close $DEV_NAME >/dev/null 2>&1 && fail
$CRYPTSETUP -q status $DEV_NAME >/dev/null 2>&1 || fail
$CRYPTSETUP close --deferred $DEV_NAME >/dev/null || fail
$CRYPTSETUP -q status $DEV_NAME >/dev/null 2>&1 || fail
$CRYPTSETUP close $DEV_NAME2 || fail
$CRYPTSETUP -q status $DEV_NAME >/dev/null 2>&1&& fail
remove_mapping
exit 0