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
This commit is contained in:
Ben Gras 2012-04-10 02:07:51 +00:00
parent 0c8e5ecc2e
commit 53f94f8ed4
11 changed files with 89 additions and 163 deletions

View file

@ -18,7 +18,7 @@ SUBDIR= add_route arp ash at awk \
less lex loadkeys loadramdisk logger look lp \ less lex loadkeys loadramdisk logger look lp \
lpd ls lspci mail make MAKEDEV \ lpd ls lspci mail make MAKEDEV \
mdb mesg mined mkfifo mkfs.mfs mknod \ 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 \ nonamed od paste patch pax \
ping postinstall poweroff pr prep printf printroot \ ping postinstall poweroff pr prep printf printroot \
profile progressbar pr_routes ps pwd pwdauth \ profile progressbar pr_routes ps pwd pwdauth \

View file

@ -1,4 +0,0 @@
SCRIPTS= newroot.sh
MAN=
.include <bsd.prog.mk>

View file

@ -1,5 +0,0 @@
#!/bin/sh
# Actually, newroot is just like mounting on the root
exec mount -n "$*" / > /dev/null

View file

@ -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: 20120413:
Boot loader menu now has an option to boot into single user mode. To Boot loader menu now has an option to boot into single user mode. To
get the menu option do: get the menu option do:

View file

@ -2,34 +2,35 @@
.include <bsd.own.mk> .include <bsd.own.mk>
PROGRAMS= at_wini cdprobe dev2name floppy loadramdisk mount \ PROG_DRIVERS=at_wini floppy pci
pci procfs sh service sysenv mfs fsck.mfs PROG_COMMANDS=cdprobe dev2name loadramdisk mount fsck.mfs sysenv sh \
SCRIPTS=newroot service
PROG_SERVERS=mfs procfs
.if ${MKSMALL} != "yes" PROG_USRSBIN=pwd_mkdb
PROGRAMS+= ahci ext2 PROGRAMS=$(PROG_DRIVERS) $(PROG_COMMANDS) $(PROG_SERVERS) $(PROG_USRSBIN)
.endif EXTRA=system.conf master.passwd pwd.db spwd.db rs.single
.if ${MKACPI} != "no"
PROGRAMS+= acpi
.endif
.if ${MKSMALL} != "yes" .if ${MKSMALL} != "yes"
PROG_DRIVERS+= ahci
PROG_SERVERS+= ext2
PROTO= proto PROTO= proto
.else .else
PROTO= proto.small PROTO= proto.small
.endif .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} CPPFLAGS+= -I${MINIXSRCDIR}/servers -I${MINIXSRCDIR}
CLEANFILES += $(PROGRAMS) $(SCRIPTS) $(EXTRA) image image.c t proto.gen CLEANFILES += $(PROGRAMS) $(SCRIPTS) $(EXTRA) image image.c t proto.gen
CLEANFILES += $(LIBRARIES)
install: all install: all
realall: image realall: image
image: proto.gen mtab rc $(EXTRA) image: proto.gen mtab rc $(EXTRA) passwd
mkfs.mfs image proto.gen || { rm -f image; false; } mkfs.mfs image proto.gen || { rm -f image; false; }
if fsck.mfs -s image | grep -q CLEAN; \ if fsck.mfs -s image | grep -q CLEAN; \
then : ; \ then : ; \
@ -38,134 +39,56 @@ image: proto.gen mtab rc $(EXTRA)
rm -f image; false; \ rm -f image; false; \
fi fi
ahci: ../ahci/ahci .for driver in $(PROG_DRIVERS)
install ${STRIPFLAG} ../$@/$@ $@ $(driver): ../$(driver)/$(driver)
install $> $@
../ahci/ahci: ../$(driver)/$(driver):
$(MAKE) -C ../ahci $(MAKE) -C ../$(driver) $(driver)
.endfor
at_wini: ../at_wini/at_wini .for cmd in $(PROG_COMMANDS)
install ${STRIPFLAG} ../$@/$@ $@ .if $(cmd) == sh
dir.$(cmd)=ash
.else
dir.$(cmd)=$(cmd)
.endif
$(cmd): ../../commands/$(dir.$(cmd))/$(cmd)
install $> $@
../at_wini/at_wini: ../../commands/$(dir.$(cmd))/$(cmd):
$(MAKE) -C ../at_wini $(MAKE) -C ../../commands/$(dir.$(cmd)) $(cmd)
.endfor
floppy: ../floppy/floppy .for etc in $(EXTRA)
install ${STRIPFLAG} ../$@/$@ $@ $(etc): ../../etc/$(etc)
install $> $@
.endfor
../floppy/floppy: .for cmd in $(PROG_USRSBIN)
$(MAKE) -C ../floppy $(cmd): ../../usr.sbin/$(cmd)/$(cmd)
install $> $@
acpi: ../acpi/acpi ../../usr.sbin/$(cmd)/$(cmd):
install ${STRIPFLAG} ../$@/$@ $@ $(MAKE) -C ../../usr.sbin/$(cmd) $(cmd)
.endfor
../acpi/acpi: .for server in $(PROG_SERVERS)
$(MAKE) -C ../acpi $(server): ../../servers/$(server)/$(server)
install $> $@
pci: ../pci/pci ../../servers/$(server)/$(server):
install ${STRIPFLAG} ../$@/$@ $@ $(MAKE) -C ../../servers/$(server) $(server)
.endfor
../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
loadramdisk: ../../commands/loadramdisk/loadramdisk
install ${STRIPFLAG} ../../commands/$@/$@ $@
../../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/$@ $@
../../servers/mfs/mfs:
$(MAKE) -C ../../servers/mfs
procfs: ../../servers/procfs/procfs
install ${STRIPFLAG} ../../servers/procfs/$@ $@
../../servers/procfs/procfs:
$(MAKE) -C ../../servers/procfs
ext2: ../../servers/ext2/ext2
install ${STRIPFLAG} ../../servers/ext2/$@ $@
../../servers/ext2/ext2:
$(MAKE) -C ../../servers/ext2
system.conf: ../../etc/system.conf
install ${STRIPFLAG} ../../etc/$@ $@
passwd: ../../etc/master.passwd ../../usr.sbin/pwd_mkdb/pwd_mkdb passwd: ../../etc/master.passwd ../../usr.sbin/pwd_mkdb/pwd_mkdb
rm -f ../../etc/master.passwd.orig ../../etc/passwd.orig rm -f ../../etc/master.passwd.orig ../../etc/passwd.orig
rm -f ../../etc/pwd.db.tmp ../../etc/spwd.db.tmp rm -f ../../etc/pwd.db.tmp ../../etc/spwd.db.tmp
../../usr.sbin/pwd_mkdb/pwd_mkdb -V 0 -p -d ../../ ../../etc/master.passwd ../../usr.sbin/pwd_mkdb/pwd_mkdb -V 0 -p -d ../../ ../../etc/master.passwd
install ${STRIPFLAG} ../../etc/$@ $@ install ../../etc/$@ $@
../../usr.sbin/pwd_mkdb/pwd_mkdb: proto.gen: $(PROGRAMS) proto.sh ${PROTO} proto.common.etc proto.common.dynamic proto.sh
$(MAKE) -C ../../usr.sbin/pwd_mkdb strip $(PROGRAMS)
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/$@ $@
proto.gen: $(PROGRAMS) $(SCRIPTS) proto.sh ${PROTO}
for p in $(PROGRAMS); do file $$p | grep -q ELF && strip -s $$p || true; done
sh -e proto.sh ${PROTO} >proto.gen sh -e proto.sh ${PROTO} >proto.gen
.include <minix.service.mk> .include <minix.service.mk>

