VFS with conflicting inodes

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
assainator
Member
Member
Posts: 30
Joined: Sun Jan 24, 2010 1:12 am
Location: The Netherlands

VFS with conflicting inodes

Post 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.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: VFS with conflicting inodes

Post 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.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: VFS with conflicting inodes

Post 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.
Post Reply