Find the answer to your Linux question:
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just 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.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,397
    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!

  3. #3
    Just 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????

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,397
    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!

  5. #5
    Just 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????

  6. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,397
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •