[Pkg-cryptsetup-devel] Bug#451916: Bug#451916: Bug#451916: cryptsetup: loopback device not detached after "/etc/init.d/cryptdisks stop"

Jonas Meurer jonas at freesources.org
Mon Dec 3 22:01:32 UTC 2007


On 03/12/2007 To René Pavlík wrote:
> > but this doesn't work - because of the false condition, especially [
> > "$loopmajor" = "$major" ].
> 
> You're correct, and i don't understand why this code has been
> implemented in the first time. checking for matching $loopmajor and
> $major doesn't work at all.
> 
> The question is rather how else we could verify that a loopback device
> has been used and needs to be deleted at stop.
> 
> I cannot imagine any way to get the loopback device from the source file
> except something like
> 
> 	losetup -a | grep -m1 "($src)$" | sed -e 's/:.*//g'
> 
> which is a rather unclean solution.

Ok, I just found out that 'cryptsetup status $dst' gives us the
information we need. the following works but could be implemented
better:

loopdev="/dev/"$(cryptsetup status "$dst" | grep "device" | sed -e 's/.*device.*\///g' | grep "^loop" || true)

if ! rm_lo_setup; then
	device_msg "$dst" "detaching loopback failed"
	continue
fi

I added it to svn, but i'm happy to replace the loopdev=... line with
some better idea ;-)

greetings,
 jonas





More information about the Pkg-cryptsetup-devel mailing list