Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: One more anomaly after 5.99.17 upgrade
On Sun, 13 Sep 2009, Paul Goyette wrote:
> >I think we need a way of distinguishing between
> >"critical_filesystems_remote=/usr because that's the default" and
> >"critical_filesystems_remote=/usr because the admin said so", with
> >no error in the first case even if /usr doesn't exist. I have two
> >simple ideas:
> >
> >A) Set critical_filesystems_remote="DEFAULT" [...]
> >B) Set critical_filesystems_remote="NOERROR:/var" [...]
> I prefer B. Option A requires embedding the "real" default value in
> some unexpected location. Even if there were a comment telling
> people where to go to find the "real" default, it's an extra step...
I agree. Here's an implementation using "OPTIONAL:foo",
which I have tested only a little.
--apb (Alan Barrett)
Index: etc/defaults/rc.conf
===================================================================
--- etc/defaults/rc.conf 11 Sep 2009 18:17:04 -0000 1.105
+++ etc/defaults/rc.conf 13 Sep 2009 17:41:39 -0000
@@ -87,10 +87,11 @@ domainname=""
# Note that `/var' is needed in $critical_filesystems_local (or
# implied as part of `/') as certain services that need /var (such as
# dhclient) may be needed to get the network operational enough to mount
-# the $critical_filesystems_remote.
+# the $critical_filesystems_remote. Prepending "OPTIONAL:" means it
+# will not be an error if that file system is not present in fstab(5).
#
-critical_filesystems_local="/var"
-critical_filesystems_remote="/usr"
+critical_filesystems_local="OPTIONAL:/var"
+critical_filesystems_remote="OPTIONAL:/usr"
# Swap device controls.
#
Index: etc/rc.subr
===================================================================
--- etc/rc.subr 11 Sep 2009 18:17:04 -0000 1.78
+++ etc/rc.subr 13 Sep 2009 17:41:41 -0000
@@ -115,25 +115,61 @@ stop_boot()
# Go through the list of critical filesystems as provided in
# the rc.conf(5) variable $critical_filesystems_${type}, checking
# each one to see if it is mounted, and if it is not, mounting it.
+# It's not an error if file systems prefixed with "OPTIONAL:"
+# are not mentioned in /etc/fstab.
#
mount_critical_filesystems()
{
eval _fslist=\$critical_filesystems_${1}
+ _mountcrit_es=0
for _fs in $_fslist; do
- mount | (
- _ismounted=false
- while read what _on on _type type; do
- if [ $on = $_fs ]; then
- _ismounted=true
+ _optional=false
+ case "$_fs" in
+ OPTIONAL:*)
+ _optional=true
+ _fs="${_fs#*:}"
+ ;;
+ esac
+ _ismounted=false
+ # look for a line like "${fs} on * type *"
+ # or "* on ${fs} type *" in the output from mount.
+ case "${nl}$( mount )${nl}" in
+ *" on ${_fs} type "*)
+ _ismounted=true
+ ;;
+ *"${nl}${_fs} on "*)
+ _ismounted=true
+ ;;
+ esac
+ if $_ismounted; then
+ :
+ else
+ _mount_output=$( mount $_fs 2>&1 )
+ _mount_es=$?
+ case "$_mount_output" in
+ *"${nl}"*)
+ # multiple lines can't be good,
+ # not even if $_optional is true
+ ;;
+ *'unknown special file or file system'*)
+ if $_optional; then
+ # ignore this error
+ print_rc_metadata \
+ "note:Ignored error for optional file system ${_fs}"
+ _mount_es=0
+ _mount_output=""
fi
- done
- if $_ismounted; then
- :
- else
- mount $_fs >/dev/null 2>&1
+ ;;
+ esac
+ if [ -n "$_mount_output" ]; then
+ printf "%s\n" "$_mount_output"
fi
- )
+ if [ "$_mount_es" != 0 ]; then
+ _es="$_mount_es"
+ fi
+ fi
done
+ return $_mountcrit_es
}
#
Index: share/man/man5/rc.conf.5
===================================================================
--- share/man/man5/rc.conf.5 11 Sep 2009 19:47:27 -0000 1.134
+++ share/man/man5/rc.conf.5 13 Sep 2009 17:41:42 -0000
@@ -279,12 +279,26 @@ Usually
is part of this, because it is needed by services such as
.Xr dhclient 8
which may be required to get the network operational.
+The default is
+.Dq "OPTIONAL:/var" ,
+where the
+.Dq OPTIONAL:
+prefix means that it's not an error if the file system is not
+present in
+.Xr fstab 5.
.It Sy critical_filesystems_remote
A string.
File systems such as
.Pa /usr
that may require network services to be available to mount,
that must be available early in the system boot for general services to use.
+The default is
+.Dq "OPTIONAL:/usr" ,
+where the
+.Dq OPTIONAL:
+prefix means that it's not an error if the file system is not
+present in
+.Xr fstab 5.
.It Sy fsck_flags
A string.
A file system is checked with
Home |
Main Index |
Thread Index |
Old Index