Module Name: src Committed By: apb Date: Mon Sep 14 12:05:12 UTC 2009
Modified Files: src/etc: rc.subr src/etc/defaults: rc.conf src/share/man/man5: rc.conf.5 Log Message: Add the ability for file systems mounted via mount_critical_filesystems() in rc.subr to be marked as optional. This means that it's not an error if the file system is not mentioned in /etc/fstab. It is still an error if something else goes wrong. Change the defaults for these two variables in /etc/defaults/rc.conf: critical_filesystems_local="OPTIONAL:/var" critical_filesystems_remote="OPTIONAL:/usr" To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/etc/rc.subr cvs rdiff -u -r1.105 -r1.106 src/etc/defaults/rc.conf cvs rdiff -u -r1.134 -r1.135 src/share/man/man5/rc.conf.5 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/etc/rc.subr diff -u src/etc/rc.subr:1.78 src/etc/rc.subr:1.79 --- src/etc/rc.subr:1.78 Fri Sep 11 18:17:04 2009 +++ src/etc/rc.subr Mon Sep 14 12:05:12 2009 @@ -1,4 +1,4 @@ -# $NetBSD: rc.subr,v 1.78 2009/09/11 18:17:04 apb Exp $ +# $NetBSD: rc.subr,v 1.79 2009/09/14 12:05:12 apb Exp $ # # Copyright (c) 1997-2004 The NetBSD Foundation, Inc. # All rights reserved. @@ -115,25 +115,62 @@ # 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 + print_rc_metadata \ + "note:File system ${_fs} was already mounted" + 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:Optional file system ${_fs} is not present" + _mount_es=0 + _mount_output="" fi - done - if $_ismounted; then - : - else - mount $_fs >/dev/null 2>&1 + ;; + esac + if [ -n "$_mount_output" ]; then + printf >&2 "%s\n" "$_mount_output" + fi + if [ "$_mount_es" != 0 ]; then + _mountcrit_es="$_mount_es" fi - ) + fi done + return $_mountcrit_es } # Index: src/etc/defaults/rc.conf diff -u src/etc/defaults/rc.conf:1.105 src/etc/defaults/rc.conf:1.106 --- src/etc/defaults/rc.conf:1.105 Fri Sep 11 18:17:04 2009 +++ src/etc/defaults/rc.conf Mon Sep 14 12:05:12 2009 @@ -1,4 +1,4 @@ -# $NetBSD: rc.conf,v 1.105 2009/09/11 18:17:04 apb Exp $ +# $NetBSD: rc.conf,v 1.106 2009/09/14 12:05:12 apb Exp $ # # /etc/defaults/rc.conf -- # default configuration of /etc/rc.conf @@ -87,10 +87,11 @@ # 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: src/share/man/man5/rc.conf.5 diff -u src/share/man/man5/rc.conf.5:1.134 src/share/man/man5/rc.conf.5:1.135 --- src/share/man/man5/rc.conf.5:1.134 Fri Sep 11 19:47:27 2009 +++ src/share/man/man5/rc.conf.5 Mon Sep 14 12:05:12 2009 @@ -1,4 +1,4 @@ -.\" $NetBSD: rc.conf.5,v 1.134 2009/09/11 19:47:27 wiz Exp $ +.\" $NetBSD: rc.conf.5,v 1.135 2009/09/14 12:05:12 apb Exp $ .\" .\" Copyright (c) 1996 Matthew R. Green .\" All rights reserved. @@ -55,7 +55,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 11, 2009 +.Dd September 14, 2009 .Dt RC.CONF 5 .Os .Sh NAME @@ -279,12 +279,26 @@ 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