Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Mar 1998 15:13:37 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, dima@tejblum.dnttm.rssi.ru
Cc:        committers@FreeBSD.ORG, mike@smith.net.au
Subject:   Re: dumb question about fstab and 226 beta
Message-ID:  <199803160413.PAA04641@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help

>> The problem here is probably that the slice alias breaks fsck's `hotroot'
>> calculation in blockcheck().  After fsck finishes writing to the cdev
>...
>You are right, of course. This trivial bogus patch fixes my test 
>case.
>...
>It is funny how various programs trust the root device in fstab, while true 
>root device stored in kernel and cannot be changed while the system run. 

This shows that trivial bogus patches :-) in utilities are the wrong way
to fix the problem.  The kernel could pretend that requests to mount sd0a
are really requests to change the kernel's idea of the root device from
sd0sNa (sN = first BSD slice) to sd0a in just a few cases.  mount(8) and
fsck(8) can't even tell the correct value of N.  It is easy to demonstrate
breakage of the current hack in mount using an exotic setup:

	labeled non-BSD slice sd0s1
	first BSD slice       sd0s2

Then requests to mount sd0a will attempt to mount sd0s1a instead of the
correct sd0s2a.

Another indication of the problem is that df after booting with -s shows
the root device as "root_device", so it is difficult to determine the
correct device to type for `mount -u /' if the device in fstab is wrong.

>It is possible obtain the dev_t of root device via stat(2), so 
>mount_ufs.c probably could test that the user-supplied device name 
>match kernel's idea, and if not, determine correct device name with 
>devname(3) :-|. (This way it should wait (in background) until devname(3) 
>available. It also could upgrade root to read-write without device name). 
>Such mount would be more tolerant to various user's mistake :-).

The problems can be limited to the root device by not rewriting the
device name except for mounting root.  mount(8) already handles this
specially.  It adds MNT_UPDATE to the flags if the mount point is "/".
Since the kernel says that the device name is "root_device", remounting
that should work :-).  "root_device" is a dummy name generated by
vfs_mountrootfs() and returned by statfs().  I can easily make statfs()
return the actual device name (as formatted by dsname()), since my
fix for the wrong name being printed in setroot() involves passing
the device name up to vfsmountrootfs() so that it can be printed later.

>I don't see similar way for fsck. Only "brute-force".

It could read the slice table, check for aliases, and only use aliases
that it understands (mainly the cdev == bdev one).  I think it shouldn't.

Bruce

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199803160413.PAA04641>