[Pkg-sysvinit-commits] r529 - sysvinit/trunk/debian/initscripts/etc/init.d

Thomas Hood jdthood-guest at costa.debian.org
Thu Jan 5 12:06:46 UTC 2006


Author: jdthood-guest
Date: 2006-01-05 12:06:39 +0000 (Thu, 05 Jan 2006)
New Revision: 529

Modified:
   sysvinit/trunk/debian/initscripts/etc/init.d/mountnfs.sh
Log:
Eliminate subshell invocation from mountnfs.sh; redirect the script's
own stdin instead.  checkroot.sh already does this.

Because this involved changing the indentation of several paragraphs,
making for a large diff, I include here a diff run with "-b" which 
shows the important changes:

Index: mountnfs.sh
===================================================================
--- mountnfs.sh	(revision 528)
+++ mountnfs.sh	(working copy)
@@ -23,14 +23,13 @@
 do_start() {
 	[ -f /etc/fstab ] || return
 	#
-	# Run in a subshell because of I/O redirection.
-	#
-	(
-		#
 		# Read through fstab line by line. If it is NFS, set the flag
 		# for mounting NFS file systems. If any NFS partition is found and it
 		# not mounted with the nolock option, we start the portmapper.
 		#
+
+	exec 9<&0 </etc/fstab
+
 		portmap=no
 		while read DEV MTPT FSTYPE OPTS REST
 		do
@@ -71,7 +70,9 @@
 				esac
 			fi
 		done
-		exec 0>&1
+
+	exec 0<&9 9<&-
+
 		if [ "$portmap" = yes ]
 		then
 			if [ -x /sbin/portmap ] && [ -z "$(pidof portmap)" ] 
@@ -121,7 +122,6 @@
 				fi
 			fi
 		fi
-	) < /etc/fstab
 }
 
 




Modified: sysvinit/trunk/debian/initscripts/etc/init.d/mountnfs.sh
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/mountnfs.sh	2006-01-05 11:17:19 UTC (rev 528)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/mountnfs.sh	2006-01-05 12:06:39 UTC (rev 529)
@@ -23,105 +23,105 @@
 do_start() {
 	[ -f /etc/fstab ] || return
 	#
-	# Run in a subshell because of I/O redirection.
+	# Read through fstab line by line. If it is NFS, set the flag
+	# for mounting NFS file systems. If any NFS partition is found and it
+	# not mounted with the nolock option, we start the portmapper.
 	#
-	(
-		#
-		# Read through fstab line by line. If it is NFS, set the flag
-		# for mounting NFS file systems. If any NFS partition is found and it
-		# not mounted with the nolock option, we start the portmapper.
-		#
-		portmap=no
-		while read DEV MTPT FSTYPE OPTS REST
-		do
-			case "$DEV" in
-			  ""|\#*)
-				continue
-				;;
-			esac
+
+	exec 9<&0 </etc/fstab
+
+	portmap=no
+	while read DEV MTPT FSTYPE OPTS REST
+	do
+		case "$DEV" in
+		  ""|\#*)
+			continue
+			;;
+		esac
+		case "$OPTS" in
+		  noauto|*,noauto|noauto,*|*,noauto,*)
+			continue
+			;;
+		esac
+		case "$FSTYPE" in
+		  nfs|nfs4)
 			case "$OPTS" in
-			  noauto|*,noauto|noauto,*|*,noauto,*)
-				continue
+			  nolock|*,nolock|nolock,*|*,nolock,*)
 				;;
+			  *)
+				portmap=yes
+				;;
 			esac
-			case "$FSTYPE" in
-			  nfs|nfs4)
-				case "$OPTS" in
-				  nolock|*,nolock|nolock,*|*,nolock,*)
-					;;
-				  *)
-					portmap=yes
-					;;
-				esac
+			;;
+		  smbfs|cifs|coda|ncp|ncpfs|ocfs2|gfs)
+			;;
+		  *)
+			FSTYPE=
+			;;
+		esac
+		if [ "$FSTYPE" ]
+		then
+			case "$NETFS" in
+			  $FSTYPE|*,$FSTYPE|$FSTYPE,*|*,$FSTYPE,*)
 				;;
-			  smbfs|cifs|coda|ncp|ncpfs|ocfs2|gfs)
-				;;
 			  *)
-				FSTYPE=
+				NETFS="$NETFS${NETFS:+,}$FSTYPE"
 				;;
 			esac
-			if [ "$FSTYPE" ]
-			then
-				case "$NETFS" in
-				  $FSTYPE|*,$FSTYPE|$FSTYPE,*|*,$FSTYPE,*)
-					;;
-				  *)
-					NETFS="$NETFS${NETFS:+,}$FSTYPE"
-					;;
-				esac
-			fi
-		done
-		exec 0>&1
-		if [ "$portmap" = yes ]
+		fi
+	done
+
+	exec 0<&9 9<&-
+
+	if [ "$portmap" = yes ]
+	then
+		if [ -x /sbin/portmap ] && [ -z "$(pidof portmap)" ] 
 		then
-			if [ -x /sbin/portmap ] && [ -z "$(pidof portmap)" ] 
+			if [ -x /etc/init.d/portmap ] 
 			then
-				if [ -x /etc/init.d/portmap ] 
-				then
-					/etc/init.d/portmap start
-				else
-					log_action_begin_msg "Starting portmap"
-					start-stop-daemon --start --quiet --exec /sbin/portmap
-					ES=$?
-					sleep 2  # FIXME: Actually synchronize with the process?
-					log_action_end_msg $ES
-				fi
+				/etc/init.d/portmap start
+			else
+				log_action_begin_msg "Starting portmap"
+				start-stop-daemon --start --quiet --exec /sbin/portmap
+				ES=$?
+				sleep 2  # FIXME: Actually synchronize with the process?
+				log_action_end_msg $ES
 			fi
 		fi
-		if [ "$NETFS" ]
+	fi
+	if [ "$NETFS" ]
+	then
+		do_mount() { mount -a -t$NETFS ; }
+		
+		# Accept 64 or 96 (32/mount failure + 64/some mount succeeded)
+		# as valid return statuses from mount.  This partly works around
+		# the problem of mount reporting an error status when
+		# some filesystems are already mounted.
+
+		if [ "$VERBOSE" != no ]
 		then
-			do_mount() { mount -a -t$NETFS ; }
-			
-			# Accept 64 or 96 (32/mount failure + 64/some mount succeeded)
-			# as valid return statuses from mount.  This partly works around
-			# the problem of mount reporting an error status when
-			# some filesystems are already mounted.
-
-			if [ "$VERBOSE" != no ]
+			log_action_msg "Will now mount remote filesystems"
+			do_mount
+			ES=$?
+			if [ 0 = "$ES" ] || [ 96 = "$ES" ] || [ 64 = "$ES" ]
 			then
-				log_action_msg "Will now mount remote filesystems"
-				do_mount
-				ES=$?
-				if [ 0 = "$ES" ] || [ 96 = "$ES" ] || [ 64 = "$ES" ]
-				then
-					log_success_msg "Done mounting remote filesystems."
-				else
-					log_failure_msg "Mounting remote filesystems failed with error code ${ES}."
-				fi
+				log_success_msg "Done mounting remote filesystems."
 			else
-				log_action_begin_msg "Mounting remote filesystems"
-				MOUNT_OUT="$(LC_ALL=C do_mount)"
-				ES=$?
-				echo "$MOUNT_OUT" | sed -e '/already mounted/d' -e '/nothing was mounted/d'
-				if [ 0 = "$ES" ] || [ 96 = "$ES" ] || [ 64 = "$ES" ]
-				then
-					log_action_end_msg 0
-				else
-					log_action_end_msg 1 "code $ES"
-				fi
+				log_failure_msg "Mounting remote filesystems failed with error code ${ES}."
 			fi
+		else
+			log_action_begin_msg "Mounting remote filesystems"
+			MOUNT_OUT="$(LC_ALL=C do_mount)"
+			ES=$?
+			echo "$MOUNT_OUT" | sed -e '/already mounted/d' -e '/nothing was mounted/d'
+			if [ 0 = "$ES" ] || [ 96 = "$ES" ] || [ 64 = "$ES" ]
+			then
+				log_action_end_msg 0
+			else
+				log_action_end_msg 1 "code $ES"
+			fi
 		fi
-	) < /etc/fstab
+	fi
 }
 
 




More information about the Pkg-sysvinit-commits mailing list