indoe to file name
I have the a files i-node number (stat struct) from which I want to get it filename or pathname (any thing useful so that i can open or close this file).
thanx -neo |
I'm unsure if this is even possible. The reason I believe this is because a single inode can have tons of links to it. How would you know which one to get?
Of course, I am probably way off base... I just noticed this thread has been sitting around for a while. |
Each file is defined by an i-node (so far, so good)...
... but the "name" of a file is stored in a directory - it is *not* associated with the inode itself. This is how the Linux "link" command works: it simply associates a different name with the inode. And all links are equal: it isn't as though one name is the "real" name and the rest are aliases. Anyway, in *nix, a "file name" (or "names"!) is a property of the filesystem's directories. There's no such thing as "the file name of an inode". 'Hope that helps .. PSM PS: If it doesn't help - or if you're curious - get a copy of Tanenbaum's classic "Operating Systems". He discusses the topic in depth. |
I was totally wrong... i did go back opened my book (richard steven) to see how the inode structure actually is and you were right it is not directly associated with filname(s) [ i mean inode of a flename],
But what i was trying there, was to have a unique identifier for each of my files. So that i can call them by this identifier even when they are renamed or move to a different location and the first thing that came to my mind was inode. well i guess i will have to create my own unique identifiers and keep track of those or may be use file pointers. thanx for all the help neo |
What you said does make sense. I can find the inode number from a file name, but why I can't reversely find the file name from the inode. I just think aloud here. I have a stupid idea to do that. Searching the inode table (whatever the name), and find out which directory owns this inode. Then go through every file under this directory until find the certain inode.
|
Quote:
|
a live sample,
Code:
ls -il /usr/bin/ksh /usr/bin/rksh if you branch out from inode to filenames you have two different filenames for the same inode |
All times are GMT -5. The time now is 07:33 AM. |