On 07/24/13 22:09, Damjan Jovanovic wrote:

The ioctl:
#define USB_FS_INIT             _IOW ('U', 195, struct usb_fs_init)
when used by a COMPAT_32BIT libusb on amd64, fails (causing
libusb_open() to fail) due to:

freebsd32_ioctl(0x6,0x800c55c3,0xffffc710,0x0,0x0,0x0) ERR#25
'Inappropriate ioctl for device'
but when hacked a bit:
freebsd32_ioctl(0x6,0x801055c3,0xffffc710,0x0,0x0,0x0) = 0 (0x0)

because sizeof(struct usb_fs_init) is 12 bytes on i386, and 16 bytes on amd64.

But the failure of even libusb_open() - a fundamental libusb function
- must mean that the COMPAT_32BIT libusb never worked. Can we please
take this opportunity to kill it and do a real 32 bit compatibility
layer in the kernel that will work from 32 bit chroots and statically
linked 32 bit binaries? I'll help.


How did you compile it? Is the structure the same size, compiled with GCC and LLVM?

The LIB32 for USB has been tested. I did a quick test and found on 9-stable:

cc -m32 -I . -L /usr/lib32 -lusb usbconfig.c dump.c
env LD_PRELOAD=/usr/lib32/libusb.so ./a.out
ugen0.1: <UHCI root HUB Intel> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA) ugen1.1: <UHCI root HUB Intel> at usbus1, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE (0mA)


Your approach requires much more code. It is not just about some structures, but also about code accessing those structures. Feel free to submit a patch however.

I would rather fix this by adding the proper __aligned() to the structures in question.


freebsd-usb@freebsd.org mailing list
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"

Reply via email to