[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] Improve error handling in rootskel/src/sbin/init



Hello All,

this patch improves the error handling in rootskel/src/sbin/init.
It is particularily useful to catch misconfigured customized
kernels.


Thiemo


Index: rootskel/src/sbin/init
===================================================================
RCS file: /cvs/debian-boot/debian-installer/rootskel/src/sbin/init,v
retrieving revision 1.2
diff -a -d -u -p -r1.2 init
--- rootskel/src/sbin/init	18 Oct 2003 20:31:23 -0000	1.2
+++ rootskel/src/sbin/init	13 Nov 2003 01:29:25 -0000
@@ -1,14 +1,28 @@
 #!/bin/sh
 # Set up filesystem as root and pivot into it.
 echo "Setting up filesystem, please wait ..."
-mount -t shm shm mnt
-cp -a `ls -1 | grep -v mnt | grep -v proc | grep -v dev | grep -v lost+found` mnt
-cd mnt
+mount -t shm /shm /mnt || {
+	echo "Mounting shm filesystem failed."
+	exit 1
+}
+cp -a $(ls -1 / |grep -v '\(dev\|lost+found\|mnt\|proc\)') /mnt || {
+	echo "Copying of the initial ramdisk failed."
+	exit 1
+}
+cd /mnt
 mkdir proc dev
-pivot_root . initrd
-mount -t proc proc proc
-mount -t devfs devfs dev
+pivot_root . initrd || {
+	echo "Switching the root directory failed."
+	exit 1
+}
+mount -t proc proc proc || {
+	echo "Mounting proc filesystem failed."
+	exit 1
+}
+mount -t devfs devfs dev || {
+	echo "Mounting devfs filesystem failed."
+	exit 1
+}
 # Close all open files on the initrd, and run busybox init.
-rm -f sbin/init # this program
-ln -s ../bin/busybox sbin/init
+ln -sf ../bin/busybox sbin/init
 exec /usr/sbin/chroot . /sbin/init <dev/console >dev/console 2>&1



Reply to: