tags:

views:

124

answers:

0

I have 3 questions:

  1. I want to figure out if a file belongs to a USB device given the file inode. By looking in the latest kernel sources (2.6.33) on LXR, I think one can find that information by following pointers as follows: inode->super_block->block_device->backing_dev_info->device->device_driver(or device_type). However, the kernel that I am working with - 2.6.22.14 - does not have struct device pointer in the backing_dev_info object. So how can I figure out to which device does a file belong to from just the inode? I see that each of the inode, super_block and block_device contain an object of type 'dev_t'. But even after searching a lot, I could not find out how to convert 'dev_t' into struct device *. Is there any way to get that infomation?

  2. I tried to print device major and minor numbers using imajor(inode) and iminor(inode). However, for every file - belonging to hdd or usb - it always prints major and minor number as zero. Why would that be happening?

  3. I searched online for USB major numbers and I found out that major number for a USB is 180. However, on multiple machines, it showed me the major number associated with the USB dev as 253.

$ ls -ltr /dev/usb*

crw-rw---- 1 root root 253, 4 2010-04-13 17:20 /dev/usbmon4

crw-rw---- 1 root root 253, 3 2010-04-13 17:20 /dev/usbmon3

crw-rw---- 1 root root 253, 8 2010-04-13 17:20 /dev/usbmon8

crw-rw---- 1 root root 253, 5 2010-04-13 17:20 /dev/usbmon5

crw-rw---- 1 root root 253, 1 2010-04-13 17:20 /dev/usbmon1

crw-rw---- 1 root root 253, 7 2010-04-13 17:20 /dev/usbmon7

Why is that so?