1833189 Members
2992 Online
110051 Solutions
New Discussion

inode question

 
SOLVED
Go to solution
Robert Fisher_1
Frequent Advisor

inode question

Hello experts,

Where in the inode is the name of the file stored? I have looked in /usr/include/sys/inode.h and I can't seem to find the file name anywhere. What am I missing? Please answer quickly because I'm asking for someone else.

TIA,
Bob
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: inode question

Well Bob, you wanted a quick answer: You don't on account of it ain't there.
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: inode question

I suppose I ought to elaborate just a bit. You have the tail wagging the dog or the cart before the horse. The filename is not stored within the inode --- and remember, multiple filenames can share a common inode. The directory entry stores the name of the file AND the inode number so that many directory entries within the same filesystem can have the same inode number. Indeed, this is the mechanism underlying "hard" links.
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: inode question

Hi Bob:

...and to add to Clay's comments, the inode number of a mounted directory is always two (2)...a rather useful thing.

Regards!

...JRF...
NMory
Respected Contributor

Re: inode question

Robert:

You can check this as a reference.

http://en.wikipedia.org/wiki/Inode

LN
NMory
Respected Contributor

Re: inode question

Bob:

To be more specific...you won't find the filename in there...

LN
florin_10
Frequent Advisor

Re: inode question

...and adding to Clay's and JRF comments. A directory is just a simple relational data base containing a list of names and inode(index node). Many names(file names via hard links) can point to same inode, however the number of names pointing to same inode is limited. Therefore removing(unlinking) a name(hard link) will not remove the inode. When the last name asscociate to that inode is removed(unlinked) than that inode becomes available to the system. Another thing, cause different names(h/l) can point to same inode no hard links can cross file systems, and of course as it was said no h/l can be done to a dir(only the kernel can) only soft links.
Regards,
Florin