Every objects (file, directory,etc) in a Unix style file system is represented by an inode. An inode is a data structure which contains information about the file object, such as user and group ownership, access mode (read, write, execute permissions) and type of file etc. An inode is again identified by a inode number, which serves as the index of the inode.
The harddrive or a partition containing a file system usually has three parts, a super block, an area for inodes, and the largest part, blocks for the actual file contents.
The inode number indexes a table of inodes in a known location on the device. From the inode number, the kernel can access the contents of the inode, including the data pointers, and so the contents of the file.
The kernel doesn't really know the name of the file in the file system. All it knows is inodes. The directories (which is a file object itself) translate file names to
inodes. Its contents is a mapping table of file names and corresponing inode.
Some commands can be used to see the inode of a file.
ls -i
example:
# ls -i /etc/passwd
# 32820 /etc/passwd
stat
example
# stat /etc/passwd
# File: `/etc/passwd'
Size: 1988 Blocks: 8 IO Block: 4096 regular file
Device: 341h/833d Inode: 32820 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2005-11-10 01:26:01.000000000 +0530
Modify: 2005-10-27 13:26:56.000000000 +0530
Change: 2005-10-27 13:26:56.000000000 +0530
Again, file name is just a human readable representation of the file. If a hardlink is created on a file, a "ls -l" command will show the file has 2 links, meaning the file has 2 names now. And if a symbolic link is created on a file, a "ls -l" command will show that the file has only 1 link. The symolic link itself is a newly created file, with its contents pointing to the original file. A symbolic link has an inode associated with it.
There are also APIs to manipulated file by inodes. There are mainly for system/application development purpose.
Subscribe to:
Post Comments (Atom)
While surfing the web, i have gone through the word inode which is a new word to me.Is inode developed in embedded systems companies ?Will inode work only in Linux platform?Hope u wuld reply soon
ReplyDeleteRegards
embedded systems development