From: Greg KH To: torvalds@transmeta.com Cc: linux-usb-devel@lists.sourceforge.net Subject: [PATCH 15 of 16] USB usbfs filesize fix Hi, Here's a patch against 2.5.3-pre3 for the that fixes the bug where the size of the usbfs device file was being reported as 0. thanks, greg k-h diff -Nru a/drivers/usb/inode.c b/drivers/usb/inode.c --- a/drivers/usb/inode.c Tue Jan 22 12:54:25 2002 +++ b/drivers/usb/inode.c Tue Jan 22 12:54:25 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();