diff --git a/src/cryptsetup.c b/src/cryptsetup.c index 91e9748d..b5b529fe 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -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; } diff --git a/tests/compat-test b/tests/compat-test index 4ffe3546..9252ac36 100755 --- a/tests/compat-test +++ b/tests/compat-test @@ -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