Question: How do you find out what physical file is actually open?
Answer: You need to take several steps in order to get the answer. The steps are:
1. Convert the Device number into a useable Major and Minor device.
The Device is displayed as a decimal number such as "2621442" which doesn't really mean much until you dissect it. First off, convert this to a Hexadecimal number. The result, 0x280002, is the actual UNIX major and minor device number with the leading zeroes stripped. Take the last 4 digits and convert from Hex to Decimal to get the minor number, then use the remaining digits and convert from Hex to Decimal to get the major device. Thus, "2621442" actually converts to Major Device 40, Minor Device 2.
2. Find out which device names match this Major/Minor number
Armed with this information, go to your /dev directory and do an "ls -l" and you'll see that the display is something like
[quote][/quote]
Code: Select all
brw-rw---- 1 root system 10, 9 Jul 05 10:27 hd1
brw-rw---- 1 root system 10, 10 Jan 06 2005 hd10opt
brw-rw---- 1 root system 10, 6 Jan 06 2005 hd2
brw-rw---- 1 root system 10, 8 Apr 20 2005 hd3
brw-rw---- 1 root system 10, 5 Jul 05 16:38 hd4
brw-rw---- 1 root system 10, 1 Jul 24 00:00 hd5
brw-rw---- 1 root system 10, 2 Jan 06 2005 hd6
brw-rw---- 1 root system 10, 4 Jan 06 2005 hd8
The columns just before the date list the major and minor device, i.e. for "hd10opt" the value is "10, 10". There can be several devices with the same major, minor number.
3. Get the mount path that corresponds to this device name.
Use the mount command to get the list of mounted devices. Only one of the names list from the previous command will match a mounted device.
Code: Select all
mount | grep hd10opt
/dev/hd10opt /opt jfs Jul 23 01:22 rw,log=/dev/hd8
The 2nd column of the output, in this case "/opt" shows you the mounted path. We are almost finished!
4. Use the find command to find the inode on that mount point
Use the find -inum command to get the actual filename. The syntax on AIX is "find {Result from #3.} -inum {inode number} -xpath 2>/dev/null" and it will return the one line that contains the fully qualified path to the file with that inode or no lines if the inode doesn't exist. The find command needs to traverse and search for the inode, so this can take several seconds or even longer on a big file system.
As far as I know these steps need to be done, but I'd welcome any more efficient approach that doesn't involve looking through the /dev and mount points.
</a>