Results 1 to 6 of 6
How does a filename is mapped to its inode ???
If I want to make our own system call and use a filename as argument
how can I get its ...
- 03-07-2010 #1Just Joined!
- Join Date
- Jan 2010
- Posts
- 8
how does filename gets mapped to its inode
How does a filename is mapped to its inode ???
If I want to make our own system call and use a filename as argument
how can I get its inode ,if I want to use some of member of inode structure in code.
Basically I want to get the fd of the file.
- 03-07-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,976
I think the inode is in the directory entry for a file. You can get the inode # of a file and/or directory with the command ls --inode or more simply ls -i
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 03-09-2010 #3Just Joined!
- Join Date
- Jan 2010
- Posts
- 8
Thanks for reply. But the above given command will return only the inode number of the file.
But my requirement is to return the whole of the inode structure with all its members. Is there a way to do the same????
- 03-09-2010 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,976
There are programmatic ways, using C library functions for example. Is that way you need, or are you looking for an existing tool that you can run from a shell?
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 03-09-2010 #5Just Joined!
- Join Date
- Jan 2010
- Posts
- 8
yeah,I am lookiing for C library function to do the job,right now i am going through the kernel source code to find such a funtion,i have come across a structure called (nameidata) which the dcache entry i.e. dentry structure which in turn contains the inode structure.WILL THIS WORK????or there are any other ways to do it????
- 03-09-2010 #6Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,976
You would need to write a kernel module to do that. I'm looking into how you would get inode info from user space. FWIW, each file system type has a different inode structure, so this isn't trivial. If you look in /usr/include/linux/ext3_fs.h you will see the ext3_inode structure which is what I think an ext3 file system keeps on disc. There is also a correlary for all the other file system types, such as ntfs-3g, ext2, xfs, et al. So, this may not be so trivial as you might wish.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote