bin/74005: [PATCH] aditional support for /etc/rc.initdiskless

Jose M Rodriguez josemi at freebsd.jazztel.es
Tue Nov 16 09:00:51 PST 2004


>Number:         74005
>Category:       bin
>Synopsis:       [PATCH] aditional support for /etc/rc.initdiskless
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 16 17:00:50 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Jose M Rodriguez
>Release:        FreeBSD 5.3-STABLE i386
>Organization:
Redes JM
>Environment:
System: FreeBSD orion.redesjm.local 5.3-STABLE FreeBSD 5.3-STABLE #0: Tue Nov 16 13:26:33 CET 2004 root at orion.redesjm.local:/usr/obj/usr/src/sys/ORION i386


>Description:
	Add aditional support to /etc/rc.initdiskless, in the way
	of use pax instead of cpio and any version of gzip.

	This also add suppor for uncompressed pax tarballs (ustar)

	Working in the way of be capable of remote booting without
	/rescue or /stand and maintain compatibility with any version
	of FreeBSD from RELENG_4

>How-To-Repeat:
>Fix:

	This have now very limited test, use with care

--- patch-initdiskless begins here ---
--- etc/rc.d/initdiskless.orig	Thu Oct 28 21:34:40 2004
+++ etc/rc.d/initdiskless	Thu Oct 28 21:34:51 2004
@@ -91,10 +91,15 @@
 #		initialize it from a template, it is preferrable to specify
 #		it in fstab e.g. as  "md /tmp mfs -s=30m,rw 0 0"
 #
+# /conf/T/SUBDIR.pax
+#		The file is expanded into /SUBDIR (and a memory filesystem
+#		is created for /SUBDIR if necessary). The presence of this
+#		file prevents the copy from other sources
+#
 # /conf/T/SUBDIR.cpio.gz
-#		The file is cpio'd into /SUBDIR (and a memory filesystem is
-#		created for /SUBDIR if necessary). The presence of this file
-#		prevents the copy from /conf/T/SUBDIR/
+#		The file is expanded into /SUBDIR (and a memory filesystem
+#		is created for /SUBDIR if necessary). The presence of this
+#		file prevents the copy from /conf/T/SUBDIR/
 #
 # /conf/T/SUBDIR.remove
 #		The list of paths contained in the file are rm -rf'd
@@ -250,6 +255,7 @@
 #   it before attemping to the remount.  This allows the root to be
 #   relocated without needing to change the remount files.
 #
+
 for i in ${templates} ; do
     for j in /conf/$i/* ; do
 	# memory filesystem size specification
@@ -291,27 +297,56 @@
 # so if the cpio archive is present, it prevents the files from dir/
 # from being copied.
 
+# a valid gzip
+if [ -x /bin/gzip ]; then
+	use_gunzip="/bin/gzip -d"
+elif [ -x /rescue/gzip ]; then
+	use_gunzip="/rescue/gzip -d"
+elif [ -x /stand/gzip ]; then
+	use_gunzip="/stand/gzip -d"
+else
+	use_gunzip=""
+fi
+
 for i in ${templates} ; do
-    for j in /conf/$i/* ; do
-	subdir=${j##*/}
-	if [ -d $j -a ! -f $j.cpio.gz  ]; then
+    for j in /conf/$i/*.pax ; do
+	subdir=${j%*.pax}
+	subdir=${subdir##*/}
+	eval _from=\$md_from_${subdir}_${i}
+	if [ -r $j -a ! -n "${_from}" ]; then
 	    create_md $subdir
-	    cp -Rp $j/* /$subdir
+	    echo "Loading /$subdir from pax archive $j"
+	    (cd / ; /bin/pax -r -pe ${busbir} < $j )
+	    eval md_from_${subdir}_${i}="$j"
 	fi
     done
-    for j in /conf/$i/*.cpio.gz ; do
-	subdir=${j%*.cpio.gz}
-	subdir=${subdir##*/}
-	if [ -f $j ]; then
+    if [ -n "${use_gunzip}" ]; then
+	for j in /conf/$i/*.cpio.gz ; do
+	    subdir=${j%*.cpio.gz}
+	    subdir=${subdir##*/}
+	    eval _from=\$md_from_${subdir}_${i}
+	    if [ -r $j -a ! -n "${_from}" ]; then
+		create_md $subdir
+		echo "Loading /$subdir from cpio archive $j"
+		(cd / ; ${use_gunzip} < $j | /bin/pax -r -pe ${subdir} )
+		eval md_from_${subdir}_${i}="$j"
+	    fi
+	done
+    fi
+    for j in /conf/$i/* ; do
+	subdir=${j##*/}
+	eval _from=\$md_from_${subdir}_${i}
+	if [ -d $j -a ! -n "${_from}" ]; then
 	    create_md $subdir
-	    echo "Loading /$subdir from cpio archive $j"
-	    (cd / ; /stand/gzip -d < $j | /stand/cpio --extract -d )
+	    echo "Copying /$subdir from $j"
+	    cp -Rp $j/* /$subdir
+	    eval md_from_${subdir}_${i}="$j"
 	fi
     done
     for j in /conf/$i/*.remove ; do
 	subdir=${j%*.remove}
 	subdir=${subdir##*/}
-	if [ -f $j ]; then
+	if [ -r $j ]; then
 	    # doubly sure it is a memory disk before rm -rf'ing
 	    create_md $subdir
 	    (cd /$subdir; rm -rf `/bin/cat $j`)
--- patch-initdiskless ends here ---



>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list