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?
Inode table storage
Re: Inode table storage
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
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