--- cryptdisks.functions.8_04.orig 2008-05-26 22:47:29.000000000 +0300 +++ /lib/cryptsetup/cryptdisks.functions 2008-05-26 22:59:20.000000000 +0300 @@ -276,6 +276,15 @@ sleep 2 fi cryptsetup $PARAMS luksOpen $src $dst <&1 + # If cryptsetup failed, get into the "if" block: + if [ $? != 0 ]; then + # remove "stale" loopback device: + losetup -d $src + # We want that $? will represent a failure (because cryptsetup + # failed, but losetup most likely succeeded). Running /bin/false + # will set $? to 1 + /bin/false + fi fi fi