On Mon, Jan 21, 2002 at 01:14:57PM -0800, David Brownell wrote:
> > > $ ls -l /proc/bus/usb/001/
> > > total 2
> > > -rw-r--r-- 1 root root 0 Jan 21 10:06 001
> > > -rw-r--r-- 1 root root 0 Jan 21 10:15 002
> > >
> > > It should be (size = 18)
> >
> > Why should it be 18, just because a previous kernel said so? :)
>
> And rather than 18, shouldn't it be instead
>
> size of device descriptor (18)
> + size of current config's descriptors (variable)
>
> If its not going to be an obvious lie, I'd rather it be correct ...:)
Good point. Here's a patch against a clean 2.5.3-pre2 that sets the
filesize to the same amount of data that you can get if you do a read()
on the file.
Does anyone object to this one?
thanks,
greg k-h
diff -Nru a/drivers/usb/inode.c b/drivers/usb/inode.c
--- a/drivers/usb/inode.c Mon Jan 21 14:11:40 2002
+++ b/drivers/usb/inode.c Mon Jan 21 14:11:40 2002
@@ -678,6 +678,8 @@
void usbfs_add_device(struct usb_device *dev)
{
char name[8];
+ int i;
+ int i_size;
sprintf (name, "%03d", dev->devnum);
dev->dentry = fs_create_file (name,
@@ -687,6 +689,17 @@
devuid, devgid);
if (dev->dentry == NULL)
return;
+
+ /* Set the size of the device's file to be
+ * equal to the size of the device descriptors. */
+ i_size = sizeof (struct usb_device_descriptor);
+ for (i = 0; i < dev->descriptor.bNumConfigurations; ++i) {
+ struct usb_config_descriptor *config =
+ (struct usb_config_descriptor *)dev->rawdescriptors[i];
+ i_size += le16_to_cpu (config->wTotalLength);
+ }
+ if (dev->dentry->d_inode)
+ dev->dentry->d_inode->i_size = i_size;
usbfs_update_special();
usbdevfs_conn_disc_event();
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel