From: Dirk Vogt Date: Tue, 1 May 2012 14:46:53 +0000 (+0200) Subject: Add ext2 ramdisk, intended for cross compilation X-Git-Tag: v3.2.1~527 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch09.html?a=commitdiff_plain;h=bfacef76c5fec8dcddc731c7604370521897b60f;p=minix.git Add ext2 ramdisk, intended for cross compilation --- diff --git a/drivers/ext2_ramdisk/Makefile b/drivers/ext2_ramdisk/Makefile new file mode 100644 index 000000000..34c381511 --- /dev/null +++ b/drivers/ext2_ramdisk/Makefile @@ -0,0 +1,68 @@ +# Makefile for ramdisk image + +.include + +BINFILES = dev2name mount sh service \ + sysenv + +SBINFILES = ahci at_wini bios_wini ext2 floppy mfs procfs \ + fsck.mfs + +ETCFILES = system.conf mtab passwd pwd.db spwd.db master.passwd \ + rs.single + +USRBINFILES = newroot loadramdisk cdprobe +USRSBINFILES = acpi pci +IMAGE_DIRS= bin sbin etc usr/bin usr/sbin + +install: +all: + +# as we are taking the binaries directly out of the destree +# we have to make sure they are already installed +# (that's a little bit to coarse grain though...) +install_files: + ${MAKE} -C ${MINIXSRCDIR}/commands install + ${MAKE} -C ${MINIXSRCDIR}/usr.bin install + ${MAKE} -C ${MINIXSRCDIR}/usr.sbin install + ${MAKE} -C ${MINIXSRCDIR}/usr.bin install + ${MAKE} -C ${MINIXSRCDIR}/sbin install + ${MAKE} -C ${MINIXSRCDIR}/bin install + ${MAKE} -C ${MINIXSRCDIR}/servers install + ${MAKE} -C ${MINIXSRCDIR}/drivers/acpi install + ${MAKE} -C ${MINIXSRCDIR}/drivers/ahci install + ${MAKE} -C ${MINIXSRCDIR}/drivers/at_wini install + ${MAKE} -C ${MINIXSRCDIR}/drivers/bios_wini install + ${MAKE} -C ${MINIXSRCDIR}/drivers/floppy install + ${MAKE} -C ${MINIXSRCDIR}/drivers/pci install + + +image.d: install_files + @echo -n "preparing image... " + rm -rf image.d + @mkdir image.d + @for f in $(IMAGE_DIRS); do mkdir -p image.d/$$f; done + @for f in $(BINFILES); do cp $(DESTDIR)/bin/$$f image.d/bin; done + @for f in $(SBINFILES); do cp $(DESTDIR)/sbin/$$f image.d/sbin; done + @for f in $(ETCFILES); do cp $(DESTDIR)/etc/$$f image.d/etc; done + @for f in $(USRBINFILES); do cp $(DESTDIR)/usr/bin/$$f image.d/usr/bin; done + @for f in $(USRSBINFILES); do cp $(DESTDIR)/usr/sbin/$$f image.d/usr/sbin; done + @cp rc $(DESTDIR)/etc; + if [ ! -z ${EXT2_EXTRA_TREE} ] ; \ + then \ + echo "Copying additional files";\ + cp -a ${EXT2_EXTRA_TREE}/* image.d/; \ + fi + @echo "done" + +image:: image.d + @echo -n "generating image... " + genext2fs -q -N 1000 -D device_table.txt -b 21000 -U -d image.d $@ + rm -rf image.d + @echo "done." + +clean: + rm -rf image.d image +.PHONY: image + +.include diff --git a/drivers/ext2_ramdisk/device_table.txt b/drivers/ext2_ramdisk/device_table.txt new file mode 100644 index 000000000..831fde5d7 --- /dev/null +++ b/drivers/ext2_ramdisk/device_table.txt @@ -0,0 +1,10 @@ +/dev d 755 0 0 - - - - - +/dev/null c 666 0 0 1 3 0 0 - +/dev/log c 666 0 0 4 0 0 0 - +/dev/console c 666 0 0 4 0 0 0 - +/dev/ttyc c 666 0 0 4 1 1 1 4 +/dev/tty c 666 0 0 5 0 0 0 - +/dev/tty0 c 666 0 0 4 0 0 1 4 +/dev/imgrd b 666 0 0 1 6 0 0 - +#/dev/ttyp c 666 0 0 4 128 128 1 16 + diff --git a/drivers/ext2_ramdisk/mtab b/drivers/ext2_ramdisk/mtab new file mode 100644 index 000000000..8b92699c0 --- /dev/null +++ b/drivers/ext2_ramdisk/mtab @@ -0,0 +1 @@ +/dev/imgrd / 3 rw diff --git a/drivers/ext2_ramdisk/rc b/drivers/ext2_ramdisk/rc new file mode 100644 index 000000000..0945cb952 --- /dev/null +++ b/drivers/ext2_ramdisk/rc @@ -0,0 +1,77 @@ +#!/bin/sh +set -e + +exec >/dev/log +exec 2>/dev/log +exec /dev/null +then + rootdevname=/dev/`/bin/sysenv rootdevname` +else + rootdev=`/bin/sysenv rootdev` || echo 'No rootdev?' + rootdevname=`/bin/dev2name "$rootdev"` || + { echo 'No device name for root device'; exit 1; } +fi + +if [ "`sysenv bin_img`" = 1 ] +then + bin_img="-i " +fi + +if sysenv cdproberoot >/dev/null +then + echo + echo 'Looking for boot CD. This may take a minute.' + echo 'Please ignore any error messages.' + echo + cddev=`/usr/bin/cdprobe` || { echo 'No CD found'; exit 1; } + export cddev + echo "Loading ramdisk from ${cddev}p1" + /usr/bin/loadramdisk "$cddev"p1 +elif [ "$rootdevname" = "/dev/ram" ] +then + if /bin/sysenv rootdevname >/dev/null + then + ramimagename=/dev/`/bin/sysenv ramimagename` + else + ramimagedev=`/bin/sysenv ramimagedev` || + { echo 'ramimagedev not found'; exit 1; } + ramimagename=`/bin/dev2name "$ramimagedev"` || + { echo 'No device name for ramimagedev'; exit 1; } + fi + + echo "Loading ramdisk from $ramimagename" + /usr/bin/loadramdisk "$ramimagename" || echo "WARNING: loadramdisk failed" +fi +echo "Root device name is $rootdevname" +if [ -e $FSCK ] +then $FSCK -p $rootdevname +fi +/usr/bin/newroot $bin_img"$rootdevname" +/bin/mount -e -n -t procfs none /proc || echo "WARNING: couldn't mount procfs" + +exec /bin/sh /etc/rc "$@"