Subject: Re: Incompatibilities between <=3.0 & current: USB_DEVICEINFO ioctl
To: Stephan Thesing <thesing@cs.uni-sb.de>
From: Pavel Cahyna <pavel@NetBSD.org>
List: current-users
Date: 09/14/2006 08:43:01
On Tue, Mar 21, 2006 at 10:04:02PM +0100, Stephan Thesing wrote:
> attached is a try for a patch which
> - adds compat ioctls with the right numbers from <=3.0 for
> USB_GET_DEVICEINFO and USB_DEVICEINFO named
> USB_GET_DEVICEINFO_OLD and USB_DEVICEINFO_OLD
> - adds structs usb_device_info_old and usb_event_old, which are
> compatible with the usb_device_info and usb_event structs form <=3.0
> - adds code to restore the old string handling for the compat ioctls
> (which is
> quite ugly)
> - adds compat code in `usbread' that transforms results into the
> usb_event_old
> struct if the read size was for that struct (to handle event reads from
> /dev/usb)
>
> This seems to work (digikam now works both with a -current compile libusb
> and a
> 3.0 one, reads from /dev/usb seem to work as well).
>
> As this patch is the result of hacking after a long day of work, it's
> probably not as nice at it could be. One thing that should probably be
> changed is making the compat code dependend on COMPAT_{16,20,30} being
> defined...
> +Static void
> +usb_copy_old_devinfo(struct usb_device_info_old *uo, struct usb_device_info *ue)
> +{
> + unsigned char *p, *q;
> + int n;
> +
> + uo->udi_bus = ue->udi_bus;
> + uo->udi_addr = ue->udi_addr;
> + uo->udi_cookie = ue->udi_cookie;
Another comment: I think that you forgot to NULL-terminate q after those
two for loops.
> + for (p=(unsigned char *)ue->udi_product,
> + q=(unsigned char *)uo->udi_product; *p; p++) {
> + if ((int)*p<0x80)
> + *q++=*p;
> + else {
> + *q++='?';
> + if ((((int)*p)&0xe0)==0xe0)
> + p++;
> + p++;
> + }
> + }
> +
> + for (p=ue->udi_vendor,
> + q=uo->udi_vendor; *p; p++) {
> + if (*p<0x80)
> + *q++=*p;
> + else {
> + *q++='?';
> + p++;
> + if ((*p&0xe0)==0xe0)
> + p++;
> + }
> + }
Pavel Cahyna