View file

@ -1,12 +1,11 @@
boot boot
840 540 1200 540
d--755 0 0 d--755 0 0
bin d--755 0 0 bin d--755 0 0
cdprobe ---755 0 0 cdprobe cdprobe ---755 0 0 cdprobe
dev2name ---755 0 0 dev2name dev2name ---755 0 0 dev2name
loadramdisk ---755 0 0 loadramdisk loadramdisk ---755 0 0 loadramdisk
mount ---755 0 0 mount mount ---755 0 0 mount
newroot ---755 0 0 newroot
sh ---755 0 0 sh sh ---755 0 0 sh
service ---755 0 0 service service ---755 0 0 service
sysenv ---755 0 0 sysenv sysenv ---755 0 0 sysenv
@ -25,14 +24,3 @@ d--755 0 0
dev d--755 0 0 dev d--755 0 0
@DEV@ @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
$
$

View file

@ -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
$
$

View file

@ -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
$

View file

@ -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; }' 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@ 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 '$'

View file

@ -6,7 +6,6 @@ d--755 0 0
dev2name ---755 0 0 dev2name dev2name ---755 0 0 dev2name
loadramdisk ---755 0 0 loadramdisk loadramdisk ---755 0 0 loadramdisk
mount ---755 0 0 mount mount ---755 0 0 mount
newroot ---755 0 0 newroot
sh ---755 0 0 sh sh ---755 0 0 sh
service ---755 0 0 service service ---755 0 0 service
sysenv ---755 0 0 sysenv sysenv ---755 0 0 sysenv
@ -22,14 +21,3 @@ d--755 0 0
dev d--755 0 0 dev d--755 0 0
@DEV@ @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
$
$

View file

@ -67,7 +67,11 @@ echo "Root device name is $rootdevname"
if [ -e $FSCK ] if [ -e $FSCK ]
then $FSCK -p $rootdevname then $FSCK -p $rootdevname
fi 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" /bin/mount -e -n -t procfs none /proc || echo "WARNING: couldn't mount procfs"
exec /bin/sh /etc/rc "$@" exec /bin/sh /etc/rc "$@"