[SCM] live-boot branch, debian-next, updated. debian/3.0_a14-1-6-g2f4baa7

Michal Suchanek hramrach at centrum.cz
Sat Feb 12 19:53:01 UTC 2011


The following commit has been merged in the debian-next branch:
commit 6791c25906be67a76737d6a6e874414fd11126cf
Author: Michal Suchanek <hramrach at centrum.cz>
Date:   Fri Feb 11 08:39:53 2011 +0100

    Simplify union mounting.

diff --git a/scripts/live b/scripts/live
index ef87d3c..9460eaa 100755
--- a/scripts/live
+++ b/scripts/live
@@ -1191,7 +1191,6 @@ setup_unionfs ()
 	croot="/"
 
 	# Let's just mount the read-only file systems first
-	rofsstring=""
 	rofslist=""
 
 	if [ "${UNIONTYPE}" = "aufs" ]
@@ -1251,7 +1250,7 @@ setup_unionfs ()
 			image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
 		fi
 
-	[ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
+		[ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
 
 		mkdir -p "${croot}"
 
@@ -1268,7 +1267,6 @@ setup_unionfs ()
 			if [ -d "${image}" ]
 			then
 				# it is a plain directory: do nothing
-				rofsstring="${image}=${roopt}:${rofsstring}"
 				rofslist="${image} ${rofslist}"
 			elif [ -f "${image}" ]
 			then
@@ -1294,9 +1292,10 @@ setup_unionfs ()
 				if [ "${UNIONTYPE}" != "unionmount" ]
 				then
 					mpoint="${croot}/${imagename}"
-					rofsstring="${mpoint}=${roopt}:${rofsstring}" && rofslist="${mpoint} ${rofslist}"
+					rofslist="${mpoint} ${rofslist}"
 				else
 					mpoint="${rootmnt}"
+					rofslist="${rootmnt} ${rofslist}"
 				fi
 				mkdir -p "${mpoint}"
 				log_begin_msg "Mounting \"${image}\" on \"${mpoint}\" via \"${backdev}\""
@@ -1308,14 +1307,14 @@ setup_unionfs ()
 		# we have a plain root system
 		mkdir -p "${croot}/filesystem"
 		log_begin_msg "Mounting \"${image_directory}\" on \"${croot}/filesystem\""
-		mount -t $(get_fstype "${image_directory}") -o ro,noatime "${image_directory}" "${croot}/filesystem" || panic "Can not mount ${image_directory} on ${croot}/filesystem" && rofsstring="${croot}/filesystem=${roopt}:${rofsstring}" && rofslist="${croot}/filesystem ${rofslist}"
+		mount -t $(get_fstype "${image_directory}") -o ro,noatime "${image_directory}" "${croot}/filesystem" || \
+			panic "Can not mount ${image_directory} on ${croot}/filesystem" && \
+			rofslist="${croot}/filesystem ${rofslist}"
 		# probably broken:
 		mount -o bind ${croot}/filesystem $mountpoint
 		log_end_msg
 	fi
 
-	rofsstring=${rofsstring%:}
-
 	mkdir -p /cow
 
 	# Looking for "${root_persistence}" device or file
@@ -1417,30 +1416,30 @@ setup_unionfs ()
 	if [ "${UNIONTYPE}" != "unionmount" ]
 	then
 
-	if [ "${cow_fstype}" = "nfs" ]
-	then
-		log_begin_msg \
-			"Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
-		nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
-			panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
-	else
-		mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
-			panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
-	fi
+		if [ "${cow_fstype}" = "nfs" ]
+		then
+			log_begin_msg \
+				"Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
+			nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
+				panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
+		else
+			mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
+				panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
+		fi
 	fi
 
 	rofscount=$(echo ${rofslist} |wc -w)
 
-	if [ -n "${EXPOSED_ROOT}" ]
+	if [ ${rofscount} -ne 1 ]
 	then
-		if [ ${rofscount} -ne 1 ]
-		then
-			panic "only one RO file system supported with exposedroot: ${rofslist}"
-		fi
-		exposedrootfs=${rofslist%% }
+		panic "only one RO file system supported with exposedroot: ${rofslist}"
+	fi
+	rofs=${rofslist%% }
 
-		mount --bind ${exposedrootfs} ${rootmnt} || \
-			panic "bind mount of ${exposedrootfs} failed"
+	if [ -n "${EXPOSED_ROOT}" ]
+	then
+		mount --bind ${rofs} ${rootmnt} || \
+			panic "bind mount of ${rofs} failed"
 
 		if [ -z "${SKIP_UNION_MOUNTS}" ]
 		then
@@ -1448,39 +1447,48 @@ setup_unionfs ()
 		else
 			cow_dirs=''
 		fi
+	else
+		cow_dirs="/"
+	fi
 
-		for dir in ${cow_dirs}; do
-			mkdir -p /cow${dir}
+	if [ "${cow_fstype}" != "tmpfs" ] && [ "${cow_dirs}" != "/" ] && [ "${UNIONTYPE}" = "unionmount" ]
+	then
+		true # FIXME: Maybe it does, I don't really know.
+		#panic "unionmount does not support subunions (${cow_dirs})."
+	fi
 
-			case "${UNIONTYPE}" in
-				unionfs-fuse)
-					(ulimit -n 16384; unionfs-fuse -o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid /cow=RW:${exposedrootfs}${dir} "${rootmnt}${dir}" || panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option cow,noinitgroups,default_permissions,allow_other,use_ino,suid=/cow=RW:${exposedrootfs}${dir}")
-					mkdir -p /dev/.initramfs/varrun
-					pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true
-					;;
+	unionmountopts=""
+	unionmountpoint=""
 
-				*)
-					mount -t ${UNIONTYPE} -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro ${UNIONTYPE} "${rootmnt}${dir}" || panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
-					;;
-			esac
-		done
-	else
+	for dir in ${cow_dirs}; do
+		mkdir -p /cow${dir}
+
+		unionmountpoint="${rootmnt}${dir}"
+		unionrw="/cow${dir}"
+		unionro="${rofs}${dir}"
+		# We don't handle spaces and other junk gracefully here, hopefully not needed.
 		case "${UNIONTYPE}" in
 			unionfs-fuse)
-				(ulimit -n 16384; unionfs-fuse -o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid /cow=RW:${rofsstring} "${rootmnt}" || panic "mount ${UNIONTYPE} on ${rootmnt} failed with option cow,noinitgroups,default_permissions,allow_other,use_ino,suid=/cow:RW:${rofsstring}")
-				mkdir -p /dev/.initramfs/varrun
-				pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true
+				unionmountopts="-o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid"
+				unionmountopts="${unionmountopts} ${unionrw}=RW:${unionro}=RO"
+				( ulimit -n 16384 ; unionfs-fuse ${unionmountopts} "${unionmountpoint}" ) && \
+					( mkdir -p /dev/.initramfs/varrun
+				pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true )
 				;;
 
 			unionmount)
-				mount_full -t ${cow_fstype} -o noatime,union,${cow_mountopt} ${cowdevice} "${rootmnt}" || panic "${UNIONTYPE} ${cowdevice} on ${rootmnt} failed with option noatime,union,${cow_mountopt}"
+				unionmountopts="-t ${cow_fstype} -o noatime,union,${cow_mountopt} ${cowdevice}"
+				mount_full $unionmountopts "${unionmountpoint}"
 				;;
 
+
 			*)
-				mount -t ${UNIONTYPE} -o noatime,${noxino_opt}dirs=/cow=rw:${rofsstring} ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on ${rootmnt} failed with option noatime,${noxino_opt}dirs=/cow=rw:${rofsstring}"
+				unionmountopts="-o noatime,${noxino_opt}dirs=${unionrw}=rw:${unionro}=${roopt}"
+				mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}"
 				;;
-		esac
-	fi
+		esac || \
+			panic "mount ${UNIONTYPE} on ${unionmountpoint} failed with option ${unionmountopts}"
+	done
 
 	# Correct the permissions of /:
 	chmod 0755 "${rootmnt}"

-- 
live-boot



More information about the debian-live-changes mailing list