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

Jonas Meurer jonas at freesources.org
Tue Dec 4 02:14:58 UTC 2007


On 03/12/2007 David Härdeman wrote:
>> 	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".

yes, better solution than my previous one. i tried to implement it:

src_major=$(dmsetup deps "$dst" 2> /dev/null | sed -e 's/^.*(\([0-9]*\), [0-9]*)$/\1/g' || true)
src_minor=$(dmsetup deps "$dst" 2> /dev/null | sed -e 's/^.*([0-9]*, \([0-9]*\))$/\1/g' || true)

[...]

if [ "$src_major" = "7" ]; then
	loopdev="/dev/loop${src_minor}"
	if ! rm_lo_setup; then
		device_msg "$dst" "detaching loopback failed"
		continue
	fi
fi

I also changed the checks for $major and $minor to $src_major and
$src_minor. $major and $minor are rather useless with the current
implementation.

greetings,
 jonas





More information about the Pkg-cryptsetup-devel mailing list