keener@upenn5.hep.upenn.edu (Paul T. Keener) (05/11/89)
Is there anyway to find the filename of a file given the inode that it is on other than to search through the filenames for it? I am running Sun OS 4.0 Thanx. -paul keener@upenn5.hep.upenn.edu / Anyone who cannot cope with mathematics is not keener@penndrls.upenn.edu / fully human. At best he is a tolerable subhuman keener@penndrls.bitnet / who has learned to wear shoes, bathe and not make / messes in the house. -L.L.
keener@upenn5.hep.upenn.edu (Paul T. Keener) (05/11/89)
In article <10993@netnews.upenn.edu> keener@upenn5.hep.upenn.edu (Paul T. Keener) writes: >Is there anyway to find the filename of a file given the inode that it is on >other than to search through the filenames for it? I am running Sun OS 4.0 >Thanx. > I guess a should have mentioned that I want to do this from inside a program and must be relatively fast. ie find / -inode foo -print is NOT what I am am looking for. -paul keener@upenn5.hep.upenn.edu / Anyone who cannot cope with mathematics is not keener@penndrls.upenn.edu / fully human. At best he is a tolerable subhuman keener@penndrls.bitnet / who has learned to wear shoes, bathe and not make / messes in the house. -L.L.
jik@athena.mit.edu (Jonathan I. Kamens) (05/12/89)
In article <10993@netnews.upenn.edu> keener@upenn5.hep.upenn.edu (Paul T. Keener) writes: >Is there anyway to find the filename of a file given the inode that it is on >other than to search through the filenames for it? I am running Sun OS 4.0 >Thanx. Yes. "ncheck -i <inode number> <filesystem device>" run as root. Jonathan Kamens USnail: MIT Project Athena 410 Memorial Drive, No. 223F jik@Athena.MIT.EDU Cambridge, MA 02139-4318 Office: 617-253-4261 Home: 617-225-8218
guy@auspex.auspex.com (Guy Harris) (05/12/89)
>>Is there anyway to find the filename of a file given the inode that it is on >>other than to search through the filenames for it? I am running Sun OS 4.0 >>Thanx. > >I guess a should have mentioned that I want to do this from inside a program >and must be relatively fast. ie find / -inode foo -print is NOT what I am >am looking for. (Well, "find / -inode foo -print" "searches through the filenames", so presumably nobody'd suggest that if they'd read your original article carefully.) Unfortunately, there really isn't a way to find all the names (yes, plural, potentially) for a file given the file system on which it resides and its i-number other than "searching through the filenames". If you know what directory it resides in, or at least what directories it could reside in (and that set is small), it's a bit easier; you can scan through those directories and "stat" each file in that directory and compare "st_dev" and "st_ino". If you know you're running on a system where the directory-reading routines will give you the i-number of a file as part of its entry (the UNIX systems with which I'm familiar do this; however, it's not guaranteed by POSIX, so there could conceivably be systems that don't), you might be able to skip the "stat" part (although you'd have to check for stuff mounted on directories within the directories you're searching). For example, "ttyname" uses this trick, since it knows that your tty is supposed to be in "/dev"; if it's not, you lose. (If it's not a tty, you lose, too, but "ttyname" isn't supposed to find names for things that aren't ttys.)
jpr@dasys1.UUCP (Jean-Pierre Radley) (05/18/89)
In article <10993@netnews.upenn.edu> keener@upenn5.hep.upenn.edu (Paul T. Keener) writes: >Is there anyway to find the filename of a file given the inode that it is on >other than to search through the filenames for it? I am running Sun OS 4.0 Why would you have the NUMBER but not the name of a file? Output of 'fsck', perhaps? Anyway, try: find / -inum NUMBER -print (If there's more than one mounted filesystem, you may turn up more than one name, corresponding to NUMBER on different drives' inode-tables.) -- Jean-Pierre Radley CIS: 72160,1341 jpr@jpradley.UUCP
rikki@macom1.UUCP (R. L. Welsh) (05/19/89)
>>other than to search through the filenames for it? I am running Sun OS 4.0 > Do you have ncheck? Try: /etc/ncheck -i xxxx -- - Rikki (UUCP: grebyn!macom1!rikki)
bob@consult.UUCP (Bob Willey) (05/21/89)
In article <9697@dasys1.UUCP> jpr@dasys1.UUCP (Jean-Pierre Radley) writes: >In article <10993@netnews.upenn.edu> keener@upenn5.hep.upenn.edu (Paul T. Keener) writes: Try ncheck -i inode (replacing inode with the number) (i.e. ncheck -i 3455 ) Hope this helps.