Hi Hans,
Patch works as expected, thanks!
Regards,
Chris
On Tue, Mar 11, 2014 at 10:45 AM, Hans de Goede <hdego...@redhat.com> wrote:
> Hi Chris,
>
>
> On 03/11/2014 05:27 PM, Chris Dickens wrote:
>
>> Hi Hans,
>>
>> Are you sure this is what was happening ? Can you perhaps try again
>> with
>> a printf added at a strategic place to ensure this is really what is
>> going
>> on?
>>
>>
>> Here's the debug output right after the DISCONNECT_CLAIM fails:
>>
>> [ 0.004913] [00007d79] libusb: debug [libusb_claim_interface] interface 1
>> [ 0.004930] [00007d79] libusb: debug [detach_kernel_driver_and_claim]
>> ioctl DISCONNECT_CLAIM error -1 errno 22
>>
>> Looking at:
>> https://git.kernel.org/cgit/linux/kernel/git/torvalds/
>> linux.git/tree/drivers/usb/core/devio.c?id=22763c5cf3690a681551162c15d34d
>> 935308c8d7
>>
>> (22763c5c is the commit id responding to the v2.6.32 tag)
>>
>> I see the following in there:
>>
>> static int usbdev_ioctl(struct inode *inode, struct file *file,
>> unsigned int cmd, unsigned long arg)
>> {
>> struct dev_state *ps = file->private_data;
>> struct usb_device *dev = ps->dev;
>> void __user *p = (void __user *)arg;
>> int ret = -ENOTTY;
>> ...
>> switch (cmd) {
>> case USBDEVFS_CONTROL:
>> ...
>> }
>> return ret;
>> }
>>
>> This code path is used for calls from both 64 bit and 32 bit
>> userspace apps,
>> so 32 bit apps should see -ENOTTY to for an unknown cmd code.
>>
>>
>> The code for RHEL's 2.6.32 kernel is a bit different, but essentially
>> boils down to the same thing. (I was referencing
>> http://ftp.redhat.com/redhat/linux/enterprise/6Workstation/
>> en/os/SRPMS/kernel-2.6.32-431.5.1.el6.src.rpm)
>>
>> Doing a bit more research, I've found this is actually happening further
>> up the call stack, before usbfs is ever involved. I noticed this in the
>> kernel log:
>>
>> ioctl32(pcs:32121): Unknown cmd fd(11) cmd(8108551b){t:'U';sz:264}
>> arg(f59b4c50) on /dev/bus/usb/001/079
>>
>> This message is generating from https://git.kernel.org/cgit/
>> linux/kernel/git/torvalds/linux.git/tree/fs/compat_ioctl.c?id=
>> 22763c5cf3690a681551162c15d34d935308c8d7#n2769
>> This is called from inside the compat_sys_ioctl function (
>> https://git.kernel.org/cgit/linux/kernel/git/torvalds/
>> linux.git/tree/fs/compat_ioctl.c?id=22763c5cf3690a681551162c15d34d
>> 935308c8d7#n2857) and is called when the file operations table does not
>> provide a compat_ioctl function and no handler is found. usbfs indeed does
>> not provide this, thus after failing to find a handler it prints this error
>> and as you can see right after returns EINVAL.
>>
>
> Ah yes I see now, and there is a big honking list of compatible ioctls (so
> which are compat without
> needing translation from 32 <-> 64 bit) higher up in the file. Which of
> course does no contain
> the new ioctls. So now we have a different return code when running in
> native 32 bit versus
> when running 32 bits code under a 64 bit kernel how nice (not).
>
> Ok, so treating EINVAL as ENOTTY is going to be the only solution then,
> can you try the
> attached patch?
>
> Thanks & Regards,
>
> Hans
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> libusbx-devel mailing list
> libusbx-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libusbx-devel
>
>
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel