On Wed, Nov 13, 2024 at 10:46:32PM +0100, Reinoud Zandijk wrote: > > Whats the point of /altroot? hier(7) says "Alternate root file system, > > in case of disaster." Is there a way to boot such that / is not inode 2, > > but that of altroot? > > Speaking of which, does NetBSD VFS code grok multiple vnodes on a > device marked with VV_ROOT that are not connected to eachother by > directories? I'd like to use that feature in my SFS code to > represent multiple mount points on a single device. I haven't tried > it out but at first glance it does seem to be legal. > > Has anyone tried this before?
We don't support more than one mount point per filesystem volume (in the sense that struct mount is both the mount point and the anchor for the global volume state like the in-memory superblock and such)... so if you want to have multiple mount points they end up being separate volumes as far as the VFS logic is concerned. They'll need to share any joint state under the covers. This means each one will have its own vnodes, and therefore its own distinct root vnode. Each of those root vnodes belongs to its own struct mount, and nothing unusual happens. So it'll all work in that sense. Ultimately this is what nullfs does. In principle we could improve the VFS code to distinguish mounts from volumes (there are various reasons to do this, in fact) but nobody's ever been all that enthusiastic about it and it's not likely to happen soon. And that doesn't by itself let you have fses with multiple entry points, unless the subvolumes (or at least the subvolume namespaces) are strictly disjoint. (If you just tag multiple vnodes VV_ROOT, what happens if one is a subdir of another? E.g. if you have a /usr volume with two entry points, one for all of it (/usr) and one for the "pkg" subtree (/usr/pkg) so you can also mount your packages somewhere else... and if you mark both the /usr and /usr/pkg vnodes with VV_ROOT, it's not obvious exactly what'll happen, but one likely possibility is that cd /usr/pkg && cd .. will put you in /.) (But also, look into what exactly happens when you mount FFS snapshots.) -- David A. Holland dholl...@netbsd.org