Inode table storage

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
LPeter
Member
Member
Posts: 30
Joined: Wed Jan 28, 2015 7:41 am

Inode table storage

Post by LPeter »

Hi!
I'm implementing the VFS and I've come to a problem: I don't know how to store the inodes. As far as I understand, I can have multiple filesystem nodes for a single file, but only one inode. So I guess I need to store the inode in some kind of table. But how big the inode table should be? What index the file should be at? I tried to look at the linux source but it's way too compilcated. Could you give me some advice?
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

Re: Inode table storage

Post by mariuszp »

The inodes are stored on disk, your filesystem driver just has to read them and convert into a common VFS format. Inodes are numbered, and that's how they are distinguished.

A file inode points to the file's data on disk. A direcotry inode points to a list of "directory entries" (you can think of directories as files that store directory entries). A directory entry contains a name, and an inode number so that you can find the file.

The root directory is defined to have a specific inode number; 2 for ext2. So to find the file /hello/world, you first read inode 2 (root directory), scan through the directory entries to find "hello" and its inode number, you then read that inode, scan throuh its directory entries to find "world", and then load its appropriate inode.

Hope that helps
Post Reply