Hi Friends,
I am new to this forum.
Can any one tell me, how to access an inode using c program.
What are all the header files, functions(APIs) and libraries etc required to do that.?
Any help on this is appreciated.
Thanks in advance.
Normally, you just open the raw device and parse the information that is specific to the filesystem. Opening the raw device is OS specific, and parsing the inode information is filesystem specific. So there's no general answer to your question.
Usually UNIX systems are picky about using an inode to reference a file for reading or writing -specifically because it bypasses security. If that is what you want it may be a problem.
You will have to use direct I/O - in other words, write a driver or (what Otheus is telling you) to do physical (sometimes called direct) I/O to a disk to retrieve the inode object.
This means you will have to understand filesystem internals.
What exact data are you after in the inode?
This question falls under the category "if you have to ask, you cannot afford it".
Thanks for the reply... Friends.
Actually i tried to dig how find command works in unix. In that i come to that i traverses all the inode for the directory. I also downloaded one inode accessing 'c' program too. But for that i need some Linux source code and libraries too. So, i am not sure how and where i can get the one.
So, Can any one guide me to get library for compling linux source code.
Or suggest me good links to compile a linux source code. I think that could solve the problem.
Thanks in advance.
Oh. You probably want to look into opendir(), readdir(), -- look at dirent.h also.
This gives you the inode number. stat() gives you what find uses to select files.
See /usr/include/sys/stat.h
Thanks a lot for the reply
!!
Actually i saw the Linux kernel source code for how the inode is handled.
I want to dig more on that. I am really interested in digging that code.
Can any one pls, suggest me the good tutorials for how to compile and partially (i mean taking only inode.c file alone and compile it). Also good tutorials for inode too.
Any help is appreciated...
inode.c from the linux kernel is not a standalone program. In fact, most individual C files, kernel or not, are not standalone programs. inode.c outside the kernel won't work because kernel code needs to be executed inside the kernel and needs things from other C files to work.
What, precisely, do you think fiddling with inodes will help you do? What do you want howto's on? I'm suspecting there's some confusion on the topic here.
An inode is essentially a unique number given to each file inside a partition. This number is only useful outside the kernel for comparison purposes, i.e. to see if two different filenames are hardlinked.