Bug 193338

Summary: vfs_mountroot_shuffle sets wrong mnt_stat.mntonname
Product: Base System Reporter: Denis V. Meltsaykin <dvm.avgoor>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Some People    
Priority: ---    
Version: 10.0-STABLE   
Hardware: Any   
OS: Any   
Description Flags
patch none

Description Denis V. Meltsaykin 2014-09-05 09:28:02 UTC
Created attachment 146853 [details]

In case if you have configured /.mount.conf with several rootfs options like (for example):

.md /mfs_root.lz readonly
.timeout 3

after fail at first rootfs kernel proceeds to next and loads it correct. But after loading system there are wrong options in mounted filesystems:

/dev/ufs/failsafe on / (ufs, local, read-only)
/dev/ufs/bootfail on /.mount (ufs, local, read-only)
/dev/ufs/boot on /.mount (ufs, local, read-only)

And a real ufs/boot is under /.mount/.mount/ instead of /.mount 
In this case you can't unmount it or remount to RW. Underlying filesystems become useless. This happens because of vfs_mountroot_shuffle() sets mporoot->mnt_stat.f_mntonname unconditional, despite the real FS hierarchy.

I have attached something looks like a patch, please review it. I hope it will help.
Thank you.