support multiple loop types

git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@53 67a159dc-881f-0410-a524-ba9dfbe2cb84
cleanup-cruft
Brad House 21 years ago
parent c50d47ba58
commit fd6d55a5e8

@ -36,6 +36,9 @@ do
loop\=*) loop\=*)
LOOP=`parse_opt "${x}"` LOOP=`parse_opt "${x}"`
;; ;;
looptype\=*)
LOOPTYPE=`parse_opt "${x}"`
;;
*) *)
;; ;;
esac esac
@ -80,7 +83,7 @@ then
sleep 1 sleep 1
# Bind our mounted dev to /dev otherwise we may not be able to mount # Bind our mounted dev to /dev otherwise we may not be able to mount
# our loop device later on # our loop device later on
mount -o bind /newroot/dev /dev # mount -o bind /newroot/dev /dev
findcdmount /newroot/dev/cdroms/* findcdmount /newroot/dev/cdroms/*
# not in /dev/cdroms try /dev/ide/cd # not in /dev/cdroms try /dev/ide/cd
if [ "${REAL_ROOT}" = "" ] if [ "${REAL_ROOT}" = "" ]
@ -168,23 +171,57 @@ done
[ -n "$QUIET" ] && echo "6" > /proc/sys/kernel/printk [ -n "$QUIET" ] && echo "6" > /proc/sys/kernel/printk
echo "STEP 5: Finishing up" echo "STEP 5: Finishing up"
check_loop() {
if [ "${LOOP}" = "" -o ! -e "mnt/cdrom/${LOOP}" ]
then
echo "Invalid loop location: ${LOOP}"
echo "please export LOOP with a valid location, or reboot and pass a proper loop="
echo "kernel command line"
/bin/ash
fi
}
if [ "${CDROOT}" = "1" ] if [ "${CDROOT}" = "1" ]
then then
echo "STEP 5a: filling tmpfs filesystem" echo "STEP 5a: filling tmpfs filesystem"
cd /newroot cd /newroot
if [ "${LOOP}" != "" ]
# Failsafe if some idiot didn't set loop type
if [ "${LOOPTYPE}" = "" ]
then then
echo "YOU FORGOT TO SPECIFY LOOPTYPE TRYING TO AUTODETECT"
if [ "${LOOP}" = "/livecd.loop" ]
then
LOOPTYPE="normal"
elif [ "${LOOP}" = "/zisofs" ]
then
LOOPTYPE="zisofs"
else
LOOPTYPE="noloop"
fi
echo "DETECTED LOOPTYPE: $LOOPTYPE"
fi
if [ "${LOOPTYPE}" = "normal" ]
then
check_loop
echo "STEP 5a1: mounting loop filesystem" echo "STEP 5a1: mounting loop filesystem"
mount -t ext2 -o loop,ro /newroot/mnt/cdrom/${LOOP} /newroot/mnt/loop mount -t ext2 -o loop,ro /newroot/mnt/cdrom/${LOOP} /newroot/mnt/loop
if [ "$?" != 0 ] if [ "$?" != "0" ]
then then
echo "FAILED TO MOUNT LOOP FILESYSTEM, barfing out to shell" echo "FAILED TO MOUNT LOOP FILESYSTEM, barfing out to shell"
/bin/ash /bin/ash
fi fi
FS_LOCATION="mnt/loop" FS_LOCATION="mnt/loop"
else elif [ "${LOOPTYPE}" = "zisofs" ]
then
check_loop
FS_LOCATION="mnt/cdrom/${LOOP}"
elif [ "${LOOPTYPE}" = "noloop" ]
then
FS_LOCATION="mnt/cdrom" FS_LOCATION="mnt/cdrom"
fi fi
echo "STEP 5a2: filling filesystem" echo "STEP 5a2: filling filesystem"
for x in ${ROOT_LINKS} for x in ${ROOT_LINKS}
do do
@ -195,7 +232,7 @@ then
(cd /newroot/${FS_LOCATION}; cp -a ${ROOT_TREES} /newroot) (cd /newroot/${FS_LOCATION}; cp -a ${ROOT_TREES} /newroot)
# Unmount the -o bind /dev and kill devfsd # Unmount the -o bind /dev and kill devfsd
umount /dev # umount /dev
kill_devfsd kill_devfsd
else else
echo "STEP 5b: setting up stuff for pivot_root" echo "STEP 5b: setting up stuff for pivot_root"
@ -232,6 +269,16 @@ then
# asking questions! # asking questions!
umount /dev umount /dev
umount /proc umount /proc
elif test "${CDROOT}" -eq "1"
then
# If automount at boot was on with devfs, we'll want to umount it
# also umount proc
echo "STEP 6a: clean up mounts"
sleep 1
umount /tmp/.initrd/dev > /dev/null 2>&1
sleep 1
umount /tmp/.initrd/proc > /dev/null 2>&1
sleep 1
fi fi
# why chroot ?? /usr/src/linux/Documentation/initrd.txt # why chroot ?? /usr/src/linux/Documentation/initrd.txt

Loading…
Cancel
Save