losetup from 7.6.1 can't detach a cloop device
In this example cx.iso was created with genisoimage and create_compressed_fs
# ls -l cx.iso
-rw-r--r-- 1 root root 122052675 Jun 4 00:39 cx.iso
# losetup -V
losetup from util-linux 2.27.1
# losetup -r /dev/cloop7 cx.iso
losetup: cx.iso: Warning: file does not fit into a 512-byte sector; the
end of the file will be ignored.
# losetup -d /dev/cloop7
losetup: /dev/cloop7: failed to use device: Success
... and cloop7 is still attached.
The warning doesn't seem to be related to the failure, but what do I know.
A workaround is to use an older losetup, for example a local copy of the
one from 7.4.2:
# ./losetup -V
./losetup: invalid option -- 'V'
losetup loop_device give info
losetup -a | --all list all used
losetup -d | --detach <loopdev> [<loopdev> ...] delete
# ./losetup -r /dev/cloop7 cx.iso
# ./losetup -d /dev/cloop7
I didn't spend the time to look at the sources of losetup, I hope
someone with more knowledge about cloop will do.