Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

How can I get only FileName associated with a INODE on Unix much faster?

Shell Programming and Scripting


Tags
filedescriptor, filename, find, inode

Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 12-07-2010
kchinnam kchinnam is offline
Registered User
 
Join Date: Jul 2008
Last Activity: 7 July 2015, 12:02 AM EDT
Location: US
Posts: 153
Thanks: 19
Thanked 2 Times in 2 Posts
How can I get only FileName associated with a INODE on Unix much faster?

How can I get only FileName associated with a INODE on Unix[solaris8] in seconds instead of minutes, as it is the case for me as shown below.


Code:
 
# Say I have FileDescriptor: 43, INODE: 2590784, File: abc.rdb. I want to get only filename associated with inode:2590784 and FD:43.
$> time find / -inum 2590784 -print 2>/dev/null 
/export/<full_path>/abc.rdb      # This is what I want in seconds or milliseconds.
/proc/4012/fd/43                 # Where 4012 is PID
/proc/4012/object/ufs.85.3.2590784
 
real    2m26.91s
user    0m2.23s
sys     0m30.29s

Sponsored Links
    #2  
Old Unix and Linux 12-07-2010
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
 
Join Date: Dec 2007
Last Activity: 23 May 2015, 9:51 AM EDT
Posts: 1,141
Thanks: 2
Thanked 90 Times in 87 Posts
try adding the -xdev option assuming the file is on /
Sponsored Links
    #3  
Old Unix and Linux 12-07-2010
kchinnam kchinnam is offline
Registered User
 
Join Date: Jul 2008
Last Activity: 7 July 2015, 12:02 AM EDT
Location: US
Posts: 153
Thanks: 19
Thanked 2 Times in 2 Posts
with -xdev whatever output I was getting earlier disappeard. So that can't be it.

I am wondering if my problem requires something like a C-shell program that talks to Unix kernel.

Last edited by kchinnam; 12-07-2010 at 11:42 PM..
    #4  
Old Unix and Linux 12-07-2010
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
 
Join Date: Dec 2007
Last Activity: 23 May 2015, 9:51 AM EDT
Posts: 1,141
Thanks: 2
Thanked 90 Times in 87 Posts
you must have missed my "assuming the file is on /" comment.

try

Code:
time find /export -inum 2590784  -xdev -print 2>/dev/null

you can also add -fstype ufs (or whatever your using) to avoid traversing the proc file system. your searching my inode so if you use / it will search all file systems. I suggest you limit your search to the file system that has your file.

Last edited by frank_rizzo; 12-07-2010 at 11:48 PM.. Reason: add comment
Sponsored Links
    #5  
Old Unix and Linux 12-08-2010
kchinnam kchinnam is offline
Registered User
 
Join Date: Jul 2008
Last Activity: 7 July 2015, 12:02 AM EDT
Location: US
Posts: 153
Thanks: 19
Thanked 2 Times in 2 Posts
Thanks Frank, that helped. I am getting it in around 16seconds.


Code:
 
$> time find /export -inum 2590784  -xdev -fstype ufs -print 2>/dev/null
/export/<full_path>/abc.rdb
 
real    0m16.28s
user    0m1.56s
sys     0m13.36s

Sorry for being too greedy, are there any other ideas to make this more quick? Since I may have to get this output for about 1000+ INODEs that are active in the runtime?
Sponsored Links
    #6  
Old Unix and Linux 12-08-2010
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
 
Join Date: Dec 2007
Last Activity: 23 May 2015, 9:51 AM EDT
Posts: 1,141
Thanks: 2
Thanked 90 Times in 87 Posts
Quote:
Originally Posted by kchinnam View Post
Sorry for being too greedy, are there any other ideas to make this more quick? Since I may have to get this output for about 1000+ INODEs that are active in the runtime?
it's an expensive search. if the files are relatively static you might be able to build an index file mapping the nodes to paths and then just grep the inode out of that file. just a quick thought.
Sponsored Links
    #7  
Old Unix and Linux 12-08-2010
michaelrozar17's Unix or Linux Image
michaelrozar17 michaelrozar17 is offline
Registered User
 
Join Date: Jul 2010
Last Activity: 15 June 2015, 2:01 AM EDT
Location: IN
Posts: 892
Thanks: 14
Thanked 182 Times in 173 Posts
You could specify the type of file (in case your aware)(-type) in the find command. So that it filter only the type of files you look for and save a few seconds..just another thought Linux
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
inode filename wowman UNIX for Dummies Questions & Answers 2 01-17-2010 08:53 AM
How to get the filename of which has been deleted if I know the inode number? JoyOnLine AIX 3 11-27-2009 09:05 AM
SCO Unix inode structure. rbn UNIX for Dummies Questions & Answers 4 05-26-2007 09:49 AM
How to map a disk block to filename/ Inode Balamurugan Solaris 1 03-21-2005 01:39 PM
UNIX Filename length restrictions? xmeh UNIX for Dummies Questions & Answers 2 06-28-2002 03:14 PM



All times are GMT -4. The time now is 07:03 AM.