On Mon, 4 Sep 2006, Siddharth Choudhuri wrote: > > > I am trying to implement a kernel module that can > > > track read/write requests to a USB-mounted flash > > > device (say, mounted as FAT filesystem). > > > > When you say "track", exactly what do you mean? > > Like Luiz said, usbmon > > will produce a log of all USB messages; is that what > > you want? > > > By track what I mean is, a log that monitors all data > read/write activities from/to the usb-flash drive.
You can't implement this with a new kernel module. But you can implement it by modifying an existing module, like usb-storage or sd_mod. > Something like a tuple [R/W, sector number, size] that > can capture all usb-flash drive data traffic. I think > where I am confused is trying to figure out the sector > number (or the address being sent to the flash drive > by the lowest level of software that interfaces with > the flash's controller). For eg: if a process writes X > bytes of data to a file that resides on usb-flash > drive; somewhere in the low level driver, this request > would be converted to an [address, buffer] that is > sent to flash controller ? This conversion takes place partially in the VFS layer, which is definitely _not_ the lowest level of software that interfaces with the device. VFS converts the file offset into a location relative to the start of the partition, and then the gendisk layer converts that into a location relative to the start of the device (a sector number). If you want to get this information, you're probably better off getting it at the point where it is sent to the device, not at the points where the conversions are made. For example, take a look at sd_init_command() in drivers/scsi/sd.c. > I looked at the struct scatterlist. How can I get the > address to where data is read/written from this > structure ? Your use of words is very confusing. "Address" generally means a location in the computer's memory, but you seem to be using it to mean a location in the flash device's memory. Instead you should call the device-location a "sector" or a "block". The scatterlist structure contains the address where the data will be stored in the computer's memory, in its "page" and "offset" members. It does not contain the sector or block number. Alan Stern ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel