From nobody@FreeBSD.org  Tue Jun 21 15:51:46 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B46831065675
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 21 Jun 2011 15:51:46 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id A40FF8FC1F
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 21 Jun 2011 15:51:46 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p5LFpkvc097096
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 21 Jun 2011 15:51:46 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p5LFpkQq097095;
	Tue, 21 Jun 2011 15:51:46 GMT
	(envelope-from nobody)
Message-Id: <201106211551.p5LFpkQq097095@red.freebsd.org>
Date: Tue, 21 Jun 2011 15:51:46 GMT
From: Brian Olsen <brian@maven-group.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] remount_optional option in rc.initdiskless doesn't actually work
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         158127
>Category:       conf
>Synopsis:       [patch] remount_optional option in rc.initdiskless doesn't actually work
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-rc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 21 16:00:22 UTC 2011
>Closed-Date:    
>Last-Modified:  Wed Jun 20 06:10:08 UTC 2012
>Originator:     Brian Olsen
>Release:        8.2
>Organization:
>Environment:
FreeBSD mail.vagtelhave.dk 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Tue Jun 21 07:23:33 CEST 2011     root@lacuna-dev.maven-group.org:/usr/obj/freakbsd.lacuna/usr/src/sys/GENERIC  i386
>Description:
When trying to use the remount_optional option on a nanobsd like build that was going to run from an iso image with an optional remount of /dev/ufs/cfg onto /conf/default/etc I discovered that it doesn't actually work.

When remount_optional is present it will always print the error message "mount -o ro /dev/ufs/cfg /conf/default/etc failed: ignoring due to remount_optional" even when the mount succeeds. And when the mount fails it still drops into a shell.

A simple fix to the problem is attached.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- /etc/rc.initdiskless	2011-02-18 02:52:09.000000000 +0100
+++ etc/rc.initdiskless	2011-06-21 17:15:21.000000000 +0200
@@ -166,14 +166,17 @@
 chkerr() {
     lastitem () ( n=$(($# - 1)) ; shift $n ; echo $1 )
     mountpoint="$(lastitem $2)"
-    [ -r $mountpoint/remount_optional ] && ( echo "$2 failed: ignoring due to remount_optional" ; return )
     case $1 in
     0)
 	;;
     *)
-	echo "$2 failed: dropping into /bin/sh"
-	/bin/sh
-	# RESUME
+	if [ -r $mountpoint/remount_optional ] ; then
+	     echo "$2 failed: ignoring due to remount_optional"
+	else
+	     echo "$2 failed: dropping into /bin/sh"
+	     /bin/sh
+	     # RESUME
+	fi
 	;;
     esac
 }


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Jun 23 18:12:03 UTC 2011 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=158127 

From: Mark Linimon <linimon@lonesome.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/158127: [patch] remount_optional option in
 rc.initdiskless doesn't actually work
Date: Wed, 20 Jun 2012 01:01:04 -0500

 ----- Forwarded message from Dewayne <dewayne.geraghty@heuristicsystems.com.au> -----
 
 Date: Wed, 20 Jun 2012 06:19:55 +1000
 From: Dewayne <dewayne.geraghty@heuristicsystems.com.au>
 To: stable@freebsd.org
 Cc: brian@maven-group.org
 Subject: Diskless ignore remount - fix (Re: conf/158127: [patch]
 	remount_optional option in rc.initdiskless doesn&#39;
 	t actually work)
 
 I notice that PR 158127 remains outstanding, June, 2011.  I've enclosed a
 patch for Stable 9.0, to correct diskless booting.  When a mountpoint
 fails, the failure may be ignored as required/documented.
 
 --- /tmp/rc.initdiskless        2012-06-19 19:01:33.000000000 +1000
 +++ /etc/rc.initdiskless        2012-06-19 19:02:16.000000000 +1000
 @@ -166,7 +166,7 @@
  chkerr() {
      lastitem () ( n=$(($# - 1)) ; shift $n ; echo $1 )
      mountpoint="$(lastitem $2)"
 -    [ -r $mountpoint/remount_optional ] && ( echo "$2 failed: ignoring due
 to remount_optional" ; return )
 +    [ -r $mountpoint/remount_optional ] && echo "$2 failed: ignoring due
 to remount_optional" && return
      case $1 in
      0)
 
 The patch has been tested with/without /conf/default/etc/remount_optional &
 is functionally correct. 
 
 It would be appreciated if someone would verify and commit.
 
 Regards, Dewayne.
 PS My apologies if Outlook has corrupted the patches appearance,we have to
 work with what we've got.
 
 ----- End forwarded message -----
>Unformatted:
