How to see actual filename that File Descriptor is pointing to for a given processID?


 
Thread Tools Search this Thread
Operating Systems Solaris How to see actual filename that File Descriptor is pointing to for a given processID?
# 8  
Old 12-07-2010
I just tried 'file' command. It simply says if its 'data' or 'ascii text'.

I don't have access to 'procfiles' command, if someone has access to that comand I would like to see what they see for FDs that point to disk but not the actual file.

Last edited by kchinnam; 12-07-2010 at 03:38 PM.. Reason: clarification
# 9  
Old 12-07-2010
So you have the process, the file descriptor and the file content. What are you missing ?

And what is this "procfiles" command you are referring to ? If it is the AIX one, /usr/proc/bin/pfiles is the equivalent on Solaris.
# 10  
Old 12-07-2010
Solaris also has "find /export -mount -ls" displaying inode on the front, so you can identify the file name from the inode #, if it is still linked to any dir. (slow, but . . . .).

And if you think it is being written, there is "truss -wall -p" to show you what it is writing.
# 11  
Old 12-07-2010
I made some progress. Answer for my question is this command.
Code:
 
$> find / -inum <[I]NODE> -print 2>/dev/null 
/export/<full_path>/<filename>
/proc/<PID#>/fd/<FD#>
/proc/<PID#>/object/ufs.85.3.<INODE#>

Following command simply proves relation between FD and PID.
Quote:
$> pfiles -F <PID>
Now my problem is it took close to 3 minutes to finish that one find command.
I am planning to do this for all FD#s for all PID#s on the system.

Is there way to get that quicker!?
How can I only get actual filename and not other two entries from /proc/<PID#>/..?
# 12  
Old 12-08-2010
So you mean lsof doesn't show the filename for a given inode number pair, but find found a real pathname for the same inode ?
# 13  
Old 12-08-2010
I do not have lsof to play with this month, so I am working from memory, but I thought it used to show me paths. I can see the path info can be difficult/expensive to acquire in some cases, especially the deleted dir entry case where there may be none, so I can roll with a inode-device display for speed.

If this is your own process, you can truss it from the start and know what each fd is, and what it is up to.
# 14  
Old 12-08-2010
It is a security feature, for one thing. It prevents literally any other process (not part of the process tree if fd's are shared parent->child ) from being able to open the file, get the filename or to perform read or write or open on file contents.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Actual SQL instead of using a file from within a shell script

I am very noobish to UNIX, our guy is on vacation so I am trying to take up some slack while he is away. Typically when we use sql from within a shell script, we do so from a file containing the sql. Example: $ORACLE_HOME/bin/sqlplus $ORA_DBCU/$ORA_DBCP @${cron_dir}/${report_file}.sql ... (10 Replies)
Discussion started by: biobill
10 Replies

2. Shell Programming and Scripting

redirecting with file descriptor

hello, Someone can help me with redirectors? I am writing this script in bash enviroment on Fedora: exec 4<> /dev/tcp/10.10.11.30/5000 #open socket in input/output strings<&4 >file.txt & I send file descriptor 4 to string command to purge data stream from special char while come from... (3 Replies)
Discussion started by: rattoeur
3 Replies

3. Shell Programming and Scripting

Unlink and copy actual file

Hello, I have a set of directories, which has inside them, symbolic links to some files. What i would like to do is to covert the links into actual files, i.e. remove the link and copy the actual file here... I tried to see unlink command but i think all it does is delete the link, is... (2 Replies)
Discussion started by: prasbala
2 Replies

4. Solaris

Before I delete any file in Unix, How can I check no open file handle is pointing to that file?

I know how to check if any file has a unix process using a file by looking at 'lsof <fullpath/filename>' command. I think using lsof is very expensive. Also to make it accurate we need to inlcude fullpath of the file. Is there another command that can tell if a file has a truely active... (12 Replies)
Discussion started by: kchinnam
12 Replies

5. Shell Programming and Scripting

Open the file and replace the variable with actual value

Hi, i have a sql file named sample.sql. The query is given below. select count(*) from $TABLE_NAME In the main script, i am sourcing this sql. I need to replace the $TABLE_NAME with actual value, before running the query. How can i achieve that? The logic i tried is given below:... (3 Replies)
Discussion started by: bharathappriyan
3 Replies

6. Shell Programming and Scripting

How to create a user interface pointing to a file?

I have to create a user interface in which user can easily update ,delete or insert a new record which is pointing to a file in AIX Server? Using awk,sed ican update ,modify the file. how to create a link to userlike GUI(without using Tomcat,IIS) (3 Replies)
Discussion started by: laknar
3 Replies

7. UNIX for Dummies Questions & Answers

File Descriptor

Hi What the below path contains? /proc/<pid>/fd (1 Reply)
Discussion started by: siba.s.nayak
1 Replies

8. Shell Programming and Scripting

File Descriptor

Hello All, Im opening a file desciptor in perl and sending data using print CMD "$xyz". is there a limit to the length of the string that I can give to this CMD at a time. (3 Replies)
Discussion started by: rimser9
3 Replies

9. UNIX for Dummies Questions & Answers

File Descriptor Help

What is a file descriptor in Unix?? How to find a file descriptor of a file in Unix?? Does it have anything to do with the Inode numbers?? (3 Replies)
Discussion started by: rahulrathod
3 Replies

10. UNIX for Dummies Questions & Answers

file activity (open/closed) file descriptor info using KORN shell scripting

I am trying to find a way to check the current status of a file. Such as some cron job processes are dependent on the completion of others. if a file is currently being accessed / modified or simply open state I will wait until it is done being processed before attempting the next process on that... (3 Replies)
Discussion started by: Gary Dunn
3 Replies
Login or Register to Ask a Question