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
# BUILD_${dir}=no, or that have no ${dir}/Makefile.
#
_SUBDIR= tools lib include gnu external crypto/external bin games
-.if defined(__MINIX)
-_SUBDIR+= minix
-.endif # defined(__MINIX)
_SUBDIR+= libexec sbin usr.bin
_SUBDIR+= usr.sbin share sys etc tests compat
_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}
.if "${dir}" == ".WAIT" \
SUBDIR+= benchmarks
SUBDIR+= bin
SUBDIR+= commands
-SUBDIR+= drivers
SUBDIR+= fs
SUBDIR+= kernel
SUBDIR+= lib
SUBDIR+= usr.bin
SUBDIR+= usr.sbin
+# BJG - build drivers last as the ramdisk depends on some other drivers
+SUBDIR+= .WAIT drivers
+
.include <bsd.subdir.mk>
SUBDIR+= bus
SUBDIR+= tty
SUBDIR+= hid
-SUBDIR+= storage
+
+# BJG - build storage last as the ramdisk depends on some other things
+SUBDIR+= .WAIT storage
.include <bsd.subdir.mk>
SUBDIR+= floppy
.endif # ${MACHINE_ARCH} == "i386"
-# memory driver must be last for ramdisk image
-SUBDIR+= ramdisk .WAIT memory
+# memory driver must be last for ramdisk image.
+# Everything else must be done before ramdisk as it needs
+# executables from other targets.
+SUBDIR+= .WAIT ramdisk .WAIT memory
.include <bsd.subdir.mk>
${OBJCOPY} -Ibinary -B${MACHINE_CPU} -O${MACHINE_GNU_PLATFORM} $< $@
CLEANFILES+= ../ramdisk/image
-../ramdisk/image: .PHONY
- ${MAKE} -C ${RAMDISK_PATH} image
+# BJG - don't invoke parallel Makes
+#../ramdisk/image: .PHONY
+# ${MAKE} -C ${RAMDISK_PATH} image
CLEANFILES+= imgrd.mfs
imgrd.mfs: ../ramdisk/image
${lib}.so.0:${PROGROOT}/lib/${lib}/${lib}.so.0
${INSTALL} $> $@
-${PROGROOT}/lib/${lib}/${lib}.so.0:
- ${MAKE} -C ${NETBSDSRCDIR}/lib/${lib} all
+# BJG - Don't invoke parallel Makes
+#${PROGROOT}/lib/${lib}/${lib}.so.0:
+# ${MAKE} -C ${NETBSDSRCDIR}/lib/${lib} all
.endfor
.for lib in ${PROG_MINIXLIBS}
${lib}.so.0:${PROGROOT}/minix/lib/${lib}/${lib}.so.0
${INSTALL} $> $@
-${PROGROOT}/minix/lib/${lib}/${lib}.so.0:
- ${MAKE} -C ${NETBSDSRCDIR}/minix/lib/${lib} all
+# BJG - Don't invoke parallel Makes
+#${PROGROOT}/minix/lib/${lib}/${lib}.so.0:
+# ${MAKE} -C ${NETBSDSRCDIR}/minix/lib/${lib} all
.endfor
# Generate dependencies rules for binaries
${prog}: ${PROGROOT}/${dir.${prog}}/${prog}
${INSTALL} $> $@
-${PROGROOT}/${dir.${prog}}/${prog}:
- ${MAKE} -C ${NETBSDSRCDIR}/${dir.${prog}} all
+# BJG - don't invoke parallel Makes
+#${PROGROOT}/${dir.${prog}}/${prog}:
+# ${MAKE} -C ${NETBSDSRCDIR}/${dir.${prog}} all
.endfor # prog
realall image: proto.gen ${ETC:C/^/etc\//} ${EXTRA} \
etc/pwd.db etc/spwd.db etc/passwd: etc/master.passwd
etc/master.passwd: ${NETBSDSRCDIR}/etc/master.passwd
- rm -rf ${.OBJDIR}/etc/
mkdir -p ${.OBJDIR}/etc
${INSTALL} $> $@
${TOOL_PWD_MKDB} -V 0 -p -d . etc/master.passwd
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_TOPROTO} | ${TOOL_SED} -e '1,4d' | \
- ${TOOL_SED} -e '$$d' |${TOOL_SED} -e '$$d' > ${.TARGET}.tmp && \
- mv ${.TARGET}.tmp ${.TARGET}
+ ${TOOL_SED} -e '$$d' |${TOOL_SED} -e '$$d' > ${.TARGET}.tmp
+ grep console ${.TARGET}.tmp # sanity check; is there a console entry?
+ mv ${.TARGET}.tmp ${.TARGET}
proto.gen: ${PROTO} ${PROTO_FILES} proto.dev ${PROGRAMS}
${STRIP} ${PROGRAMS}
vm_notify_sig_wrapper(rmp->mp_endpoint);
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;
}
if (proc_nr_e == VFS_PROC_NR)
} else {
if(bblocks < strtol(token[0], (char **) NULL, 10)) {
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,
strtol(token[0], (char **) NULL, 10));
};
(int)next_inode-1, next_zone);
}
- if(insertmode) printf("%ld\n", written_fs_size);
+ if(insertmode) printf("%llu\n", written_fs_size);
return(0);
fssize->zonecount++; /* Symlink contents is always stored a block */
} else {
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) {
pexit("dynamic size detection failed: seek to end of %s",
token[4]);
} else {
/* Regular file. Go read it. */
if ((f = open(token[4], O_RDONLY)) < 0) {
- fprintf(stderr, "%s: Can't open %s: %s\n",
- progname, token[4], strerror(errno));
+/* on minix natively, allow EACCES and skip the entry.
+ * 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 {
eat_file(n, f);
}
num = next_inode++;
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;
off = (num - 1) % inodes_per_block;
get_block(b, inodes);
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);
}
inodes[off].i_mode = mode;
if(w < 0)
err(1, "mkfs_write: write failed");
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 */
fssize = mkfs_seek(0, SEEK_CUR);
LDADD= -lutil
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
CPPFLAGS+= -DCHROOT
.elifdef SMALLPROG