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

David Härdeman david at hardeman.nu
Mon Dec 3 19:16:01 UTC 2007


On Mon, Dec 03, 2007 at 06:10:31PM +0100, Jonas Meurer wrote:
>On 20/11/2007 René Pavlík wrote:
>> So I think if the loopback device is allocated by this script it
>> should be also freed by this script. There is a do_stop() func in the
>> script (mean in the sourced library). This func tries to do detaching
>> at the very end:
>> 
>>                 # Detach loopback device, if attached
>>                 if [ -f "$src" ] && [ -n "$loopmajor" ] && [
>> "$loopmajor" = "$major" ]; then
>>                         losetup -d "/dev/loop$minor" > /dev/null 2>&1
>> || true
>>                 fi
>> 
>> but this doesn't work - because of the false condition, especially [
>> "$loopmajor" = "$major" ].
>
>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. David, do you have any better
>solution? i guess you do ;-)

I haven't looked in depth at this code (yet), but perhaps "dmsetup deps $dst" 
could be used?

Example output:

# dmsetup deps cweird
1 dependencies  : (7, 0)

7 is the major number for loop devices...so if we have (7, X) it's a 
loopback device...the check needs to be done before "do_close" though 
and the actual "losetup -d" needs to be done after "do_close".

-- 
David Härdeman





More information about the Pkg-cryptsetup-devel mailing list