Re: losetup from 7.6.1 can't detach a cloop device
Hi,
Worse... Apparently, losetup has been deliberately changed by its
developer(s) to only execute the -d option for devices having the
loopback major block device id.
---
sys-utils/losetup.c:
case 'd':
act = A_DELETE;
if (!is_loopdev(optarg) ||
loopcxt_set_device(&lc, optarg))
err(EXIT_FAILURE, _("%s: failed to use device"),
optarg);
break;
---
lib/loopdev.c:
int is_loopdev(const char *device)
{
struct stat st;
if (!device)
return 0;
return (stat(device, &st) == 0 &&
S_ISBLK(st.st_mode) &&
major(st.st_rdev) == LOOPDEV_MAJOR);
}
---
Because of this, losetup from util-linux no longer works for cloop
devices. I just filed a bug report, hoping the very strict checking can
be reconsidered for removal.
Use busybox losetup for now.
Regards
-Klaus
> On 4 June 2016 at 15:53, Klaus Knopper <[1]debian-knoppix@knopper.net>
> wrote:
>
> Hello hb,
> On Sat, Jun 04, 2016 at 01:42:19PM +0200, hb wrote:
> > 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.
> [...]
>
> I've seen this, and have been wondering about it, too. The new losetup
> error message does not make much sense to me, it's probably supposed to
> mean "file size is not aligned to sector size". I still don't see why
> this should be a problem now, it has always worked in the past. And,
> losetup failing to detach the file that it attached happily before, is
> definitiely a bug, from my point of view.
>
> I'd recommend using busybox internal losetup command for now for
> attaching and detaching cloop files manually.
>
> Detach:
> sudo busybox losetup -d /dev/cloop7
>
> Attach:
> sudo busybox losetup -r /dev/cloop7 cx.iso[.cloop]
>
> Knoppix only uses the busybox-internal losetup during startup and
> shutdown, anyways.
>
> Regards
> -Klaus
Reply to: