Automatic deletion of loopback device upon umount?

Rich Felker dalias at aerifal.cx
Mon Apr 16 10:50:03 UTC 2012


On Sun, Apr 15, 2012 at 11:02:20PM -0500, Rob Landley wrote:
> I really don't understand this deference to the limitations of
> util-linux. If we have a spec we should document and justify deviations
> from the spec. But when all we have is some example implementation, they
> can be _wrong_. It doesn't _matter_ what they do, what matters is that
> we get the behavior right.

I don't think it's deference but desire to avoid breaking things. Some
people setup loop devices manually with losetup, and don't want them
automatically deleted, or even just don't expect the automatic
deletion. For example:

dev=$(losetup -f --show "$file")
mkfs "$dev"
mount "$dev" "$mountpoint"
...
umount "$dev"
dd if=/dev/zero of="$dev"
losetup -d "$dev"

With the automatic loop deletion, this code has a DANGEROUS race
condition. Note that the automatic loop deletion is safe if you can
determine that the loop device was auto-created by mount, but it's
extremely unsafe when it was manually created by losetup.

Rich


More information about the busybox mailing list