Automatic deletion of loopback device upon umount?
Rob Landley
rob at landley.net
Mon Apr 16 18:31:09 UTC 2012
On 04/16/2012 05:50 AM, Rich Felker wrote:
> 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.
That's why I added -D to disable it.
> 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.
A) Which is why I added -D in the first place.
B) "rm -rf mountpoint/*; cat /dev/zero > mountpoint/blah; umount", or
you could blank the $FILE instead of the block device...
> 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.
"Root could write bad code, and not understand what they're doing."
This is your definition of "extremely unsafe".
Rob
--
GNU/Linux isn't: Linux=GPLv2, GNU=GPLv3+, they can't share code.
Either it's "mere aggregation", or a license violation. Pick one.
More information about the busybox
mailing list