bin/122282: [patch] check the presence of fstab's obsoleted 'nodev' option by mergemaster

Eygene Ryabinkin rea-fbsd at codelabs.ru
Sun Mar 30 23:30:02 PDT 2008


>Number:         122282
>Category:       bin
>Synopsis:       [patch] check the presence of fstab's obsoleted 'nodev' option by mergemaster
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 31 06:30:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Eygene Ryabinkin
>Release:        FreeBSD 7.0-STABLE amd64
>Organization:
Code Labs
>Environment:

System: FreeBSD XXX 7.0-STABLE FreeBSD 7.0-STABLE #6: Tue Mar 18 16:46:28 MSK 2008 root at XXX:/usr/src/sys/amd64/compile/XXX amd64

>Description:

Option 'nodev' in fstab(5) is obsoleted since FreeBSD 7.x [1] (It was
no-op since FreeBSD 6.x).  So in the upgrade path FreeBSD 6.x ->
FreeBSD 7.x such options in /etc/fstab could survive the upgrade.
This will render the corresponding filesystems inaccessible after
reboot.

[1] http://www.freebsd.org/cgi/cvsweb.cgi/src/sbin/mount/mntopts.h,
    revision 1.28.

>How-To-Repeat:

Insert 'nodev' into the options field in /etc/fstab and try to mount
the filesystem.

>Fix:

I propose to add the check to the mergemaster.sh and warn the user if
'nodev' options are found.

--- check-nodev-in-mergemaster begins here ---
>From f55d0cd0b64c2949687222251304f6fb1a09f10d Mon Sep 17 00:00:00 2001
From: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
Date: Sun, 30 Mar 2008 15:54:41 +0400

Option 'nodev' was eliminated in FreeBSD 7.x, so some systems,
upgrading from 6.x or earlier, can have this option in /etc/fstab.

If option(s) will be left in fstab(5), the system will fail to mount
the corresponding filesystem(s).  And if update is done remotely,
this can render the system unusable before someone will go to the
console, drop to the single-user mode or boot from other media and
correct the things.

Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
---
 usr.sbin/mergemaster/mergemaster.sh |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/usr.sbin/mergemaster/mergemaster.sh b/usr.sbin/mergemaster/mergemaster.sh
index 06266e9..1749f79 100755
--- a/usr.sbin/mergemaster/mergemaster.sh
+++ b/usr.sbin/mergemaster/mergemaster.sh
@@ -1000,6 +1000,12 @@ if [ -n "${TEST_FOR_FILES}" ]; then
   echo ''
 fi
 
+if [ -e "${DESTDIR}/etc/fstab" ] && sed -e'/^#/d' "${DESTDIR}/etc/fstab" | \
+  awk -F '[[:space:]]+' '{ print $4; }' | \
+  grep -E '(^nodev$|^nodev,|,nodev,|,nodev$)' > /dev/null; then
+	NEED_TO_REMOVE_FSTAB_NODEV=yes
+fi
+
 case "${AUTO_RUN}" in
 '')
   echo -n "Do you wish to delete what is left of ${TEMPROOT}? [no] "
@@ -1096,6 +1102,14 @@ run_it_now () {
   esac
 }
 
+any_key () {
+  local input
+  [ -t 0 ] || return
+  [ -n "$AUTO_RUN" ] && return
+  echo -n '    Press any key... '
+  read input
+}
+
 case "${NEED_MAKEDEV}" in
 '') ;;
 *)
@@ -1151,6 +1165,19 @@ case "${NEED_PWD_MKDB}" in
   ;;
 esac
 
+case "${NEED_TO_REMOVE_FSTAB_NODEV}" in
+'') ;;
+*)
+  echo ''
+  echo "*** Your fstab file has obsolete 'nodev' options."
+  echo "    Please, remove them before next system boot"
+  echo "    or filesystem mounts will likely fail."
+  echo ''
+  echo "    Fstab file is ${DESTDIR}/etc/fstab"
+  any_key
+  ;;
+esac
+
 echo ''
 
 if [ -r "${MM_EXIT_SCRIPT}" ]; then
-- 
1.5.3.8
--- check-nodev-in-mergemaster ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list