So, I can mount sysfs (the virtual filesystem for /sys) for example at multiple places, and I'll see the same contents each time. Similarly, I can mount the same block device (like /dev/sda1) at multiple mount points.
I'm writing a VFS for my kernel at the moment, and I'm struggling with the specifics of how mount-point dentries are attached to parts of the filesystem.
So my question is: Are the dentry structs used to represent a (for example) sysfs filesystem at (for example) /mnt the same structs used if I mount sysfs again at /mnt2? Or, alternatively, are these structs different?
If they are different, are the inodes shared?
The dentries are shared. Each filesystem root dentry is stored in the corresponding superblock struct, and these structs are linked to mountpoint dentries using vfsmount structs.
Have a look a fs/super.c for the details.