Page 1 of 1

VFS with conflicting inodes

Posted: Tue Nov 06, 2012 7:01 am
by assainator
Hello all,
ATM, I'm developing a VFS, which is coming along nicely, but I've hit a small though problem.
Say we have two filesystems. A root filesystem and a filesystem mounted to a node in the root filesystem.
How to make sure the inodes of the filesystems don't conflict?
Say both filesystems contain 10 nodes, thus have 11 inodes (root_node.inode = 0), how could I determine to what filesystem they belong?
I could off course add a pointer/ID to/for the filesystem to the VFS internal structures, but isn't the whole idea of an inode that it represents only a single node?

I hope my question is clear enough, thanks a lot in advance.

Re: VFS with conflicting inodes

Posted: Tue Nov 06, 2012 7:47 am
by bluemoon
The inode is meant to be valid within the underlying file system, you are trying to expose that information outside its scope and this is the point causing you trouble.

There are many way to pack(or optimize) multiple information (eg, device id + inode#) into a single entity:
for example, introduce a new entity, VFSNode = ((Device ID & 0xFF) << 56) | (inode & 0x00FFFFFFFFFFFFFF)), or create a struct, you got the idea.

By the way, I do not see why you need to expose that inode number to outside the driver anyway.

Re: VFS with conflicting inodes

Posted: Tue Nov 06, 2012 9:53 am
by Owen
bluemoon wrote:By the way, I do not see why you need to expose that inode number to outside the driver anyway.
man stat(2)

Though note that struct stat contains st_dev to discriminate between devices.