From 53f94f8ed43177edb056b907d96bb7fa95cf1bc5 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Tue, 10 Apr 2012 02:07:51 +0000 Subject: [PATCH] dynamic executables on ramdisk support See UPDATING about upgrading clang for dynamic linking. . allow executables on ramdisk to be dynamically linked; this means putting a few required shared libraries and ld.elf_so on the ramdisk. . this makes the ramdisk (usage) smaller when they are dynamic, but bigger when they're not. . also we can safely ditch newroot and call mount directly as that is all newroot does. . create proto.common to share a bunch of entries between small/nonsmall cases --- commands/Makefile | 2 +- commands/newroot/Makefile | 4 - commands/newroot/newroot.sh | 5 - docs/UPDATING | 6 + drivers/ramdisk/Makefile | 177 ++++++++------------------- drivers/ramdisk/proto | 14 +-- drivers/ramdisk/proto.common.dynamic | 11 ++ drivers/ramdisk/proto.common.etc | 10 ++ drivers/ramdisk/proto.sh | 5 + drivers/ramdisk/proto.small | 12 -- drivers/ramdisk/rc | 6 +- 11 files changed, 89 insertions(+), 163 deletions(-) delete mode 100644 commands/newroot/Makefile delete mode 100644 commands/newroot/newroot.sh create mode 100644 drivers/ramdisk/proto.common.dynamic create mode 100644 drivers/ramdisk/proto.common.etc diff --git a/commands/Makefile b/commands/Makefile index 8be3ed5c7..747e07e90 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -18,7 +18,7 @@ SUBDIR= add_route arp ash at awk \ less lex loadkeys loadramdisk logger look lp \ lpd ls lspci mail make MAKEDEV \ mdb mesg mined mkfifo mkfs.mfs mknod \ - mkproto mount mt netconf newroot nice acknm nohup \ + mkproto mount mt netconf nice acknm nohup \ nonamed od paste patch pax \ ping postinstall poweroff pr prep printf printroot \ profile progressbar pr_routes ps pwd pwdauth \ diff --git a/commands/newroot/Makefile b/commands/newroot/Makefile deleted file mode 100644 index d23bb9dc2..000000000 --- a/commands/newroot/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -SCRIPTS= newroot.sh -MAN= - -.include diff --git a/commands/newroot/newroot.sh b/commands/newroot/newroot.sh deleted file mode 100644 index 1042c3887..000000000 --- a/commands/newroot/newroot.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -# Actually, newroot is just like mounting on the root -exec mount -n "$*" / > /dev/null - diff --git a/docs/UPDATING b/docs/UPDATING index 3378358ed..9740f6cb5 100644 --- a/docs/UPDATING +++ b/docs/UPDATING @@ -1,3 +1,9 @@ +20120416: + Upgrade your clang to clang-2.9nb6 or clang-3.1nb3 to be able to + build shared libraries and dynamically linked executables. The + system will keep working without them, but a dynamic-capable + system will be a requirement soon. + 20120413: Boot loader menu now has an option to boot into single user mode. To get the menu option do: diff --git a/drivers/ramdisk/Makefile b/drivers/ramdisk/Makefile index 682ae0ca7..6a4400709 100644 --- a/drivers/ramdisk/Makefile +++ b/drivers/ramdisk/Makefile @@ -2,34 +2,35 @@ .include -PROGRAMS= at_wini cdprobe dev2name floppy loadramdisk mount \ - pci procfs sh service sysenv mfs fsck.mfs -SCRIPTS=newroot - -.if ${MKSMALL} != "yes" -PROGRAMS+= ahci ext2 -.endif - -.if ${MKACPI} != "no" -PROGRAMS+= acpi -.endif +PROG_DRIVERS=at_wini floppy pci +PROG_COMMANDS=cdprobe dev2name loadramdisk mount fsck.mfs sysenv sh \ + service +PROG_SERVERS=mfs procfs +PROG_USRSBIN=pwd_mkdb +PROGRAMS=$(PROG_DRIVERS) $(PROG_COMMANDS) $(PROG_SERVERS) $(PROG_USRSBIN) +EXTRA=system.conf master.passwd pwd.db spwd.db rs.single .if ${MKSMALL} != "yes" +PROG_DRIVERS+= ahci +PROG_SERVERS+= ext2 PROTO= proto .else PROTO= proto.small .endif -EXTRA=system.conf master.passwd passwd pwd.db spwd.db rs.single +.if ${MKACPI} != "no" +PROG_DRIVERS+= acpi +.endif CPPFLAGS+= -I${MINIXSRCDIR}/servers -I${MINIXSRCDIR} CLEANFILES += $(PROGRAMS) $(SCRIPTS) $(EXTRA) image image.c t proto.gen +CLEANFILES += $(LIBRARIES) install: all realall: image -image: proto.gen mtab rc $(EXTRA) +image: proto.gen mtab rc $(EXTRA) passwd mkfs.mfs image proto.gen || { rm -f image; false; } if fsck.mfs -s image | grep -q CLEAN; \ then : ; \ @@ -38,134 +39,56 @@ image: proto.gen mtab rc $(EXTRA) rm -f image; false; \ fi -ahci: ../ahci/ahci - install ${STRIPFLAG} ../$@/$@ $@ - -../ahci/ahci: - $(MAKE) -C ../ahci - -at_wini: ../at_wini/at_wini - install ${STRIPFLAG} ../$@/$@ $@ - -../at_wini/at_wini: - $(MAKE) -C ../at_wini - -floppy: ../floppy/floppy - install ${STRIPFLAG} ../$@/$@ $@ - -../floppy/floppy: - $(MAKE) -C ../floppy - -acpi: ../acpi/acpi - install ${STRIPFLAG} ../$@/$@ $@ - -../acpi/acpi: - $(MAKE) -C ../acpi - -pci: ../pci/pci - install ${STRIPFLAG} ../$@/$@ $@ - -../pci/pci: - $(MAKE) -C ../pci - -cdprobe: ../../commands/cdprobe/cdprobe - install ${STRIPFLAG} ../../commands/$@/$@ $@ - -../../commands/cdprobe: - $(MAKE) -C ../../commands/cdprobe - -dev2name: ../../commands/dev2name/dev2name - install ${STRIPFLAG} ../../commands/$@/$@ $@ - -../../commands/dev2name/dev2name: - $(MAKE) -C ../../commands/dev2name +.for driver in $(PROG_DRIVERS) +$(driver): ../$(driver)/$(driver) + install $> $@ -loadramdisk: ../../commands/loadramdisk/loadramdisk - install ${STRIPFLAG} ../../commands/$@/$@ $@ +../$(driver)/$(driver): + $(MAKE) -C ../$(driver) $(driver) +.endfor -../../commands/loadramdisk/loadramdisk: - $(MAKE) -C ../../commands/loadramdisk - -mount: ../../commands/mount/mount - install ${STRIPFLAG} ../../commands/$@/$@ $@ - -../../commands/mount/mount: - $(MAKE) -C ../../commands/mount - -fsck.mfs: ../../commands/fsck.mfs/fsck.mfs - install ${STRIPFLAG} ../../commands/$@/$@ $@ - -../../commands/fsck.mfs/fsck.mfs: - $(MAKE) -C ../../commands/fsck.mfs - -newroot: ../../commands/newroot/newroot.sh - install ${STRIPFLAG} ../../commands/$@/$@.sh $@ - -../../commands/newroot/newroot: - $(MAKE) -C ../../commands/newroot - -sysenv: ../../commands/sysenv/sysenv - install ${STRIPFLAG} ../../commands/$@/$@ $@ - -../../commands/sysenv/sysenv: - $(MAKE) -C ../../commands/sysenv - -sh: ../../commands/ash/sh - install ${STRIPFLAG} ../../commands/ash/$@ $@ - -../../commands/ash/sh: - $(MAKE) -C ../../commands/ash sh - -service: ../../commands/service/service - install ${STRIPFLAG} ../../commands/service/$@ $@ - -../../commands/service/service: - $(MAKE) -C ../../commands/service - -mfs: ../../servers/mfs/mfs - install ${STRIPFLAG} ../../servers/mfs/$@ $@ +.for cmd in $(PROG_COMMANDS) +.if $(cmd) == sh +dir.$(cmd)=ash +.else +dir.$(cmd)=$(cmd) +.endif +$(cmd): ../../commands/$(dir.$(cmd))/$(cmd) + install $> $@ -../../servers/mfs/mfs: - $(MAKE) -C ../../servers/mfs +../../commands/$(dir.$(cmd))/$(cmd): + $(MAKE) -C ../../commands/$(dir.$(cmd)) $(cmd) +.endfor -procfs: ../../servers/procfs/procfs - install ${STRIPFLAG} ../../servers/procfs/$@ $@ +.for etc in $(EXTRA) +$(etc): ../../etc/$(etc) + install $> $@ +.endfor -../../servers/procfs/procfs: - $(MAKE) -C ../../servers/procfs +.for cmd in $(PROG_USRSBIN) +$(cmd): ../../usr.sbin/$(cmd)/$(cmd) + install $> $@ -ext2: ../../servers/ext2/ext2 - install ${STRIPFLAG} ../../servers/ext2/$@ $@ +../../usr.sbin/$(cmd)/$(cmd): + $(MAKE) -C ../../usr.sbin/$(cmd) $(cmd) +.endfor -../../servers/ext2/ext2: - $(MAKE) -C ../../servers/ext2 +.for server in $(PROG_SERVERS) +$(server): ../../servers/$(server)/$(server) + install $> $@ -system.conf: ../../etc/system.conf - install ${STRIPFLAG} ../../etc/$@ $@ +../../servers/$(server)/$(server): + $(MAKE) -C ../../servers/$(server) $(server) +.endfor passwd: ../../etc/master.passwd ../../usr.sbin/pwd_mkdb/pwd_mkdb rm -f ../../etc/master.passwd.orig ../../etc/passwd.orig rm -f ../../etc/pwd.db.tmp ../../etc/spwd.db.tmp ../../usr.sbin/pwd_mkdb/pwd_mkdb -V 0 -p -d ../../ ../../etc/master.passwd - install ${STRIPFLAG} ../../etc/$@ $@ - -../../usr.sbin/pwd_mkdb/pwd_mkdb: - $(MAKE) -C ../../usr.sbin/pwd_mkdb - -master.passwd: ../../etc/master.passwd - install ${STRIPFLAG} ../../etc/$@ $@ - -pwd.db: passwd - install ${STRIPFLAG} ../../etc/$@ $@ - -spwd.db: passwd - install ${STRIPFLAG} ../../etc/$@ $@ - -rs.single: ../../etc/rs.single - install ${STRIPFLAG} ../../etc/$@ $@ + install ../../etc/$@ $@ -proto.gen: $(PROGRAMS) $(SCRIPTS) proto.sh ${PROTO} - for p in $(PROGRAMS); do file $$p | grep -q ELF && strip -s $$p || true; done +proto.gen: $(PROGRAMS) proto.sh ${PROTO} proto.common.etc proto.common.dynamic proto.sh + strip $(PROGRAMS) sh -e proto.sh ${PROTO} >proto.gen .include diff --git a/drivers/ramdisk/proto b/drivers/ramdisk/proto index a5dbeb827..d134caaa5 100644 --- a/drivers/ramdisk/proto +++ b/drivers/ramdisk/proto @@ -1,12 +1,11 @@ boot -840 540 +1200 540 d--755 0 0 bin d--755 0 0 cdprobe ---755 0 0 cdprobe dev2name ---755 0 0 dev2name loadramdisk ---755 0 0 loadramdisk mount ---755 0 0 mount - newroot ---755 0 0 newroot sh ---755 0 0 sh service ---755 0 0 service sysenv ---755 0 0 sysenv @@ -25,14 +24,3 @@ d--755 0 0 dev d--755 0 0 @DEV@ $ - etc d--755 0 0 - system.conf ---644 0 0 system.conf - mtab ---644 0 0 mtab - passwd ---644 0 0 passwd - pwd.db ---644 0 0 pwd.db - spwd.db ---600 0 0 spwd.db - master.passwd ---600 0 0 master.passwd - rc ---755 0 0 rc - rs.single ---755 0 0 rs.single - $ -$ diff --git a/drivers/ramdisk/proto.common.dynamic b/drivers/ramdisk/proto.common.dynamic new file mode 100644 index 000000000..82a9fb150 --- /dev/null +++ b/drivers/ramdisk/proto.common.dynamic @@ -0,0 +1,11 @@ + libexec d--755 0 0 + ld.elf_so ---755 0 0 /libexec/ld.elf_so + $ + usr d--755 0 0 + lib d--755 0 0 + libc.so.12 ---755 0 0 /lib/libc.so.12 + libminlib.so.1 ---755 0 0 /lib/libminlib.so.1 + libcompat_minix.so.1 ---755 0 0 /lib/libcompat_minix.so.1 + libterminfo.so.1 ---755 0 0 /lib/libterminfo.so.1 + $ + $ diff --git a/drivers/ramdisk/proto.common.etc b/drivers/ramdisk/proto.common.etc new file mode 100644 index 000000000..b2c12f28e --- /dev/null +++ b/drivers/ramdisk/proto.common.etc @@ -0,0 +1,10 @@ + etc d--755 0 0 + system.conf ---644 0 0 system.conf + mtab ---644 0 0 mtab + passwd ---644 0 0 passwd + pwd.db ---644 0 0 pwd.db + spwd.db ---600 0 0 spwd.db + master.passwd ---600 0 0 master.passwd + rc ---755 0 0 rc + rs.single ---755 0 0 rs.single + $ diff --git a/drivers/ramdisk/proto.sh b/drivers/ramdisk/proto.sh index 3ed5ce691..630fcdc1e 100644 --- a/drivers/ramdisk/proto.sh +++ b/drivers/ramdisk/proto.sh @@ -18,3 +18,8 @@ sed -e 's/^[bc]/& /' -e 's/rw-/6/g' -e 's/r--/4/g' \ awk '{ printf "\t\t%s %s--%s %d %d %d %d \n", $11, $1, $2, $4, $5, $6, $7; }' ) sed -n '/@DEV/,$p' <${PROTO} | grep -v @DEV@ +cat proto.common.etc +if [ -x /libexec/ld.elf_so ] +then cat proto.common.dynamic +fi +echo '$' diff --git a/drivers/ramdisk/proto.small b/drivers/ramdisk/proto.small index 1cc6d5235..1dec5f427 100644 --- a/drivers/ramdisk/proto.small +++ b/drivers/ramdisk/proto.small @@ -6,7 +6,6 @@ d--755 0 0 dev2name ---755 0 0 dev2name loadramdisk ---755 0 0 loadramdisk mount ---755 0 0 mount - newroot ---755 0 0 newroot sh ---755 0 0 sh service ---755 0 0 service sysenv ---755 0 0 sysenv @@ -22,14 +21,3 @@ d--755 0 0 dev d--755 0 0 @DEV@ $ - etc d--755 0 0 - system.conf ---644 0 0 system.conf - mtab ---644 0 0 mtab - passwd ---644 0 0 passwd - pwd.db ---644 0 0 pwd.db - spwd.db ---600 0 0 spwd.db - master.passwd ---600 0 0 master.passwd - rc ---755 0 0 rc - rs.single ---755 0 0 rs.single - $ -$ diff --git a/drivers/ramdisk/rc b/drivers/ramdisk/rc index 0aeb4a95b..7be8797b6 100644 --- a/drivers/ramdisk/rc +++ b/drivers/ramdisk/rc @@ -67,7 +67,11 @@ echo "Root device name is $rootdevname" if [ -e $FSCK ] then $FSCK -p $rootdevname fi -/bin/newroot $bin_img"$rootdevname" + +# Change root from temporary boot ramdisk to the configure +# root device +/bin/mount -n $bin_img"$rootdevname" / + /bin/mount -e -n -t procfs none /proc || echo "WARNING: couldn't mount procfs" exec /bin/sh /etc/rc "$@" -- 2.44.0