Re: /dev/loop0 offset doen't work on /dev/scd0

Harald Koenig (koenig@tat.physik.uni-tuebingen.de)
Thu, 22 Apr 1999 15:20:07 +0200


thanks for your hint!!

using the following patch I fixed both the `-o 2048' problem and SIGSEV
for losetup for me:

--- util-linux-2.9i/mount/losetup.c~ Sun Oct 11 19:19:22 1998
+++ util-linux-2.9i/mount/losetup.c Thu Apr 22 15:14:57 1999
@@ -11,6 +11,11 @@
#include <errno.h>
#include <sys/ioctl.h>

+#if __GLIBC__ == 2 && __GLIBC_MINOR__ == 0
+typedef unsigned short loop__dev_t;
+#define __dev_t loop__dev_t
+#endif
+
#include "loop.h"
#include "lomount.h"

On Apr 22, Andi Kleen wrote:

> Harald Koenig <koenig@tat.physik.uni-tuebingen.de> writes:
>
> > why isn't it possible to use
> >
> > # losetup -o 2048 /dev/loop0 /dev/scd0
> > ioctl: LOOP_SET_STATUS: Invalid argument
> >
> > without `-o 2048' the loopback works fine (but is useless because I need to skip
> > the first sector;). strace shows:
> >
> > # strace losetup -o 2048 /dev/loop0 /dev/scd0
> > ...
> > open("/dev/scd0", O_RDWR) = -1 EROFS (Read-only file system)
> > open("/dev/scd0", O_RDONLY) = 3
> > open("/dev/loop0", O_RDONLY) = 4
> > ioctl(4, LOOP_SET_FD, 0x3) = 0
> > ioctl(4, LOOP_SET_STATUS, 0xbffff500) = -1 EINVAL (Invalid argument)
> > ioctl(4, LOOP_CLR_FD, 0) = 0
> > write(2, "ioctl: LOOP_SET_STATUS: Invalid "..., 41ioctl: LOOP_SET_STATUS: Invalid argument) = 41
>
>
> My guess is that you have a miscompiled losetup utility. Most losetups
> compiled with glibc 2.0 are broken, because glibc changed the size of dev_t
> without bothering to supply a linux/loop.h replacement (struct loop_info
> contains dev_t). Compiled with a 32bit dev_t you really need set
> lo_encrypt_type, and the kernel obviously doesn't know how to deal with
> lo_encrypt_type 2048.
>
> Unfortunately there is no easy way to fix losetup without introducing
> glibc version dependencies, because glibc offers no public function to convert
> its dev_t (from its stat wrapper) into a kernel dev_t.
>
> I filled a glibc PR for this some time ago, but it was closed for reasons
> I cannot follow (because the glibc bug is still here).
>
> -Andi
>
> --
> This is like TV. I don't like TV.

Harald

--
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/