INIT died problem / build system robustness
Changes provoked by debugging / making 'PM: INIT died' error debuggable. This was caused (in one instance) by a missing /dev/console (and everything else) on the boot time ramdisk. . sanity-check against this case by checking for console . PM: print init stacktrace and exit status when init dies . eliminate some explicitly invoked ${MAKE}s and a rm -rf in Makefiles, causing race conditions; use explicit ordering (.WAIT) instead, moving some of the burden of dependencies of partial builds to the user. On the plus side, generate ramdisk just once. . make mkfs.mfs fail as soon as it sees an error missing file in the proto file. - except for EACCES on minix native for the mfs test. also fix some fmt warnings. . init: include debug info in executable Change-Id: I8eea4986a4f64ecaf223aff5da321d8b4f4a3fa4
This commit is contained in:
parent
11eaad3501
commit
cd34841de5
9 changed files with 60 additions and 27 deletions
7
Makefile
7
Makefile
|
@ -138,12 +138,13 @@ _SRC_TOP_OBJ_=
|
||||||
# BUILD_${dir}=no, or that have no ${dir}/Makefile.
|
# BUILD_${dir}=no, or that have no ${dir}/Makefile.
|
||||||
#
|
#
|
||||||
_SUBDIR= tools lib include gnu external crypto/external bin games
|
_SUBDIR= tools lib include gnu external crypto/external bin games
|
||||||
.if defined(__MINIX)
|
|
||||||
_SUBDIR+= minix
|
|
||||||
.endif # defined(__MINIX)
|
|
||||||
_SUBDIR+= libexec sbin usr.bin
|
_SUBDIR+= libexec sbin usr.bin
|
||||||
_SUBDIR+= usr.sbin share sys etc tests compat
|
_SUBDIR+= usr.sbin share sys etc tests compat
|
||||||
_SUBDIR+= .WAIT rescue .WAIT distrib regress
|
_SUBDIR+= .WAIT rescue .WAIT distrib regress
|
||||||
|
.if defined(__MINIX)
|
||||||
|
# the minix subdir depends on some other things (e.g. lib/)
|
||||||
|
_SUBDIR+= .WAIT minix
|
||||||
|
.endif # defined(__MINIX)
|
||||||
|
|
||||||
.for dir in ${_SUBDIR}
|
.for dir in ${_SUBDIR}
|
||||||
.if "${dir}" == ".WAIT" \
|
.if "${dir}" == ".WAIT" \
|
||||||
|
|
|
@ -3,7 +3,6 @@ SUBDIR+= include .WAIT
|
||||||
SUBDIR+= benchmarks
|
SUBDIR+= benchmarks
|
||||||
SUBDIR+= bin
|
SUBDIR+= bin
|
||||||
SUBDIR+= commands
|
SUBDIR+= commands
|
||||||
SUBDIR+= drivers
|
|
||||||
SUBDIR+= fs
|
SUBDIR+= fs
|
||||||
SUBDIR+= kernel
|
SUBDIR+= kernel
|
||||||
SUBDIR+= lib
|
SUBDIR+= lib
|
||||||
|
@ -17,4 +16,7 @@ SUBDIR+= tests
|
||||||
SUBDIR+= usr.bin
|
SUBDIR+= usr.bin
|
||||||
SUBDIR+= usr.sbin
|
SUBDIR+= usr.sbin
|
||||||
|
|
||||||
|
# BJG - build drivers last as the ramdisk depends on some other drivers
|
||||||
|
SUBDIR+= .WAIT drivers
|
||||||
|
|
||||||
.include <bsd.subdir.mk>
|
.include <bsd.subdir.mk>
|
||||||
|
|
|
@ -20,6 +20,8 @@ SUBDIR+= vmm_guest
|
||||||
SUBDIR+= bus
|
SUBDIR+= bus
|
||||||
SUBDIR+= tty
|
SUBDIR+= tty
|
||||||
SUBDIR+= hid
|
SUBDIR+= hid
|
||||||
SUBDIR+= storage
|
|
||||||
|
# BJG - build storage last as the ramdisk depends on some other things
|
||||||
|
SUBDIR+= .WAIT storage
|
||||||
|
|
||||||
.include <bsd.subdir.mk>
|
.include <bsd.subdir.mk>
|
||||||
|
|
|
@ -17,7 +17,9 @@ SUBDIR+= at_wini
|
||||||
SUBDIR+= floppy
|
SUBDIR+= floppy
|
||||||
.endif # ${MACHINE_ARCH} == "i386"
|
.endif # ${MACHINE_ARCH} == "i386"
|
||||||
|
|
||||||
# memory driver must be last for ramdisk image
|
# memory driver must be last for ramdisk image.
|
||||||
SUBDIR+= ramdisk .WAIT memory
|
# Everything else must be done before ramdisk as it needs
|
||||||
|
# executables from other targets.
|
||||||
|
SUBDIR+= .WAIT ramdisk .WAIT memory
|
||||||
|
|
||||||
.include <bsd.subdir.mk>
|
.include <bsd.subdir.mk>
|
||||||
|
|
|
@ -26,8 +26,9 @@ touch-genfiles:
|
||||||
${OBJCOPY} -Ibinary -B${MACHINE_CPU} -O${MACHINE_GNU_PLATFORM} $< $@
|
${OBJCOPY} -Ibinary -B${MACHINE_CPU} -O${MACHINE_GNU_PLATFORM} $< $@
|
||||||
|
|
||||||
CLEANFILES+= ../ramdisk/image
|
CLEANFILES+= ../ramdisk/image
|
||||||
../ramdisk/image: .PHONY
|
# BJG - don't invoke parallel Makes
|
||||||
${MAKE} -C ${RAMDISK_PATH} image
|
#../ramdisk/image: .PHONY
|
||||||
|
# ${MAKE} -C ${RAMDISK_PATH} image
|
||||||
|
|
||||||
CLEANFILES+= imgrd.mfs
|
CLEANFILES+= imgrd.mfs
|
||||||
imgrd.mfs: ../ramdisk/image
|
imgrd.mfs: ../ramdisk/image
|
||||||
|
|
|
@ -151,8 +151,9 @@ CLEANFILES += ${lib}.so.0
|
||||||
${lib}.so.0:${PROGROOT}/lib/${lib}/${lib}.so.0
|
${lib}.so.0:${PROGROOT}/lib/${lib}/${lib}.so.0
|
||||||
${INSTALL} $> $@
|
${INSTALL} $> $@
|
||||||
|
|
||||||
${PROGROOT}/lib/${lib}/${lib}.so.0:
|
# BJG - Don't invoke parallel Makes
|
||||||
${MAKE} -C ${NETBSDSRCDIR}/lib/${lib} all
|
#${PROGROOT}/lib/${lib}/${lib}.so.0:
|
||||||
|
# ${MAKE} -C ${NETBSDSRCDIR}/lib/${lib} all
|
||||||
.endfor
|
.endfor
|
||||||
|
|
||||||
.for lib in ${PROG_MINIXLIBS}
|
.for lib in ${PROG_MINIXLIBS}
|
||||||
|
@ -161,8 +162,9 @@ CLEANFILES += ${lib}.so.0
|
||||||
${lib}.so.0:${PROGROOT}/minix/lib/${lib}/${lib}.so.0
|
${lib}.so.0:${PROGROOT}/minix/lib/${lib}/${lib}.so.0
|
||||||
${INSTALL} $> $@
|
${INSTALL} $> $@
|
||||||
|
|
||||||
${PROGROOT}/minix/lib/${lib}/${lib}.so.0:
|
# BJG - Don't invoke parallel Makes
|
||||||
${MAKE} -C ${NETBSDSRCDIR}/minix/lib/${lib} all
|
#${PROGROOT}/minix/lib/${lib}/${lib}.so.0:
|
||||||
|
# ${MAKE} -C ${NETBSDSRCDIR}/minix/lib/${lib} all
|
||||||
.endfor
|
.endfor
|
||||||
|
|
||||||
# Generate dependencies rules for binaries
|
# Generate dependencies rules for binaries
|
||||||
|
@ -170,8 +172,9 @@ ${PROGROOT}/minix/lib/${lib}/${lib}.so.0:
|
||||||
${prog}: ${PROGROOT}/${dir.${prog}}/${prog}
|
${prog}: ${PROGROOT}/${dir.${prog}}/${prog}
|
||||||
${INSTALL} $> $@
|
${INSTALL} $> $@
|
||||||
|
|
||||||
${PROGROOT}/${dir.${prog}}/${prog}:
|
# BJG - don't invoke parallel Makes
|
||||||
${MAKE} -C ${NETBSDSRCDIR}/${dir.${prog}} all
|
#${PROGROOT}/${dir.${prog}}/${prog}:
|
||||||
|
# ${MAKE} -C ${NETBSDSRCDIR}/${dir.${prog}} all
|
||||||
.endfor # prog
|
.endfor # prog
|
||||||
|
|
||||||
realall image: proto.gen ${ETC:C/^/etc\//} ${EXTRA} \
|
realall image: proto.gen ${ETC:C/^/etc\//} ${EXTRA} \
|
||||||
|
@ -182,7 +185,6 @@ realall image: proto.gen ${ETC:C/^/etc\//} ${EXTRA} \
|
||||||
etc/pwd.db etc/spwd.db etc/passwd: etc/master.passwd
|
etc/pwd.db etc/spwd.db etc/passwd: etc/master.passwd
|
||||||
|
|
||||||
etc/master.passwd: ${NETBSDSRCDIR}/etc/master.passwd
|
etc/master.passwd: ${NETBSDSRCDIR}/etc/master.passwd
|
||||||
rm -rf ${.OBJDIR}/etc/
|
|
||||||
mkdir -p ${.OBJDIR}/etc
|
mkdir -p ${.OBJDIR}/etc
|
||||||
${INSTALL} $> $@
|
${INSTALL} $> $@
|
||||||
${TOOL_PWD_MKDB} -V 0 -p -d . etc/master.passwd
|
${TOOL_PWD_MKDB} -V 0 -p -d . etc/master.passwd
|
||||||
|
@ -201,8 +203,9 @@ proto.dev.mtree:
|
||||||
proto.dev: proto.dev.mtree etc/pwd.db etc/spwd.db etc/passwd etc/group
|
proto.dev: proto.dev.mtree etc/pwd.db etc/spwd.db etc/passwd etc/group
|
||||||
${TOOL_MTREE} -f ${.TARGET}.mtree -N ${.OBJDIR}/etc -C -K device | \
|
${TOOL_MTREE} -f ${.TARGET}.mtree -N ${.OBJDIR}/etc -C -K device | \
|
||||||
${TOOL_TOPROTO} | ${TOOL_SED} -e '1,4d' | \
|
${TOOL_TOPROTO} | ${TOOL_SED} -e '1,4d' | \
|
||||||
${TOOL_SED} -e '$$d' |${TOOL_SED} -e '$$d' > ${.TARGET}.tmp && \
|
${TOOL_SED} -e '$$d' |${TOOL_SED} -e '$$d' > ${.TARGET}.tmp
|
||||||
mv ${.TARGET}.tmp ${.TARGET}
|
grep console ${.TARGET}.tmp # sanity check; is there a console entry?
|
||||||
|
mv ${.TARGET}.tmp ${.TARGET}
|
||||||
|
|
||||||
proto.gen: ${PROTO} ${PROTO_FILES} proto.dev ${PROGRAMS}
|
proto.gen: ${PROTO} ${PROTO_FILES} proto.dev ${PROGRAMS}
|
||||||
${STRIP} ${PROGRAMS}
|
${STRIP} ${PROGRAMS}
|
||||||
|
|
|
@ -314,7 +314,8 @@ int dump_core; /* flag indicating whether to dump core */
|
||||||
vm_notify_sig_wrapper(rmp->mp_endpoint);
|
vm_notify_sig_wrapper(rmp->mp_endpoint);
|
||||||
if (proc_nr_e == INIT_PROC_NR)
|
if (proc_nr_e == INIT_PROC_NR)
|
||||||
{
|
{
|
||||||
printf("PM: INIT died\n");
|
printf("PM: INIT died with exit status %d; showing stacktrace\n", exit_status);
|
||||||
|
sys_diagctl_stacktrace(proc_nr_e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (proc_nr_e == VFS_PROC_NR)
|
if (proc_nr_e == VFS_PROC_NR)
|
||||||
|
|
|
@ -308,7 +308,7 @@ main(int argc, char *argv[])
|
||||||
} else {
|
} else {
|
||||||
if(bblocks < strtol(token[0], (char **) NULL, 10)) {
|
if(bblocks < strtol(token[0], (char **) NULL, 10)) {
|
||||||
errx(1, "%s: number of blocks given as parameter(%d)"
|
errx(1, "%s: number of blocks given as parameter(%d)"
|
||||||
" is too small for given proto file(%d).",
|
" is too small for given proto file(%ld).",
|
||||||
argv[optind], bblocks,
|
argv[optind], bblocks,
|
||||||
strtol(token[0], (char **) NULL, 10));
|
strtol(token[0], (char **) NULL, 10));
|
||||||
};
|
};
|
||||||
|
@ -432,7 +432,7 @@ main(int argc, char *argv[])
|
||||||
(int)next_inode-1, next_zone);
|
(int)next_inode-1, next_zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(insertmode) printf("%ld\n", written_fs_size);
|
if(insertmode) printf("%llu\n", written_fs_size);
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
|
@ -502,7 +502,15 @@ sizeup_dir(struct fs_size * fssize)
|
||||||
fssize->zonecount++; /* Symlink contents is always stored a block */
|
fssize->zonecount++; /* Symlink contents is always stored a block */
|
||||||
} else {
|
} else {
|
||||||
if ((f = fopen(token[4], "rb")) == NULL) {
|
if ((f = fopen(token[4], "rb")) == NULL) {
|
||||||
warn("dynamic sizing: can't open %s", token[4]);
|
/* on minix natively, allow EACCES and skip the entry.
|
||||||
|
* while crossbuilding, always fail on error.
|
||||||
|
*/
|
||||||
|
#ifdef __minix
|
||||||
|
if(errno == EACCES)
|
||||||
|
warn("dynamic sizing: can't open %s", token[4]);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
err(1, "dynamic sizing: can't open %s", token[4]);
|
||||||
} else if (fseek(f, 0, SEEK_END) < 0) {
|
} else if (fseek(f, 0, SEEK_END) < 0) {
|
||||||
pexit("dynamic size detection failed: seek to end of %s",
|
pexit("dynamic size detection failed: seek to end of %s",
|
||||||
token[4]);
|
token[4]);
|
||||||
|
@ -805,8 +813,15 @@ eat_dir(ino_t parent)
|
||||||
} else {
|
} else {
|
||||||
/* Regular file. Go read it. */
|
/* Regular file. Go read it. */
|
||||||
if ((f = open(token[4], O_RDONLY)) < 0) {
|
if ((f = open(token[4], O_RDONLY)) < 0) {
|
||||||
fprintf(stderr, "%s: Can't open %s: %s\n",
|
/* on minix natively, allow EACCES and skip the entry.
|
||||||
progname, token[4], strerror(errno));
|
* while crossbuilding, always fail on error.
|
||||||
|
*/
|
||||||
|
#ifdef __minix
|
||||||
|
if(errno == EACCES)
|
||||||
|
warn("Can't open %s", token[4]);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
err(1, "Can't open %s", token[4]);
|
||||||
} else {
|
} else {
|
||||||
eat_file(n, f);
|
eat_file(n, f);
|
||||||
}
|
}
|
||||||
|
@ -1103,7 +1118,7 @@ alloc_inode(int mode, int usrid, int grpid)
|
||||||
|
|
||||||
num = next_inode++;
|
num = next_inode++;
|
||||||
if (num > nrinodes) {
|
if (num > nrinodes) {
|
||||||
pexit("File system does not have enough inodes (only %d)", nrinodes);
|
pexit("File system does not have enough inodes (only %llu)", nrinodes);
|
||||||
}
|
}
|
||||||
b = ((num - 1) / inodes_per_block) + inode_offset;
|
b = ((num - 1) / inodes_per_block) + inode_offset;
|
||||||
off = (num - 1) % inodes_per_block;
|
off = (num - 1) % inodes_per_block;
|
||||||
|
@ -1114,7 +1129,7 @@ alloc_inode(int mode, int usrid, int grpid)
|
||||||
|
|
||||||
get_block(b, inodes);
|
get_block(b, inodes);
|
||||||
if (inodes[off].i_mode) {
|
if (inodes[off].i_mode) {
|
||||||
pexit("allocation new inode %d with non-zero mode - this cannot happen",
|
pexit("allocation new inode %llu with non-zero mode - this cannot happen",
|
||||||
num);
|
num);
|
||||||
}
|
}
|
||||||
inodes[off].i_mode = mode;
|
inodes[off].i_mode = mode;
|
||||||
|
@ -1614,7 +1629,7 @@ mkfs_write(void * buf, size_t count)
|
||||||
if(w < 0)
|
if(w < 0)
|
||||||
err(1, "mkfs_write: write failed");
|
err(1, "mkfs_write: write failed");
|
||||||
if(w != count)
|
if(w != count)
|
||||||
errx(1, "mkfs_write: short write: %ld != %ld", w, count);
|
errx(1, "mkfs_write: short write: %zd != %zu", w, count);
|
||||||
|
|
||||||
/* Check if this has made the FS any bigger; count bytes after offset */
|
/* Check if this has made the FS any bigger; count bytes after offset */
|
||||||
fssize = mkfs_seek(0, SEEK_CUR);
|
fssize = mkfs_seek(0, SEEK_CUR);
|
||||||
|
|
|
@ -7,6 +7,12 @@ DPADD= ${LIBUTIL}
|
||||||
LDADD= -lutil
|
LDADD= -lutil
|
||||||
CPPFLAGS+= -DMFS_DEV_IF_NO_CONSOLE -DSUPPORT_UTMP -DSUPPORT_UTMPX
|
CPPFLAGS+= -DMFS_DEV_IF_NO_CONSOLE -DSUPPORT_UTMP -DSUPPORT_UTMPX
|
||||||
|
|
||||||
|
#.if defined(__MINIX)
|
||||||
|
# BJG - by default produce line numbers in case init exits without producing
|
||||||
|
# output
|
||||||
|
DBG=-g
|
||||||
|
#.endif
|
||||||
|
|
||||||
.ifdef INIT_CHROOT
|
.ifdef INIT_CHROOT
|
||||||
CPPFLAGS+= -DCHROOT
|
CPPFLAGS+= -DCHROOT
|
||||||
.elifdef SMALLPROG
|
.elifdef SMALLPROG
|
||||||
|
|
Loading…
Reference in a new issue