|
OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
list open files - fstat?
I am trying to find the list of open files for a process. I did a search and found:
http://lserinol.blogspot.com/2009/01...n-freebsd.html I figure that I should be able to use fstat. However, it does not display the file's name. According to the name page there should be a 'NAME' column. From the man page: ... The following fields are printed: ... NAME If filename arguments are specified and the -f flag is not, then this field is present and is the name associated with the given file. Normally the name cannot be determined since there is no mapping from an open file back to the directory entry that was used to open that file. Also, since different directory entries may reference the same file (via ln(1)), the name printed may not be the actual name that the process originally used to open that file. ... Not sure how to get it to display any file names. I tried using "-f" and a mount point or directory, but does not make a difference; no name column is displayed. I also tried as root, to ensure that there is no permission problem. I also used the search for the forums here, but nothing came up. Am I misreading the man page? |
|
|||
It simply isn't practical to reverse the name of a the inode without traversing through the entire filesystem hierarchy.. inode numbers can obviously conflict.
The inode does NOT contain the filename, as there can be many references, or hard "links" to a file. A lot of people don't realize that directory inodes are special, this where name mappings for inodes are stored. Once you have the inode, you can use find -inum or ls -i to locate it. Last edited by BSDfan666; 31st August 2011 at 03:56 AM. |
|
|||
Thanks for the information.
Yes, I prefer to be as stock as possible. It seems silly to add unnecessary software when not needed. Also, it seems wise to know what is provided in the base in case one is stuck with just the base system. Seems counter intuitive that the name is supplied only when one specifies the path. Good point about the inode and the mapping. Good to know that "fstat" and "find" will give the actual files open by a process. From what I tested, it can be quite slow using find if there are a lot of files on the mount. I found '-x' argument to 'find' reduce the time dramatically. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
List of 4.7 packages? | guitarscn | OpenBSD Packages and Ports | 5 | 23rd August 2010 05:37 PM |
Can't open PDF files, FBSD 7.2-release | Mantazz | FreeBSD Ports and Packages | 7 | 24th December 2009 01:10 PM |
How to get a list of volumes? | PeterSteele | Programming | 12 | 17th July 2008 09:32 AM |
How to view & open DOCX files in Ubuntu/OpenOffice. | unixdude | Other BSD and UNIX/UNIX-like | 0 | 11th July 2008 08:38 AM |
fstat | grep internet | grep -v -e '>' -e '<' | mfaridi | OpenBSD General | 4 | 10th June 2008 09:58 PM |