Home | History | Annotate | only in /src/sys/lib/libsa
History log of /src/sys/lib/libsa
RevisionDateAuthorComments
 1.98 29-Jun-2024  rin libsa: Hook getopt.c

Its declaration (as well as `optarg` et al.) is already in stand.h.
 1.97 07-Oct-2023  rin Drop -O[01] hacks for vax; no longer necessary for patched GCC 10

PR port-vax/57646: Import major vax toolchain fix by Kalvis Duckmanton

XXXRO: GCC 12 may require hacks for a while, but it turned out that
GCC 12 should be treated differently from older versions; a lot of new
files need -O[01] flags, while some may no longer require it.

I will take a look later.

Note that these hacks are not required if Kalvis's patches for GCC 12
are applied.

Keep doc/HACKS entries for a while (will be sync with update for GCC 12).

diff --git a/crypto/external/bsd/openssh/lib/Makefile b/crypto/external/bsd/openssh/lib/Makefile
index 96a93f5e396..4e38be1b642 100644
--- a/crypto/external/bsd/openssh/lib/Makefile
+++ b/crypto/external/bsd/openssh/lib/Makefile
@@ -117,12 +117,6 @@ COPTS.${f}.c+= -Wno-pointer-sign
# XXX
COPTS.channels.c+= -fno-strict-aliasing

-# XXX
-.if ${MACHINE} == "vax"
-COPTS.poly1305.c+= -O0
-COPTS.umac.c+= -O0
-.endif
-
COPTS.hostfile.c+= ${CC_WNO_FORMAT_TRUNCATION}
COPTS.sshkey.c+= ${CC_WNO_FORMAT_TRUNCATION}
COPTS.cipher.c+= -Wno-error=deprecated-declarations
diff --git a/distrib/utils/x_ping/Makefile b/distrib/utils/x_ping/Makefile
index f1c452a0d60..8ee77580a3f 100644
--- a/distrib/utils/x_ping/Makefile
+++ b/distrib/utils/x_ping/Makefile
@@ -12,10 +12,6 @@ CPPFLAGS+= -I${SRCDIR} -DCRUNCHOPS
DPADD= ${LIBM}
LDADD= -lm

-.if ${MACHINE_ARCH} == "vax"
-COPTS.ping.c=-O0
-.endif
-
.include <bsd.prog.mk>

.PATH: ${SRCDIR}
diff --git a/external/apache2/argon2/lib/libargon2/Makefile.inc b/external/apache2/argon2/lib/libargon2/Makefile.inc
index d3f4470c6c7..6a1dd146d7d 100644
--- a/external/apache2/argon2/lib/libargon2/Makefile.inc
+++ b/external/apache2/argon2/lib/libargon2/Makefile.inc
@@ -16,7 +16,3 @@ CFLAGS+= -pthread
LDADD+=-lpthread
DPADD+=${LIBPTHREAD}
.endif
-
-.if ${MACHINE} == "vax"
-COPTS.blake2b.c+= -O0
-.endif
diff --git a/external/bsd/jemalloc/lib/Makefile.inc b/external/bsd/jemalloc/lib/Makefile.inc
index 2f524358f46..d5da774f293 100644
--- a/external/bsd/jemalloc/lib/Makefile.inc
+++ b/external/bsd/jemalloc/lib/Makefile.inc
@@ -53,12 +53,6 @@ COPTS.ctl.c+=-Wno-error=stack-protector
COPTS.stats.c+=-Wno-error=stack-protector
COPTS.tcache.c+=-Wno-error=stack-protector

-.if ${MACHINE_ARCH} == "vax"
-# in merge_overlapping_regs, at regrename.c
-COPTS.arena.c+=-O0
-COPTS.extent.c+=-O0
-.endif
-
SRCS+=${JEMALLOC_SRCS}

jemalloc.d jemalloc.pico jemalloc.o jemalloc.ln jemalloc.po jemalloc.go: \
diff --git a/external/bsd/mdocml/lib/libmandoc/Makefile b/external/bsd/mdocml/lib/libmandoc/Makefile
index 40d7e29ae88..dfd3077a2c7 100644
--- a/external/bsd/mdocml/lib/libmandoc/Makefile
+++ b/external/bsd/mdocml/lib/libmandoc/Makefile
@@ -39,11 +39,6 @@ tbl_opts.c

MAN= mandoc.3

-# XXX
-.if ${MACHINE} == "vax"
-COPTS.mdoc_macro.c+=-O0
-.endif
-
COPTS.man_validate.c+=-Wno-error=array-bounds

.include <bsd.lib.mk>
diff --git a/external/gpl3/binutils.old/lib/libbfd/Makefile b/external/gpl3/binutils.old/lib/libbfd/Makefile
index 03477232b55..74a354532fa 100644
--- a/external/gpl3/binutils.old/lib/libbfd/Makefile
+++ b/external/gpl3/binutils.old/lib/libbfd/Makefile
@@ -41,10 +41,6 @@ CPPFLAGS+= -I${.CURDIR}/arch/${BFD_MACHINE_ARCH} -I${DIST}/include -I. \
-DDEBUGDIR=\"${DEBUGDIR}\" -DLIBDIR=\"${LIBDIR}\" \
-DBINDIR=\"${BINDIR}\"

-.if (${BFD_MACHINE_ARCH} == "vax")
-CPPFLAGS.elf.c += -O0
-.endif
-
COPTS.pei-x86_64.c+= -Wno-stack-protector
COPTS.elfxx-mips.c+= -Wno-stack-protector
COPTS.elf.c+= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-overflow :}
diff --git a/external/gpl3/binutils/lib/libbfd/Makefile b/external/gpl3/binutils/lib/libbfd/Makefile
index 00cb2b20081..a3f0c25fd35 100644
--- a/external/gpl3/binutils/lib/libbfd/Makefile
+++ b/external/gpl3/binutils/lib/libbfd/Makefile
@@ -41,10 +41,6 @@ CPPFLAGS+= -I${.CURDIR}/arch/${BFD_MACHINE_ARCH} -I${DIST}/include -I. \
-DDEBUGDIR=\"${DEBUGDIR}\" -DLIBDIR=\"${LIBDIR}\" \
-DBINDIR=\"${BINDIR}\"

-.if (${BFD_MACHINE_ARCH} == "vax")
-CPPFLAGS.elf.c += -O0
-.endif
-
COPTS.pei-x86_64.c+= -Wno-stack-protector
COPTS.elfxx-mips.c+= -Wno-stack-protector
COPTS.elf.c+= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-overflow :}
diff --git a/external/gpl3/gcc.old/lib/Makefile.sanitizer b/external/gpl3/gcc.old/lib/Makefile.sanitizer
index efd36ae4bee..5173a5109a0 100644
--- a/external/gpl3/gcc.old/lib/Makefile.sanitizer
+++ b/external/gpl3/gcc.old/lib/Makefile.sanitizer
@@ -88,22 +88,3 @@ COPTS+=-fno-builtin -fno-exceptions -fno-rtti -funwind-tables

# Can't profile without it`
#-fomit-frame-pointer
-
-.if ${MACHINE_ARCH} == "vax"
-COPTS.sanitizer_allocator.cc += -O1
-COPTS.sanitizer_common.cc += -O1
-COPTS.sanitizer_common_libcdep.cc += -O1
-COPTS.sanitizer_coverage_libcdep.cc += -O1
-COPTS.sanitizer_coverage_mapping_libcdep.cc += -O1
-COPTS.sanitizer_deadlock_detector1.cc += -O1
-COPTS.sanitizer_mac.cc += -O1
-COPTS.sanitizer_netbsd.cc += -O1
-COPTS.sanitizer_posix.cc += -O1
-COPTS.sanitizer_printf.cc += -O1
-COPTS.sanitizer_procmaps_common.cc += -O1
-COPTS.sanitizer_stackdepot.cc += -O1
-COPTS.sanitizer_symbolizer_libcdep.cc += -O1
-COPTS.sanitizer_symbolizer_report.cc += -O1
-COPTS.ubsan_diag.cc += -O1
-COPTS.ubsan_init.cc += -O1
-.endif
diff --git a/external/gpl3/gcc.old/lib/libasan/Makefile b/external/gpl3/gcc.old/lib/libasan/Makefile
index 1e6f9608abe..3da7bbf2f58 100644
--- a/external/gpl3/gcc.old/lib/libasan/Makefile
+++ b/external/gpl3/gcc.old/lib/libasan/Makefile
@@ -49,14 +49,6 @@ LIBDPLIBS+= m ${NETBSDSRCDIR}/lib/libm
LIBDPLIBS+= pthread ${NETBSDSRCDIR}/lib/libpthread
CPPFLAGS+=-DCAN_SANITIZE_UB=0

-.if ${MACHINE_ARCH} == "vax"
-COPTS.asan_allocator.cc += -O1
-COPTS.asan_report.cc += -O1
-COPTS.sanitizer_file.cc += -O1
-COPTS.ubsan_diag.cc += -O1
-COPTS.ubsan_init.cc += -O1
-.endif
-
.if ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb"
COPTS.asan_interceptors.cc += -O1
.endif
diff --git a/external/gpl3/gcc.old/lib/liblsan/Makefile b/external/gpl3/gcc.old/lib/liblsan/Makefile
index 4578544a9a8..ddb7981077c 100644
--- a/external/gpl3/gcc.old/lib/liblsan/Makefile
+++ b/external/gpl3/gcc.old/lib/liblsan/Makefile
@@ -16,11 +16,6 @@ LSAN_SRCS+= \
lsan_linux.cc \
lsan_thread.cc

-.if ${MACHINE_ARCH} == "vax"
-COPTS.lsan_allocator.cc += -O1
-COPTS.sanitizer_file.cc += -O1
-.endif
-
LIB= lsan
SRCS+= ${LSAN_SRCS}
LIBDPLIBS+= m ${NETBSDSRCDIR}/lib/libm
diff --git a/external/gpl3/gcc.old/lib/libubsan/Makefile b/external/gpl3/gcc.old/lib/libubsan/Makefile
index 2e2faca7b1c..9de82550d14 100644
--- a/external/gpl3/gcc.old/lib/libubsan/Makefile
+++ b/external/gpl3/gcc.old/lib/libubsan/Makefile
@@ -26,10 +26,6 @@ UBSAN_SRCS= \
COPTS.${_s}.cc+=-frtti
.endfor

-.if ${MACHINE_ARCH} == "vax"
-COPTS.sanitizer_file.cc += -O1
-.endif
-
LIB= ubsan
SRCS+= ${UBSAN_SRCS}
LIBDPLIBS+= m ${NETBSDSRCDIR}/lib/libm
diff --git a/external/gpl3/gcc.old/usr.bin/cc1/Makefile b/external/gpl3/gcc.old/usr.bin/cc1/Makefile
index c55e292ee8e..ff12a5be524 100644
--- a/external/gpl3/gcc.old/usr.bin/cc1/Makefile
+++ b/external/gpl3/gcc.old/usr.bin/cc1/Makefile
@@ -46,17 +46,6 @@ CPPFLAGS.default-c.c+= -I${BACKENDOBJ}
BUILDSYMLINKS+= ${GNUHOSTDIST}/gcc/config/sh/sh-c.cc sh-c.c
.endif

-.if ${MACHINE_CPU} == "vax"
-COPTS.c-decl.c+=-O0
-COPTS.c-typeck.c+=-O0
-COPTS.c-array-notation.c+=-O0
-COPTS.c-common.c+=-O0
-COPTS.c-ada-spec.c+=-O0
-COPTS.cilk.c+=-O0
-COPTS.c-ubsan.c+=-O0
-COPTS.cc1-checksum.c+=-O0
-.endif
-
.if ${MACHINE_ARCH} == "mipseb" || ${MACHINE_ARCH} == "mipsel"
COPTS.c-common.c+=-O3
.endif
diff --git a/external/gpl3/gcc.old/usr.bin/cc1obj/Makefile b/external/gpl3/gcc.old/usr.bin/cc1obj/Makefile
index 3123ee0d60b..aab82ad3448 100644
--- a/external/gpl3/gcc.old/usr.bin/cc1obj/Makefile
+++ b/external/gpl3/gcc.old/usr.bin/cc1obj/Makefile
@@ -44,16 +44,8 @@ COPTS.objc-act.c+= -Wno-stack-protector
COPTS.objc-gnu-runtime-abi-01.c+= -Wno-stack-protector
COPTS.objc-next-runtime-abi-01.c+= -Wno-stack-protector

-.if ${MACHINE_ARCH} == "vax"
-COPTS.c-decl.c+=-O0
-COPTS.c-typeck.c+=-O0
-COPTS.c-array-notation.c+=-O0
-COPTS.c-common.c+=-O0
-COPTS.c-ada-spec.c+=-O0
-COPTS.cilk.c+=-O0
-COPTS.c-ubsan.c+=-O0
-COPTS.cc1obj-checksum.c+=-O0
-.endif
+COPTS.c-cppbuiltin.c+= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} == 8:? -Wno-error=format-overflow :}
+COPTS.c-typeck.c+= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} == 8:? -Wno-error=format-overflow :}

.if ${MACHINE_ARCH} == "mipseb" || ${MACHINE_ARCH} == "mipsel"
COPTS.c-common.c+=-O3
diff --git a/external/gpl3/gcc.old/usr.bin/cc1objplus/Makefile b/external/gpl3/gcc.old/usr.bin/cc1objplus/Makefile
index b9c108251c5..e04e8fc7f53 100644
--- a/external/gpl3/gcc.old/usr.bin/cc1objplus/Makefile
+++ b/external/gpl3/gcc.old/usr.bin/cc1objplus/Makefile
@@ -69,18 +69,6 @@ COPTS.objc-act.c+= -Wno-stack-protector
COPTS.objc-gnu-runtime-abi-01.c+= -Wno-stack-protector
COPTS.objc-next-runtime-abi-01.c+= -Wno-stack-protector

-.if ${MACHINE_ARCH} == "vax"
-COPTS.c-decl.c+=-O0
-COPTS.c-typeck.c+=-O0
-COPTS.c-array-notation.c+=-O0
-COPTS.c-common.c+=-O0
-COPTS.c-ada-spec.c+=-O0
-COPTS.cilk.c+=-O0
-COPTS.c-ubsan.c+=-O0
-COPTS.cc1obj-checksum.c+=-O0
-COPTS.decl.c+=-O0
-.endif
-
.if ${MACHINE_ARCH} == "mipseb" || ${MACHINE_ARCH} == "mipsel"
COPTS.c-common.c+=-O3
.endif
diff --git a/external/gpl3/gcc.old/usr.bin/cc1plus/Makefile b/external/gpl3/gcc.old/usr.bin/cc1plus/Makefile
index 7936efd3a5e..7c54559e21a 100644
--- a/external/gpl3/gcc.old/usr.bin/cc1plus/Makefile
+++ b/external/gpl3/gcc.old/usr.bin/cc1plus/Makefile
@@ -31,23 +31,6 @@ CHECKSUM_OBJS= ${LIBBACKTRACEOBJ}/libbacktrace.a \

CFLAGS+= -Wno-error=stack-protector

-.if ${MACHINE_ARCH} == "vax"
-COPTS.call.c+=-O0
-COPTS.decl.c+=-O0
-COPTS.typeck2.c+=-O0
-COPTS.class.c+=-O0
-COPTS.typeck.c+=-O0
-COPTS.init.c+=-O0
-COPTS.semantics.c+=-O0
-COPTS.mangle.c+=-O0
-COPTS.constexpr.c+=-O0
-COPTS.c-common.c+=-O0
-COPTS.c-ada-spec.c+=-O0
-COPTS.cilk.c+=-O0
-COPTS.c-ubsan.c+=-O0
-COPTS.cc1plus-checksum.c+=-O0
-.endif
-
.if ${MACHINE_ARCH} == "mipseb" || ${MACHINE_ARCH} == "mipsel"
COPTS.c-common.c+=-O3
.endif
diff --git a/external/gpl3/gcc.old/usr.bin/gcc/Makefile b/external/gpl3/gcc.old/usr.bin/gcc/Makefile
index 7a66d77ffc7..a5a4b1c3adf 100644
--- a/external/gpl3/gcc.old/usr.bin/gcc/Makefile
+++ b/external/gpl3/gcc.old/usr.bin/gcc/Makefile
@@ -25,9 +25,6 @@ ${SRCS}: ${GCCARCH}/defs.mk
.include <bsd.info.mk>

COPTS.gcc.c= -Wno-stack-protector
-.if ${MACHINE_ARCH} == "vax"
-COPTS.dse.c= -O1
-.endif

.PATH: ${DIST}/gcc ${DIST}/gcc/doc ${DIST}/gcc/c

diff --git a/external/gpl3/gcc.old/usr.bin/libdecnumber/Makefile b/external/gpl3/gcc.old/usr.bin/libdecnumber/Makefile
index 751d1513eec..33aeb1c9898 100644
--- a/external/gpl3/gcc.old/usr.bin/libdecnumber/Makefile
+++ b/external/gpl3/gcc.old/usr.bin/libdecnumber/Makefile
@@ -14,10 +14,6 @@ SRCS= decNumber.c decContext.c decimal32.c decimal64.c decimal128.c
CPPFLAGS+= -I${.CURDIR}/arch/${GCC_MACHINE_ARCH} -I${DIST}/libdecnumber
CPPFLAGS+= -I${DIST}/libgcc

-.if ${MACHINE_ARCH} == "vax"
-COPTS.decNumber.c=-O0
-.endif
-
.include <bsd.lib.mk>

# Force using C++ for this
diff --git a/external/gpl3/gcc.old/usr.bin/lto-dump/Makefile b/external/gpl3/gcc.old/usr.bin/lto-dump/Makefile
index 90f44a9fcf6..fd251464fb7 100644
--- a/external/gpl3/gcc.old/usr.bin/lto-dump/Makefile
+++ b/external/gpl3/gcc.old/usr.bin/lto-dump/Makefile
@@ -24,11 +24,6 @@ COPTS.lto-common.c+= -Wno-stack-protector
.include "../Makefile.backtrace"
.include "../Makefile.libdecnumber"

-.if ${MACHINE_ARCH} == "vax"
-COPTS.lto-lang.c+=-O0
-COPTS.lto-symtab.c+=-O0
-.endif
-
LDADD+= ${LIBIBERTY} ${LIBMPC} ${LIBMPFR} ${LIBGMP} -lintl -lz -lm
DPADD+= ${LIBIBERTY} ${LIBMPC} ${LIBMPFR} ${LIBGMP} ${LIBINTL} ${LIBZ} ${LIBM}

diff --git a/external/gpl3/gcc.old/usr.bin/lto1/Makefile b/external/gpl3/gcc.old/usr.bin/lto1/Makefile
index 4c49161a64c..340d3c6124f 100644
--- a/external/gpl3/gcc.old/usr.bin/lto1/Makefile
+++ b/external/gpl3/gcc.old/usr.bin/lto1/Makefile
@@ -21,11 +21,6 @@ COPTS.lto-common.c+= -Wno-stack-protector
.include "../Makefile.libcpp"
.include "../Makefile.libdecnumber"

-.if ${MACHINE_ARCH} == "vax"
-COPTS.lto-lang.c+=-O0
-COPTS.lto-symtab.c+=-O0
-.endif
-
LDADD+= ${LIBIBERTYOBJ}/libiberty.a
DPADD+= ${LIBIBERTYOBJ}/libiberty.a
LDADD+= ${LIBIBERTY} ${LIBMPC} ${LIBMPFR} ${LIBGMP} -lintl -lz -lm
diff --git a/external/gpl3/gdb.old/lib/libdecnumber/Makefile b/external/gpl3/gdb.old/lib/libdecnumber/Makefile
index bcd4ae5b222..ce28811526b 100644
--- a/external/gpl3/gdb.old/lib/libdecnumber/Makefile
+++ b/external/gpl3/gdb.old/lib/libdecnumber/Makefile
@@ -18,10 +18,6 @@ CPPFLAGS+= -I${.CURDIR}/arch/${GDB_MACHINE_ARCH} \

SRCS= ${G_OBJS:.o=.c} ${G_SOURCES}

-.if ${MACHINE_ARCH} == "vax"
-COPTS.decNumber.c=-O0
-.endif
-
.PATH: ${DIST}/libdecnumber ${DIST}/libdecnumber/dpd

.include <bsd.lib.mk>
diff --git a/external/gpl3/gdb/lib/libdecnumber/Makefile b/external/gpl3/gdb/lib/libdecnumber/Makefile
index c95d36e3dfa..e3169865304 100644
--- a/external/gpl3/gdb/lib/libdecnumber/Makefile
+++ b/external/gpl3/gdb/lib/libdecnumber/Makefile
@@ -18,10 +18,6 @@ CPPFLAGS+= -I${.CURDIR}/arch/${GDB_MACHINE_ARCH} \

SRCS= ${G_OBJS:.o=.c} ${G_SOURCES}

-.if ${MACHINE_ARCH} == "vax"
-COPTS.decNumber.c=-O0
-.endif
-
.PATH: ${DIST}/libdecnumber ${DIST}/libdecnumber/dpd ${DIST}/libdecnumber/bid

.include <bsd.lib.mk>
diff --git a/external/gpl3/gdb/lib/libgdb/Makefile b/external/gpl3/gdb/lib/libgdb/Makefile
index b87a515d13a..c118c363975 100644
--- a/external/gpl3/gdb/lib/libgdb/Makefile
+++ b/external/gpl3/gdb/lib/libgdb/Makefile
@@ -66,12 +66,6 @@ CFLAGS:= ${CXXFLAGS} -std=gnu++17 -Wno-error=stack-protector

ada-exp.c: ada-lex.c

-.if ${MACHINE} == "vax"
-. if ${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8
-COPTS.read.c+= -O0
-. endif
-.endif
-
# These are generated by implicit rules and are not easy to generate
CLEANDIRFILES+= \
ada-exp.c ada-lex.c \
diff --git a/external/mit/xorg/lib/gallium.old/Makefile b/external/mit/xorg/lib/gallium.old/Makefile
index 55b2fe3d1c1..bfa40c8974f 100644
--- a/external/mit/xorg/lib/gallium.old/Makefile
+++ b/external/mit/xorg/lib/gallium.old/Makefile
@@ -1211,10 +1211,6 @@ SYMLINKS+= gallium_dri.so.${SHLIB_MAJOR}.debug ${DRIDEBUGDIR}/${_d}_dri.so.${SHL
COPTS+= ${${ACTIVE_CC} == "clang":? -Wa,-Av8plus :}
.endif

-.if ${MACHINE_ARCH} == "vax"
-COPTS.nir.c += -O1
-.endif
-
# XXXGCC12
.if ${MACHINE_ARCH} == "m68k"
COPTS.st_glsl_to_tgsi.cpp += -O1
diff --git a/external/mit/xorg/lib/gallium/Makefile b/external/mit/xorg/lib/gallium/Makefile
index 6778a8c11c8..9f1422080fe 100644
--- a/external/mit/xorg/lib/gallium/Makefile
+++ b/external/mit/xorg/lib/gallium/Makefile
@@ -1428,10 +1428,6 @@ SYMLINKS+= gallium_dri.so.${SHLIB_MAJOR}.debug ${DRIDEBUGDIR}/${_d}_dri.so.${SHL
COPTS+= ${${ACTIVE_CC} == "clang":? -Wa,-Av8plus :}
.endif

-.if ${MACHINE_ARCH} == "vax"
-COPTS.nir.c += -O1
-.endif
-
COPTS.u_atomic.c+= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-builtin-declaration-mismatch :}

.include <bsd.lib.mk>
diff --git a/external/mit/xorg/lib/libX11/Makefile.libx11 b/external/mit/xorg/lib/libX11/Makefile.libx11
index e103d9ace12..0e55c2a4732 100644
--- a/external/mit/xorg/lib/libX11/Makefile.libx11
+++ b/external/mit/xorg/lib/libX11/Makefile.libx11
@@ -471,11 +471,6 @@ COPTS.OpenDis.c+= -Wno-error # XXX xf86bigfstr.h
COPTS.XlibInt.c+= -Wno-error # XXX xcmiscstr.h
COPTS.XKBBind.c+= -Wno-deprecated-declarations # uses XKeycodeToKeysym

-# XXX
-.if ${MACHINE} == "vax"
-COPTS.lcWrap.c+= -O0
-.endif
-
CWARNFLAGS.clang+= -Wno-string-plus-int

.include "${NETBSDSRCDIR}/external/mit/xorg/tools/makekeys/Makefile.makekeys"
diff --git a/games/gomoku/Makefile b/games/gomoku/Makefile
index e86a63aaea7..678537066ed 100644
--- a/games/gomoku/Makefile
+++ b/games/gomoku/Makefile
@@ -9,10 +9,6 @@ LDADD= -lcurses -lterminfo
HIDEGAME=hidegame
CPPFLAGS+= ${DEBUG:D-DDEBUG}

-.if ${MACHINE} == "vax"
-COPTS.pickmove.c += -O0
-.endif
-
#WARNS= 6 # would produce warnings about small integer types
LINTFLAGS+= -w # treat warnings as errors
LINTFLAGS+= -T # strict bool mode
diff --git a/games/phantasia/Makefile b/games/phantasia/Makefile
index e9c53f23ae5..b919dac17c6 100644
--- a/games/phantasia/Makefile
+++ b/games/phantasia/Makefile
@@ -52,7 +52,3 @@ map: map.c
./map | plot > /dev/tty

.include <bsd.prog.mk>
-
-.if defined(HAVE_GCC) && ${MACHINE_ARCH} == "vax"
-COPTS.misc.c+= -O0
-.endif
diff --git a/lib/i18n_module/UTF7/Makefile b/lib/i18n_module/UTF7/Makefile
index 712c1515d42..7136f7f0cc3 100644
--- a/lib/i18n_module/UTF7/Makefile
+++ b/lib/i18n_module/UTF7/Makefile
@@ -3,6 +3,3 @@
SRCPRE=citrus_
.include <bsd.lib.mk>

-.if ${MACHINE_ARCH} == "vax" && defined(HAVE_GCC)
-COPTS.citrus_utf7.c+= -O0
-.endif
diff --git a/lib/libbz2/Makefile b/lib/libbz2/Makefile
index b2aea1e04b0..e60a2862d48 100644
--- a/lib/libbz2/Makefile
+++ b/lib/libbz2/Makefile
@@ -15,11 +15,6 @@ SRCS= blocksort.c huffman.c crctable.c randtable.c compress.c \
INCS= bzlib.h
INCSDIR= /usr/include

-# XXX huffman.c gets mis-compiled with 2.95.3
-.if ${MACHINE_ARCH} == "vax"
-COPTS+= -O0
-.endif
-
COPTS+= ${CC_WNO_IMPLICIT_FALLTHROUGH}

# XXX blocksort.c gets mis-compiled with 4.1
diff --git a/lib/libc/gdtoa/Makefile.inc b/lib/libc/gdtoa/Makefile.inc
index 132686fc33d..609da919803 100644
--- a/lib/libc/gdtoa/Makefile.inc
+++ b/lib/libc/gdtoa/Makefile.inc
@@ -44,10 +44,3 @@ SRCS+= dmisc.c \
.if ${MACHINE_ARCH} != "vax"
SRCS+= strtord.c
.endif
-
-# XXX revisit with newer GCC.
-# Ensure numbers like 0xffff319f5fa95963 print correctly
-# ("999999999999999.98", not garbage like "?A>C>@>C:BA;A><.:<")
-.if ${MACHINE_ARCH} == "vax" && defined(HAVE_GCC)
-COPTS.misc.c+= -O0
-.endif
diff --git a/lib/libcrypt/Makefile b/lib/libcrypt/Makefile
index cb3f89d6d09..e9c8be820da 100644
--- a/lib/libcrypt/Makefile
+++ b/lib/libcrypt/Makefile
@@ -30,9 +30,6 @@ SRCS+= crypt-argon2.c
SRCS+= ${src}
COPTS.${src}+= -fvisibility=hidden
. endfor
-. if ${MACHINE} == "vax"
-COPTS.blake2b.c+= -O0
-. endif
.endif

WARNS?= 5
diff --git a/libexec/ld.elf_so/Makefile b/libexec/ld.elf_so/Makefile
index f5baae1e883..24f7e1121e5 100644
--- a/libexec/ld.elf_so/Makefile
+++ b/libexec/ld.elf_so/Makefile
@@ -141,10 +141,6 @@ CPPFLAGS+= -DRTLD_DEFAULT_LIBRARY_PATH=\"${SHLIBDIR}:${LIBDIR}\"
COPTS.rtld.c+= -Wno-stack-protector
COPTS.symbol.c+=-Wno-stack-protector

-.if ${MACHINE_CPU} == "vax"
-COPTS.rtld.c+= -O0
-.endif
-
LDADD+= -Wl,--version-script=${.CURDIR}/symbols.map
LDADD+= -L${CLIBOBJ} -L${DESTDIR}${LIBDIR}
.if ${MKPICLIB} != "no"
diff --git a/sbin/fsck_ffs/Makefile.common b/sbin/fsck_ffs/Makefile.common
index 765638b2801..824e3bf2628 100644
--- a/sbin/fsck_ffs/Makefile.common
+++ b/sbin/fsck_ffs/Makefile.common
@@ -36,7 +36,3 @@ COPTS.ffs_appleufs.c+= -Wno-pointer-sign
.if ${MACHINE_ARCH} == "m68000"
COPTS.pass1.c+= -fno-tree-fre -fno-tree-lrs
.endif
-.if ${MACHINE_ARCH} == "vax"
-COPTS.pass1.c+= -O0
-COPTS.inode.c+= -O0
-.endif
diff --git a/sbin/fsdb/Makefile b/sbin/fsdb/Makefile
index c039f73a1eb..3b0331e5880 100644
--- a/sbin/fsdb/Makefile
+++ b/sbin/fsdb/Makefile
@@ -39,12 +39,6 @@ COPTS.${f}.c+= -Wno-pointer-sign
COPTS.pass1.c+= -fno-tree-fre -fno-tree-lrs
.endif

-.if ${MACHINE_ARCH} == "vax"
-COPTS.pass1.c+= -O0
-COPTS.inode.c+= -O0
-COPTS.fsdb.c+= -O0
-.endif
-
CWARNFLAGS.gcc+= ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}

.include <bsd.prog.mk>
diff --git a/sbin/newfs_ext2fs/Makefile b/sbin/newfs_ext2fs/Makefile
index 40a44b9a038..ecfdbff4d3a 100644
--- a/sbin/newfs_ext2fs/Makefile
+++ b/sbin/newfs_ext2fs/Makefile
@@ -20,8 +20,4 @@ DPADD+=${LIBPROP}

.PATH: ${NETBSDSRCDIR}/sys/ufs/ext2fs ${FSCK}

-.if ${MACHINE_ARCH} == "vax"
-COPTS.mke2fs.c=-O0
-.endif
-
.include <bsd.prog.mk>
diff --git a/sbin/ping/Makefile b/sbin/ping/Makefile
index 4f33501ea7a..1f7f56e3ea5 100644
--- a/sbin/ping/Makefile
+++ b/sbin/ping/Makefile
@@ -12,8 +12,4 @@ CPPFLAGS+= -DIPSEC
LDADD+= -lipsec
DPADD+= ${LIBIPSEC}

-.if ${MACHINE_ARCH} == "vax"
-COPTS.ping.c=-O0
-.endif
-
.include <bsd.prog.mk>
diff --git a/sys/arch/vax/conf/Makefile.vax b/sys/arch/vax/conf/Makefile.vax
index cf095d54a86..c483eaa644a 100644
--- a/sys/arch/vax/conf/Makefile.vax
+++ b/sys/arch/vax/conf/Makefile.vax
@@ -34,7 +34,6 @@ GENASSYM_CONF= ${VAX}/vax/genassym.cf
CPPFLAGS+= -D_VAX_INLINE_
AFLAGS+= -x assembler-with-cpp -fno-pic
CFLAGS+= -fno-pic
-COPTS.wsmux.c+= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 9:? -O1 :}


##
diff --git a/sys/lib/libsa/Makefile b/sys/lib/libsa/Makefile
index 718c97ce857..4ef3840c753 100644
--- a/sys/lib/libsa/Makefile
+++ b/sys/lib/libsa/Makefile
@@ -96,7 +96,3 @@ SRCS+= ufs.c
lib${LIB}.o:: ${OBJS:O} __buildstdlib

CPPFLAGS+= -Wno-pointer-sign
-
-.if defined(HAVE_GCC) && ${MACHINE_ARCH} == "vax"
-COPTS.bootp.c+= -O0
-.endif
diff --git a/sys/lib/libz/Makefile b/sys/lib/libz/Makefile
index 6945c0da6c6..61fb7d4f652 100644
--- a/sys/lib/libz/Makefile
+++ b/sys/lib/libz/Makefile
@@ -25,7 +25,3 @@ CLEANFILES+= lib${LIB}.o
.include <bsd.lib.mk>

lib${LIB}.o:: ${OBJS:O} __buildstdlib
-
-.if defined(HAVE_GCC) && ${MACHINE_ARCH} == "vax"
-COPTS.inftrees.c+= -O0
-.endif
diff --git a/sys/modules/lfs/Makefile b/sys/modules/lfs/Makefile
index 962538821a5..ea8f187e160 100644
--- a/sys/modules/lfs/Makefile
+++ b/sys/modules/lfs/Makefile
@@ -18,9 +18,4 @@ SRCS+= ulfs_bmap.c ulfs_dirhash.c ulfs_inode.c ulfs_lookup.c \

WARNS= 3

-.if ${MACHINE} == "vax"
-# GCC 6.5 and 7.4 cannot compile this with -DDIAGNOSTIC and -O2/-O1
-COPTS.lfs_inode.c+= -O0
-.endif
-
.include <bsd.kmodule.mk>
diff --git a/sys/rump/fs/lib/liblfs/Makefile b/sys/rump/fs/lib/liblfs/Makefile
index abade3767d9..68b74c62502 100644
--- a/sys/rump/fs/lib/liblfs/Makefile
+++ b/sys/rump/fs/lib/liblfs/Makefile
@@ -17,9 +17,6 @@ SRCS+= ulfs_bmap.c ulfs_dirhash.c ulfs_extattr.c \


CFLAGS+= -DLFS_KERNEL_RFW
-.if ${MACHINE_ARCH} == "vax"
-COPTS.lfs_inode.c+=-O0
-.endif

.include <bsd.lib.mk>
.include <bsd.klinks.mk>
diff --git a/usr.sbin/mtrace/Makefile b/usr.sbin/mtrace/Makefile
index aef09db6198..9c125c15265 100644
--- a/usr.sbin/mtrace/Makefile
+++ b/usr.sbin/mtrace/Makefile
@@ -12,10 +12,6 @@ PROG= mtrace
SRCS= igmp.c inet.c kern.c mtrace.c
MAN= mtrace.8

-.if ${MACHINE_ARCH} == "vax"
-COPTS.mtrace.c=-O0
-.endif
-
BINMODE=4555
BINOWN= root

diff --git a/external/gpl3/gcc.old/usr.bin/backend/Makefile b/external/gpl3/gcc.old/usr.bin/backend/Makefile
index d69a26fe619..99e881c783d 100644
--- a/external/gpl3/gcc.old/usr.bin/backend/Makefile
+++ b/external/gpl3/gcc.old/usr.bin/backend/Makefile
@@ -533,68 +533,9 @@ COPTS.insn-recog.c+=-Wno-error

.if ${GCC_MACHINE_ARCH} == "vax"
CPPFLAGS+=-I${.CURDIR}/../../lib/libgcc/libgcov/arch/${GCC_MACHINE_ARCH}
-COPTS.builtins.c+=-O0
-COPTS.calls.c+=-O0
-COPTS.convert.c+=-O0
-COPTS.data-streamer-out.c+=-O0
-COPTS.dse.c+=-O0 # XXX port-vax/51967
-COPTS.dwarf2out.c+=-O0
-COPTS.expmed.c+=-O0
-COPTS.expr.c+=-O0 -Wno-error=tautological-compare
-COPTS.fixed-value.c+=-O0
-COPTS.fold-const.c+=-O0
-COPTS.generic-match.c+=-O0
-COPTS.gimple-fold.c+=-O0
-COPTS.gimple-match.c+=-O0
-COPTS.gimple-ssa-strength-reduction.c+=-O0
-COPTS.gimple-ssa-warn-restrict.c+=-O0
-COPTS.gimple.c+=-O0
-COPTS.internal-fn.c+=-O0
-COPTS.lto-streamer-out.c+=-O0
-COPTS.omp-low.c+=-O0
-COPTS.predict.c+=-O0
-COPTS.range-op.cc+=-O0
-COPTS.recog.c+=-O0
-COPTS.sanopt.c+=-O0
-COPTS.stmt.c+=-O0
-COPTS.stor-layout.c+=-O0
-COPTS.targhooks.c+=-O0
-COPTS.tree-affine.c+=-O0
-COPTS.tree-cfg.c+=-O0
-COPTS.tree-data-ref.c+=-O0
-COPTS.tree-eh.c+=-O0
-COPTS.tree-if-conv.c+=-O0
-COPTS.tree-object-size.c+=-O0
-COPTS.tree-parloops.c+=-O0
-COPTS.tree-predcom.c+=-O0
-COPTS.tree-pretty-print.c+=-O0
-COPTS.tree-ssa-alias.c+=-O0
-COPTS.tree-ssa-ccp.c+=-O0
-COPTS.tree-ssa-forwprop.c+=-O0
-COPTS.tree-ssa-loop-ivopts.c+=-O0
-COPTS.tree-ssa-loop-manip.c+=-O0
-COPTS.tree-ssa-loop-niter.c+=-O0
-COPTS.tree-ssa-math-opts.c+=-O0
-COPTS.tree-ssa-phiopt.c+= -O0
-COPTS.tree-ssa-pre.c+=-O0
-COPTS.tree-ssa-reassoc.c+=-O0
-COPTS.tree-ssa-strlen.c+=-O0
-COPTS.tree-ssa-uninit.c+=-O0
-COPTS.tree-ssa.c+=-O0
-COPTS.tree-switch-conversion.c+=-O0
-COPTS.tree-vect-data-refs.c+=-O0
-COPTS.tree-vect-loop-manip.c+=-O0
-COPTS.tree-vect-loop.c+=-O0
-COPTS.tree-vect-patterns.c+=-O0
-COPTS.tree-vect-stmts.c+=-O0
-COPTS.tree-vrp.c+=-O0
-COPTS.tree.c+=-O0
-COPTS.ubsan.c+=-O0
-COPTS.varasm.c+=-O0
-COPTS.vr-values.c+=-O0
-COPTS.web.c+=-O0
-COPTS.wide-int-range.cc+=-O0
-COPTS.wide-int.cc+=-O0
+
+COPTS.expmed.c+=-Wno-error=tautological-compare
+COPTS.expr.c+=-Wno-error=tautological-compare
.else
COPTS.tree.c= ${${ACTIVE_CC} == "clang" :? -O0 :}
.endif
 1.96 30-Aug-2023  christos We don't want SSP/FORTIFY here.
 1.95 27-May-2021  mrg branches: 1.95.12;
add bi-endian support to the libsa ufs reader and enable it in efiboot.

ffs frontends to "ufs.c" now also define ufs_dinode_swap, ufs_indp_swap,
and FS_MAGIC (moved from ufs.c #if segments.) these are used to call
the right (32/64 bit) ffsv1/v2 version.

ufs.c 'struct file' gains f_swapped member. accessors for d_magic,
d_reclen, and d_ino are introduced (they need to be swapped.) sfter
reading an inode from disk, read_inode() may call ufs_dinode_swap().
indirect block number and caches may be swapped.

error handling in ffs_find_superblock() is cleaned up. (size is slightly
reduced on some ports with this part.)

defaults for new defines added to ufs.c. (XXX: we build ufs.c but i think
all the consumers don't use it, and we can stop building it.)

LFS support is not included.

add a cut-down copy of ffs_bswap.c from the kernel.

also enable bi-endian disklabel support in efiboot.

most ports build and sizes compared for platforms that don't enable this
code and all but one saw reduced code size. booted several platforms with
new boot code.
 1.94 17-May-2021  mrg move bi-endian disklabel support from the kernel and libsa into libkern.

- dkcksum() and dkcksum_sized() move from subr_disk.c and from
libsa into libkern/dkcksum.c (which is missing _sized() version),
using the version from usr.sbin/disklabel.

- swap_disklabel() moves from subr_disk_mbr.c into libkern, now called
disklabel_swap(). (the sh3 version should be updated to use this.)

- DISKLABEL_EI becomes a first-class option with opt_disklabel.h.

- add libkern.h to libsa/disklabel.c.

this enables future work for bi-endian libsa/ufs.c (relevant for ffsv1,
ffsv2, lfsv1, and lfsv2), as well as making it possible for ports not
using subr_disk_mbr.c to include bi-endian disklabel support (which,
afaict, includes any disk on mbr-supporting platforms that do not have
an mbr as well as disklabel.)

builds successsfully on: alpha, i386, amd64, sun2, sun3, evbarm64,
evbarm64-eb, sparc, and sparc64. tested in anita on i386 and sparc,
testing in hardware on evbarm64*.
 1.93 07-Sep-2020  mrg branches: 1.93.6; 1.93.8;
oops, move GCC_NO_ADDR_OF_PACKED_MEMBER into the right header.
 1.92 07-Sep-2020  mrg apply GCC_NO_ADDR_OF_PACKED_MEMBER
 1.91 21-Jul-2019  rin Add SA_ENABLE_BIENDIAN option, which enable us to load kernel image of
opposite byte order (for arm EFI bootloader).

XXX
Currently, it is restricted to load_elf*.c. It would be nice if we can
recognize disklabel and filesystem of opposite byte order.
 1.90 02-Apr-2019  christos fix sign-compare and sign-passing errors.
 1.89 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.88 05-Jun-2018  christos branches: 1.88.2;
Use the standard build rules.
 1.87 22-Mar-2016  mrg branches: 1.87.16;
remove a bunch of "@echo done" from the tail of rules. these messages
were vaguely useful back when we didn't run make -j, but now you end
up with a single line "done" every so often, with no idea what it is
for. very few other targets claim they're done so just remove these.
 1.86 07-Sep-2015  uebayasi Order library object build.
 1.85 07-Sep-2015  uebayasi Sprinkle more done messages.
 1.84 10-Aug-2014  isaki branches: 1.84.4;
Unify all arch/*/stand's atoi() to MI libsa.
lib/libsa/atoi.c was separated from lib/libsa/bootcfg.c.
PR/49084
 1.83 28-Jun-2014  rtr patch posted to tech-kern@ 2014/06/25 for review with minor changes
resulting from feedback.

move multiple copies of code for parsing boot.cfg file from sparc, i386
and zaurus into libsa/bootcfg.{h,c}. largely retained i386 parsing logic
in addition to keeping sparc dispatch function while remaining consistent
with boot.cfg(5).

previous sparc64 file format has been obsoleted but only used by boot
CDs distrib/sparc64/bootfs/boot.cfg has been updated to compensate.

exported names have been prefixed with either BOOTCFG_ or bootcfg_ as per
feedback from christos@

tested on amd64 & sparc64 but not zaurus.
 1.82 14-Jun-2014  mrg remove remaining makefile support for GCC < 45 that i found.
 1.81 26-Mar-2014  christos branches: 1.81.2;
Remove {v,}sprintf
 1.80 12-Jan-2014  tsutsui Remove obsolete exec.c for a.out. It was superseded by loadfile() long ago.
 1.79 21-Aug-2013  matt Use LIBISPRIVATE?= yes
 1.78 10-Aug-2012  joerg branches: 1.78.2; 1.78.4;
Deal with optional HAVE_GCC.
 1.77 16-Jan-2012  christos PR/45796: Evgeniy Ivanov minixfs3 support.
Split out fn_match since we have 3 copies now.
 1.76 25-Dec-2011  tsutsui Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.75 03-Jul-2011  mrg branches: 1.75.2; 1.75.6;
apply some -O0 with gcc 4.5 and vax.
 1.74 20-Jun-2011  mrg remove HAVE_GCC == 4 conditional
 1.73 16-Jun-2011  joerg Don't use C versions of memcmp, memcpy, memmove, memset and strchr
on x86 for standalone code. The assembler versions are much smaller.
 1.72 11-May-2011  zoltan branches: 1.72.2;
Separate the IP and UDP code paths inside libsa, so I can add HTTP booting
later.
 1.71 10-Feb-2010  martin branches: 1.71.2; 1.71.4;
Utility function to lookup a symbol value in an elf symbol table - allows,
for example, a bootloader to access symbols in the just loaded kernel
(or module).
 1.70 25-Aug-2009  he branches: 1.70.2;
Uh, move loadfile_aout.c in under the check for ${SA_USE_LOADFILE}
again, so that it's not unconditionally compiled, fixing the previous.
 1.69 21-Aug-2009  he If we're on mips, don't build exec.c or loadfile_aout.c, since they
both deal with a.out format executables.
 1.68 20-Mar-2009  tsutsui Allow MD standalone Makefiles overriding MI libsa settings
by SA_EXTRADIR variable passed via SAMISCMAKEFLAGS.
 1.67 29-Aug-2008  gmcgarry branches: 1.67.2; 1.67.8;
Wrap compiler-specific flags with HAVE_GCC and HAVE_PCC as necessary. Add a few flags for PCC.
 1.66 11-May-2008  mlelstv branches: 1.66.4;
There is also ARP_DEBUG for those who need it.
 1.65 25-Mar-2008  christos branches: 1.65.2; 1.65.4; 1.65.6;
add bcopy and bzero for loadfile for now. Should get rid of it.
 1.64 25-Mar-2008  christos - use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.63 14-Mar-2008  dsl Add a strchr() - for dosfs in particular.
The i386 asm version in src/common is rather larger than this one.
 1.62 25-Feb-2008  tsutsui Fix typo in comment.
 1.61 08-Dec-2007  tsutsui branches: 1.61.8; 1.61.12;
ufs_ls.c doesn't belong to lfs.
 1.60 01-Dec-2007  tsutsui branches: 1.60.2;
- build ext2fs.c
- put SRCS per each file system.
 1.59 12-May-2006  mrg branches: 1.59.22; 1.59.32; 1.59.34; 1.59.40;
apply -Wno-pointer-sign with GCC4.
 1.58 24-Jan-2006  christos branches: 1.58.2; 1.58.4; 1.58.6; 1.58.10;
PR/32613: Yves-Emmanuel JUTARD: Incoherencies in file sys/lib/libsa/net.h
- Make prototype of ether_sprintf() match the one in sys/net.
- Rename in_cksum to ip_cksum and fix its prototype. in_cksum() operates
on an mbuf and ip_cksum() operates on a plain buffer. We should not call
functions that operate on different arguments the same name (this is not
c++).
 1.57 11-Dec-2005  christos branches: 1.57.2;
merge ktrace-lwp.
 1.56 13-Jun-2005  junyoung branches: 1.56.2;
Remove bcmp(). Use memcmp() instead.
 1.55 19-May-2004  abs Add qsort to libsa (taken from sys/dev/vinum/vinumqsort.c) and use instead of
bubblesort in acorn32 bootloader. Reduces time to sort memory on A710 equipped
RiscPC from over twenty seconds to effectively instantaneous.
Update boot version to 3.30
 1.54 11-Apr-2003  dsl branches: 1.54.2; 1.54.4;
Build ffsv1 and ffsv2
 1.53 12-Mar-2003  drochner separate ether_sprintf() from the rest of ethernet support -- sometimes
it makes sense to use the former w/o the latter (eg PXE)
 1.52 23-Feb-2003  simonb Add support for LFSv2 filesystems. From a libsa standpoint, LFSv1 and
LFSv2 are treated as separate filesystem types for size considerations.
 1.51 15-Mar-2002  simonb Move files[] from globals.c to its own file. Including all of globals.o
breaks the size limit for at least the pmax bootblocks.

Fixes PR port-pmax/15924 from Gregory McGarry.
 1.50 17-Feb-2002  thorpej Add a comment describing what SA_USE_LOADFILE is for.
 1.49 12-Dec-2001  tv MKfoo=no -> NOfoo
 1.48 14-Nov-2001  tv Undefine DESTDIR; we don't want the special DESTDIR <bsd.lib.mk>
handling for kernel libraries.

XXX this build method should be replaced by something more sane
 1.47 31-Oct-2001  thorpej Split elf32 vs. elf64 handling in loadfile(), including support for
each separately and explicitly. BOOT_ELF is now BOOT_ELF32 and
BOOT_ELF64, and ELFSIZE should no longer be defined in loadfile_machdep.h.
 1.46 31-Oct-2001  thorpej Build the loadfile() a.out, ECOFF, and ELF back-ends as separate
objects.
 1.45 02-Sep-2001  tsutsui branches: 1.45.4;
Add a small version of memmove() for libsa.
Mostly identical with libsa/bcopy.c.
 1.44 31-Mar-2001  hubertf branches: 1.44.2;
Explain some SA_* options - reading compressed kernels, netboot
Useful for stripping down bootcode.
 1.43 02-Nov-2000  thorpej branches: 1.43.2;
Add a standalone MS-DOS file system reader package, lifted
from FreeBSD, and modified use NetBSD's already-existing
MS-DOS file system data structure definitions, rather than
defining our own.
 1.42 25-Oct-2000  thorpej Split the UDP routines out of net.c.
 1.41 13-Nov-1999  thorpej branches: 1.41.4;
Backout my libsa changes.
 1.40 12-Nov-1999  lukem add -DNET_DEBUG to the list of commented-out debug options
 1.39 12-Nov-1999  simonb Add strncpy().

Add prototypes for bcmp(), bzero() so the libsa compiles with WARNS=1
 1.38 11-Nov-1999  thorpej Small, MI strcat() and strcpy().
 1.37 11-Nov-1999  thorpej The hack needed to work around gcc lameness.
 1.36 11-Nov-1999  thorpej Networking routines needed for libsa to be self-contained.
 1.35 11-Nov-1999  thorpej Add small, MI strcmp(), strlen(), and strncmp() functions. Modules within
libsa depend on them, to it seems rather silly to have to build an additional
library (e.g. libkern) to get them.
 1.34 09-Sep-1999  drochner branches: 1.34.2; 1.34.4; 1.34.8;
add a function to verify a password against an in-core md5 sum
 1.33 18-Aug-1999  cgd Add a standalone LFS implementation. Currently not merged with ufs (FFS),
but should be (and will be before too long). Until then, it and ufs.?
should be easily diffable.
 1.32 07-May-1999  drochner Build libraries for kernel/standalone code from within their compilation
directories and use .PATH to lookup the source files.
(Formerly, the libs were built from the source dirs, with MAKEOBJDIR
set to the compilation directory.)
This solves 2 problems:
-"mkdep" and "make" are now consistent about the file lookup, this fixes
bad interactions with amd reported in PR bin/7374 (Arne Juul) and
lossage reported by Andrew Gillham ("obj" dirs and relative paths still
don't work well together)
-kernel compile trees can be moved around without forcing a new
"make depend" - fixing PR kern/4021 by Martin Husemann
 1.31 28-Apr-1999  christos MI loadfile (used by i386, pmax and sparc shortly)
 1.30 14-Apr-1999  drochner move "ls" utility from i386/stand/libsa here
 1.29 01-Apr-1999  simonb branches: 1.29.4;
It's no use having a memcmp() that calls bcmp() if there's no bcmp() in
the SA library. Basically copied from ../libkern with a few less #if's
and #include's.
 1.28 30-Mar-1999  cgd Add bzero.c, errno.c, and memset.c to SRCS
 1.27 24-Feb-1999  drochner build tftp filesystem, rearrange .ifdef slightly so that network stuff
is not built if ${SA_INCLUDE_NET} is not set
 1.26 13-Feb-1999  pk Split the printf variants into separate files.
 1.25 13-Feb-1999  lukem convert from NOxxx= to MKxxx=no.
include <bsd.own.mk> if testing a MKxxx variable.
 1.24 12-Feb-1999  drochner We can't prototype exit() publically because it might take an argument or
not, depending on the port-specific environment.
Separate panic() and exit() so that the mi/default panic() can be used
without conflicting with a local exit() definition, move exit(void)
prototype to the default exit() implementation.
Closes PR bin/6990 by Wolfgang Helbig <helbig@Informatik.BA-Stuttgart.DE>.
 1.23 24-Sep-1998  ross tfs -> ustarfs
 1.22 22-Sep-1998  ross Add tfs.c to SRCS.
 1.21 26-Oct-1997  lukem use COPTS instead of CFLAGS (entry currently commented out)
 1.20 26-Jun-1997  drochner branches: 1.20.8;
Don't define STANDALONE here, it is not used by sys/lib/libsa code.
Port dependant code depending on it must define it in its own Makefile.
 1.19 31-May-1997  cjs Back out BUILDDIR and NOINSTALL changes.
 1.18 30-May-1997  cjs Use new NOINSTALL option for libraries that are used only during the build
of a program, and not installed into the final system.
 1.17 07-May-1997  mycroft Use libinstall::, not install:, to prevent instaling LIB.
 1.16 16-Feb-1997  cgd branches: 1.16.2;
allow includers to specify library-specific CPP flags via ${LIB}MISCCPPFLAGS
 1.15 23-Jan-1997  cgd clean up variable use, standardize with other kernel library Makefiles.
rename 'NO_NET' variable to SA_INCLUDE_NET, which defaults to 'yes' but can
be set differently. kill EXTRACFLAGS, add SACPPFLAGS (generated from
CPPFLAGS by Makefile.inc) to CFLAGS. Add support for including gzipped-file
read support, enabled by setting SA_USE_CREAD to yes (defaults to no).
 1.14 16-Jan-1997  cgd add memcmp, implemented as a wrapper around bcmp() (like memcpy() is
implemented as a wrapper around bcopy()).
 1.13 02-Oct-1996  ws branches: 1.13.2;
Remove superfluous -I. accidently introduced when I imported the PPC port
 1.12 30-Sep-1996  ws Add support for booting from cd9660 fs
Support directory traversal and symbolic links for nfs booting
Close device when file opening failed
Plug memory leak in ufs code
 1.11 13-Jan-1996  leo Some files containing more than one function are split. This reduces the
size of the resulting loader. The read_inode() function now returns the
result of the strategy function instead of success in all cases (ufs.c).
Fixes pr#1817
 1.10 01-Oct-1995  phil Don't add network files to SRCS if NO_NET is defined. (I'm getting
very short of disk space on STEELHEAD!) The pc532 doesn't use the
network (yet?) from boot.
 1.9 17-Sep-1995  pk De-activate DEBUGFLAGS again.
 1.8 17-Sep-1995  pk Revert fs_ops read/write declarations; these return error numbers.
Get rid of some more compiler warnings.
Set errno where appropriate.
 1.7 14-Sep-1995  pk Mirror libkern makefiles.
 1.6 26-Oct-1994  cgd new RCS ID format.
 1.5 22-Aug-1994  brezak branches: 1.5.2;
Cleanup to make more ANSI compliant; checkpoint
 1.4 04-Aug-1994  brezak Make libsa compile again by not including sys/errno.h
 1.3 27-Jul-1994  cgd get includes from sys, and define KERNEL
 1.2 08-May-1994  brezak branches: 1.2.2;
Standalone networking for network boot loaders.
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.2.2.2 05-Aug-1994  mycroft update from trunk, per Brezak
 1.2.2.1 27-Jul-1994  cgd update from trunk.
 1.5.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.5.2.1 22-Aug-1994  brezak file Makefile was added on branch netbsd-1-0 on 1994-08-22 21:55:59 +0000
 1.13.2.1 18-Jan-1997  thorpej Update from trunk.
 1.16.2.2 16-Feb-1997  cgd allow includers to specify library-specific CPP flags via ${LIB}MISCCPPFLAGS
 1.16.2.1 16-Feb-1997  cgd file Makefile was added on branch is-newarp on 1997-02-16 21:25:21 +0000
 1.20.8.1 12-Nov-1997  thorpej Sync w/ trunk.
 1.29.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.34.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.34.4.1 15-Nov-1999  fvdl Sync with -current
 1.34.2.3 21-Apr-2001  bouyer Sync with HEAD
 1.34.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.34.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.41.4.1 01-Apr-2001  he Pull up revision 1.44 (requested by hubertf):
Document some SA_* options, in case someone needs to strip down
the bootblock to enable or add new features, such as enabling
password support. Addressess PR#12506.
 1.43.2.7 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.43.2.6 28-Feb-2002  nathanw Catch up to -current.
 1.43.2.5 08-Jan-2002  nathanw Catch up to -current.
 1.43.2.4 14-Nov-2001  thorpej Merge from -current, required to cross-build kernels properly.
 1.43.2.3 14-Nov-2001  nathanw Catch up to -current.
 1.43.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.43.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.44.2.4 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.44.2.3 16-Mar-2002  jdolecek Catch up with -current.
 1.44.2.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.44.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.45.4.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.54.4.1 22-May-2004  he Pull up revision 1.55 (requested by abs in ticket #369):
Add qsort to libsa (taken from sys/dev/vinum/vinumqsort.c)
and use instead of bubblesort in acorn32 bootloader. Reduces
time to sort memory on A710 equipped RiscPC from over twenty
seconds to effectively instantaneous. Update boot version
to 3.30
 1.54.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.54.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.54.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.54.2.1 03-Aug-2004  skrll Sync with HEAD
 1.56.2.5 17-Mar-2008  yamt sync with head.
 1.56.2.4 27-Feb-2008  yamt sync with head.
 1.56.2.3 21-Jan-2008  yamt sync with head
 1.56.2.2 07-Dec-2007  yamt sync with head
 1.56.2.1 21-Jun-2006  yamt sync with head.
 1.57.2.1 01-Feb-2006  yamt sync with head.
 1.58.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.58.6.1 24-May-2006  yamt sync with head.
 1.58.4.1 01-Jun-2006  kardel Sync with head.
 1.58.2.1 09-Sep-2006  rpaulo sync with head
 1.59.40.2 27-Dec-2007  mjf Sync with HEAD.
 1.59.40.1 08-Dec-2007  mjf Sync with HEAD.
 1.59.34.2 23-Mar-2008  matt sync with HEAD
 1.59.34.1 09-Jan-2008  matt sync with HEAD
 1.59.32.2 09-Dec-2007  jmcneill Sync with HEAD.
 1.59.32.1 03-Dec-2007  joerg Sync with HEAD.
 1.59.22.1 09-Dec-2007  reinoud Pullup to HEAD
 1.60.2.1 08-Dec-2007  ad Sync with head.
 1.61.12.3 28-Sep-2008  mjf Sync with HEAD.
 1.61.12.2 02-Jun-2008  mjf Sync with HEAD.
 1.61.12.1 03-Apr-2008  mjf Sync with HEAD.
 1.61.8.1 24-Mar-2008  keiichi sync with head.
 1.65.6.2 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.65.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.65.4.4 11-Mar-2010  yamt sync with head
 1.65.4.3 16-Sep-2009  yamt sync with head
 1.65.4.2 04-May-2009  yamt sync with head.
 1.65.4.1 16-May-2008  yamt sync with head.
 1.65.2.1 18-May-2008  yamt sync with head.
 1.66.4.1 19-Oct-2008  haad Sync with HEAD.
 1.67.8.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.67.2.1 28-Apr-2009  skrll Sync with HEAD.
 1.70.2.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.71.4.1 06-Jun-2011  jruoho Sync with HEAD.
 1.71.2.1 31-May-2011  rmind sync with head
 1.72.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.75.6.1 18-Feb-2012  mrg merge to -current.
 1.75.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.75.2.2 30-Oct-2012  yamt sync with head
 1.75.2.1 17-Apr-2012  yamt sync with head
 1.78.4.2 18-May-2014  rmind sync with head
 1.78.4.1 28-Aug-2013  rmind sync with head
 1.78.2.2 03-Dec-2017  jdolecek update from HEAD
 1.78.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.81.2.1 10-Aug-2014  tls Rebase.
 1.84.4.2 22-Apr-2016  skrll Sync with HEAD
 1.84.4.1 22-Sep-2015  skrll Sync with HEAD
 1.87.16.1 25-Jun-2018  pgoyette Sync with HEAD
 1.88.2.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.88.2.1 10-Jun-2019  christos Sync with HEAD
 1.93.8.1 31-May-2021  cjep sync with head
 1.93.6.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.95.12.1 08-Oct-2023  martin Pull up following revision(s) (requested by rin in ticket #394):

external/gpl3/binutils/dist/gas/config/tc-vax.h: revision 1.10
tools/gcc/Makefile: revision 1.109
external/gpl3/binutils/dist/gas/config/tc-vax.c: revision 1.16
external/gpl3/binutils/dist/gas/config/tc-vax.c: revision 1.17
external/gpl3/binutils/dist/gas/config/tc-vax.c: revision 1.18
external/gpl3/gcc.old/dist/gcc/recog.c: revision 1.12
external/gpl3/gcc.old/dist/gcc/function.c: revision 1.16
external/gpl3/gcc.old/dist/gcc/dse.c: revision 1.14 - 1.16
external/gpl3/gcc.old/dist/gcc/config/vax/vax.c: revision 1.13
external/gpl3/gcc.old/dist/gcc/config/vax/vax.c: revision 1.14
external/gpl3/gcc.old/dist/gcc/config/vax/vax.c: revision 1.15
external/gpl3/gcc.old/dist/gcc/doc/tm.texi.in: revision 1.10
external/gpl3/gcc.old/dist/gcc/config/vax/vax.c: revision 1.16
external/gpl3/gcc.old/dist/gcc/config/vax/vax.c: revision 1.17
external/gpl3/gcc.old/dist/gcc/config/vax/vax.c: revision 1.18
external/gpl3/gcc.old/dist/gcc/config/vax/vax.c: revision 1.19
external/gpl3/gcc.old/dist/gcc/config/vax/vax.md: revision 1.12
external/gpl3/gcc.old/dist/gcc/config/vax/vax.md: revision 1.13
external/gpl3/gcc.old/usr.bin/backend/Makefile: revision 1.20
external/gpl3/gcc.old/dist/gcc/targhooks.c: revision 1.12
external/gpl3/gcc.old/dist/gcc/config/vax/vax.md: revision 1.14
external/gpl3/gcc.old/dist/gcc/config/vax/vax.md: revision 1.15
external/gpl3/gcc.old/dist/gcc/config/vax/builtins.md: revision 1.12
external/gpl3/gcc.old/dist/gcc/config/vax/vax.md: revision 1.16
external/gpl3/gcc.old/dist/gcc/config/vax/builtins.md: revision 1.13
external/gpl3/gcc.old/dist/gcc/doc/tm.texi: revision 1.12
external/gpl3/gcc.old/dist/gcc/config/vax/vax.md: revision 1.17
external/gpl3/gcc.old/dist/gcc/config/vax/vax.md: revision 1.18
external/gpl3/gcc.old/dist/gcc/config/vax/elf.h: revision 1.12
external/gpl3/gcc.old/dist/gcc/config/vax/elf.h: revision 1.13
external/gpl3/gcc.old/dist/gcc/targhooks.h: revision 1.12
external/gpl3/gcc.old/dist/gcc/target.def: revision 1.10
external/gpl3/gcc.old/dist/gcc/rtlanal.c: revision 1.14
external/gpl3/gcc.old/dist/gcc/reload.c: revision 1.12
external/gpl3/gcc.old/usr.bin/gcc/Makefile: revision 1.11
external/gpl3/gcc.old/usr.bin/lto-dump/Makefile: revision 1.3
external/gpl3/gcc.old/lib/Makefile.sanitizer: revision 1.7
external/gpl3/binutils.old/lib/libbfd/Makefile: revision 1.10
distrib/utils/x_ping/Makefile: revision 1.9
games/phantasia/Makefile: revision 1.38
external/apache2/argon2/lib/libargon2/Makefile.inc: revision 1.2
external/gpl3/gcc.old/lib/libubsan/Makefile: revision 1.8
external/bsd/mdocml/lib/libmandoc/Makefile: revision 1.13
sbin/ping/Makefile: revision 1.18
sbin/newfs_ext2fs/Makefile: revision 1.7
sys/lib/libz/Makefile: revision 1.24
sys/lib/libsa/Makefile: revision 1.97
external/gpl3/gcc.old/usr.bin/cc1objplus/Makefile: revision 1.3
external/gpl3/gdb/lib/libgdb/Makefile: revision 1.36
sys/modules/lfs/Makefile: revision 1.11
external/mit/xorg/lib/gallium/Makefile: revision 1.51
external/gpl3/gdb.old/lib/libdecnumber/Makefile: revision 1.10
external/mit/xorg/lib/libX11/Makefile.libx11: revision 1.26
libexec/ld.elf_so/Makefile: revision 1.148
external/bsd/jemalloc/lib/Makefile.inc: revision 1.16
external/gpl3/gcc.old/usr.bin/libdecnumber/Makefile: revision 1.14
crypto/external/bsd/openssh/lib/Makefile: revision 1.38
external/gpl3/gcc.old/usr.bin/backend/Makefile: revision 1.21
external/gpl3/gcc.old/usr.bin/cc1/Makefile: revision 1.12
external/gpl3/gcc.old/lib/libasan/Makefile: revision 1.11
external/gpl3/gcc.old/usr.bin/cc1plus/Makefile: revision 1.13
lib/libcrypt/Makefile: revision 1.36
external/gpl3/gdb/lib/libdecnumber/Makefile: revision 1.5
lib/libc/gdtoa/Makefile.inc: revision 1.13
games/gomoku/Makefile: revision 1.13
sbin/fsdb/Makefile: revision 1.43
external/gpl3/gcc.old/usr.bin/lto1/Makefile: revision 1.9
external/mit/xorg/lib/gallium.old/Makefile: revision 1.8
lib/libbz2/Makefile: revision 1.22
external/gpl3/gcc.old/usr.bin/cc1obj/Makefile: revision 1.12
usr.sbin/mtrace/Makefile: revision 1.14
external/gpl3/gcc.old/usr.bin/cc1obj/Makefile: revision 1.13
sys/arch/vax/conf/Makefile.vax: revision 1.86
sys/rump/fs/lib/liblfs/Makefile: revision 1.18
sbin/fsck_ffs/Makefile.common: revision 1.3
external/gpl3/binutils/lib/libbfd/Makefile: revision 1.27
lib/i18n_module/UTF7/Makefile: revision 1.5
external/gpl3/gcc.old/lib/liblsan/Makefile: revision 1.7
doc/CHANGES (apply patch)
(all external/gpl3/gcc.old/ changes applied to external/gpl3/gcc/)

PR 57646: Import major vax toolchain fix.
 1.27 30-Aug-2023  christos explicitly pass COPTS
 1.26 07-Sep-2020  mrg remove GCC_NO_ADDR_OF_PACKED_MEMBER for several subdir builds
that are now handled by lfs_accessors.h internally.
 1.25 07-Sep-2020  mrg oops, move GCC_NO_ADDR_OF_PACKED_MEMBER into the right header.
 1.24 27-May-2018  christos - Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Revert :Q to work as before.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@
XXX: pullup 8
 1.23 22-Mar-2016  mrg branches: 1.23.10; 1.23.16;
remove a bunch of "@echo done" from the tail of rules. these messages
were vaguely useful back when we didn't run make -j, but now you end
up with a single line "done" every so often, with no idea what it is
for. very few other targets claim they're done so just remove these.
 1.22 06-Sep-2015  uebayasi In kernel lib build, print message when things not only start bug also end.
 1.21 12-Dec-2012  matt branches: 1.21.14;
Pass down an empty CPUFLAGS since CPUFLAGS is contained in CFLAGS.
 1.20 26-May-2011  joerg branches: 1.20.4; 1.20.14;
Default to -Wno-sign-compare -Wno-pointer-sign for clang.
Push -Wno-array-bounds down to the cases that depend on it.
Selectively disable warnings for 3rd party software or non-trivial
issues to be reviewed later to get clang -Werror to build most of the
tree.
 1.19 26-Jan-2006  christos branches: 1.19.96; 1.19.102;
Add the source directory of zlib in the include paths so that cread.c can
find zlib.h which is needed from <lib/libz/libz.h>.
 1.18 11-Dec-2005  christos branches: 1.18.2;
merge ktrace-lwp.
 1.17 07-Nov-2003  dsl branches: 1.17.16;
Make 'dependall' generate dependencies in these libraries.
 1.16 21-Nov-2001  jmc branches: 1.16.16;
Don't make clean and cleandir depend on the lib subdir. Just check for it's
existance before running the submake. This makes it possible to run a
make build (which runs cleandir before make obj) in a r/o source tree
 1.15 05-Dec-2000  sommerfeld branches: 1.15.2; 1.15.4;
Have recursive make invocations depend on the .MAKE pseudo-target so
make knows to handle them specially.
 1.14 01-Feb-2000  tsutsui Revert STRIPPROG -> STRIP
 1.13 19-Jan-2000  tsutsui STRIP -> STRIPPROG
 1.12 07-May-1999  drochner branches: 1.12.2;
Build libraries for kernel/standalone code from within their compilation
directories and use .PATH to lookup the source files.
(Formerly, the libs were built from the source dirs, with MAKEOBJDIR
set to the compilation directory.)
This solves 2 problems:
-"mkdep" and "make" are now consistent about the file lookup, this fixes
bad interactions with amd reported in PR bin/7374 (Arne Juul) and
lossage reported by Andrew Gillham ("obj" dirs and relative paths still
don't work well together)
-kernel compile trees can be moved around without forcing a new
"make depend" - fixing PR kern/4021 by Martin Husemann
 1.11 05-Sep-1998  lukem branches: 1.11.8;
distclean is a synonym for cleandir
 1.10 07-Feb-1998  cgd make sure that LORDER, TSORT, AR, NM, RANLIB, and SIZE are correctly
and consistently set when doing kernel library builds.
 1.9 16-Feb-1997  cgd branches: 1.9.2;
allow includers to specify library-specific CPP flags via ${LIB}MISCCPPFLAGS
 1.8 23-Jan-1997  cgd clean up substantially. Transform clean, depend, cleandir targets from ::
to :, so they can be used e.g. with <bsd.prog.mk>. Standardize variable
names used to configure kernel libraries.

Variables used by these Makefile.inc's are:

S must be set to the top of the 'sys' tree.
${LIB}DST may be set to the location of the directory where library
objects are to be built. Defaults to ${.OBJDIR}/lib/${lib}.
${LIB}_AS may be set to 'obj' to build a object from the library's
object files. (Otherwise, a library will be built.)
Defaults to 'library'.
${LIB}MISCMAKEFLAGS
Miscellaneous flags to be passed to the library's Makefile when
building. See library's Makefile for more details about
supported flags and their default values.

(where LIB is KERN, SA, or Z, and lib is kern, sa, or z, depending on which
library's Makefile.inc is being discussed.)
 1.7 02-Jan-1997  christos Typo police from: Juergen Hannken-Illjes
 1.6 26-Dec-1996  christos PR/2981: use ${VAR:Q} instead of "${VAR}" to avoid quoting problems
 1.5 30-Sep-1996  ws Add support for booting from cd9660 fs
Support directory traversal and symbolic links for nfs booting
Close device when file opening failed
Plug memory leak in ufs code
 1.4 01-Oct-1995  phil Don't add network files to SRCS if NO_NET is defined. (I'm getting
very short of disk space on STEELHEAD!) The pc532 doesn't use the
network (yet?) from boot.
 1.3 14-Sep-1995  pk Mirror libkern makefiles.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.9.2.2 16-Feb-1997  cgd allow includers to specify library-specific CPP flags via ${LIB}MISCCPPFLAGS
 1.9.2.1 16-Feb-1997  cgd file Makefile.inc was added on branch is-newarp on 1997-02-16 21:25:22 +0000
 1.11.8.1 21-Jun-1999  thorpej Sync w/ -current.
 1.12.2.2 08-Dec-2000  bouyer Sync with HEAD.
 1.12.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.15.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.2.1 08-Jan-2002  nathanw Catch up to -current.
 1.16.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.16.16.1 03-Aug-2004  skrll Sync with HEAD
 1.17.16.1 21-Jun-2006  yamt sync with head.
 1.18.2.1 01-Feb-2006  yamt sync with head.
 1.19.102.1 06-Jun-2011  jruoho Sync with HEAD.
 1.19.96.1 31-May-2011  rmind sync with head
 1.20.14.1 25-Feb-2013  tls resync with head
 1.20.4.1 16-Jan-2013  yamt sync with (a bit old) head
 1.21.14.2 22-Apr-2016  skrll Sync with HEAD
 1.21.14.1 22-Sep-2015  skrll Sync with HEAD
 1.23.16.1 25-Jun-2018  pgoyette Sync with HEAD
 1.23.10.1 09-Jun-2018  martin Pull up following revision(s) (requested by christos in ticket #870):

sys/lib/libgnuefi/Makefile.inc: revision 1.5
external/mit/xorg/xorg-pkg-ver.mk: revision 1.9
sys/arch/i386/stand/lib/Makefile.inc: revision 1.17
sys/compat/common/Makefile.inc: revision 1.25
usr.bin/make/unit-tests/varquote.exp: revision 1.1, 1.2
sys/lib/libsa/Makefile.inc: revision 1.24
usr.bin/make/var.c: revision 1.220
sys/arch/ia64/stand/efi/libefi/Makefile.inc: revision 1.5
sys/arch/hppa/spmath/Makefile.inc: revision 1.10
usr.bin/make/unit-tests/varquote.mk: revision 1.1, 1.2
usr.bin/make/unit-tests/Makefile: revision 1.53
sys/lib/libkern/Makefile.inc: revision 1.45
sys/arch/acorn32/stand/lib/Makefile.inc: revision 1.4
sys/arch/m68k/fpsp/Makefile.inc: revision 1.21
usr.bin/make/make.1: revision 1.273
sys/lib/libz/Makefile.inc: revision 1.17

- Introduce :q modifier for make variables and make it double escape $'s so
that passing variables to recursive makes with :q works as expected.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@

XXX: pullup 8
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 11-Nov-1999  thorpej The hack needed to work around gcc lameness.
 1.28 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.27 05-Jun-2016  maxv branches: 1.27.18;
Remove the ALLOC_FIRST_FIT and ALLOC_TRACE options. This is a rather simple
allocator, and it does not need to be that complicated.
 1.26 30-Jul-2011  jakllsch branches: 1.26.12; 1.26.30;
Fix printf formating in ifdef DEBUG sections.
 1.25 16-Jun-2011  joerg Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.24 25-Dec-2010  jakllsch branches: 1.24.6;
Correct recently exposed printf format problem.
 1.23 02-Dec-2007  tsutsui branches: 1.23.40;
unsigned -> unsigned int
 1.22 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.21 25-Jan-2006  christos branches: 1.21.42; 1.21.44; 1.21.50;
free -> dealloc
 1.20 11-Dec-2005  christos branches: 1.20.2;
merge ktrace-lwp.
 1.19 26-Feb-2005  perry branches: 1.19.4;
nuke trailing whitespace
 1.18 30-Jun-2004  christos branches: 1.18.4; 1.18.6;
help with casts, and lint hints.
 1.17 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.16 01-Feb-2003  dsl branches: 1.16.2;
KNR, removing ugly 'unsigned' variables.
Probably should be size_t, but now matched prototype.
(mainly agreed with christos - he wanted size_t....)
 1.15 30-Mar-2000  augustss Kill some more register declarations.
 1.14 28-May-1999  cgd branches: 1.14.2;
don't bother initializing 'freelist' -- it can be bss
 1.13 11-Apr-1999  simonb The "found" label is not used if ALLOC_FIRST_FIT is defined.
 1.12 01-Apr-1999  simonb branches: 1.12.4;
bestsize is unused if ALLOC_FIRST_FIT is defined.
 1.11 17-Sep-1997  drochner fix printf() format warnings in debug output
 1.10 04-Jul-1997  drochner branches: 1.10.2;
Fix syntax error which appeared #ifdef DEBUG ("end[]").
Simplify the heap location stuff.
 1.9 26-Jun-1997  drochner Allow to define the location of the heap at runtime #if HEAP_VARIABLE.
That helps to test libsa code in user space.
 1.8 13-Jun-1997  drochner Bring prototypes into scope.
 1.7 16-Feb-1997  leo branches: 1.7.2;
Initialize 'bestf' to make this compile again with -Wall.
 1.6 04-Feb-1997  thorpej Add some debugging code to free(), to catch frees before the
start of the heap and beyond the end of the heap (if a heap limit
is defined).
 1.5 22-Jan-1997  cgd Add a whole bunch of features, from Matthias Drochner:
best-fit, rather than first-fit, algorithm.
ability to handle free()s with zero size (needed for gzip read
support).
ability to start the heap someplace else (defined by HEAP_START).
ability to limit growth of the heap (via HEAP_LIMIT).
debugging sanity checks (ifdef DEBUG).
allocation tracing support, to help debugging (ifdef ALLOC_TRACE).
and from me:
ability to pick a (smaller) first-fit algorithm (via ALLOC_FIRST_FIT).
lots of comments.

If heap limits and all of the debugging features are disabled (the default),
and ALLOC_FIRST_FIT is defined (not the default), compiled with -O on the
alpha the new version is the same (object) size as the old version.
 1.4 26-Sep-1996  cgd make sure new allocations are aligned.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 27-Jul-1994  cgd branches: 1.2.2;
use ALIGN, rather than hard-coded numbers
 1.1 26-Jan-1994  brezak branches: 1.1.2;
CMU/4.4 stand-alone library
 1.1.2.1 27-Jul-1994  cgd update from trunk.
 1.2.2.2 27-Jul-1994  cgd use ALIGN, rather than hard-coded numbers
 1.2.2.1 27-Jul-1994  cgd file alloc.c was added on branch netbsd-1-0 on 1994-07-27 07:39:18 +0000
 1.7.2.2 16-Feb-1997  leo Initialize 'bestf' to make this compile again with -Wall.
 1.7.2.1 16-Feb-1997  leo file alloc.c was added on branch is-newarp on 1997-02-16 13:03:00 +0000
 1.10.2.1 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.12.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.14.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.16.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.16.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.16.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.16.2.1 03-Aug-2004  skrll Sync with HEAD
 1.18.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.18.4.1 29-Apr-2005  kent sync with -current
 1.19.4.2 07-Dec-2007  yamt sync with head
 1.19.4.1 21-Jun-2006  yamt sync with head.
 1.20.2.1 01-Feb-2006  yamt sync with head.
 1.21.50.1 08-Dec-2007  mjf Sync with HEAD.
 1.21.44.1 09-Jan-2008  matt sync with HEAD
 1.21.42.2 03-Dec-2007  joerg Sync with HEAD.
 1.21.42.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.23.40.1 05-Mar-2011  rmind sync with head
 1.24.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.26.30.1 09-Jul-2016  skrll Sync with HEAD
 1.26.12.1 03-Dec-2017  jdolecek update from HEAD
 1.27.18.1 10-Jun-2019  christos Sync with HEAD
 1.35 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.34 29-Mar-2014  jakllsch branches: 1.34.30;
Use ETHER_ADDR_LEN more.
 1.33 17-Jan-2009  tsutsui branches: 1.33.14; 1.33.24; 1.33.28;
Remove __P().
 1.32 12-Jan-2009  tsutsui Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.31 25-Mar-2008  christos branches: 1.31.4; 1.31.12;
remove stray comment
 1.30 25-Mar-2008  christos fix typo
 1.29 25-Mar-2008  christos - use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.28 24-Nov-2007  isaki branches: 1.28.14;
style, indent, and ANSI-fy.
 1.27 11-Dec-2005  christos branches: 1.27.44; 1.27.46; 1.27.52;
merge ktrace-lwp.
 1.26 13-Jun-2005  junyoung branches: 1.26.2;
Remove bcmp(). Use memcmp() instead.
 1.25 26-Feb-2005  perry nuke trailing whitespace
 1.24 31-Aug-2003  fvdl branches: 1.24.8; 1.24.10;
Fix signed/unsigned warnings.
 1.23 27-Sep-2002  provos branches: 1.23.6;
remove trailing \n in panic(). approved perry.
 1.22 18-Oct-2001  jdolecek Fix compilation on Alpha with ARP_DEBUG.
Fixes kern/6440 by R. C. Dowdeswell
 1.21 30-Mar-2000  augustss branches: 1.21.6; 1.21.8;
Kill some more register declarations.
 1.20 13-Nov-1999  thorpej Backout my libsa changes.
 1.19 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.18 07-Jul-1997  drochner branches: 1.18.20; 1.18.22; 1.18.26;
Don't use private copy of old netinet/if_ether.h.
Use <net/if_ether.h> for ethernet specific definitions, and insert private
definitions for ARP if needed. (The new ARP macros in <net/if_arp.h> are
not used because they create larger code, and we really don't need more
than ethernet/ip support here.)
 1.17 26-Jun-1997  drochner Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.16 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.15 13-Oct-1996  christos branches: 1.15.6;
backout previous kprintf changes
 1.14 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.13 08-Dec-1995  gwr Check return value from sendrecv so that ARP timeout does not cause
garbage to be entered into the ARP table. Also fix ARP_DEBUG code.
 1.12 27-Sep-1995  pk branches: 1.12.2;
Careful with initializers.
 1.11 23-Sep-1995  gwr More cleanup: change some private types to eliminate casts,
replace some "goto xxx" with return(-1). (mostly cosmetic)
 1.10 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.9 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.8 13-Sep-1995  gwr Correct the padding to min Ethernet packet size.
 1.7 11-Sep-1995  thorpej Changes from Gordon Ross:
a) check against `my' ethernet or broadcast addresses done in
ether.c
b) changed interface to readether() to provide ethertype info
c) respond to arp requests when appropriate.
First two are clean-up. Last fixes hp300 and presumably mvme68k netboot
code.
 1.6 04-Aug-1995  thorpej Kill extra declaration of bcea[]. It's also defined in globals.c.
 1.5 27-Jun-1995  gwr Pad the request out to the minimum Ethernet length.
Improve some debug prints...
 1.4 20-Feb-1995  mycroft Various:
* Fix some misused types.
* Encapsulate the protocols better.
* Rearrange the RPC stuff to work more like the kernel. (Needs more work.)
* Remove a bunch of extra hair when reading a file over NFS.
* Use RPCAUTH_UNIX when talking to the NFS server.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 04-Aug-1994  brezak branches: 1.2.2;
Make libsa compile again by not including sys/errno.h
 1.1 08-May-1994  brezak branches: 1.1.2;
Standalone networking for network boot loaders.
 1.1.2.1 05-Aug-1994  mycroft update from trunk, per Brezak
 1.2.2.2 04-Aug-1994  brezak Make libsa compile again by not including sys/errno.h
 1.2.2.1 04-Aug-1994  brezak file arp.c was added on branch netbsd-1-0 on 1994-08-04 19:39:35 +0000
 1.12.2.1 22-Jan-1996  gwr Do not enter garbage in the ARP cache if sendrecv() times out.
 1.15.6.1 07-Mar-1997  is Use the local copy of the old-style if_ether.h for the moment, til we have
time to modernize the libsa ARP support.
 1.18.26.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.18.22.1 15-Nov-1999  fvdl Sync with -current
 1.18.20.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.21.8.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.21.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.21.6.2 18-Oct-2002  nathanw Catch up to -current.
 1.21.6.1 22-Oct-2001  nathanw Catch up to -current.
 1.23.6.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.23.6.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.23.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.23.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.23.6.1 03-Aug-2004  skrll Sync with HEAD
 1.24.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.24.8.1 29-Apr-2005  kent sync with -current
 1.26.2.1 07-Dec-2007  yamt sync with head
 1.27.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.27.46.1 09-Jan-2008  matt sync with HEAD
 1.27.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.28.14.2 17-Jan-2009  mjf Sync with HEAD.
 1.28.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.31.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.31.4.1 04-May-2009  yamt sync with head.
 1.33.28.1 18-May-2014  rmind sync with head
 1.33.24.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.33.14.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.34.30.1 10-Jun-2019  christos Sync with HEAD
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 11-Nov-1999  thorpej Minimal quad routines needed for libsa to be self-contained. The compiler
emits a reference to this one in the UFS code.
 1.2 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.1 10-Aug-2014  isaki branches: 1.1.4; 1.1.30;
Unify all arch/*/stand's atoi() to MI libsa.
lib/libsa/atoi.c was separated from lib/libsa/bootcfg.c.
PR/49084
 1.1.30.1 10-Jun-2019  christos Sync with HEAD
 1.1.4.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.4.1 10-Aug-2014  tls file atoi.c was added on branch tls-maxphys on 2014-08-20 00:04:30 +0000
 1.7 13-Jun-2005  junyoung Remove bcmp(). Use memcmp() instead.
 1.6 01-Sep-2003  dsl Another attempt to get libsa to contain the right things.
- put a 'standards conforming' memcmp into memcmp.c
- make bcmp be a second label on the same code
- make bcmp.c be just #include "memcmp.c"
This means that libsa.o might contain both a memcmp.o and a bcmp.o, but
both contain the same code (defining both symbols) so it doesn't matter
which ld uses.
Saves worrying about which of bcmp.c and memcmp.c the architecture specific
Makefile requests.
 1.5 29-Aug-2003  dsl The __strong_alias() seems to have to be in the file with the definition.
So make bcmp.c define bcmp and memcmp.
This should (?) fix the atari build.
(I've now no idea why the previous change defined memcpy for the alpha build.)
 1.4 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 13-Nov-1999  thorpej branches: 1.3.28;
Backout my libsa changes.
 1.2 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.1 01-Apr-1999  simonb branches: 1.1.8; 1.1.10; 1.1.14;
It's no use having a memcmp() that calls bcmp() if there's no bcmp() in
the SA library. Basically copied from ../libkern with a few less #if's
and #include's.
 1.1.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.10.1 15-Nov-1999  fvdl Sync with -current
 1.1.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.3.28.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.28.1 03-Aug-2004  skrll Sync with HEAD
 1.12 25-Mar-2008  christos - use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.11 24-Nov-2007  isaki branches: 1.11.14;
style, indent, and ANSI-fy.
 1.10 11-Dec-2005  christos branches: 1.10.44; 1.10.46; 1.10.52;
merge ktrace-lwp.
 1.9 07-Aug-2003  agc branches: 1.9.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.8 30-Mar-2000  augustss branches: 1.8.28;
Kill some more register declarations.
 1.7 30-Mar-1999  cgd branches: 1.7.8;
#undef bcopy, so that this will still compile if LIBSA_USE_MEMCPY is defined
 1.6 13-Jan-1996  leo Some files containing more than one function are split. This reduces the
size of the resulting loader. The read_inode() function now returns the
result of the strategy function instead of success in all cases (ufs.c).
Fixes pr#1817
 1.5 22-Apr-1995  cgd various type fixups
 1.4 26-Oct-1994  cgd new RCS ID format.
 1.3 27-Jul-1994  cgd branches: 1.3.2;
make bcopy work for overlapping regions, as is standard.
 1.2 26-Feb-1994  pk branches: 1.2.2;
Don't use aggregate initialization;
Add memcpy().
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.2.2.1 27-Jul-1994  cgd update from trunk.
 1.3.2.2 27-Jul-1994  cgd make bcopy work for overlapping regions, as is standard.
 1.3.2.1 27-Jul-1994  cgd file bcopy.c was added on branch netbsd-1-0 on 1994-07-27 07:38:18 +0000
 1.7.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.8.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.8.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.8.28.1 03-Aug-2004  skrll Sync with HEAD
 1.9.16.1 07-Dec-2007  yamt sync with head
 1.10.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.10.46.1 09-Jan-2008  matt sync with HEAD
 1.10.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.11.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.10 06-May-2025  pgoyette Allow the dev= command when processing /boot.cfg file. This
addresses kern/59207
 1.9 05-Jan-2022  andvar branches: 1.9.10;
fix typos, mainly s/comand/command/
 1.8 17-Oct-2021  jmcneill Only define DEFAULT_TIMEOUT if it is not already defined.
 1.7 07-Sep-2021  nia Remove banner printing code from bootloaders, add it to libsa.

This harmonizes efiboot and the various x86 bootloaders to use shared
code for printing the banner. By friendly coincidence, it also adds
support for specifying 'banner=' in arm efiboot's boot.cfg, as on x86.
 1.6 30-May-2021  mlelstv Add "root" command to provide a BTINFO_ROOTDEVICE parameter.
 1.5 27-Jun-2020  jmcneill branches: 1.5.6; 1.5.8;
Support loading boot.cfg from non file-system based devices.
 1.4 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.3 02-Apr-2018  nonaka branches: 1.3.2;
efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.2 10-Aug-2014  isaki branches: 1.2.4; 1.2.22; 1.2.28;
Unify all arch/*/stand's atoi() to MI libsa.
lib/libsa/atoi.c was separated from lib/libsa/bootcfg.c.
PR/49084
 1.1 28-Jun-2014  rtr branches: 1.1.2;
patch posted to tech-kern@ 2014/06/25 for review with minor changes
resulting from feedback.

move multiple copies of code for parsing boot.cfg file from sparc, i386
and zaurus into libsa/bootcfg.{h,c}. largely retained i386 parsing logic
in addition to keeping sparc dispatch function while remaining consistent
with boot.cfg(5).

previous sparc64 file format has been obsoleted but only used by boot
CDs distrib/sparc64/bootfs/boot.cfg has been updated to compensate.

exported names have been prefixed with either BOOTCFG_ or bootcfg_ as per
feedback from christos@

tested on amd64 & sparc64 but not zaurus.
 1.1.2.2 10-Aug-2014  tls Rebase.
 1.1.2.1 28-Jun-2014  tls file bootcfg.c was added on branch tls-earlyentropy on 2014-08-10 06:56:02 +0000
 1.2.28.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.2.22.1 04-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #692):

sys/arch/i386/stand/efiboot/devopen.c: revision 1.4
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.5
sys/arch/i386/stand/efiboot/devopen.h: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.3
sys/lib/libsa/bootcfg.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.9
sys/lib/libsa/bootcfg.c: revision 1.3
sys/arch/i386/stand/lib/bootmenu.c: revision 1.17
sys/arch/i386/stand/lib/biosdisk.c: revision 1.49
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.5
sys/arch/i386/stand/lib/bootmenu.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.h: revision 1.10

efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.2.4.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.4.1 10-Aug-2014  tls file bootcfg.c was added on branch tls-maxphys on 2014-08-20 00:04:30 +0000
 1.3.2.1 10-Jun-2019  christos Sync with HEAD
 1.5.8.1 31-May-2021  cjep sync with head
 1.5.6.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.9.10.1 02-Aug-2025  perseant Sync with HEAD
 1.6 06-May-2025  pgoyette Allow the dev= command when processing /boot.cfg file. This
addresses kern/59207
 1.5 07-Sep-2021  nia branches: 1.5.10;
Remove banner printing code from bootloaders, add it to libsa.

This harmonizes efiboot and the various x86 bootloaders to use shared
code for printing the banner. By friendly coincidence, it also adds
support for specifying 'banner=' in arm efiboot's boot.cfg, as on x86.
 1.4 30-May-2021  mlelstv Add "root" command to provide a BTINFO_ROOTDEVICE parameter.
 1.3 31-Mar-2019  christos branches: 1.3.16; 1.3.18;
fix warnings, printf formats, etc.
 1.2 02-Apr-2018  nonaka branches: 1.2.2;
efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.1 28-Jun-2014  rtr branches: 1.1.2; 1.1.6; 1.1.24; 1.1.30;
patch posted to tech-kern@ 2014/06/25 for review with minor changes
resulting from feedback.

move multiple copies of code for parsing boot.cfg file from sparc, i386
and zaurus into libsa/bootcfg.{h,c}. largely retained i386 parsing logic
in addition to keeping sparc dispatch function while remaining consistent
with boot.cfg(5).

previous sparc64 file format has been obsoleted but only used by boot
CDs distrib/sparc64/bootfs/boot.cfg has been updated to compensate.

exported names have been prefixed with either BOOTCFG_ or bootcfg_ as per
feedback from christos@

tested on amd64 & sparc64 but not zaurus.
 1.1.30.1 07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.1.24.1 04-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #692):

sys/arch/i386/stand/efiboot/devopen.c: revision 1.4
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.5
sys/arch/i386/stand/efiboot/devopen.h: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.3
sys/lib/libsa/bootcfg.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.9
sys/lib/libsa/bootcfg.c: revision 1.3
sys/arch/i386/stand/lib/bootmenu.c: revision 1.17
sys/arch/i386/stand/lib/biosdisk.c: revision 1.49
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.5
sys/arch/i386/stand/lib/bootmenu.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.h: revision 1.10

efiboot: try to read boot.cfg from /EFI/NetBSD on ESP of the booted disk.
 1.1.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.6.1 28-Jun-2014  tls file bootcfg.h was added on branch tls-maxphys on 2014-08-20 00:04:30 +0000
 1.1.2.2 10-Aug-2014  tls Rebase.
 1.1.2.1 28-Jun-2014  tls file bootcfg.h was added on branch tls-earlyentropy on 2014-08-10 06:56:02 +0000
 1.2.2.1 10-Jun-2019  christos Sync with HEAD
 1.3.18.1 31-May-2021  cjep sync with head
 1.3.16.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.5.10.1 02-Aug-2025  perseant Sync with HEAD
 1.43 05-Apr-2019  christos Go back ot using 0x%x instead of %#x because we don't always support the
format. See subr_prf.c
 1.42 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.41 25-Jun-2016  isaki branches: 1.41.18;
Fix typo.
 1.40 25-Jul-2015  isaki white space -> tab.
 1.39 20-Mar-2014  christos branches: 1.39.6;
kill sprintf
 1.38 11-May-2011  zoltan branches: 1.38.4; 1.38.14; 1.38.18;
Separate the IP and UDP code paths inside libsa, so I can add HTTP booting
later.
 1.37 10-Jul-2009  roy branches: 1.37.4; 1.37.6;
Use a function to add extra data to the vendor area so that data added
remains constant for both DISCOVER and REQUEST messages.
 1.36 10-Jul-2009  roy We should request the DHCP parameters we need.
 1.35 06-May-2009  roy We should check for potential overflows.

ok: martin
 1.34 17-Jan-2009  tsutsui branches: 1.34.2;
Remove __P().
 1.33 12-Jan-2009  tsutsui Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.32 25-Mar-2008  christos branches: 1.32.4; 1.32.12;
- use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.31 24-Nov-2007  isaki branches: 1.31.14;
style, indent, and ANSI-fy.
 1.30 01-Oct-2007  martin branches: 1.30.4;
Make a few debug outputs only happen when debugging.
 1.29 20-May-2006  mrg branches: 1.29.16; 1.29.30; 1.29.32; 1.29.34;
add (char *) cast to quieten GCC.
 1.28 11-Dec-2005  christos branches: 1.28.4; 1.28.6; 1.28.8; 1.28.12; 1.28.14;
merge ktrace-lwp.
 1.27 13-Jun-2005  junyoung branches: 1.27.2;
Remove bcmp(). Use memcmp() instead.
 1.26 26-Feb-2005  perry nuke trailing whitespace
 1.25 31-Aug-2003  fvdl branches: 1.25.8; 1.25.10;
Fix signed/unsigned warnings.
 1.24 12-Mar-2003  drochner branches: 1.24.2;
no need to include "netif.h" anymore
(shared interface stuff is in iodesc.h, included by net.h)
 1.23 25-Feb-2003  ragge Remove bogus check for bogus netmask.
 1.22 20-Mar-2002  thorpej * Add a NetBSD Vendor Class Identifier option as proposed on tech-net
in message <20020216172527.C23901@dr-evil.shagadelic.org>.
* Print the bootp/dhcp response, as is done for rarp/bootparam
responses.
* Nuke bootp_flags and BOOTP_PXE; they're not used, nor should they be.
 1.21 19-Jul-2001  wiz Fix typo (`information' has an 'r').
 1.20 02-Nov-2000  thorpej branches: 1.20.2; 1.20.4;
Introduce a way for boot programs to modify the behavior of
bootp(). Add a BOOTP_PXE flag which causes bootp() to send
"PXEClient" in the DHCP class field.

Derived from similar code in FreeBSD.
 1.19 30-Mar-2000  augustss Kill some more register declarations.
 1.18 13-Nov-1999  thorpej Backout my libsa changes.
 1.17 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.16 12-Feb-1999  drochner branches: 1.16.8; 1.16.10; 1.16.14;
Add some #ifdef SUPPORT_LINUX code which specifies a BOOTP tag to pass
a command line for that kernel.
Minor sizeof() sanity.
 1.15 24-Apr-1998  drochner -catch zero and broadcast IP addresses sent by a DHCP server
-KNF
 1.14 16-Feb-1998  drochner Always set own IP address to 0.0.0.0 before BOOTP or DHCP.
 1.13 17-Sep-1997  drochner branches: 1.13.2;
Keep a copy of the original BOOTP bp_siaddr field, in case we want to
use it later for TFTP.
 1.12 06-Sep-1997  drochner -add DHCP support - this option also extends the vendor extension area
to 312 bytes (The classical 64 bytes are likely to be too small if a
rootpath is transferred.)
-make CMU vendor extension support optional
-remove code handling domain name/server (unneeded for boot code)
- -Wall fixes in debug code
 1.11 26-Jun-1997  drochner branches: 1.11.4;
Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.10 13-Oct-1996  christos backout previous kprintf changes
 1.9 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.8 26-Sep-1996  cgd enough 64-bit fixes to make network booting work on the Alpha. In general,
these are hacks (s/long/int/, etc.), but this code really needs a heavy
cleaning (including fixed-size typing) and I don't have time to give it one
now.
 1.7 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.6 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.5 22-Apr-1995  cgd cast ptrs to longs.
 1.4 21-Feb-1995  mycroft Clean up a little.
 1.3 20-Feb-1995  mycroft Various:
* Fix some misused types.
* Encapsulate the protocols better.
* Rearrange the RPC stuff to work more like the kernel. (Needs more work.)
* Remove a bunch of extra hair when reading a file over NFS.
* Use RPCAUTH_UNIX when talking to the NFS server.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.11.4.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.11.4.1 06-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.13.2.2 08-May-1998  mycroft Pull up 1.14, per request of drochner.
 1.13.2.1 08-May-1998  mycroft Pull up 1.15, per request of drochner.
 1.16.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.16.10.1 15-Nov-1999  fvdl Sync with -current
 1.16.8.2 22-Nov-2000  bouyer Sync with HEAD.
 1.16.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.20.4.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.20.4.1 03-Aug-2001  lukem update to -current
 1.20.2.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.20.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.24.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.24.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.24.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.24.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.24.2.1 03-Aug-2004  skrll Sync with HEAD
 1.25.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.25.8.1 29-Apr-2005  kent sync with -current
 1.27.2.3 07-Dec-2007  yamt sync with head
 1.27.2.2 27-Oct-2007  yamt sync with head.
 1.27.2.1 21-Jun-2006  yamt sync with head.
 1.28.14.1 19-Jun-2006  chap Sync with head.
 1.28.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.28.8.1 24-May-2006  yamt sync with head.
 1.28.6.1 01-Jun-2006  kardel Sync with head.
 1.28.4.1 09-Sep-2006  rpaulo sync with head
 1.29.34.1 06-Oct-2007  yamt sync with head.
 1.29.32.2 09-Jan-2008  matt sync with HEAD
 1.29.32.1 06-Nov-2007  matt sync with HEAD
 1.29.30.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.29.30.1 02-Oct-2007  joerg Sync with HEAD.
 1.29.16.1 09-Oct-2007  ad Sync with head.
 1.30.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.31.14.2 17-Jan-2009  mjf Sync with HEAD.
 1.31.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.32.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.32.4.3 18-Jul-2009  yamt sync with head.
 1.32.4.2 16-May-2009  yamt sync with head
 1.32.4.1 04-May-2009  yamt sync with head.
 1.34.2.2 23-Jul-2009  jym Sync with HEAD.
 1.34.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.37.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.37.4.1 31-May-2011  rmind sync with head
 1.38.18.1 18-May-2014  rmind sync with head
 1.38.14.2 03-Dec-2017  jdolecek update from HEAD
 1.38.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.39.6.2 09-Jul-2016  skrll Sync with HEAD
 1.39.6.1 22-Sep-2015  skrll Sync with HEAD
 1.41.18.1 10-Jun-2019  christos Sync with HEAD
 1.10 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.9 17-Jan-2009  tsutsui branches: 1.9.66;
Remove __P().
 1.8 24-Nov-2007  isaki branches: 1.8.18; 1.8.26;
style, indent, and ANSI-fy.
 1.7 20-Mar-2002  thorpej branches: 1.7.28; 1.7.84; 1.7.86; 1.7.92;
* Add a NetBSD Vendor Class Identifier option as proposed on tech-net
in message <20020216172527.C23901@dr-evil.shagadelic.org>.
* Print the bootp/dhcp response, as is done for rarp/bootparam
responses.
* Nuke bootp_flags and BOOTP_PXE; they're not used, nor should they be.
 1.6 02-Nov-2000  thorpej branches: 1.6.2; 1.6.4;
Introduce a way for boot programs to modify the behavior of
bootp(). Add a BOOTP_PXE flag which causes bootp() to send
"PXEClient" in the DHCP class field.

Derived from similar code in FreeBSD.
 1.5 11-Feb-1999  pk branches: 1.5.8;
Add missing prototypes.
 1.4 06-Sep-1997  drochner -add DHCP support - this option also extends the vendor extension area
to 312 bytes (The classical 64 bytes are likely to be too small if a
rootpath is transferred.)
-make CMU vendor extension support optional
-remove code handling domain name/server (unneeded for boot code)
- -Wall fixes in debug code
 1.3 26-Sep-1996  cgd branches: 1.3.10;
enough 64-bit fixes to make network booting work on the Alpha. In general,
these are hacks (s/long/int/, etc.), but this code really needs a heavy
cleaning (including fixed-size typing) and I don't have time to give it one
now.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.3.10.1 06-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.5.8.1 22-Nov-2000  bouyer Sync with HEAD.
 1.6.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.2.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.7.92.1 08-Dec-2007  mjf Sync with HEAD.
 1.7.86.1 09-Jan-2008  matt sync with HEAD
 1.7.84.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.7.28.1 07-Dec-2007  yamt sync with head
 1.8.26.1 19-Jan-2009  skrll Sync with HEAD.
 1.8.18.1 04-May-2009  yamt sync with head.
 1.9.66.1 10-Jun-2019  christos Sync with HEAD
 1.21 02-Apr-2019  christos fix sign-compare and sign-passing errors.
 1.20 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.19 21-Oct-2009  snj branches: 1.19.64;
Drop 3rd and 4th clauses. Approved by gwr@ (copyright holder).
 1.18 17-Jan-2009  tsutsui Remove __P().
 1.17 25-Mar-2008  christos branches: 1.17.4; 1.17.12;
- use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.16 24-Nov-2007  isaki branches: 1.16.14;
style, indent, and ANSI-fy.
 1.15 19-Mar-2003  drochner branches: 1.15.18; 1.15.74; 1.15.76; 1.15.82;
Move global variables which are used only by bootparam here.
("domainname" is useless and could be removed, but adding code to
skip this in the RPC reply would probably be more expensive than leaving
it as a dummy variable.)
 1.14 12-Mar-2003  drochner no need to include "netif.h" anymore
(shared interface stuff is in iodesc.h, included by net.h)
 1.13 13-Nov-1999  thorpej Backout my libsa changes.
 1.12 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.11 26-Jun-1997  drochner branches: 1.11.22; 1.11.24; 1.11.28;
Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.10 14-Oct-1996  thorpej Delete spurious #endif
 1.9 13-Oct-1996  christos backout previous kprintf changes
 1.8 10-Oct-1996  christos - printf -> kprintf, sprintf -> ksprintf
- use a debugging printf macro instead of #ifdef #endif everywhere.
 1.7 26-Feb-1996  gwr Make this code independent of <sys/nfs> now that we use very little
from there anyway, so we can ignore changes in the NFS code...
 1.6 08-Dec-1995  gwr Correct error which caused truncation of port number on i386 (PR#1823)
 1.5 23-Sep-1995  gwr More cleanup: change some private types to eliminate casts,
replace some "goto xxx" with return(-1). (mostly cosmetic)
 1.4 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.3 17-Sep-1995  pk Revert fs_ops read/write declarations; these return error numbers.
Get rid of some more compiler warnings.
Set errno where appropriate.
 1.2 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.1 27-Jun-1995  gwr Support functions for NFS boot (get server address and root path).
 1.11.28.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.11.24.1 15-Nov-1999  fvdl Sync with -current
 1.11.22.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.15.82.1 08-Dec-2007  mjf Sync with HEAD.
 1.15.76.1 09-Jan-2008  matt sync with HEAD
 1.15.74.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.15.18.1 07-Dec-2007  yamt sync with head
 1.16.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.17.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.17.4.2 11-Mar-2010  yamt sync with head
 1.17.4.1 04-May-2009  yamt sync with head.
 1.19.64.1 10-Jun-2019  christos Sync with HEAD
 1.4 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.3 05-Jan-1998  perry branches: 1.3.64; 1.3.120; 1.3.122; 1.3.128;
RCSID Police.
 1.2 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.1 27-Jun-1995  gwr Support functions for NFS boot (get server address and root path).
 1.3.128.1 08-Dec-2007  mjf Sync with HEAD.
 1.3.122.1 09-Jan-2008  matt sync with HEAD
 1.3.120.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.3.64.1 07-Dec-2007  yamt sync with head
 1.3 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.2 31-Oct-2001  thorpej branches: 1.2.2; 1.2.4; 1.2.6; 1.2.38; 1.2.94; 1.2.96; 1.2.102;
Add standalone 64-bit to/from {big,little}-endian routines.
 1.1 30-Oct-2001  thorpej Add standalone byte-swapping routines that don't require testing
the system's byte-order:
- host to {big,little}-endian {16,32}
- {big,little}-endian {16,32} to host

These are not intended to be used in libsa directly, but are rather
intended to be used by host tools which may use libsa routines (such
as loadfile()) which need to use explicit byte-ordering.
 1.2.102.1 08-Dec-2007  mjf Sync with HEAD.
 1.2.96.1 09-Jan-2008  matt sync with HEAD
 1.2.94.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.2.38.1 07-Dec-2007  yamt sync with head
 1.2.6.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.6.1 31-Oct-2001  thorpej file byteorder.c was added on branch kqueue on 2002-01-10 20:00:36 +0000
 1.2.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.2.4.1 31-Oct-2001  nathanw file byteorder.c was added on branch nathanw_sa on 2001-11-14 19:16:51 +0000
 1.2.2.2 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.2.2.1 31-Oct-2001  thorpej file byteorder.c was added on branch thorpej-mips-cache on 2001-11-12 21:19:04 +0000
 1.3 31-Oct-2001  thorpej branches: 1.3.2; 1.3.4; 1.3.6;
Oops, committed wrong copy of file in previous revision.
 1.2 31-Oct-2001  thorpej Add standalone 64-bit to/from {big,little}-endian routines.
 1.1 30-Oct-2001  thorpej Add standalone byte-swapping routines that don't require testing
the system's byte-order:
- host to {big,little}-endian {16,32}
- {big,little}-endian {16,32} to host

These are not intended to be used in libsa directly, but are rather
intended to be used by host tools which may use libsa routines (such
as loadfile()) which need to use explicit byte-ordering.
 1.3.6.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.6.1 31-Oct-2001  thorpej file byteorder.h was added on branch kqueue on 2002-01-10 20:00:37 +0000
 1.3.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.3.4.1 31-Oct-2001  nathanw file byteorder.h was added on branch nathanw_sa on 2001-11-14 19:16:51 +0000
 1.3.2.2 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.3.2.1 31-Oct-2001  thorpej file byteorder.h was added on branch thorpej-mips-cache on 2001-11-12 21:19:05 +0000
 1.5 25-Mar-2008  christos - use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.4 24-Nov-2007  isaki branches: 1.4.14;
style, indent, and ANSI-fy.
 1.3 13-Nov-1999  thorpej branches: 1.3.44; 1.3.100; 1.3.102; 1.3.108;
Backout my libsa changes.
 1.2 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.1 30-Mar-1999  cgd branches: 1.1.8; 1.1.10; 1.1.14;
add simple (small) implementations of memset and bzero. the versions
in libkern are fine for the kernel, but the versions here are smaller
and in libsa the point is size.
 1.1.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.10.1 15-Nov-1999  fvdl Sync with -current
 1.1.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.3.108.1 08-Dec-2007  mjf Sync with HEAD.
 1.3.102.1 09-Jan-2008  matt sync with HEAD
 1.3.100.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.3.44.1 07-Dec-2007  yamt sync with head
 1.4.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.2 26-Jan-1994  mycroft Clean up deleted files.
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.32 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.31 08-Mar-2018  nonaka branches: 1.31.2;
Add missed file in previous commit.

> efiboot: system can boot from CD/DVD-ROM media.
 1.30 20-Mar-2014  christos branches: 1.30.22; 1.30.28;
reduce size by 1K by sharing the ls code.
 1.29 23-Jul-2012  mhitch branches: 1.29.2; 1.29.4;
Fix cd9660_read() to not read past the end of the file. This would result
in incorrect resid values, and causes the read of /boot.cfg to ignore the
file. If the requested transfer extends past the end of the file, force
the internal buffer to be used, and when transferring data from the
internal buffer, limit the transfer to what's left in the file. CDROM
boot will now process the /boot.cfg file.
 1.28 25-Dec-2011  tsutsui branches: 1.28.2;
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.27 16-Jun-2011  joerg branches: 1.27.2; 1.27.6;
Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.26 18-Oct-2010  ws branches: 1.26.6;
Allow multiple path separators between/after directory names.
Problem found while analyzing PR kern/43963.
 1.25 22-Mar-2010  jakllsch Ensure cd9660_read() gives accurate EOF indication.
Should fix PR/42983.
 1.24 19-Nov-2008  ad branches: 1.24.6; 1.24.8;
For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.23 24-Nov-2007  isaki branches: 1.23.14; 1.23.18; 1.23.24; 1.23.26;
style, indent, and ANSI-fy.
 1.22 05-Mar-2007  he branches: 1.22.14; 1.22.16; 1.22.22;
We need char* for pointer arithmetic.
 1.21 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.20 25-Jan-2006  christos branches: 1.20.24;
free -> dealloc
 1.19 11-Dec-2005  christos branches: 1.19.2;
merge ktrace-lwp.
 1.18 13-Jun-2005  junyoung branches: 1.18.2;
Oops, missed a semicolon.
 1.17 13-Jun-2005  junyoung ANSI, De-__P(), and some cosmetic changes including
bcmp -> memcmp, bzero -> memset, bcopy -> memcpy.
 1.16 26-Feb-2005  perry nuke trailing whitespace
 1.15 18-Oct-2003  itohy branches: 1.15.8; 1.15.10;
Rename local variables `read' to `nread' to shut up -Wshadow.
 1.14 21-Aug-2003  elric make 'path' argument to cd9660_open 'const char *' and fix the fallout.
 1.13 30-Dec-2002  veego branches: 1.13.2;
Fix broken build due too the move of the cd9660 and msdosfs kernel source code.
 1.12 05-Apr-2001  thorpej libkern.h now has the ctype routines.
 1.11 23-Nov-1999  simonb branches: 1.11.6;
Remove leading '/' from pathnames, using same logic as ufs.c. Allows new
style (but not yet committed) pmax bootblocks to open "/boot.pmax" on an
ISO image. Same problem reported for NFS by Jason Thorpe.
 1.10 13-Nov-1999  thorpej Backout my libsa changes.
 1.9 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.8 31-Mar-1999  cgd branches: 1.8.8; 1.8.10; 1.8.14;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.7 26-Mar-1999  dbj Changes to compile the next68k bootblocks with
egcs -Wpointer-arith -Wstrict-prototypes
This closes pr 6653
 1.6 11-Feb-1999  pk Add missing prototypes.
 1.5 26-Jun-1997  drochner Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.4 13-Jun-1997  drochner -Wall fixes
 1.3 24-Jan-1997  cgd isonum_722 and isonum_732 are now back in iso.h
 1.2 24-Jan-1997  cgd update for iso.h changes which remove the need for the nastiness that was here
 1.1 30-Sep-1996  ws Add support for booting from cd9660 fs
Support directory traversal and symbolic links for nfs booting
Close device when file opening failed
Plug memory leak in ufs code
 1.8.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.8.10.1 15-Nov-1999  fvdl Sync with -current
 1.8.8.2 21-Apr-2001  bouyer Sync with HEAD
 1.8.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.11.6.2 30-Dec-2002  thorpej Sync with HEAD.
 1.11.6.1 09-Apr-2001  nathanw Catch up with -current.
 1.13.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.13.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.15.8.1 29-Apr-2005  kent sync with -current
 1.18.2.3 07-Dec-2007  yamt sync with head
 1.18.2.2 03-Sep-2007  yamt sync with head.
 1.18.2.1 21-Jun-2006  yamt sync with head.
 1.19.2.1 01-Feb-2006  yamt sync with head.
 1.20.24.1 12-Mar-2007  rmind Sync with HEAD.
 1.22.22.1 08-Dec-2007  mjf Sync with HEAD.
 1.22.16.1 09-Jan-2008  matt sync with HEAD
 1.22.14.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.23.26.1 19-Jan-2009  skrll Sync with HEAD.
 1.23.24.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.23.18.2 11-Aug-2010  yamt sync with head.
 1.23.18.1 04-May-2009  yamt sync with head.
 1.23.14.1 17-Jan-2009  mjf Sync with HEAD.
 1.24.8.2 05-Mar-2011  rmind sync with head
 1.24.8.1 30-May-2010  rmind sync with head
 1.24.6.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.24.6.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.26.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.27.6.1 18-Feb-2012  mrg merge to -current.
 1.27.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.27.2.2 30-Oct-2012  yamt sync with head
 1.27.2.1 17-Apr-2012  yamt sync with head
 1.28.2.1 25-Jul-2012  martin Pull up following revision(s) (requested by mhitch in ticket #440):
sys/lib/libsa/cd9660.c: revision 1.29
Fix cd9660_read() to not read past the end of the file. This would result
in incorrect resid values, and causes the read of /boot.cfg to ignore the
file. If the requested transfer extends past the end of the file, force
the internal buffer to be used, and when transferring data from the
internal buffer, limit the transfer to what's left in the file. CDROM
boot will now process the /boot.cfg file.
 1.29.4.1 18-May-2014  rmind sync with head
 1.29.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.30.28.1 15-Mar-2018  pgoyette Synch with HEAD
 1.30.22.1 13-Mar-2018  martin Pull up following revision(s) (requested by nonaka in ticket #625):
sys/arch/i386/stand/efiboot/efidisk.c: revision 1.2
sys/arch/i386/stand/efiboot/devopen.c: revision 1.2
sys/arch/i386/stand/efiboot/efidisk.h: revision 1.2
sys/arch/i386/stand/efiboot/boot.c: revision 1.6
sys/arch/i386/stand/efiboot/efidisk_ll.c: revision 1.2
sys/arch/i386/stand/efiboot/efidev.c: revision 1.1
sys/arch/i386/stand/lib/biosdisk_ll.h: revision 1.16
sys/arch/i386/stand/lib/biosdisk.h: revision 1.9
sys/lib/libsa/cd9660.c: revision 1.31
sys/arch/i386/stand/efiboot/efiboot.c: revision 1.5
sys/arch/i386/stand/efiboot/efiboot.h: revision 1.6
sys/arch/i386/stand/lib/biosdisk.c: revision 1.47
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.10
sys/arch/i386/stand/efiboot/TODO.efiboot: revision 1.4
efiboot: system can boot from CD/DVD-ROM media.

Add missed file in previous commit.
 1.31.2.1 10-Jun-2019  christos Sync with HEAD
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 21-Aug-2003  elric make 'path' argument to cd9660_open 'const char *' and fix the fallout.
 1.1 30-Sep-1996  ws branches: 1.1.62;
Add support for booting from cd9660 fs
Support directory traversal and symbolic links for nfs booting
Close device when file opening failed
Plug memory leak in ufs code
 1.1.62.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.62.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.62.1 03-Aug-2004  skrll Sync with HEAD
 1.11 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.10 05-Sep-2016  dholland branches: 1.10.16;
Check bounds on input. From Michael Plass.
 1.9 06-Jan-2011  jakllsch branches: 1.9.14; 1.9.18; 1.9.20; 1.9.28; 1.9.34; 1.9.36; 1.9.38; 1.9.42;
Pacify Clang -Wformat-security.
 1.8 24-Nov-2007  isaki branches: 1.8.40;
style, indent, and ANSI-fy.
 1.7 11-Dec-2005  christos branches: 1.7.44; 1.7.46; 1.7.52;
merge ktrace-lwp.
 1.6 13-Jun-2005  junyoung branches: 1.6.2;
Remove bcmp(). Use memcmp() instead.
 1.5 15-Apr-2003  dsl branches: 1.5.2;
Add interface to boot password checking code that takes password parameter.
 1.4 30-Mar-2000  augustss Kill some more register declarations.
 1.3 13-Nov-1999  thorpej Backout my libsa changes.
 1.2 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.1 09-Sep-1999  drochner branches: 1.1.2; 1.1.4; 1.1.8;
add a function to verify a password against an in-core md5 sum
 1.1.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.4.1 15-Nov-1999  fvdl Sync with -current
 1.1.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.5.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.6.2.1 07-Dec-2007  yamt sync with head
 1.7.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.7.46.1 09-Jan-2008  matt sync with HEAD
 1.7.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.8.40.1 05-Mar-2011  rmind sync with head
 1.9.42.1 18-Jan-2017  skrll Sync with netbsd-5
 1.9.38.1 25-Sep-2016  bouyer Pull up following revision(s) (requested by dholland in ticket #1250):
sys/lib/libsa/checkpasswd.c: revision 1.10
Check bounds on input. From Michael Plass.
 1.9.36.1 05-Oct-2016  skrll Sync with HEAD
 1.9.34.1 25-Sep-2016  bouyer Pull up following revision(s) (requested by dholland in ticket #1250):
sys/lib/libsa/checkpasswd.c: revision 1.10
Check bounds on input. From Michael Plass.
 1.9.28.1 24-Sep-2016  bouyer Pull up following revision(s) (requested by dholland in ticket #1406):
sys/lib/libsa/checkpasswd.c: revision 1.10
Check bounds on input. From Michael Plass.
 1.9.20.1 24-Sep-2016  bouyer Pull up following revision(s) (requested by dholland in ticket #1406):
sys/lib/libsa/checkpasswd.c: revision 1.10
Check bounds on input. From Michael Plass.
 1.9.18.1 03-Dec-2017  jdolecek update from HEAD
 1.9.14.1 24-Sep-2016  bouyer Pull up following revision(s) (requested by dholland in ticket #1406):
sys/lib/libsa/checkpasswd.c: revision 1.10
Check bounds on input. From Michael Plass.
 1.10.16.1 10-Jun-2019  christos Sync with HEAD
 1.14 02-Dec-2007  tsutsui unsigned -> unsigned int
 1.13 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.12 11-Dec-2005  christos branches: 1.12.44; 1.12.46; 1.12.52;
merge ktrace-lwp.
 1.11 26-Feb-2005  perry branches: 1.11.4;
nuke trailing whitespace
 1.10 07-Aug-2003  agc branches: 1.10.8; 1.10.10;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.9 30-Mar-2000  augustss branches: 1.9.28;
Kill some more register declarations.
 1.8 31-Mar-1999  cgd branches: 1.8.8;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.7 22-Jan-1997  cgd define these functions with an 'o' prepended to their names if
__INTERNAL_LIBSA_CREAD is defined (so that they can be used by the
compressed-read code).
 1.6 13-Jan-1996  leo Some files containing more than one function are split. This reduces the
size of the resulting loader. The read_inode() function now returns the
result of the strategy function instead of success in all cases (ufs.c).
Fixes pr#1817
 1.5 06-Sep-1995  pk Avoid calling device-close routine when open() not completed. Otherwise you
lose if this sequence occurs: open()->devopen()->...->panic()->closeall().
 1.4 26-Oct-1994  cgd new RCS ID format.
 1.3 22-Aug-1994  brezak branches: 1.3.2;
Cleanup to make more ANSI compliant; checkpoint
 1.2 08-May-1994  brezak Standalone networking for network boot loaders.
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.3.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.3.2.1 22-Aug-1994  brezak file close.c was added on branch netbsd-1-0 on 1994-08-22 21:56:00 +0000
 1.8.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.9.28.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.9.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.28.1 03-Aug-2004  skrll Sync with HEAD
 1.10.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.10.8.1 29-Apr-2005  kent sync with -current
 1.11.4.1 07-Dec-2007  yamt sync with head
 1.12.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.12.46.1 09-Jan-2008  matt sync with HEAD
 1.12.44.2 03-Dec-2007  joerg Sync with HEAD.
 1.12.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.5 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.4 11-Dec-2005  christos branches: 1.4.44; 1.4.46; 1.4.52;
merge ktrace-lwp.
 1.3 26-Feb-2005  perry branches: 1.3.4;
nuke trailing whitespace
 1.2 07-Aug-2003  agc branches: 1.2.8; 1.2.10;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 13-Jan-1996  leo branches: 1.1.64;
Some files containing more than one function are split. This reduces the
size of the resulting loader. The read_inode() function now returns the
result of the strategy function instead of success in all cases (ufs.c).
Fixes pr#1817
 1.1.64.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.1.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.64.1 03-Aug-2004  skrll Sync with HEAD
 1.2.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.2.8.1 29-Apr-2005  kent sync with -current
 1.3.4.1 07-Dec-2007  yamt sync with head
 1.4.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.4.46.1 09-Jan-2008  matt sync with HEAD
 1.4.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.2 26-Jan-1994  mycroft Clean up deleted files.
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.29 14-Jun-2023  rin Add /* FALLTHROUGH */ comment for sure.
 1.28 17-Jan-2016  tsutsui Add an option (LIBSA_CREAD_NOCRC) to disable gunzip CRC32 calculation.

No obvious sideeffect on booting i386 GENERIC kernels (without the option).
Closes PR/50638 (Extreme slowness on loading gzipped kernels on old CPUs).
 1.27 25-Jul-2015  isaki white space -> tab.
 1.26 13-Oct-2013  joerg branches: 1.26.6;
Let's not use uninitialized variables to write to random memory
locations, shall we?
 1.25 11-Oct-2013  pgoyette Rework previous (1.24) change. Rather than depending on the
file's flags to decide if decompress cleanup is needed, just
check to see if the open() allocated the 'struct sd *' used for
decompression.

This fixes recent problem where presence of a "load=ffs" command
in my /boot.cfg resulted in a "heap full" error at boot time.

OK martin@
 1.24 14-Apr-2013  martin branches: 1.24.4;
Make the check in close() for a non-deflatable file mode symetric to
the one in open().
Avoids dealloc() calls on NULL.
 1.23 25-Mar-2009  tls branches: 1.23.12; 1.23.22;
Fix build problems caused by crc32 addition to libkern. Also, this makes
the i386 bootblocks about 2K smaller than they were before we monkeyed
with crc32 at all.
 1.22 17-Jan-2009  tsutsui branches: 1.22.2;
Remove __P().
 1.21 25-Mar-2008  christos branches: 1.21.4; 1.21.12; 1.21.14; 1.21.20;
- use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.20 02-Dec-2007  tsutsui branches: 1.20.14;
unsigned -> unsigned int
 1.19 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.18 25-Jan-2006  christos branches: 1.18.42; 1.18.44; 1.18.50;
free -> dealloc
 1.17 14-Jan-2006  christos Don't include zlib.h directly; redirect through libz.h; this mirrors how
libkern is done and let's us abstract where the real zlib.h is kept.
 1.16 11-Dec-2005  christos branches: 1.16.2;
merge ktrace-lwp.
 1.15 24-Mar-2004  drochner branches: 1.15.16;
remove license clauses 3 and 4 from my cpoyright notices
 1.14 18-Mar-2003  mycroft branches: 1.14.2;
Move some stuff into .rodata.
 1.13 26-Nov-2000  simonb Fix tyop in comment.
 1.12 03-Feb-2000  drochner cosmetics: remove double semicolon, whitespace
 1.11 13-Nov-1999  thorpej Backout my libsa changes.
 1.10 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.9 31-Mar-1999  cgd branches: 1.9.8; 1.9.10; 1.9.14;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.8 12-Feb-1999  drochner That got broken in KNFifying.
 1.7 11-Feb-1999  pk Add missing prototypes and KNF the lot.
 1.6 18-Oct-1997  cjs Change sd.transparent to sd.compressed, so that we default to non-
compressed mode when we zero out the structure. Check_header() now
does not force us to uncompressed mode if we read no data (EOF);
it leaves the default, so that if we check at the end of a file,
we don't set the file to uncompressed mode and blow up later lseeks
on it.
 1.5 04-Jul-1997  drochner Catch errors from underlying reads, ie where oread() returns -1.
(Original code used fread() which never returns -1, so this case was
not handled.)
 1.4 26-Jun-1997  drochner Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.3 13-Jun-1997  drochner Bring prototypes into scope.
 1.2 04-Feb-1997  thorpej In close(), if the file descriptor was used for writing, don't free
data structures that weren't allocated. Fix sanity-checked
by Matthias Drochner.
 1.1 22-Jan-1997  cgd code to open/close/read/lseek gzipped files, from Matthias Drochner.
 1.9.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.9.10.1 15-Nov-1999  fvdl Sync with -current
 1.9.8.2 08-Dec-2000  bouyer Sync with HEAD.
 1.9.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.14.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.15.16.2 07-Dec-2007  yamt sync with head
 1.15.16.1 21-Jun-2006  yamt sync with head.
 1.16.2.2 01-Feb-2006  yamt sync with head.
 1.16.2.1 15-Jan-2006  yamt sync with head.
 1.18.50.1 08-Dec-2007  mjf Sync with HEAD.
 1.18.44.1 09-Jan-2008  matt sync with HEAD
 1.18.42.2 03-Dec-2007  joerg Sync with HEAD.
 1.18.42.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.20.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.21.20.1 21-Apr-2010  matt sync to netbsd-5
 1.21.14.1 03-May-2009  snj Pull up following revision(s) (requested by tls in ticket #611):
common/dist/zlib/zlib.h: revision 1.3
sys/lib/libkern/crc32.c: revision 1.2
sys/lib/libkern/libkern.h: revision 1.90 via patch
sys/lib/libsa/cread.c: revision 1.23
sys/lib/libz/Makefile: revision 1.16
Fix build problems caused by crc32 addition to libkern. Also, this makes
the i386 bootblocks about 2K smaller than they were before we monkeyed
with crc32 at all.
 1.21.12.2 28-Apr-2009  skrll Sync with HEAD.
 1.21.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.21.4.1 04-May-2009  yamt sync with head.
 1.22.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.23.22.3 03-Dec-2017  jdolecek update from HEAD
 1.23.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.23.22.1 23-Jun-2013  tls resync from head
 1.23.12.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.24.4.1 18-May-2014  rmind sync with head
 1.26.6.2 19-Mar-2016  skrll Sync with HEAD
 1.26.6.1 22-Sep-2015  skrll Sync with HEAD
 1.8 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.7 11-Dec-2005  christos branches: 1.7.44; 1.7.46; 1.7.52;
merge ktrace-lwp.
 1.6 07-Aug-2003  agc branches: 1.6.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.5 30-Mar-1999  cgd branches: 1.5.42;
move errno to its own file; if you just need errno, you don't need dev.c's fns
 1.4 30-Oct-1994  cgd be more careful with types, also pull in headers where necessary.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 22-Aug-1994  brezak branches: 1.2.2;
Cleanup to make more ANSI compliant; checkpoint
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.2.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.2.2.1 22-Aug-1994  brezak file dev.c was added on branch netbsd-1-0 on 1994-08-22 21:56:02 +0000
 1.5.42.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.42.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.42.1 03-Aug-2004  skrll Sync with HEAD
 1.6.16.1 07-Dec-2007  yamt sync with head
 1.7.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.7.46.1 09-Jan-2008  matt sync with HEAD
 1.7.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.27 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.26 17-Jul-2011  joerg branches: 1.26.54;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.25 08-Aug-2010  chs print the correct error code if nfs_mount() fails.
 1.24 17-Jan-2009  tsutsui branches: 1.24.4; 1.24.6;
Remove __P().
 1.23 28-Apr-2008  martin branches: 1.23.8;
Remove clause 3 and 4 from TNF licenses
 1.22 24-Nov-2007  isaki branches: 1.22.14; 1.22.16; 1.22.18;
style, indent, and ANSI-fy.
 1.21 27-Oct-2007  tsutsui branches: 1.21.2;
Include "bootp.h" for a function declaration of bootp().
 1.20 01-Oct-2007  martin branches: 1.20.2;
Make a few debug outputs only happen when debugging.
 1.19 17-Mar-2002  gmcgarry branches: 1.19.28; 1.19.70; 1.19.84; 1.19.86; 1.19.88;
Protect remaining references to 'debug' with NETIF_DEBUG.
 1.18 13-Nov-1999  thorpej branches: 1.18.6; 1.18.8;
Backout my libsa changes.
 1.17 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.16 07-May-1999  drochner branches: 1.16.2; 1.16.4; 1.16.8;
move intoa() from libsa:net.c to libkern, turn inet_ntoa() into a macro,
nuke ip_convertaddr()
 1.15 26-Mar-1999  dbj branches: 1.15.4;
Changes to compile the next68k bootblocks with
egcs -Wpointer-arith -Wstrict-prototypes
This closes pr 6653
 1.14 29-Jun-1998  gwr Be quiet if bootparamd gives us an empty gateway spec.
(which is quite normal). Just make noise if it was
missing, which explains the very long timeout...
(Would be nice if sendrecv said "retrying...")
 1.13 16-Jun-1998  gwr When the gateway bootparam is missing, be clear about that
in the error message instead of showing zero or nothing.
 1.12 10-Dec-1997  gwr Oops - forgot to set netmask=smask
 1.11 10-Dec-1997  gwr Request the "gateway" parameter and use its contents
to determine our gateway and subnet mask, consistent
with what is done by nfs_mountroot.
 1.10 22-Jul-1997  drochner Don't use "if_ether.h", it's not used.
 1.9 26-Jun-1997  drochner Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.8 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.7 14-Mar-1997  gwr Fix a warning.
 1.6 14-Mar-1997  gwr Sun RPC/bootparams always enabled (No -DSUN_BOOTPARAMS needed)
Add SUPPORT_BOOTP (and global try_bootp) to allow MD code to
determine whether BOOTP is used (compile-time and run-time).
Thanks to Matthias Drochner for the SUPPORT_BOOTP ideas.
Copyright asigned to The NetBSD Foundation.
 1.5 11-Mar-1997  gwr Moved here (via repository copy) so they are more easily shared.
I did not add them to the library, but rather compile them where
the netboot program is built so I can add -DSUN_BOOTPARAMS, etc.
 1.4 29-Jan-1996  gwr branches: 1.4.8;
Clean-up open/close logic of "net" device. Fixes PR 1726
 1.3 23-Sep-1995  gwr Cleanup, and catch up with libsa changes.
 1.2 08-Aug-1995  gwr Add bcea[] here now that is is gone from arp.c
 1.1 09-Jun-1995  gwr branches: 1.1.1;
Initial revision
 1.1.1.1 09-Jun-1995  gwr Have netboot!
 1.4.8.2 12-Mar-1997  is Merge in changes from The Trunk
 1.4.8.1 07-Mar-1997  is Use libsa copy of oldstyle if_ether.h for now
 1.15.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.16.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.16.4.1 15-Nov-1999  fvdl Sync with -current
 1.16.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.18.8.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.18.6.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.19.88.1 06-Oct-2007  yamt sync with head.
 1.19.86.2 09-Jan-2008  matt sync with HEAD
 1.19.86.1 06-Nov-2007  matt sync with HEAD
 1.19.84.3 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.19.84.2 28-Oct-2007  joerg Sync with HEAD.
 1.19.84.1 02-Oct-2007  joerg Sync with HEAD.
 1.19.70.1 09-Oct-2007  ad Sync with head.
 1.19.28.3 07-Dec-2007  yamt sync with head
 1.19.28.2 15-Nov-2007  yamt sync with head.
 1.19.28.1 27-Oct-2007  yamt sync with head.
 1.20.2.1 13-Nov-2007  bouyer Sync with HEAD
 1.21.2.1 08-Dec-2007  mjf Sync with HEAD.
 1.22.18.3 11-Aug-2010  yamt sync with head.
 1.22.18.2 04-May-2009  yamt sync with head.
 1.22.18.1 16-May-2008  yamt sync with head.
 1.22.16.1 18-May-2008  yamt sync with head.
 1.22.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.23.8.1 19-Jan-2009  skrll Sync with HEAD.
 1.24.6.1 05-Mar-2011  rmind sync with head
 1.24.4.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.26.54.1 10-Jun-2019  christos Sync with HEAD
 1.6 17-Jan-2009  tsutsui Remove __P().
 1.5 27-Oct-2007  tsutsui branches: 1.5.20; 1.5.28;
Add an extern decl of try_bootp variable here since MD sources could set it.
 1.4 26-Mar-1999  dbj branches: 1.4.58; 1.4.94; 1.4.108; 1.4.114; 1.4.116; 1.4.120;
Changes to compile the next68k bootblocks with
egcs -Wpointer-arith -Wstrict-prototypes
This closes pr 6653
 1.3 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.2 11-Mar-1997  gwr Moved here (via repository copy) so they are more easily shared.
I did not add them to the library, but rather compile them where
the netboot program is built so I can add -DSUN_BOOTPARAMS, etc.
 1.1 09-Jun-1995  gwr branches: 1.1.1;
Initial revision
 1.1.1.1 09-Jun-1995  gwr branches: 1.1.1.1.10;
Have netboot!
 1.1.1.1.10.1 12-Mar-1997  is Merge in changes from The Trunk
 1.4.120.1 13-Nov-2007  bouyer Sync with HEAD
 1.4.116.1 06-Nov-2007  matt sync with HEAD
 1.4.114.1 28-Oct-2007  joerg Sync with HEAD.
 1.4.108.1 06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.4.94.1 04-Nov-2007  pavel Pull up following revisions (requested by tsutsui in ticket #974):
sys/arch/cobalt/cobalt/autoconf.c: revision 1.25-1.26
sys/arch/cobalt/cobalt/machdep.c: revision 1.89
sys/arch/cobalt/stand/boot/Makefile: revision 1.12
sys/arch/cobalt/stand/boot/boot.c: revision 1.10
sys/arch/cobalt/stand/boot/boot.h: revision 1.6
sys/arch/cobalt/stand/boot/cache.c: revision 1.1-1.2
sys/arch/cobalt/stand/boot/clock.c: revision 1.2
sys/arch/cobalt/stand/boot/conf.c: revision 1.5
sys/arch/cobalt/stand/boot/devopen.c: revision 1.4
sys/arch/cobalt/stand/boot/nif_tlp.c: revision 1.1
sys/arch/cobalt/stand/boot/start.S: revision 1.6
sys/arch/cobalt/stand/boot/tlp.c: revision 1.1-1.3
sys/arch/cobalt/stand/boot/version: revision 1.6
sys/lib/libsa/dev_net.h: revision 1.5
Add an extern decl of try_bootp variable here since MD sources could set it.

In device_register(), check booted devices more properly:
- check "tlp" name on netboot
- use ata channel and drive numbers to check wd unit

Assume netboot if "nfsroot=/path" is specified in bootstring.

Use PCI bus/dev/function numbers rather than device unit
to check first tlp in device_register().

Add support for netboot via tlp0 with standalone tlp(4) driver
taken from arch/sandpoint/stand/netboot.
There are still some kludge but it just works on RaQ and RaQ2.

Fix my stupid bug in cache flush code and remove one kludge for it.

- use chaned mode for RX descs and allocate only one desc per each cacheline
to avoid possible race condition between CPU writeback vs DMA write
- remove unnecessary FS and LS bits from RxD->xd0
(sys/dev/ic/tulipvar.h sets them but maybe they are ignored?)
 1.4.58.1 15-Nov-2007  yamt sync with head.
 1.5.28.1 19-Jan-2009  skrll Sync with HEAD.
 1.5.20.1 04-May-2009  yamt sync with head.
 1.12 26-May-2021  mrg in getdisklabel() swap the other-endian disklabel, #ifdef LIBSA_DISKLABEL_EI
 1.11 17-May-2021  mrg move bi-endian disklabel support from the kernel and libsa into libkern.

- dkcksum() and dkcksum_sized() move from subr_disk.c and from
libsa into libkern/dkcksum.c (which is missing _sized() version),
using the version from usr.sbin/disklabel.

- swap_disklabel() moves from subr_disk_mbr.c into libkern, now called
disklabel_swap(). (the sh3 version should be updated to use this.)

- DISKLABEL_EI becomes a first-class option with opt_disklabel.h.

- add libkern.h to libsa/disklabel.c.

this enables future work for bi-endian libsa/ufs.c (relevant for ffsv1,
ffsv2, lfsv1, and lfsv2), as well as making it possible for ports not
using subr_disk_mbr.c to include bi-endian disklabel support (which,
afaict, includes any disk on mbr-supporting platforms that do not have
an mbr as well as disklabel.)

builds successsfully on: alpha, i386, amd64, sun2, sun3, evbarm64,
evbarm64-eb, sparc, and sparc64. tested in anita on i386 and sparc,
testing in hardware on evbarm64*.
 1.10 24-Nov-2007  isaki branches: 1.10.122; 1.10.124;
style, indent, and ANSI-fy.
 1.9 11-Dec-2005  christos branches: 1.9.44; 1.9.46; 1.9.52;
merge ktrace-lwp.
 1.8 26-Feb-2005  perry branches: 1.8.4;
nuke trailing whitespace
 1.7 30-Jun-2004  christos branches: 1.7.4; 1.7.6;
constification fixes.
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.5 31-Mar-1999  cgd branches: 1.5.42;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.4 13-Jan-1996  leo Some files containing more than one function are split. This reduces the
size of the resulting loader. The read_inode() function now returns the
result of the strategy function instead of success in all cases (ufs.c).
Fixes pr#1817
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 22-Aug-1994  brezak branches: 1.2.2;
Cleanup to make more ANSI compliant; checkpoint
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.2.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.2.2.1 22-Aug-1994  brezak file disklabel.c was added on branch netbsd-1-0 on 1994-08-22 21:56:03 +0000
 1.5.42.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.42.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.42.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.42.1 03-Aug-2004  skrll Sync with HEAD
 1.7.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.4.1 29-Apr-2005  kent sync with -current
 1.8.4.1 07-Dec-2007  yamt sync with head
 1.9.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.9.46.1 09-Jan-2008  matt sync with HEAD
 1.9.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.10.124.1 31-May-2021  cjep sync with head
 1.10.122.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.6 17-May-2021  mrg move bi-endian disklabel support from the kernel and libsa into libkern.

- dkcksum() and dkcksum_sized() move from subr_disk.c and from
libsa into libkern/dkcksum.c (which is missing _sized() version),
using the version from usr.sbin/disklabel.

- swap_disklabel() moves from subr_disk_mbr.c into libkern, now called
disklabel_swap(). (the sh3 version should be updated to use this.)

- DISKLABEL_EI becomes a first-class option with opt_disklabel.h.

- add libkern.h to libsa/disklabel.c.

this enables future work for bi-endian libsa/ufs.c (relevant for ffsv1,
ffsv2, lfsv1, and lfsv2), as well as making it possible for ports not
using subr_disk_mbr.c to include bi-endian disklabel support (which,
afaict, includes any disk on mbr-supporting platforms that do not have
an mbr as well as disklabel.)

builds successsfully on: alpha, i386, amd64, sun2, sun3, evbarm64,
evbarm64-eb, sparc, and sparc64. tested in anita on i386 and sparc,
testing in hardware on evbarm64*.
 1.5 11-Dec-2005  christos branches: 1.5.180; 1.5.182;
merge ktrace-lwp.
 1.4 30-Jun-2004  christos constification fixes.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 30-Mar-2000  augustss branches: 1.2.28;
Kill some more register declarations.
 1.1 13-Jan-1996  leo branches: 1.1.30;
Some files containing more than one function are split. This reduces the
size of the resulting loader. The read_inode() function now returns the
result of the strategy function instead of success in all cases (ufs.c).
Fixes pr#1817
 1.1.30.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.2.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.28.1 03-Aug-2004  skrll Sync with HEAD
 1.5.182.1 31-May-2021  cjep sync with head
 1.5.180.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.23 22-Jan-2020  martin To support big partitions we need to make sure all byte offsets are calculated
in 64 bit arithmetic. Pointed out by Rob Newberry.
Unfortunately this causes a code size increase breaking some boot blocks,
so conditionalize it and use 32 bit arithmetic if SA_DOSFS_NO_BIG_PART_SUPPORT
is defined.
 1.22 31-Mar-2019  christos branches: 1.22.6;
fix warnings, printf formats, etc.
 1.21 11-Mar-2016  christos branches: 1.21.18;
PR/50952: David Binderman: Clarify expression
 1.20 20-Mar-2014  christos branches: 1.20.6;
reduce size by 1K by sharing the ls code.
 1.19 20-Oct-2013  christos use new function to avoid array overflow
 1.18 25-Dec-2011  tsutsui branches: 1.18.6; 1.18.10;
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.17 16-Jun-2011  joerg branches: 1.17.2; 1.17.6;
Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.16 24-Nov-2008  ad branches: 1.16.14;
msdosfs -> msdos
 1.15 19-Nov-2008  ad For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.14 25-Mar-2008  christos branches: 1.14.4; 1.14.10; 1.14.12;
- use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.13 14-Mar-2008  dsl Add a local strcasecmp() instead of pulling the bloat from libkern.
 1.12 24-Nov-2007  isaki branches: 1.12.10; 1.12.14;
style, indent, and ANSI-fy.
 1.11 02-Dec-2006  dogcow branches: 1.11.18; 1.11.20; 1.11.26;
make bootxx_msdos fit in 8k again; thanks, __internal_memset_, for spilling
registers all over the place.
 1.10 25-Jan-2006  christos branches: 1.10.18; 1.10.20; 1.10.22;
free -> dealloc
 1.9 11-Dec-2005  christos branches: 1.9.2;
merge ktrace-lwp.
 1.8 31-Aug-2003  fvdl branches: 1.8.16;
Fix signed/unsigned warnings.
 1.7 18-Aug-2003  dsl make 'path' argument to ufs_open 'const char *' and fix the fallout.
 1.6 15-Jul-2003  scw In lookup(), don't free "dir" on exit if we found a matching entry.
Otherwise the caller ends up with a pointer to free'd memory...
 1.5 30-Dec-2002  veego branches: 1.5.2;
Fix broken build due too the move of the cd9660 and msdosfs kernel source code.
 1.4 09-Nov-2000  matt branches: 1.4.2; 1.4.4;
dos_unmount is only is dos_close is present but so conditionalize it like
dos_close.
 1.3 08-Nov-2000  matt avoid pointer addition on void pointers
 1.2 02-Nov-2000  thorpej Sprinkle some const -- gets things out of the .data segment, which
is important in the i386 boot blocks (grmumble).
 1.1 02-Nov-2000  thorpej Add a standalone MS-DOS file system reader package, lifted
from FreeBSD, and modified use NetBSD's already-existing
MS-DOS file system data structure definitions, rather than
defining our own.
 1.4.4.1 30-Dec-2002  thorpej Sync with HEAD.
 1.4.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.4.2.1 09-Nov-2000  bouyer file dosfs.c was added on branch thorpej_scsipi on 2000-11-22 16:05:41 +0000
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.16.4 17-Mar-2008  yamt sync with head.
 1.8.16.3 07-Dec-2007  yamt sync with head
 1.8.16.2 30-Dec-2006  yamt sync with head.
 1.8.16.1 21-Jun-2006  yamt sync with head.
 1.9.2.1 01-Feb-2006  yamt sync with head.
 1.10.22.1 02-Dec-2006  bouyer Pull up following revision(s) (requested by dogcow in ticket #240):
sys/lib/libsa/dosfs.c: revision 1.11
make bootxx_msdos fit in 8k again; thanks, __internal_memset_, for spilling
registers all over the place.
 1.10.20.1 10-Dec-2006  yamt sync with head.
 1.10.18.1 12-Jan-2007  ad Sync with head.
 1.11.26.1 08-Dec-2007  mjf Sync with HEAD.
 1.11.20.2 23-Mar-2008  matt sync with HEAD
 1.11.20.1 09-Jan-2008  matt sync with HEAD
 1.11.18.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.12.14.2 17-Jan-2009  mjf Sync with HEAD.
 1.12.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.12.10.1 24-Mar-2008  keiichi sync with head.
 1.14.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.14.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.14.4.1 04-May-2009  yamt sync with head.
 1.16.14.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.17.6.1 18-Feb-2012  mrg merge to -current.
 1.17.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.2.1 17-Apr-2012  yamt sync with head
 1.18.10.1 18-May-2014  rmind sync with head
 1.18.6.2 03-Dec-2017  jdolecek update from HEAD
 1.18.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.20.6.1 19-Mar-2016  skrll Sync with HEAD
 1.21.18.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.21.18.1 10-Jun-2019  christos Sync with HEAD
 1.22.6.1 25-Jan-2020  ad Sync with head.
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 18-Aug-2003  dsl make 'path' argument to ufs_open 'const char *' and fix the fallout.
 1.1 02-Nov-2000  thorpej branches: 1.1.2; 1.1.26;
Add a standalone MS-DOS file system reader package, lifted
from FreeBSD, and modified use NetBSD's already-existing
MS-DOS file system data structure definitions, rather than
defining our own.
 1.1.26.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.26.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.26.1 03-Aug-2004  skrll Sync with HEAD
 1.1.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.1 02-Nov-2000  bouyer file dosfs.h was added on branch thorpej_scsipi on 2000-11-22 16:05:42 +0000
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 30-Mar-1999  cgd branches: 1.1.42;
move errno to its own file; if you just need errno, you don't need dev.c's fns
 1.1.42.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.42.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.42.1 03-Aug-2004  skrll Sync with HEAD
 1.24 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.23 29-Mar-2014  jakllsch branches: 1.23.30;
Obtain and/or use ETHER_ADDR_LEN.
 1.22 12-Jan-2009  tsutsui branches: 1.22.14; 1.22.24; 1.22.28;
Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.21 24-Nov-2007  isaki branches: 1.21.14; 1.21.18; 1.21.26;
style, indent, and ANSI-fy.
 1.20 11-Dec-2005  christos branches: 1.20.44; 1.20.46; 1.20.52;
merge ktrace-lwp.
 1.19 13-Jun-2005  junyoung branches: 1.19.2;
Remove bcmp(). Use memcmp() instead.
 1.18 31-Aug-2003  fvdl Fix signed/unsigned warnings.
 1.17 12-Mar-2003  drochner branches: 1.17.2;
separate ether_sprintf() from the rest of ethernet support -- sometimes
it makes sense to use the former w/o the latter (eg PXE)
 1.16 12-Mar-2003  drochner no need to include "netif.h" anymore
(shared interface stuff is in iodesc.h, included by net.h)
 1.15 30-Mar-2000  augustss Kill some more register declarations.
 1.14 13-Nov-1999  thorpej Backout my libsa changes.
 1.13 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.12 14-May-1998  drochner branches: 1.12.14; 1.12.16; 1.12.20;
egcs -Wall -Werror
 1.11 07-Jul-1997  drochner Don't use private copy of old netinet/if_ether.h.
Use <net/if_ether.h> for ethernet specific definitions, and insert private
definitions for ARP if needed. (The new ARP macros in <net/if_arp.h> are
not used because they create larger code, and we really don't need more
than ethernet/ip support here.)
 1.10 26-Jun-1997  drochner Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.9 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.8 13-Oct-1996  christos branches: 1.8.6;
backout previous kprintf changes
 1.7 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.6 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.5 11-Sep-1995  thorpej Changes from Gordon Ross:
a) check against `my' ethernet or broadcast addresses done in
ether.c
b) changed interface to readether() to provide ethertype info
c) respond to arp requests when appropriate.
First two are clean-up. Last fixes hp300 and presumably mvme68k netboot
code.
 1.4 20-Feb-1995  mycroft Various:
* Fix some misused types.
* Encapsulate the protocols better.
* Rearrange the RPC stuff to work more like the kernel. (Needs more work.)
* Remove a bunch of extra hair when reading a file over NFS.
* Use RPCAUTH_UNIX when talking to the NFS server.
 1.3 19-Feb-1995  mycroft Remove duplicate defn of bcea.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.8.6.1 07-Mar-1997  is Use the local copy of the old-style if_ether.h for the moment, til we have
time to modernize the libsa ARP support.
 1.12.20.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.16.1 15-Nov-1999  fvdl Sync with -current
 1.12.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.17.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.17.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.17.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.17.2.1 03-Aug-2004  skrll Sync with HEAD
 1.19.2.1 07-Dec-2007  yamt sync with head
 1.20.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.20.46.1 09-Jan-2008  matt sync with HEAD
 1.20.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.21.26.1 19-Jan-2009  skrll Sync with HEAD.
 1.21.18.1 04-May-2009  yamt sync with head.
 1.21.14.1 17-Jan-2009  mjf Sync with HEAD.
 1.22.28.1 18-May-2014  rmind sync with head
 1.22.24.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.22.14.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.23.30.1 10-Jun-2019  christos Sync with HEAD
 1.7 29-Mar-2014  jakllsch Obtain and use ETHER_ADDR_LEN where appropriate.
Drop unnecessary includes.

XXX libsa ether_sprintf() should maybe be ether_snprintf.
 1.6 24-Nov-2007  isaki branches: 1.6.52; 1.6.62; 1.6.68;
style, indent, and ANSI-fy.
 1.5 24-Jan-2006  christos branches: 1.5.42; 1.5.44; 1.5.50;
PR/32613: Yves-Emmanuel JUTARD: Incoherencies in file sys/lib/libsa/net.h
- Make prototype of ether_sprintf() match the one in sys/net.
- Rename in_cksum to ip_cksum and fix its prototype. in_cksum() operates
on an mbuf and ip_cksum() operates on a plain buffer. We should not call
functions that operate on different arguments the same name (this is not
c++).
 1.4 11-Dec-2005  christos branches: 1.4.2;
merge ktrace-lwp.
 1.3 17-May-2005  christos branches: 1.3.2;
Yes, it was a cool trick >20 years ago to use "0123456789abcdef"[a] to
implement, xtoa(), but I think defining the samestring 50 times is a bit
too much. Defined HEXDIGITS and hexdigits in subr_prf.c and use it...
 1.2 25-Mar-2003  mycroft branches: 1.2.2;
const! const!
 1.1 12-Mar-2003  drochner separate ether_sprintf() from the rest of ethernet support -- sometimes
it makes sense to use the former w/o the latter (eg PXE)
 1.2.2.1 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.3.2.2 07-Dec-2007  yamt sync with head
 1.3.2.1 21-Jun-2006  yamt sync with head.
 1.4.2.1 01-Feb-2006  yamt sync with head.
 1.5.50.1 08-Dec-2007  mjf Sync with HEAD.
 1.5.44.1 09-Jan-2008  matt sync with HEAD
 1.5.42.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.6.68.1 18-May-2014  rmind sync with head
 1.6.62.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.52.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.29 12-Jan-2014  tsutsui Remove obsolete exec.c for a.out. It was superseded by loadfile() long ago.
 1.28 29-Dec-2009  elad branches: 1.28.12; 1.28.22; 1.28.26;
Don't abuse INSECURE for allowing exec() to load files not owned by uid 0.

Adjust references where this has been used.
 1.27 16-Aug-2009  matt Change include of <sys/exec.h> to <sys/exec_aout.h> since these files want
the a.out stuff.
 1.26 25-Mar-2008  christos branches: 1.26.4;
- use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.25 24-Nov-2007  isaki branches: 1.25.14;
style, indent, and ANSI-fy.
 1.24 11-Dec-2005  christos branches: 1.24.44; 1.24.46; 1.24.52;
merge ktrace-lwp.
 1.23 31-Aug-2003  fvdl branches: 1.23.16;
Fix signed/unsigned warnings.
 1.22 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.21 23-Jun-2003  martin branches: 1.21.2;
Protect opt_*.h include by _KERNEL_OPT
 1.20 23-Jun-2003  martin Make sure to include opt_foo.h if a defflag option FOO is used.
 1.19 13-Nov-1999  thorpej Backout my libsa changes.
 1.18 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.17 28-Jun-1997  thorpej branches: 1.17.22; 1.17.24; 1.17.28;
- Fix ZMAGIC image loading.
- Deal with stripped kernels.
- Let machine-dependent code frob the start address.
- General cleanup.
From Matthias Pfaller <matthias@netbsd.org>
 1.16 26-Jun-1997  drochner Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.15 13-Oct-1996  christos backout previous kprintf changes
 1.14 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.13 02-Jun-1996  ragge Fix include file order to confirm to KNF in master tree also.
 1.12 14-May-1996  leo branches: 1.12.4;
Fix gcc -Wall warnings about printf arguments.
 1.11 20-Oct-1995  cgd cast pointer to long, not int
 1.10 04-Aug-1995  thorpej Fix off-by-one error when padding text segment.
 1.9 22-Apr-1995  cgd cast ptrs to longs, etc.
 1.8 21-Feb-1995  mycroft Correct some error strings, and add a few more. Don't print error messages in
exec(); let the caller do it.
 1.7 21-Feb-1995  mycroft exec() doesn't need to return a value.
 1.6 21-Feb-1995  mycroft Add the security check in the hp300 code, and clean a little.
 1.5 21-Feb-1995  mycroft Add a generic twiddler.
 1.4 25-Nov-1994  deraadt round text segment to __LDPGSZ bytes
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 22-Aug-1994  brezak branches: 1.2.2;
Cleanup to make more ANSI compliant; checkpoint
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.2.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.2.2.1 22-Aug-1994  brezak file exec.c was added on branch netbsd-1-0 on 1994-08-22 21:56:04 +0000
 1.12.4.1 02-Jun-1996  ragge Fix include file order to confirm to KNF.
 1.17.28.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.17.24.1 15-Nov-1999  fvdl Sync with -current
 1.17.22.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.21.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.21.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.21.2.1 03-Aug-2004  skrll Sync with HEAD
 1.23.16.1 07-Dec-2007  yamt sync with head
 1.24.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.24.46.1 09-Jan-2008  matt sync with HEAD
 1.24.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.25.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.26.4.2 11-Mar-2010  yamt sync with head
 1.26.4.1 19-Aug-2009  yamt sync with head.
 1.28.26.1 18-May-2014  rmind sync with head
 1.28.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.28.12.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.16 11-Dec-2005  christos branches: 1.16.44; 1.16.46; 1.16.52;
merge ktrace-lwp.
 1.15 26-Feb-2005  perry branches: 1.15.4;
nuke trailing whitespace
 1.14 01-Jun-2002  itojun branches: 1.14.6; 1.14.14; 1.14.16;
use exit(int), not exit(void), consistently - even if the arg has no meaning.
 1.13 12-Feb-1999  drochner branches: 1.13.20; 1.13.22; 1.13.34;
We can't prototype exit() publically because it might take an argument or
not, depending on the port-specific environment.
Separate panic() and exit() so that the mi/default panic() can be used
without conflicting with a local exit() definition, move exit(void)
prototype to the default exit() implementation.
Closes PR bin/6990 by Wolfgang Helbig <helbig@Informatik.BA-Stuttgart.DE>.
 1.12 26-Jun-1997  drochner Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.11 01-Dec-1996  pk kvprintf => vprintf (PR#2989, Juergen Hannken-Illjes).
 1.10 13-Oct-1996  christos backout previous kprintf changes
 1.9 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.8 09-Feb-1996  gwr use vprintf where appropriate
 1.7 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.6 17-Sep-1995  pk Revert fs_ops read/write declarations; these return error numbers.
Get rid of some more compiler warnings.
Set errno where appropriate.
 1.5 22-Apr-1995  cgd note properly whether or not functions return, etc.
 1.4 26-Oct-1994  cgd new RCS ID format.
 1.3 22-Aug-1994  brezak branches: 1.3.2;
Cleanup to make more ANSI compliant; checkpoint
 1.2 08-May-1994  brezak Standalone networking for network boot loaders.
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.3.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.3.2.1 22-Aug-1994  brezak file exit.c was added on branch netbsd-1-0 on 1994-08-22 21:56:05 +0000
 1.13.34.1 20-Jun-2002  gehenna catch up with -current.
 1.13.22.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.13.20.1 20-Jun-2002  nathanw Catch up to -current.
 1.14.16.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.14.14.1 29-Apr-2005  kent sync with -current
 1.14.6.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.15.4.1 07-Dec-2007  yamt sync with head
 1.16.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.16.46.1 09-Jan-2008  matt sync with HEAD
 1.16.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.34 29-Apr-2022  rin Re-introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
used instead of secsize obtained by SAIOSECSIZE ioctl.

This hack avoids divdi3 and friends from being linked, in order to
support variable secsize for some archs.

Should be useful for ancient archs, for which secsize is fixed.

Thanks christos@ for comment.
 1.33 27-Apr-2022  rin Revert previous at the moment.

This is wrong reasoning; 68020 and above (incl. 040 and 060) support
32-bit displacements for PC relative addressing (via "fully extension
addressing mode" with null index register).

I've still not figured out what goes wrong with amiga/boot(8) when
compiled without -l option for gas(1)...

On 2022/04/27 20:48, Rin Okuyama wrote:
> Module Name: src
> Committed By: rin
> Date: Wed Apr 27 11:48:26 UTC 2022
>
> Modified Files:
> src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c
>
> Log Message:
> Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
> used instead of secsize obtained by SAIOSECSIZE ioctl.
>
> This hack avoids divdi3 and friends from being linked, in order to
> support variable secsize.
>
> This is useful for amiga/boot(8); it is loaded by firmware into
> unpredictable address, and therefore all symbols should be
> addressable by PC relative mode with only 16-bit displacements.
>
> See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for
> more details.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/ext2fs.c
> cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/minixfs3.c
> cvs rdiff -u -r1.83 -r1.84 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
 1.32 27-Apr-2022  rin Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
used instead of secsize obtained by SAIOSECSIZE ioctl.

This hack avoids divdi3 and friends from being linked, in order to
support variable secsize.

This is useful for amiga/boot(8); it is loaded by firmware into
unpredictable address, and therefore all symbols should be
addressable by PC relative mode with only 16-bit displacements.

See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for
more details.
 1.31 24-Apr-2022  mlelstv Ask driver about sector size to support reading superblocks from fixed
byte offsets.
 1.30 19-Apr-2022  skrll Typo in comment. avoinds -> avoids
 1.29 24-Jan-2020  jakllsch Use dp->e2d_namlen rather than strlen(dp->e2d_name) in ext2fs_ls().

Prevents garbage beyond the end of the name from appearing on screen.
 1.28 24-Jun-2019  pgoyette branches: 1.28.4;
Now that the ufs module has been split out from ffs and ext2fs, we need
to update the boot-loader to push all modules required to support the
booted filesystem. We treat the fsmod string as a slash-separated list
of module names (relative to kern.module.path), rather than as a single
module path name.

Note that ffsv1 and ffsv2 are still exempted from the boot-loader's
auto-push, but the list of required filesystems is still noted in the
source.

Also note that arch/sandpoint needs a similar change. I have not made
this change because I am totally unable to test it.

Tested on my kernel with _no_ built-in file-systems and with the ffs
bootloader settings of fsmod enabled.
 1.27 05-Apr-2019  christos Go back ot using 0x%x instead of %#x because we don't always support the
format. See subr_prf.c
 1.26 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.25 21-Aug-2016  christos branches: 1.25.16;
delete now unused function .
 1.24 04-Aug-2016  rjs Another header change.
 1.23 04-Aug-2016  nonaka Sync with sys/ufs/ext2fs/ext2fs_bswap.c.
 1.22 04-Aug-2016  nonaka pass EXT2_DINODE_SIZE(fs) as isize to e2fs_iload().
should fix build failure.
 1.21 03-Aug-2016  rjs Adjust for change to kernel ext2fs headers.
 1.20 20-Mar-2014  christos branches: 1.20.6; 1.20.10;
reduce size by 1K by sharing the ls code.
 1.19 20-Oct-2013  christos XXX: gcc initializations
 1.18 23-Jun-2013  dholland branches: 1.18.2;
Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

lblkno
lblktosize
lfragtosize
numfrags
blkroundup
fragroundup
 1.17 23-Jun-2013  dholland fsbtodb() -> FFS_FSBTODB(), EXT2_FSBTODB(), or MFS_FSBTODB()
dbtofsb() -> FFS_DBTOFSB() or EXT2_DBTOFSB()

(Christos already did the lfs ones a few days back)
 1.16 19-Jun-2013  dholland Rename ambiguous macros:
MAXDIRSIZE -> UFS_MAXDIRSIZE or LFS_MAXDIRSIZE
NINDIR -> FFS_NINDIR, EXT2_NINDIR, LFS_NINDIR, or MFS_NINDIR
INOPB -> FFS_INOPB, LFS_INOPB
INOPF -> FFS_INOPF, LFS_INOPF
blksize -> ffs_blksize, ext2_blksize, or lfs_blksize
sblksize -> ffs_blksize

These are not the only ambiguously defined filesystem macros, of
course, there's a pile more. I may not have found all the ambiguous
definitions of blksize(), too, as there are a lot of other things
called 'blksize' in the system.
 1.15 10-May-2013  tsutsui Wrap >80 char lines that overflowed on NDADDR -> EXT2FS_NDADDR changes.
 1.14 22-Jan-2013  dholland Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.
 1.13 21-May-2012  dsl branches: 1.13.2;
Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.12 16-Jan-2012  christos branches: 1.12.2;
PR/45796: Evgeniy Ivanov minixfs3 support.
Split out fn_match since we have 3 copies now.
 1.11 25-Dec-2011  tsutsui Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.10 16-Jun-2011  joerg branches: 1.10.2; 1.10.6;
Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.9 02-Jan-2011  jakllsch branches: 1.9.6;
Zero the in-memory super block after allocation. It contains a pointer
that, if not properly initialized, could be improperly deallocated.
 1.8 19-Oct-2009  bouyer branches: 1.8.4;
Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
 1.7 02-Mar-2009  tsutsui Use EXT2_DINODE_SIZE() to get offset of inode, not struct ext2fs_dinode array.
 1.6 01-Mar-2009  christos catch up with variable inode size.
 1.5 19-Nov-2008  ad branches: 1.5.4;
For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.4 02-Dec-2007  tsutsui branches: 1.4.2; 1.4.6; 1.4.8; 1.4.16; 1.4.22; 1.4.26; 1.4.32; 1.4.34; 1.4.36;
- also pass correct size on dealloc() of in-memory superblock data
- also call dealloc() for group descriptor blocks
 1.3 02-Dec-2007  tsutsui Allocate correct size for in-memory data struct m_ext2fs
(which is larger than SBSIZE).
 1.2 02-Dec-2007  tsutsui - fix description about index structure of an inode to match ext2fs_dinode
- put more byteswap ops on reading block numbers in indirect blocks
(XXX: untested on big endian machines)
 1.1 01-Dec-2007  tsutsui Add ext2fs support for libsa.

Mostly based on ufs.c, and some ext2fs specific stuff is pulled from
sys/ufs/ext2fs/ext2fs_bswap.c and sys/ufs/ext2fs/ext2fs_vfsops.c.

XXX1: Should we share ufs.c with #ifdef LIBSA_EXT2FS as ffs and lfs do?
XXX2: Maybe we should share ext2fs_bswap.c with kernel.
 1.4.36.1 16-Jan-2011  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1486):
sbin/fsck_ext2fs/setup.c: revision 1.26
sbin/newfs_ext2fs/mke2fs.c: revision 1.10
sbin/newfs_ext2fs/mke2fs.c: revision 1.11
sbin/newfs_ext2fs/mke2fs.c: revision 1.12
sbin/fsck_ext2fs/inode.c: revision 1.24
sys/lib/libsa/ext2fs.c: revision 1.6
sbin/newfs_ext2fs/extern.h: revision 1.3
sbin/fsck_ext2fs/inode.c: revision 1.25
sys/lib/libsa/ext2fs.c: revision 1.7
sbin/fsck_ext2fs/inode.c: revision 1.26
sys/ufs/ext2fs/ext2fs_inode.c: revision 1.68
sbin/fsck_ext2fs/inode.c: revision 1.27
sbin/fsck_ext2fs/inode.c: revision 1.28
sys/ufs/ext2fs/ext2fs_dinode.h: revision 1.18
sys/ufs/ext2fs/ext2fs_dinode.h: revision 1.19
sbin/newfs_ext2fs/newfs_ext2fs.c: revision 1.5
sbin/newfs_ext2fs/newfs_ext2fs.8: revision 1.2
sbin/newfs_ext2fs/newfs_ext2fs.c: revision 1.6
sbin/newfs_ext2fs/newfs_ext2fs.8: revision 1.3
sys/ufs/ext2fs/ext2fs_vfsops.c: revision 1.142
sbin/newfs_ext2fs/newfs_ext2fs.c: revision 1.7
sbin/newfs_ext2fs/newfs_ext2fs.8: revision 1.4
sbin/newfs_ext2fs/newfs_ext2fs.c: revision 1.8
PR/40936: Frederik Sausmikat: ext2fs: add support for inodes > 128 bytes
Support variable inode sizes.
catch up with variable inode size.
Don't use e2fs_inode_size in superblock on E2FS_REV0 file system.
- accept only EXT2_REV0_DINODE_SIZE inodesize on -O 0
- use inodesize to get offset of inode, not struct ext2fs_dinode array
Replace a magic number with a new EXT2_REV0_DINODE_SIZE macro.
Use EXT2_DINODE_SIZE() to get offset of inode, not struct ext2fs_dinode array.
Fix botched logic in inodesize check.
Use inodesize to get offset of inode in one more place.
- add a sanity check for e2fs_inode_size in readsb()
- use EXT2_DINODE_SIZE() rather than sizeof(struct ext2fs_dinode) or
struct ext2fs_dinode array/pointer to see e2fs_ipb and inode offsets
Sort options.
New sentence, new line.
Sort options in usage.
- unsigned -> unsigned int
- remove unnecessary casts from malloc(3) and free(3)
- fix a bogus indent
Use "size > INT32_MAX" rather than "size >= 0x80000000U" to check 2GB limit.
Add missed byteswap ops against ext2fs_dinode members.
Handle 32 bit uid field on E2FS_REV1.
 1.4.34.2 03-Mar-2009  skrll Sync with HEAD.
 1.4.34.1 19-Jan-2009  skrll Sync with HEAD.
 1.4.32.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.4.26.2 11-Mar-2010  yamt sync with head
 1.4.26.1 04-May-2009  yamt sync with head.
 1.4.22.1 17-Jan-2009  mjf Sync with HEAD.
 1.4.16.2 09-Jan-2008  matt sync with HEAD
 1.4.16.1 02-Dec-2007  matt file ext2fs.c was added on branch matt-armv6 on 2008-01-09 01:56:39 +0000
 1.4.8.2 08-Dec-2007  mjf Sync with HEAD.
 1.4.8.1 02-Dec-2007  mjf file ext2fs.c was added on branch mjf-devfs on 2007-12-08 18:20:52 +0000
 1.4.6.2 07-Dec-2007  yamt sync with head
 1.4.6.1 02-Dec-2007  yamt file ext2fs.c was added on branch yamt-lazymbuf on 2007-12-07 17:33:40 +0000
 1.4.2.2 03-Dec-2007  joerg Sync with HEAD.
 1.4.2.1 02-Dec-2007  joerg file ext2fs.c was added on branch jmcneill-pm on 2007-12-03 16:15:02 +0000
 1.5.4.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.8.4.1 05-Mar-2011  rmind sync with head
 1.9.6.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.10.6.2 02-Jun-2012  mrg sync to latest -current.
 1.10.6.1 18-Feb-2012  mrg merge to -current.
 1.10.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.10.2.3 23-Jan-2013  yamt sync with head
 1.10.2.2 23-May-2012  yamt sync with head.
 1.10.2.1 17-Apr-2012  yamt sync with head
 1.12.2.1 03-Jun-2012  jdc Pull up revisions:
src/sys/arch/i386/stand/lib/exec.c revision 1.50
src/sys/arch/sandpoint/stand/altboot/main.c revision 1.21 via patch
src/sys/lib/libsa/ext2fs.c revision 1.13
src/sys/lib/libsa/ffsv1.c revision 1.6
src/sys/lib/libsa/ffsv2.c revision 1.6
src/sys/lib/libsa/globals.c revision 1.9
src/sys/lib/libsa/lfsv1.c revision 1.5
src/sys/lib/libsa/lfsv2.c revision 1.5
src/sys/lib/libsa/stand.h revision 1.76
src/sys/lib/libsa/ufs.c revision 1.58
(requested by dsl in ticket #279).

Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.13.2.4 03-Dec-2017  jdolecek update from HEAD
 1.13.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.13.2.2 23-Jun-2013  tls resync from head
 1.13.2.1 25-Feb-2013  tls resync with head
 1.18.2.1 18-May-2014  rmind sync with head
 1.20.10.1 06-Aug-2016  pgoyette Sync with HEAD
 1.20.6.1 05-Oct-2016  skrll Sync with HEAD
 1.25.16.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.25.16.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.25.16.1 10-Jun-2019  christos Sync with HEAD
 1.28.4.1 25-Jan-2020  ad Sync with head.
 1.1 01-Dec-2007  tsutsui branches: 1.1.2; 1.1.6; 1.1.8; 1.1.16;
Add ext2fs support for libsa.

Mostly based on ufs.c, and some ext2fs specific stuff is pulled from
sys/ufs/ext2fs/ext2fs_bswap.c and sys/ufs/ext2fs/ext2fs_vfsops.c.

XXX1: Should we share ufs.c with #ifdef LIBSA_EXT2FS as ffs and lfs do?
XXX2: Maybe we should share ext2fs_bswap.c with kernel.
 1.1.16.2 09-Jan-2008  matt sync with HEAD
 1.1.16.1 01-Dec-2007  matt file ext2fs.h was added on branch matt-armv6 on 2008-01-09 01:56:40 +0000
 1.1.8.2 08-Dec-2007  mjf Sync with HEAD.
 1.1.8.1 01-Dec-2007  mjf file ext2fs.h was added on branch mjf-devfs on 2007-12-08 18:20:52 +0000
 1.1.6.2 07-Dec-2007  yamt sync with head
 1.1.6.1 01-Dec-2007  yamt file ext2fs.h was added on branch yamt-lazymbuf on 2007-12-07 17:33:41 +0000
 1.1.2.2 03-Dec-2007  joerg Sync with HEAD.
 1.1.2.1 01-Dec-2007  joerg file ext2fs.h was added on branch jmcneill-pm on 2007-12-03 16:15:02 +0000
 1.1 27-May-2021  mrg branches: 1.1.2; 1.1.6;
add bi-endian support to the libsa ufs reader and enable it in efiboot.

ffs frontends to "ufs.c" now also define ufs_dinode_swap, ufs_indp_swap,
and FS_MAGIC (moved from ufs.c #if segments.) these are used to call
the right (32/64 bit) ffsv1/v2 version.

ufs.c 'struct file' gains f_swapped member. accessors for d_magic,
d_reclen, and d_ino are introduced (they need to be swapped.) sfter
reading an inode from disk, read_inode() may call ufs_dinode_swap().
indirect block number and caches may be swapped.

error handling in ffs_find_superblock() is cleaned up. (size is slightly
reduced on some ports with this part.)

defaults for new defines added to ufs.c. (XXX: we build ufs.c but i think
all the consumers don't use it, and we can stop building it.)

LFS support is not included.

add a cut-down copy of ffs_bswap.c from the kernel.

also enable bi-endian disklabel support in efiboot.

most ports build and sizes compared for platforms that don't enable this
code and all but one saw reduced code size. booted several platforms with
new boot code.
 1.1.6.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.1.6.1 27-May-2021  thorpej file ffs_bswap.c was added on branch thorpej-i2c-spi-conf on 2021-06-17 04:46:34 +0000
 1.1.2.2 31-May-2021  cjep sync with head
 1.1.2.1 27-May-2021  cjep file ffs_bswap.c was added on branch cjep_staticlib_x on 2021-05-31 22:15:21 +0000
 1.10 17-Nov-2022  chs Restore backward compatibility of UFS2 with previous NetBSD releases by
disabling support in UFS2 for extended attributes (including ACLs).
Add a new variant of UFS2 called "UFS2ea" that does support extended attributes.
Add new fsck_ffs operations "-c ea" and "-c no-ea" to convert file systems
from UFS2 to UFS2ea and vice-versa (both of which delete all existing extended
attributes in the process).
 1.9 24-Apr-2022  mlelstv Don't load filessytem module for filesystem that was found but isn't used
for booting.
 1.8 27-May-2021  mrg add bi-endian support to the libsa ufs reader and enable it in efiboot.

ffs frontends to "ufs.c" now also define ufs_dinode_swap, ufs_indp_swap,
and FS_MAGIC (moved from ufs.c #if segments.) these are used to call
the right (32/64 bit) ffsv1/v2 version.

ufs.c 'struct file' gains f_swapped member. accessors for d_magic,
d_reclen, and d_ino are introduced (they need to be swapped.) sfter
reading an inode from disk, read_inode() may call ufs_dinode_swap().
indirect block number and caches may be swapped.

error handling in ffs_find_superblock() is cleaned up. (size is slightly
reduced on some ports with this part.)

defaults for new defines added to ufs.c. (XXX: we build ufs.c but i think
all the consumers don't use it, and we can stop building it.)

LFS support is not included.

add a cut-down copy of ffs_bswap.c from the kernel.

also enable bi-endian disklabel support in efiboot.

most ports build and sizes compared for platforms that don't enable this
code and all but one saw reduced code size. booted several platforms with
new boot code.
 1.7 24-Jun-2019  pgoyette branches: 1.7.14; 1.7.16;
Now that the ufs module has been split out from ffs and ext2fs, we need
to update the boot-loader to push all modules required to support the
booted filesystem. We treat the fsmod string as a slash-separated list
of module names (relative to kern.module.path), rather than as a single
module path name.

Note that ffsv1 and ffsv2 are still exempted from the boot-loader's
auto-push, but the list of required filesystems is still noted in the
source.

Also note that arch/sandpoint needs a similar change. I have not made
this change because I am totally unable to test it.

Tested on my kernel with _no_ built-in file-systems and with the ffs
bootloader settings of fsmod enabled.
 1.6 21-May-2012  dsl branches: 1.6.40;
Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.5 25-Dec-2011  tsutsui branches: 1.5.2;
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.4 19-Nov-2008  ad branches: 1.4.16; 1.4.20;
For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.3 11-Dec-2005  christos branches: 1.3.70; 1.3.74; 1.3.80; 1.3.84;
merge ktrace-lwp.
 1.2 31-Aug-2003  fvdl Fix signed/unsigned warnings.
 1.1 11-Apr-2003  dsl branches: 1.1.2;
Files to build ffsv1 and ffsv2 versions of ufs.c
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.3.84.1 19-Jan-2009  skrll Sync with HEAD.
 1.3.80.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.3.74.1 04-May-2009  yamt sync with head.
 1.3.70.1 17-Jan-2009  mjf Sync with HEAD.
 1.4.20.2 02-Jun-2012  mrg sync to latest -current.
 1.4.20.1 18-Feb-2012  mrg merge to -current.
 1.4.16.2 23-May-2012  yamt sync with head.
 1.4.16.1 17-Apr-2012  yamt sync with head
 1.5.2.1 03-Jun-2012  jdc Pull up revisions:
src/sys/arch/i386/stand/lib/exec.c revision 1.50
src/sys/arch/sandpoint/stand/altboot/main.c revision 1.21 via patch
src/sys/lib/libsa/ext2fs.c revision 1.13
src/sys/lib/libsa/ffsv1.c revision 1.6
src/sys/lib/libsa/ffsv2.c revision 1.6
src/sys/lib/libsa/globals.c revision 1.9
src/sys/lib/libsa/lfsv1.c revision 1.5
src/sys/lib/libsa/lfsv2.c revision 1.5
src/sys/lib/libsa/stand.h revision 1.76
src/sys/lib/libsa/ufs.c revision 1.58
(requested by dsl in ticket #279).

Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.6.40.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7.16.1 31-May-2021  cjep sync with head
 1.7.14.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.10 17-Nov-2022  chs Restore backward compatibility of UFS2 with previous NetBSD releases by
disabling support in UFS2 for extended attributes (including ACLs).
Add a new variant of UFS2 called "UFS2ea" that does support extended attributes.
Add new fsck_ffs operations "-c ea" and "-c no-ea" to convert file systems
from UFS2 to UFS2ea and vice-versa (both of which delete all existing extended
attributes in the process).
 1.9 24-Apr-2022  mlelstv Don't load filessytem module for filesystem that was found but isn't used
for booting.
 1.8 27-May-2021  mrg add bi-endian support to the libsa ufs reader and enable it in efiboot.

ffs frontends to "ufs.c" now also define ufs_dinode_swap, ufs_indp_swap,
and FS_MAGIC (moved from ufs.c #if segments.) these are used to call
the right (32/64 bit) ffsv1/v2 version.

ufs.c 'struct file' gains f_swapped member. accessors for d_magic,
d_reclen, and d_ino are introduced (they need to be swapped.) sfter
reading an inode from disk, read_inode() may call ufs_dinode_swap().
indirect block number and caches may be swapped.

error handling in ffs_find_superblock() is cleaned up. (size is slightly
reduced on some ports with this part.)

defaults for new defines added to ufs.c. (XXX: we build ufs.c but i think
all the consumers don't use it, and we can stop building it.)

LFS support is not included.

add a cut-down copy of ffs_bswap.c from the kernel.

also enable bi-endian disklabel support in efiboot.

most ports build and sizes compared for platforms that don't enable this
code and all but one saw reduced code size. booted several platforms with
new boot code.
 1.7 24-Jun-2019  pgoyette branches: 1.7.14; 1.7.16;
Now that the ufs module has been split out from ffs and ext2fs, we need
to update the boot-loader to push all modules required to support the
booted filesystem. We treat the fsmod string as a slash-separated list
of module names (relative to kern.module.path), rather than as a single
module path name.

Note that ffsv1 and ffsv2 are still exempted from the boot-loader's
auto-push, but the list of required filesystems is still noted in the
source.

Also note that arch/sandpoint needs a similar change. I have not made
this change because I am totally unable to test it.

Tested on my kernel with _no_ built-in file-systems and with the ffs
bootloader settings of fsmod enabled.
 1.6 21-May-2012  dsl branches: 1.6.40;
Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.5 25-Dec-2011  tsutsui branches: 1.5.2;
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.4 19-Nov-2008  ad branches: 1.4.16; 1.4.20;
For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.3 11-Dec-2005  christos branches: 1.3.70; 1.3.74; 1.3.80; 1.3.84;
merge ktrace-lwp.
 1.2 31-Aug-2003  fvdl Fix signed/unsigned warnings.
 1.1 11-Apr-2003  dsl branches: 1.1.2;
Files to build ffsv1 and ffsv2 versions of ufs.c
 1.1.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.2.1 03-Aug-2004  skrll Sync with HEAD
 1.3.84.1 19-Jan-2009  skrll Sync with HEAD.
 1.3.80.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.3.74.1 04-May-2009  yamt sync with head.
 1.3.70.1 17-Jan-2009  mjf Sync with HEAD.
 1.4.20.2 02-Jun-2012  mrg sync to latest -current.
 1.4.20.1 18-Feb-2012  mrg merge to -current.
 1.4.16.2 23-May-2012  yamt sync with head.
 1.4.16.1 17-Apr-2012  yamt sync with head
 1.5.2.1 03-Jun-2012  jdc Pull up revisions:
src/sys/arch/i386/stand/lib/exec.c revision 1.50
src/sys/arch/sandpoint/stand/altboot/main.c revision 1.21 via patch
src/sys/lib/libsa/ext2fs.c revision 1.13
src/sys/lib/libsa/ffsv1.c revision 1.6
src/sys/lib/libsa/ffsv2.c revision 1.6
src/sys/lib/libsa/globals.c revision 1.9
src/sys/lib/libsa/lfsv1.c revision 1.5
src/sys/lib/libsa/lfsv2.c revision 1.5
src/sys/lib/libsa/stand.h revision 1.76
src/sys/lib/libsa/ufs.c revision 1.58
(requested by dsl in ticket #279).

Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.6.40.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.7.16.1 31-May-2021  cjep sync with head
 1.7.14.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.2 24-Apr-2022  mlelstv Don't load filessytem module for filesystem that was found but isn't used
for booting.
 1.1 15-Mar-2002  simonb branches: 1.1.4; 1.1.10;
Move files[] from globals.c to its own file. Including all of globals.o
breaks the size limit for at least the pmax bootblocks.

Fixes PR port-pmax/15924 from Gregory McGarry.
 1.1.10.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.10.1 15-Mar-2002  jdolecek file files.c was added on branch kqueue on 2002-06-23 17:49:52 +0000
 1.1.4.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.1.4.1 15-Mar-2002  nathanw file files.c was added on branch nathanw_sa on 2002-04-01 07:48:08 +0000
 1.1 16-Jan-2012  christos branches: 1.1.4; 1.1.6;
PR/45796: Evgeniy Ivanov minixfs3 support.
Split out fn_match since we have 3 copies now.
 1.1.6.2 17-Apr-2012  yamt sync with head
 1.1.6.1 16-Jan-2012  yamt file fnmatch.c was added on branch yamt-pagecache on 2012-04-17 00:08:33 +0000
 1.1.4.2 18-Feb-2012  mrg merge to -current.
 1.1.4.1 16-Jan-2012  mrg file fnmatch.c was added on branch jmcneill-usbmp on 2012-02-18 07:35:35 +0000
 1.7 02-Dec-2007  tsutsui unsigned -> unsigned int
 1.6 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.5 11-Dec-2005  christos branches: 1.5.44; 1.5.46; 1.5.52;
merge ktrace-lwp.
 1.4 07-Aug-2003  agc branches: 1.4.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 30-Mar-2000  augustss branches: 1.3.28;
Kill some more register declarations.
 1.2 31-Mar-1999  cgd branches: 1.2.8;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.1 13-Jan-1996  leo Some files containing more than one function are split. This reduces the
size of the resulting loader. The read_inode() function now returns the
result of the strategy function instead of success in all cases (ufs.c).
Fixes pr#1817
 1.2.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.3.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.28.1 03-Aug-2004  skrll Sync with HEAD
 1.4.16.1 07-Dec-2007  yamt sync with head
 1.5.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.5.46.1 09-Jan-2008  matt sync with HEAD
 1.5.44.2 03-Dec-2007  joerg Sync with HEAD.
 1.5.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.10 11-Jun-2016  dholland PR 51200 gets in libsa considered harmful: use kgets
 1.9 24-Nov-2007  isaki branches: 1.9.62; 1.9.82;
style, indent, and ANSI-fy.
 1.8 11-Dec-2005  christos branches: 1.8.44; 1.8.46; 1.8.52;
merge ktrace-lwp.
 1.7 07-Aug-2003  agc branches: 1.7.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.6 14-Oct-1996  cgd branches: 1.6.62;
fix a bogon in some new functionality apparently added in the last
commit (which was supposed only to back out the printf->kprintf changes).
The new functionality is: if the user enters control-D, return an error.
 1.5 13-Oct-1996  christos backout previous kprintf changes
 1.4 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 22-Aug-1994  brezak branches: 1.2.2;
Cleanup to make more ANSI compliant; checkpoint
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.2.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.2.2.1 22-Aug-1994  brezak file getfile.c was added on branch netbsd-1-0 on 1994-08-22 21:56:07 +0000
 1.6.62.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.62.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.62.1 03-Aug-2004  skrll Sync with HEAD
 1.7.16.1 07-Dec-2007  yamt sync with head
 1.8.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.8.46.1 09-Jan-2008  matt sync with HEAD
 1.8.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.9.82.1 09-Jul-2016  skrll Sync with HEAD
 1.9.62.1 03-Dec-2017  jdolecek update from HEAD
 1.15 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.14 27-Aug-2016  dholland branches: 1.14.16;
PR 51200 gets in libsa considered harmful: remove gets() from libsa.
 1.13 11-Jun-2016  dholland gets_s -> kgets.

The exact name isn't that important; but it is important not to use
"gets_s" and thereby allow anyone to falsely get the impression we're
implementing Annex K. We aren't.

ok core.
 1.12 05-Jun-2016  christos dedup
 1.11 05-Jun-2016  maxv Use gets_s instead of gets. The x86 bootloader prompt is easy to
overflow.
 1.10 24-Nov-2007  isaki branches: 1.10.62; 1.10.82;
style, indent, and ANSI-fy.
 1.9 11-Dec-2005  christos branches: 1.9.44; 1.9.46; 1.9.52;
merge ktrace-lwp.
 1.8 07-Aug-2003  agc branches: 1.8.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.7 30-Mar-2000  augustss branches: 1.7.28;
Kill some more register declarations.
 1.6 11-Oct-1995  pk branches: 1.6.30;
Conditionalize ancient `@' and `#' erasors.
 1.5 26-Oct-1994  cgd branches: 1.5.2;
new RCS ID format.
 1.4 22-Aug-1994  brezak branches: 1.4.2;
Cleanup to make more ANSI compliant; checkpoint
 1.3 09-Aug-1994  pk Echo terminating NL too.
 1.2 18-Jul-1994  pk do echo.
 1.1 26-Jan-1994  brezak branches: 1.1.2;
CMU/4.4 stand-alone library
 1.1.2.2 13-Aug-1994  mycroft update from trunk
 1.1.2.1 27-Jul-1994  cgd update from trunk.
 1.4.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.4.2.1 22-Aug-1994  brezak file gets.c was added on branch netbsd-1-0 on 1994-08-22 21:56:08 +0000
 1.5.2.1 13-Oct-1995  pk Update from trunk: erase characters.
 1.6.30.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.7.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.28.1 03-Aug-2004  skrll Sync with HEAD
 1.8.16.1 07-Dec-2007  yamt sync with head
 1.9.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.9.46.1 09-Jan-2008  matt sync with HEAD
 1.9.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.10.82.2 05-Oct-2016  skrll Sync with HEAD
 1.10.82.1 09-Jul-2016  skrll Sync with HEAD
 1.10.62.1 03-Dec-2017  jdolecek update from HEAD
 1.14.16.1 10-Jun-2019  christos Sync with HEAD
 1.12 24-Apr-2022  mlelstv Don't load filessytem module for filesystem that was found but isn't used
for booting.
 1.11 29-Mar-2014  jakllsch Obtain and/or use ETHER_ADDR_LEN.
 1.10 05-Jan-2014  jakllsch Make libsa fsmod string pointer const.
 1.9 21-May-2012  dsl branches: 1.9.2; 1.9.4;
Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.8 19-Nov-2008  ad branches: 1.8.16; 1.8.20; 1.8.22;
For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.7 27-Mar-2003  drochner branches: 1.7.100; 1.7.104; 1.7.110; 1.7.114;
There is no point in initializing "rootpath" to "/".
Move it into BSS.
 1.6 19-Mar-2003  drochner remove stuff just moved to bootparam.c and some variables which are
never used.
 1.5 15-Mar-2002  simonb Move files[] from globals.c to its own file. Including all of globals.o
breaks the size limit for at least the pmax bootblocks.

Fixes PR port-pmax/15924 from Gregory McGarry.
 1.4 23-Feb-2002  thorpej Move files[] from open.c to globals.c, so that it's possible to
use libsa in an application where there are no file systems or
devices.
 1.3 18-Sep-1995  pk branches: 1.3.44; 1.3.46;
Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.3.46.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.3.46.1 16-Mar-2002  jdolecek Catch up with -current.
 1.3.44.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.3.44.1 28-Feb-2002  nathanw Catch up to -current.
 1.7.114.1 19-Jan-2009  skrll Sync with HEAD.
 1.7.110.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.7.104.1 04-May-2009  yamt sync with head.
 1.7.100.1 17-Jan-2009  mjf Sync with HEAD.
 1.8.22.1 03-Jun-2012  jdc Pull up revisions:
src/sys/arch/i386/stand/lib/exec.c revision 1.50
src/sys/arch/sandpoint/stand/altboot/main.c revision 1.21 via patch
src/sys/lib/libsa/ext2fs.c revision 1.13
src/sys/lib/libsa/ffsv1.c revision 1.6
src/sys/lib/libsa/ffsv2.c revision 1.6
src/sys/lib/libsa/globals.c revision 1.9
src/sys/lib/libsa/lfsv1.c revision 1.5
src/sys/lib/libsa/lfsv2.c revision 1.5
src/sys/lib/libsa/stand.h revision 1.76
src/sys/lib/libsa/ufs.c revision 1.58
(requested by dsl in ticket #279).

Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.8.20.1 02-Jun-2012  mrg sync to latest -current.
 1.8.16.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8.16.1 23-May-2012  yamt sync with head.
 1.9.4.1 18-May-2014  rmind sync with head
 1.9.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 11-Nov-1999  thorpej Networking routines needed for libsa to be self-contained.
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 11-Nov-1999  thorpej Networking routines needed for libsa to be self-contained.
 1.26 22-Jul-1997  drochner Remove this relict, it's not needed anymore.
 1.25 17-Jan-1997  mikel branches: 1.25.2;
fix my typo; found by Klaus Klein <kleink@layla.inka.de>
 1.24 17-Jan-1997  mikel add prototypes for ethers(3) functions; fixes PR 2471.
fix suggested by Jason Thorpe.
 1.23 09-Oct-1996  thorpej Merge netbsd-1-2 branch back into mainline.
 1.22 11-May-1996  mycroft branches: 1.22.4;
When sending an ARP request, use the interface address for the route, rather
than the first address assigned. This gives slightly different behaviour in
the presence of aliases. From Bill Fenner, via Pete Bentley.
 1.21 13-Feb-1996  christos netinet prototypes
 1.20 12-Jun-1995  mycroft Various cleanup, including:
* Convert several data structures to use queue.h.
* Split in_pcbnotify() into two parts; one for notifying a specific PCB, and
one for notifying all PCBs for a particular foreign address.
 1.19 16-May-1995  cgd parenthesize macro arg usage
 1.18 15-May-1995  cgd spacing fixups and KNF. #define ether address size, so it's not
hardcoded as '6' all over.
 1.17 17-Apr-1995  cgd spacing cleaup. also, minor type mixup fixups.
 1.16 13-Apr-1995  cgd be a bit more careful and explicit with types. (basically a large no-op.)
 1.15 10-Apr-1995  mycroft Remove now unneeded #ifdef. Prototype new function.
 1.14 29-Mar-1995  briggs KERNEL -> _KERNEL
 1.13 26-Mar-1995  jtc KERNEL -> _KERNEL
 1.12 06-Mar-1995  glass remove references to arptnew. fix spelling error
 1.11 27-Feb-1995  glass fix some typos. from frank@fwi.uva.nl (Frank van der Linden)
 1.10 29-Jun-1994  cgd New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'
 1.9 13-May-1994  mycroft Update to 4.4-Lite networking code, with a few local changes.
 1.8 02-Feb-1994  hpeyerl Multicast is no longer optional.
 1.7 08-Jan-1994  mycroft Fix some inconsistent spacing; spaces at the end of lines, etc.
 1.6 30-Dec-1993  deraadt "struct ether_addr" for ethers(3) functions.
 1.5 13-Dec-1993  hpeyerl >From cmaeda@cs.washington.edu; part of the multicast patches derived
from the Multicast patches for BSDI.

(I am a "big dopey bear" for having forgotten this. Thanx Havard.)
 1.4 05-Sep-1993  cassidy Add definition for reverse address resolution protocol.
 1.3 20-May-1993  cgd more rcsid additions and file header cleanups
 1.2 19-Apr-1993  mycroft Add consistent multiple-inclusion protection.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.22.4.1 17-Jun-1996  gwr Pad the struct arpcom to avoid unnecessary misalignments on m68k ports.
 1.25.2.3 06-Mar-1997  is Wipe out double function prototypes.
 1.25.2.2 18-Feb-1997  is Having converted everything, remove the struct ether_arp definition completely.
Some small cleanup.
STILLTODO: some sanity checks of the (now) variable link level address length
in incoming packets..
 1.25.2.1 07-Feb-1997  is Snapshot of new ARP code.

Our old ARP code was hardwired for 6-byte length medium
addresses, while the protocol is designed for any size.

This snapshot contains a first hack at getting rid of
Ethernet specific data structures. The ep driver is updated
(and tested on the PCI bus), the iy and fpa drivers have been
updated, but not real life tested yet.

If you want to test this with other drivers, you have to update
them first yourself, and probably tag the relevant directories.
Better contact me if you want to do this.
 1.7 24-Jan-2006  christos PR/32613: Yves-Emmanuel JUTARD: Incoherencies in file sys/lib/libsa/net.h
- Make prototype of ether_sprintf() match the one in sys/net.
- Rename in_cksum to ip_cksum and fix its prototype. in_cksum() operates
on an mbuf and ip_cksum() operates on a plain buffer. We should not call
functions that operate on different arguments the same name (this is not
c++).
 1.6 31-Mar-2000  castor branches: 1.6.44; 1.6.56;
Make standalone in_cksum work on little-endian machines, too, courtesy of
Jeff Smith, <jeffs@geocast.com>.
 1.5 30-Mar-2000  augustss Kill some more register declarations.
 1.4 11-Feb-1999  pk branches: 1.4.8;
Add missing prototypes.
 1.3 22-Apr-1995  cgd cast pointers to longs
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.4.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.6.56.1 01-Feb-2006  yamt sync with head.
 1.6.44.1 21-Jun-2006  yamt sync with head.
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 11-Nov-1999  thorpej Networking routines needed for libsa to be self-contained.
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 11-Nov-1999  thorpej Networking routines needed for libsa to be self-contained.
 1.11 02-Dec-2007  tsutsui unsigned -> unsigned int
 1.10 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.9 11-Dec-2005  christos branches: 1.9.44; 1.9.46; 1.9.52;
merge ktrace-lwp.
 1.8 26-Feb-2005  perry branches: 1.8.4;
nuke trailing whitespace
 1.7 07-Aug-2003  agc branches: 1.7.8; 1.7.10;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.6 30-Mar-2000  augustss branches: 1.6.28;
Kill some more register declarations.
 1.5 31-Mar-1999  cgd branches: 1.5.8;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.4 30-Oct-1994  cgd be more careful with types, also pull in headers where necessary.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 08-May-1994  brezak Standalone networking for network boot loaders.
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.5.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.6.28.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.28.1 03-Aug-2004  skrll Sync with HEAD
 1.7.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.8.1 29-Apr-2005  kent sync with -current
 1.8.4.1 07-Dec-2007  yamt sync with head
 1.9.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.9.46.1 09-Jan-2008  matt sync with HEAD
 1.9.44.2 03-Dec-2007  joerg Sync with HEAD.
 1.9.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.10 29-Mar-2014  jakllsch Obtain and/or use ETHER_ADDR_LEN.
 1.9 17-Jan-2009  tsutsui branches: 1.9.14; 1.9.24; 1.9.28;
Remove __P().
 1.8 12-Jan-2009  tsutsui Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.7 11-Dec-2005  christos branches: 1.7.70; 1.7.74; 1.7.84;
merge ktrace-lwp.
 1.6 26-Feb-2005  perry nuke trailing whitespace
 1.5 12-Mar-2003  drochner branches: 1.5.2; 1.5.10; 1.5.12;
separate the netif interface from the rest of the networking code,
so that it can be replaced easily in md code
 1.4 23-Sep-1995  gwr Fix/improve some comments.
 1.3 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.5.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.5.10.1 29-Apr-2005  kent sync with -current
 1.5.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.84.1 19-Jan-2009  skrll Sync with HEAD.
 1.7.74.1 04-May-2009  yamt sync with head.
 1.7.70.1 17-Jan-2009  mjf Sync with HEAD.
 1.9.28.1 18-May-2014  rmind sync with head
 1.9.24.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.9.14.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.5 08-Jul-2022  skrll alredy -> already
 1.4 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.3 09-May-2018  maxv branches: 1.3.2;
Remove annoying things, style, and fix buffer overflows.
 1.2 13-May-2011  nakayama branches: 1.2.2; 1.2.6; 1.2.58;
Use %zd for ssize_t, and %zu for size_t.
 1.1 11-May-2011  zoltan Separate the IP and UDP code paths inside libsa, so I can add HTTP booting
later.
 1.2.58.1 21-May-2018  pgoyette Sync with HEAD
 1.2.6.2 06-Jun-2011  jruoho Sync with HEAD.
 1.2.6.1 13-May-2011  jruoho file ip.c was added on branch jruoho-x86intr on 2011-06-06 09:09:43 +0000
 1.2.2.2 31-May-2011  rmind sync with head
 1.2.2.1 13-May-2011  rmind file ip.c was added on branch rmind-uvmplock on 2011-05-31 03:05:05 +0000
 1.3.2.1 10-Jun-2019  christos Sync with HEAD
 1.2 25-Jan-2006  christos branches: 1.2.4; 1.2.18;
Changing len from int to size_t caused an infinite loop. Noticed by chuq.
 1.1 24-Jan-2006  christos PR/32613: Yves-Emmanuel JUTARD: Incoherencies in file sys/lib/libsa/net.h
- Make prototype of ether_sprintf() match the one in sys/net.
- Rename in_cksum to ip_cksum and fix its prototype. in_cksum() operates
on an mbuf and ip_cksum() operates on a plain buffer. We should not call
functions that operate on different arguments the same name (this is not
c++).
 1.2.18.2 21-Jun-2006  yamt sync with head.
 1.2.18.1 25-Jan-2006  yamt file ip_cksum.c was added on branch yamt-lazymbuf on 2006-06-21 15:10:23 +0000
 1.2.4.2 01-Feb-2006  yamt sync with head.
 1.2.4.1 25-Jan-2006  yamt file ip_cksum.c was added on branch yamt-uio_vmspace on 2006-02-01 14:52:36 +0000
 1.12 16-Apr-2003  dsl lfs code is built from ufs.c
 1.11 02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.10 23-Feb-2003  simonb Add support for LFSv2 filesystems. From a libsa standpoint, LFSv1 and
LFSv2 are treated as separate filesystem types for size considerations.
 1.9 23-Feb-2003  simonb Use the MAX() macro from <sys/param.h> instead of a local inline. Results
in same code size in ufs.c and removes an unused inline function in lfs.c.
 1.8 24-Jan-2003  fvdl Bump daddr_t to 64 bits. Replace it with int32_t in all places where
it was used on-disk, so that on-disk formats remain the same.
Remove ufs_daddr_t and ufs_lbn_t for the time being.
 1.7 07-May-2002  simonb Remove two shadowed variables, one of which was set to what it was
shadowing(!) and the other a temporary variable (as was it's shadow).
Code generated with "gcc -O2" is the same before and after.
 1.6 30-Mar-2000  augustss branches: 1.6.6; 1.6.8;
Kill some more register declarations.
 1.5 13-Nov-1999  thorpej Backout my libsa changes.
 1.4 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.3 19-Aug-1999  simonb branches: 1.3.2; 1.3.4; 1.3.8;
Remove prototype for find_inode().
 1.2 18-Aug-1999  cgd note that these files should be easily diffable (until they share common code
 1.1 18-Aug-1999  cgd Add a standalone LFS implementation. Currently not merged with ufs (FFS),
but should be (and will be before too long). Until then, it and ufs.?
should be easily diffable.
 1.3.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.3.4.1 15-Nov-1999  fvdl Sync with -current
 1.3.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.6.8.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.6.1 20-Jun-2002  nathanw Catch up to -current.
 1.5 11-Dec-2005  christos merge ktrace-lwp.
 1.4 18-Aug-2003  dsl make 'path' argument to ufs_open 'const char *' and fix the fallout.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 23-Feb-2003  simonb branches: 1.2.2;
Add support for LFSv2 filesystems. From a libsa standpoint, LFSv1 and
LFSv2 are treated as separate filesystem types for size considerations.
 1.1 18-Aug-1999  cgd Add a standalone LFS implementation. Currently not merged with ufs (FFS),
but should be (and will be before too long). Until then, it and ufs.?
should be easily diffable.
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.16 17-Nov-2022  chs Restore backward compatibility of UFS2 with previous NetBSD releases by
disabling support in UFS2 for extended attributes (including ACLs).
Add a new variant of UFS2 called "UFS2ea" that does support extended attributes.
Add new fsck_ffs operations "-c ea" and "-c no-ea" to convert file systems
from UFS2 to UFS2ea and vice-versa (both of which delete all existing extended
attributes in the process).
 1.15 27-May-2021  mrg add bi-endian support to the libsa ufs reader and enable it in efiboot.

ffs frontends to "ufs.c" now also define ufs_dinode_swap, ufs_indp_swap,
and FS_MAGIC (moved from ufs.c #if segments.) these are used to call
the right (32/64 bit) ffsv1/v2 version.

ufs.c 'struct file' gains f_swapped member. accessors for d_magic,
d_reclen, and d_ino are introduced (they need to be swapped.) sfter
reading an inode from disk, read_inode() may call ufs_dinode_swap().
indirect block number and caches may be swapped.

error handling in ffs_find_superblock() is cleaned up. (size is slightly
reduced on some ports with this part.)

defaults for new defines added to ufs.c. (XXX: we build ufs.c but i think
all the consumers don't use it, and we can stop building it.)

LFS support is not included.

add a cut-down copy of ffs_bswap.c from the kernel.

also enable bi-endian disklabel support in efiboot.

most ports build and sizes compared for platforms that don't enable this
code and all but one saw reduced code size. booted several platforms with
new boot code.
 1.14 12-Aug-2015  dholland branches: 1.14.34; 1.14.36;
Hack up dinode usage to be 64 vs. 32 as needed. Part 1.

(This part changes the native lfs code; the ufs-derived code already
has 64 vs. 32 logic, but as aspects of it are unsafe, and don't
entirely interoperate cleanly with the lfs 64/32 stuff, pass 2 will be
rehashing that.)
 1.13 12-Aug-2015  dholland Add IFILE32 and IFILE64 structures for the on-disk ifile entries.
Add and use accessors. There are also a bunch of places that cast and
I hope I've found them all...
 1.12 02-Aug-2015  dholland Add a (draft) 64-bit superblock. Make things build again.

Add pieces of support for using both superblock types where
convenient, and specifically to the superblock accessors, but don't
actually enable it anywhere.

First substantive step on PR 50000.
 1.11 24-Jul-2015  dholland Switch to accessor functions for elements of the LFS on-disk
superblock. This will allow switching between 32/64 bit forms on the
fly; it will also allow handling LFS_EI reasonably tidily. (That
currently doesn't work on the superblock.)

It also gets rid of cpp abuse in the form of fake structure member
macros.

Also, instead of doing sleep/wakeup on &lfs_avail and &lfs_nextseg
inside the on-disk superblock, add extra elements to the in-memory
struct lfs for this. (XXX: these should be changed to condvars, but
not right now)

XXX: this migrates a structure needed by the lfs code in libsa (struct
salfs) into lfs.h, where it doesn't belong, but for the time being
this is necessary in order to allow the accessors (and the various
lfs macros and other goop that relies on them) to compile.
 1.10 24-Jul-2015  dholland Rearrange the structures in the lfs bootbollocks slightly.
This generates the same output (at least on amd64) but will be more
robust until we're ready to deploy lfs64 bootblocks too.

XXX: I don't think these actually work right now, and the logic for
picking between v1 and v2 lfs formats (which is not related to ffsv1
vs. ffsv2) is definitely broken. But I haven't made it any worse.
 1.9 23-Jun-2013  dholland branches: 1.9.10;
Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

lblkno
lblktosize
lfragtosize
numfrags
blkroundup
fragroundup
 1.8 19-Jun-2013  dholland Rename ambiguous macros:
MAXDIRSIZE -> UFS_MAXDIRSIZE or LFS_MAXDIRSIZE
NINDIR -> FFS_NINDIR, EXT2_NINDIR, LFS_NINDIR, or MFS_NINDIR
INOPB -> FFS_INOPB, LFS_INOPB
INOPF -> FFS_INOPF, LFS_INOPF
blksize -> ffs_blksize, ext2_blksize, or lfs_blksize
sblksize -> ffs_blksize

These are not the only ambiguously defined filesystem macros, of
course, there's a pile more. I may not have found all the ambiguous
definitions of blksize(), too, as there are a lot of other things
called 'blksize' in the system.
 1.7 18-Jun-2013  christos Prefix most of the cpp macros with lfs_ and LFS_ to avoid conflicts with ffs.
This was done so that boot blocks that want to compile both FFS and LFS in
the same file work.
 1.6 09-Jun-2013  dholland Build properly against the lfs changes.
 1.5 21-May-2012  dsl branches: 1.5.2;
Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.4 25-Dec-2011  tsutsui branches: 1.4.2;
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.3 19-Nov-2008  ad branches: 1.3.16; 1.3.20;
For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.2 11-Apr-2003  dsl branches: 1.2.100; 1.2.104; 1.2.110; 1.2.114;
Use common ffs/lfs file ufs.c instead of lfs specific version.
 1.1 23-Feb-2003  simonb Add support for LFSv2 filesystems. From a libsa standpoint, LFSv1 and
LFSv2 are treated as separate filesystem types for size considerations.
 1.2.114.1 19-Jan-2009  skrll Sync with HEAD.
 1.2.110.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.2.104.1 04-May-2009  yamt sync with head.
 1.2.100.1 17-Jan-2009  mjf Sync with HEAD.
 1.3.20.2 02-Jun-2012  mrg sync to latest -current.
 1.3.20.1 18-Feb-2012  mrg merge to -current.
 1.3.16.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.16.2 23-May-2012  yamt sync with head.
 1.3.16.1 17-Apr-2012  yamt sync with head
 1.4.2.1 03-Jun-2012  jdc Pull up revisions:
src/sys/arch/i386/stand/lib/exec.c revision 1.50
src/sys/arch/sandpoint/stand/altboot/main.c revision 1.21 via patch
src/sys/lib/libsa/ext2fs.c revision 1.13
src/sys/lib/libsa/ffsv1.c revision 1.6
src/sys/lib/libsa/ffsv2.c revision 1.6
src/sys/lib/libsa/globals.c revision 1.9
src/sys/lib/libsa/lfsv1.c revision 1.5
src/sys/lib/libsa/lfsv2.c revision 1.5
src/sys/lib/libsa/stand.h revision 1.76
src/sys/lib/libsa/ufs.c revision 1.58
(requested by dsl in ticket #279).

Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.5.2.3 03-Dec-2017  jdolecek update from HEAD
 1.5.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.2.1 23-Jun-2013  tls resync from head
 1.9.10.1 22-Sep-2015  skrll Sync with HEAD
 1.14.36.1 31-May-2021  cjep sync with head
 1.14.34.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.16 17-Nov-2022  chs Restore backward compatibility of UFS2 with previous NetBSD releases by
disabling support in UFS2 for extended attributes (including ACLs).
Add a new variant of UFS2 called "UFS2ea" that does support extended attributes.
Add new fsck_ffs operations "-c ea" and "-c no-ea" to convert file systems
from UFS2 to UFS2ea and vice-versa (both of which delete all existing extended
attributes in the process).
 1.15 27-May-2021  mrg add bi-endian support to the libsa ufs reader and enable it in efiboot.

ffs frontends to "ufs.c" now also define ufs_dinode_swap, ufs_indp_swap,
and FS_MAGIC (moved from ufs.c #if segments.) these are used to call
the right (32/64 bit) ffsv1/v2 version.

ufs.c 'struct file' gains f_swapped member. accessors for d_magic,
d_reclen, and d_ino are introduced (they need to be swapped.) sfter
reading an inode from disk, read_inode() may call ufs_dinode_swap().
indirect block number and caches may be swapped.

error handling in ffs_find_superblock() is cleaned up. (size is slightly
reduced on some ports with this part.)

defaults for new defines added to ufs.c. (XXX: we build ufs.c but i think
all the consumers don't use it, and we can stop building it.)

LFS support is not included.

add a cut-down copy of ffs_bswap.c from the kernel.

also enable bi-endian disklabel support in efiboot.

most ports build and sizes compared for platforms that don't enable this
code and all but one saw reduced code size. booted several platforms with
new boot code.
 1.14 12-Aug-2015  dholland branches: 1.14.34; 1.14.36;
Hack up dinode usage to be 64 vs. 32 as needed. Part 1.

(This part changes the native lfs code; the ufs-derived code already
has 64 vs. 32 logic, but as aspects of it are unsafe, and don't
entirely interoperate cleanly with the lfs 64/32 stuff, pass 2 will be
rehashing that.)
 1.13 12-Aug-2015  dholland Add IFILE32 and IFILE64 structures for the on-disk ifile entries.
Add and use accessors. There are also a bunch of places that cast and
I hope I've found them all...
 1.12 02-Aug-2015  dholland Add a (draft) 64-bit superblock. Make things build again.

Add pieces of support for using both superblock types where
convenient, and specifically to the superblock accessors, but don't
actually enable it anywhere.

First substantive step on PR 50000.
 1.11 24-Jul-2015  dholland Switch to accessor functions for elements of the LFS on-disk
superblock. This will allow switching between 32/64 bit forms on the
fly; it will also allow handling LFS_EI reasonably tidily. (That
currently doesn't work on the superblock.)

It also gets rid of cpp abuse in the form of fake structure member
macros.

Also, instead of doing sleep/wakeup on &lfs_avail and &lfs_nextseg
inside the on-disk superblock, add extra elements to the in-memory
struct lfs for this. (XXX: these should be changed to condvars, but
not right now)

XXX: this migrates a structure needed by the lfs code in libsa (struct
salfs) into lfs.h, where it doesn't belong, but for the time being
this is necessary in order to allow the accessors (and the various
lfs macros and other goop that relies on them) to compile.
 1.10 24-Jul-2015  dholland Rearrange the structures in the lfs bootbollocks slightly.
This generates the same output (at least on amd64) but will be more
robust until we're ready to deploy lfs64 bootblocks too.

XXX: I don't think these actually work right now, and the logic for
picking between v1 and v2 lfs formats (which is not related to ffsv1
vs. ffsv2) is definitely broken. But I haven't made it any worse.
 1.9 23-Jun-2013  dholland branches: 1.9.10;
Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

lblkno
lblktosize
lfragtosize
numfrags
blkroundup
fragroundup
 1.8 19-Jun-2013  dholland Rename ambiguous macros:
MAXDIRSIZE -> UFS_MAXDIRSIZE or LFS_MAXDIRSIZE
NINDIR -> FFS_NINDIR, EXT2_NINDIR, LFS_NINDIR, or MFS_NINDIR
INOPB -> FFS_INOPB, LFS_INOPB
INOPF -> FFS_INOPF, LFS_INOPF
blksize -> ffs_blksize, ext2_blksize, or lfs_blksize
sblksize -> ffs_blksize

These are not the only ambiguously defined filesystem macros, of
course, there's a pile more. I may not have found all the ambiguous
definitions of blksize(), too, as there are a lot of other things
called 'blksize' in the system.
 1.7 18-Jun-2013  christos Prefix most of the cpp macros with lfs_ and LFS_ to avoid conflicts with ffs.
This was done so that boot blocks that want to compile both FFS and LFS in
the same file work.
 1.6 09-Jun-2013  dholland Build properly against the lfs changes.
 1.5 21-May-2012  dsl branches: 1.5.2;
Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.4 25-Dec-2011  tsutsui branches: 1.4.2;
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.3 19-Nov-2008  ad branches: 1.3.16; 1.3.20;
For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.2 11-Apr-2003  dsl branches: 1.2.100; 1.2.104; 1.2.110; 1.2.114;
Use common ffs/lfs file ufs.c instead of lfs specific version.
 1.1 23-Feb-2003  simonb Add support for LFSv2 filesystems. From a libsa standpoint, LFSv1 and
LFSv2 are treated as separate filesystem types for size considerations.
 1.2.114.1 19-Jan-2009  skrll Sync with HEAD.
 1.2.110.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.2.104.1 04-May-2009  yamt sync with head.
 1.2.100.1 17-Jan-2009  mjf Sync with HEAD.
 1.3.20.2 02-Jun-2012  mrg sync to latest -current.
 1.3.20.1 18-Feb-2012  mrg merge to -current.
 1.3.16.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3.16.2 23-May-2012  yamt sync with head.
 1.3.16.1 17-Apr-2012  yamt sync with head
 1.4.2.1 03-Jun-2012  jdc Pull up revisions:
src/sys/arch/i386/stand/lib/exec.c revision 1.50
src/sys/arch/sandpoint/stand/altboot/main.c revision 1.21 via patch
src/sys/lib/libsa/ext2fs.c revision 1.13
src/sys/lib/libsa/ffsv1.c revision 1.6
src/sys/lib/libsa/ffsv2.c revision 1.6
src/sys/lib/libsa/globals.c revision 1.9
src/sys/lib/libsa/lfsv1.c revision 1.5
src/sys/lib/libsa/lfsv2.c revision 1.5
src/sys/lib/libsa/stand.h revision 1.76
src/sys/lib/libsa/ufs.c revision 1.58
(requested by dsl in ticket #279).

Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.5.2.3 03-Dec-2017  jdolecek update from HEAD
 1.5.2.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.2.1 23-Jun-2013  tls resync from head
 1.9.10.1 22-Sep-2015  skrll Sync with HEAD
 1.14.36.1 31-May-2021  cjep sync with head
 1.14.34.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.33 21-May-2021  jmcneill Capture the endianness of the ELF file loaded in 'netbsd_elf_data', the
same way we do already for the class in 'netbsd_elf_class'.
 1.32 05-Apr-2019  christos branches: 1.32.16; 1.32.18;
Go back ot using 0x%x instead of %#x because we don't always support the
format. See subr_prf.c
 1.31 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.30 20-May-2008  ad branches: 1.30.86;
Take $MACHINE into account when looking for modules.
 1.29 20-May-2008  ad Extract kernel version from the note section and stuff into a global
netbsd_version.
 1.28 28-Apr-2008  martin branches: 1.28.2;
Remove clause 3 and 4 from TNF licenses
 1.27 29-Dec-2007  tsutsui branches: 1.27.6; 1.27.8; 1.27.10;
ANSIfy.
 1.26 24-Nov-2007  isaki branches: 1.26.6;
style, indent, and ANSI-fy.
 1.25 09-Dec-2006  chs branches: 1.25.18; 1.25.20; 1.25.26;
in fdloadfile(), fail if we can't read the entire exec header.
 1.24 11-Dec-2005  christos branches: 1.24.20; 1.24.22; 1.24.24;
merge ktrace-lwp.
 1.23 07-Aug-2003  agc branches: 1.23.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.22 24-Feb-2003  pk branches: 1.22.2;
Introduce fdloadfile() to load an image from an open file descriptor;
implement loadfile() in terms of it.

This allows clients to open a file once and "load" it multiple times (e.g.
first with COUNT_KERNEL, then with LOAD_KERNEL) without the side-effects
of multiple open calls.
 1.21 11-Dec-2002  pk Only display the final progress counter if any of the LOAD_ flags was given.
Fix comment describing the return value.
 1.20 31-Oct-2001  thorpej Split elf32 vs. elf64 handling in loadfile(), including support for
each separately and explicitly. BOOT_ELF is now BOOT_ELF32 and
BOOT_ELF64, and ELFSIZE should no longer be defined in loadfile_machdep.h.
 1.19 31-Oct-2001  thorpej Build the loadfile() a.out, ECOFF, and ELF back-ends as separate
objects.
 1.18 30-Oct-2001  thorpej Split the exec formats included by loadfile() into separate files.
Primary goal: explcitly select which ELF format (elf32 or elf64) to
support for a cross tool which uses loadfile().
 1.17 31-Jul-2001  bjh21 branches: 1.17.4;
When loading ELF, zero out:
The e_shstrndx field in the ELF header, since we don't load .shstrtab.
The sh_name field in each section header, for the same reason.
The sh_offset field for any section we don't load.

This means the kernel has some chance of knowing what it's being given. It
also means that the behaviour of old kernels with new loaders should be
deterministic (if not terribly useful: they still can't find the symbol
table).
 1.16 31-Jul-2001  bjh21 G/C "off", since it was just tracking the difference between maxp and elfp.
 1.15 31-Jul-2001  bjh21 Fix a small memory leak when counting the size of the symbol table (shp was
ALLOC'ed if (LOAD_SYM|COUNT_SYM), but FREEd if (LOAD_SYM)).
 1.14 31-Jul-2001  bjh21 When loading an ELF kernel, don't load all the STRTAB sections. Instead, just
load those STRTAB sections that are referenced by a SYMTAB that we're loading.

The main advantage of this is that (at least with the binaries output by my
ARM ELF linker) this removes the need to seek backwards through the file, which
is a big win when loading a gzipped kernel.

While we're here, don't allocate space for string tables we don't load.
 1.13 19-Jul-2001  fvdl Avoid warnings about uninitialised usage.
 1.12 13-Jul-2001  christos Back out previous. The booter will need to find the symbol table itself,
as explained in the code.
 1.11 13-Jul-2001  christos From Nigel Pearson: Make SYMS and NSYMS work on ELF.
The MacOS booter needs them.
 1.10 03-Dec-2000  tsutsui branches: 1.10.2; 1.10.4;
Don't try to load a.out header if there is no space for it before text.
 1.9 11-Nov-2000  tsutsui Don't print "]" if loading kernel does not have symbol table.
 1.8 01-Nov-2000  ragge Add define NO_MID_CHECK that avoids checking of the a.out mid field.
 1.7 29-Dec-1999  hannken branches: 1.7.4;
Fix IS_DATA and IS_TEXT. PF_X and PF_W are valid on p_pflags, not p_ptype.
 1.6 13-Nov-1999  thorpej Backout my libsa changes.
 1.5 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.4 25-Oct-1999  kleink Update to match new SVR4-style definition names in <sys/exec_elf.h>.
 1.3 08-Oct-1999  itohy branches: 1.3.2; 1.3.4;
- a.out header is not a part of text segment in NMAGIC.
- Fix section alignment code.
Patch supplied by Izumi Tsutsui, PR #8575.
 1.2 28-Apr-1999  christos branches: 1.2.2; 1.2.4;
cosmetic printf change
 1.1 28-Apr-1999  christos MI loadfile (used by i386, pmax and sparc shortly)
 1.2.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.2.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.3.4.1 15-Nov-1999  fvdl Sync with -current
 1.3.2.3 08-Dec-2000  bouyer Sync with HEAD.
 1.3.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.3.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.7.4.2 15-Mar-2003  he Apply patch (requested by gmcgarry in ticket #7):
Initialize some local variables so that this compiles cleanly with
later toolchains.
 1.7.4.1 15-Dec-2000  he Pull up revision 1.9 (requested by tsutsui):
Don't print ``]'' if loading kernel does not have a symbol table.
 1.10.4.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.10.4.1 03-Aug-2001  lukem update to -current
 1.10.2.3 11-Dec-2002  thorpej Sync with HEAD.
 1.10.2.2 14-Nov-2001  nathanw Catch up to -current.
 1.10.2.1 24-Aug-2001  nathanw Catch up with -current.
 1.17.4.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.22.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.22.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.22.2.1 03-Aug-2004  skrll Sync with HEAD
 1.23.16.3 21-Jan-2008  yamt sync with head
 1.23.16.2 07-Dec-2007  yamt sync with head
 1.23.16.1 30-Dec-2006  yamt sync with head.
 1.24.24.1 12-Jan-2007  bouyer Pull up following revision(s) (requested by chs in ticket #348):
sys/lib/libsa/loadfile.c: revision 1.25
in fdloadfile(), fail if we can't read the entire exec header.
 1.24.22.1 10-Dec-2006  yamt sync with head.
 1.24.20.1 12-Jan-2007  ad Sync with head.
 1.25.26.2 18-Feb-2008  mjf Sync with HEAD.
 1.25.26.1 08-Dec-2007  mjf Sync with HEAD.
 1.25.20.1 09-Jan-2008  matt sync with HEAD
 1.25.18.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.26.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.27.10.2 04-May-2009  yamt sync with head.
 1.27.10.1 16-May-2008  yamt sync with head.
 1.27.8.2 04-Jun-2008  yamt sync with head
 1.27.8.1 18-May-2008  yamt sync with head.
 1.27.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.28.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.30.86.1 10-Jun-2019  christos Sync with HEAD
 1.32.18.1 31-May-2021  cjep sync with head
 1.32.16.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.15 21-May-2021  jmcneill Capture the endianness of the ELF file loaded in 'netbsd_elf_data', the
same way we do already for the class in 'netbsd_elf_class'.
 1.14 07-Oct-2017  maxv branches: 1.14.20; 1.14.22;
Add a new option in libsa, to load dynamic binaries. A separate function
is used, and it does not break in any way the generic static loader. Then,
add a new "pkboot" command in the x86 bootloader, which boots a
GENERIC_KASLR kernel via the prekern. (See thread on tech-kern@.)
 1.13 03-Dec-2016  maxv Fix a wrong flag and KNF.
 1.12 25-Aug-2010  christos branches: 1.12.18; 1.12.36; 1.12.40;
add a LOAD_BACKWARDS flag on sections that might load backwards.
 1.11 25-Aug-2010  christos Add a new LOAD_MINIMAL flag to avoid loading sections that might seek backwards
and are not really needed like the note and the symbol section.
 1.10 25-Sep-2008  christos branches: 1.10.14; 1.10.16;
add a LOAD_NOTE flag to make loading the note optional.
 1.9 20-May-2008  ad branches: 1.9.4;
Take $MACHINE into account when looking for modules.
 1.8 20-May-2008  ad Extract kernel version from the note section and stuff into a global
netbsd_version.
 1.7 28-Apr-2008  martin branches: 1.7.2;
Remove clause 3 and 4 from TNF licenses
 1.6 05-Jun-2007  martin branches: 1.6.28; 1.6.30; 1.6.32;
Add a MARK_DATA marker containing the effective VA of the first loaded
data segment.
 1.5 29-Apr-2003  scw branches: 1.5.18; 1.5.60; 1.5.62;
Allow the default location of "machine/loadfile_machdep.h" to be
overridden if MACHINE_LOADFILE_MACHDEP is defined.
This makes life much simpler in the face of the myriad of
different boot options for the evb* ports.
 1.4 24-Feb-2003  pk Introduce fdloadfile() to load an image from an open file descriptor;
implement loadfile() in terms of it.

This allows clients to open a file once and "load" it multiple times (e.g.
first with COUNT_KERNEL, then with LOAD_KERNEL) without the side-effects
of multiple open calls.
 1.3 31-Oct-2001  thorpej Split elf32 vs. elf64 handling in loadfile(), including support for
each separately and explicitly. BOOT_ELF is now BOOT_ELF32 and
BOOT_ELF64, and ELFSIZE should no longer be defined in loadfile_machdep.h.
 1.2 31-Oct-2001  thorpej Build the loadfile() a.out, ECOFF, and ELF back-ends as separate
objects.
 1.1 28-Apr-1999  christos branches: 1.1.2; 1.1.16; 1.1.18; 1.1.22;
MI loadfile (used by i386, pmax and sparc shortly)
 1.1.22.1 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.1.18.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.16.1 14-Nov-2001  nathanw Catch up to -current.
 1.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.62.1 11-Jul-2007  mjf Sync with head.
 1.5.60.1 09-Jun-2007  ad Sync with head.
 1.5.18.1 03-Sep-2007  yamt sync with head.
 1.6.32.3 09-Oct-2010  yamt sync with head
 1.6.32.2 04-May-2009  yamt sync with head.
 1.6.32.1 16-May-2008  yamt sync with head.
 1.6.30.2 04-Jun-2008  yamt sync with head
 1.6.30.1 18-May-2008  yamt sync with head.
 1.6.28.2 28-Sep-2008  mjf Sync with HEAD.
 1.6.28.1 02-Jun-2008  mjf Sync with HEAD.
 1.7.2.2 10-Oct-2008  skrll Sync with HEAD.
 1.7.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.9.4.1 19-Oct-2008  haad Sync with HEAD.
 1.10.16.1 05-Mar-2011  rmind sync with head
 1.10.14.1 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.12.40.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.12.36.1 05-Dec-2016  skrll Sync with HEAD
 1.12.18.1 03-Dec-2017  jdolecek update from HEAD
 1.14.22.1 31-May-2021  cjep sync with head
 1.14.20.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.15 20-Feb-2014  joerg Casting to void is the canonical way of marking a variable as
potentially unused.
 1.14 16-Aug-2009  matt branches: 1.14.12; 1.14.22; 1.14.26;
Change include of <sys/exec.h> to <sys/exec_aout.h> since these files want
the a.out stuff.
 1.13 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.12 29-Dec-2007  tsutsui branches: 1.12.6; 1.12.8; 1.12.10;
ANSIfy.
 1.11 03-Dec-2007  isaki branches: 1.11.6;
Use standard error code (EIO) instead of standalone error code
(ESHORT). Because loadfile_*() is used with or without
_STANDALONE, therefore, don't use error code in "saerrno.h".
Pointed out by and discussed with he@.
 1.10 23-Nov-2007  isaki loadfile_*() must set errno when it returns -1.
 1.9 05-Jun-2007  martin branches: 1.9.6; 1.9.8; 1.9.14;
Add a MARK_DATA marker containing the effective VA of the first loaded
data segment.
 1.8 11-Dec-2005  christos branches: 1.8.30; 1.8.32;
merge ktrace-lwp.
 1.7 26-Feb-2005  perry branches: 1.7.4;
nuke trailing whitespace
 1.6 31-Aug-2003  fvdl branches: 1.6.8; 1.6.10;
Fix signed/unsigned warnings.
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 10-Dec-2002  thorpej branches: 1.4.6;
Rename __LDPGSZ to AOUT_LDPGSZ, to accurately reflect what it is.
 1.3 11-Feb-2002  reinoud Not all ports use the `offset' in their calulations and on those platforms
compile errors are generated due to it. By explicitly using `offset=offset'
the variable is used in the compilers view and is optimised away anyway.
 1.2 31-Oct-2001  thorpej branches: 1.2.2; 1.2.4; 1.2.6;
Build the loadfile() a.out, ECOFF, and ELF back-ends as separate
objects.
 1.1 30-Oct-2001  thorpej Split the exec formats included by loadfile() into separate files.
Primary goal: explcitly select which ELF format (elf32 or elf64) to
support for a cross tool which uses loadfile().
 1.2.6.3 16-Mar-2002  jdolecek Catch up with -current.
 1.2.6.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.2.6.1 31-Oct-2001  thorpej file loadfile_aout.c was added on branch kqueue on 2002-01-10 20:00:38 +0000
 1.2.4.4 11-Dec-2002  thorpej Sync with HEAD.
 1.2.4.3 28-Feb-2002  nathanw Catch up to -current.
 1.2.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.2.4.1 31-Oct-2001  nathanw file loadfile_aout.c was added on branch nathanw_sa on 2001-11-14 19:16:52 +0000
 1.2.2.2 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.2.2.1 31-Oct-2001  thorpej file loadfile_aout.c was added on branch thorpej-mips-cache on 2001-11-12 21:19:05 +0000
 1.4.6.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.6.1 03-Aug-2004  skrll Sync with HEAD
 1.6.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.6.8.1 29-Apr-2005  kent sync with -current
 1.7.4.3 21-Jan-2008  yamt sync with head
 1.7.4.2 07-Dec-2007  yamt sync with head
 1.7.4.1 03-Sep-2007  yamt sync with head.
 1.8.32.1 11-Jul-2007  mjf Sync with head.
 1.8.30.1 09-Jun-2007  ad Sync with head.
 1.9.14.2 18-Feb-2008  mjf Sync with HEAD.
 1.9.14.1 08-Dec-2007  mjf Sync with HEAD.
 1.9.8.1 09-Jan-2008  matt sync with HEAD
 1.9.6.2 03-Dec-2007  joerg Sync with HEAD.
 1.9.6.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.11.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.12.10.2 19-Aug-2009  yamt sync with head.
 1.12.10.1 16-May-2008  yamt sync with head.
 1.12.8.1 18-May-2008  yamt sync with head.
 1.12.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.26.1 18-May-2014  rmind sync with head
 1.14.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.12.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.11 29-Dec-2007  tsutsui branches: 1.11.6; 1.11.8; 1.11.10;
ANSIfy.
 1.10 03-Dec-2007  isaki branches: 1.10.6;
Use standard error code (EIO) instead of standalone error code
(ESHORT). Because loadfile_*() is used with or without
_STANDALONE, therefore, don't use error code in "saerrno.h".
Pointed out by and discussed with he@.
 1.9 23-Nov-2007  isaki loadfile_*() must set errno when it returns -1.
 1.8 06-Jun-2007  martin branches: 1.8.6; 1.8.8; 1.8.14;
It is "data_start" not "data" - pointed out by Tom Spindler
 1.7 05-Jun-2007  martin Add a MARK_DATA marker containing the effective VA of the first loaded
data segment.
 1.6 11-Dec-2005  christos branches: 1.6.30; 1.6.32;
merge ktrace-lwp.
 1.5 26-Feb-2005  perry branches: 1.5.4;
nuke trailing whitespace
 1.4 11-Feb-2002  reinoud branches: 1.4.16; 1.4.24; 1.4.26;
Not all ports use the `offset' in their calulations and on those platforms
compile errors are generated due to it. By explicitly using `offset=offset'
the variable is used in the compilers view and is optimised away anyway.
 1.3 09-Nov-2001  christos branches: 1.3.2; 1.3.4; 1.3.6;
Remove USB copyrights. The coff and elf loading code did not come with BSD4.4.
 1.2 31-Oct-2001  thorpej Build the loadfile() a.out, ECOFF, and ELF back-ends as separate
objects.
 1.1 30-Oct-2001  thorpej Split the exec formats included by loadfile() into separate files.
Primary goal: explcitly select which ELF format (elf32 or elf64) to
support for a cross tool which uses loadfile().
 1.3.6.3 16-Mar-2002  jdolecek Catch up with -current.
 1.3.6.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.6.1 09-Nov-2001  thorpej file loadfile_ecoff.c was added on branch kqueue on 2002-01-10 20:00:39 +0000
 1.3.4.3 28-Feb-2002  nathanw Catch up to -current.
 1.3.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.3.4.1 09-Nov-2001  nathanw file loadfile_ecoff.c was added on branch nathanw_sa on 2001-11-14 19:16:52 +0000
 1.3.2.2 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.3.2.1 09-Nov-2001  thorpej file loadfile_ecoff.c was added on branch thorpej-mips-cache on 2001-11-12 21:19:05 +0000
 1.4.26.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.4.24.1 29-Apr-2005  kent sync with -current
 1.4.16.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.4.3 21-Jan-2008  yamt sync with head
 1.5.4.2 07-Dec-2007  yamt sync with head
 1.5.4.1 03-Sep-2007  yamt sync with head.
 1.6.32.1 11-Jul-2007  mjf Sync with head.
 1.6.30.1 09-Jun-2007  ad Sync with head.
 1.8.14.2 18-Feb-2008  mjf Sync with HEAD.
 1.8.14.1 08-Dec-2007  mjf Sync with HEAD.
 1.8.8.1 09-Jan-2008  matt sync with HEAD
 1.8.6.2 03-Dec-2007  joerg Sync with HEAD.
 1.8.6.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.10.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.11.10.1 16-May-2008  yamt sync with head.
 1.11.8.1 18-May-2008  yamt sync with head.
 1.11.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.59 13-Sep-2020  jmcneill Elf64_Phdr::p_offset is 64 bits, not 32
 1.58 13-Sep-2020  jmcneill Elf64_Phdr::p_flags is 32 bits, not 64
 1.57 07-May-2020  maxv Update the comments.
 1.56 17-Oct-2019  maxv Make sure we're dealing with a static binary. Otherwise we could crash if
the user mistakenly tries to boot a KASLR kernel with 'boot' instead of
'pkboot'. Now we fail cleanly. Reported by cryo@.
 1.55 21-Jul-2019  rin branches: 1.55.2;
Add SA_ENABLE_BIENDIAN option, which enable us to load kernel image of
opposite byte order (for arm EFI bootloader).

XXX
Currently, it is restricted to load_elf*.c. It would be nice if we can
recognize disklabel and filesystem of opposite byte order.
 1.54 20-Jun-2019  maxv Add KASLR support in UEFI.
 1.53 23-Aug-2018  jmcneill Support loading read-only data sections. ARM64 ELF kernels need this. ok skrll@
 1.52 21-Dec-2017  maxv branches: 1.52.2; 1.52.4;
Make sure we're loading a relocatable binary, to give the user a chance to
correct the kernel name if he mistakenly typed pkboot on a static kernel,
without having to reboot the machine (currently the prekern sees it's a
static kernel and panics).
 1.51 15-Nov-2017  maxv Support large pages on KASLR kernels, in a way that does not reduce
randomness, but on the contrary that increases it.

The size of the kernel sub-blocks is changed to be 1MB. This produces a
kernel with sections that are always < 2MB in size, that can fit a large
page.

Each section is put in a 2MB physical chunk. In this chunk, there is a
padding of approximately 1MB. The prekern uses a random offset aligned to
sh_addralign, to shift the section in physical memory.

For example, physical memory layout created by the bootloader for .text.4
and .rodata.0:
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
|+---------------+ |+---------------+ |
|| .text.4 | PAD || .rodata.0 | PAD |
|+---------------+ |+---------------+ |
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
PA PA+2MB PA+4MB

Then, physical memory layout, after having been shifted by the prekern:
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
| P +---------------+ | +---------------+ |
| A | .text.4 | PAD | PAD | .rodata.0 | PAD |
| D +---------------+ | +---------------+ |
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
PA PA+2MB PA+4MB

The kernel maps these 2MB physical chunks with 2MB large pages. Therefore,
randomness is enforced at both the virtual and physical levels, and the
resulting entropy is higher than that of our current implementaion until
now.

The padding around the section is filled by the prekern. Not to consume
too much memory, the sections that are smaller than PAGE_SIZE are mapped
with normal pages - because there is no point in optimizing them. In these
normal pages, the same shift is applied.

This change has two additional advantages: (a) the cache attacks based on
the TLB are mostly mitigated, because even if you are able to determine
that a given page-aligned range is mapped as executable you don't know
where exactly within that range the section actually begins, and (b) given
that we are slightly randomizing the physical layout we are making some
rare physical attacks more difficult to conduct.

NOTE: after this change you need to update GENERIC_KASLR / prekern /
bootloader.
 1.50 13-Nov-2017  maxv Don't process ELF sections that don't have the ALLOC flag set.

NOTE: you need to update both the prekern and the bootloader after this
change.
 1.49 13-Nov-2017  maxv Revert my last revision, that is to say, don't group sections into
segments anymore. Initially I did this because I wanted to compress the
sections by reducing the padding between them; but we'll handle that
differently.
 1.48 18-Oct-2017  maxv Group the sections into segments, and align to KERNALIGN only between
segments. Prerequisite for other changes. Unfortunately the code is not
very compact, but whatever.
 1.47 13-Oct-2017  maxv Introduce two functions, and dedup code.
 1.46 13-Oct-2017  maxv Constify offset, it must not change.
 1.45 08-Oct-2017  maxv Improve comments.
 1.44 07-Oct-2017  maxv Add a new option in libsa, to load dynamic binaries. A separate function
is used, and it does not break in any way the generic static loader. Then,
add a new "pkboot" command in the x86 bootloader, which boots a
GENERIC_KASLR kernel via the prekern. (See thread on tech-kern@.)
 1.43 05-Oct-2017  christos try a different style of __used.
 1.42 04-Oct-2017  christos mark first as used for platforms that define PROGRESS to nothing (mvme68k)
 1.41 25-Sep-2017  maxv Clean up and split loadfile, reduces a patch I have.
 1.40 18-Apr-2017  uwe Swap arguments to strncmp() so that the thing we are testing, the
section name, comes first; and so that the length of the string
constant is right next to that constant.
 1.39 18-Apr-2017  uwe Move deallocation of shstrsz inside the block where it is allocated.
 1.38 17-Apr-2017  uwe Section at index 0 is SHN_UNDEF. When searching for symbol sections
skip it and start with index 1.
 1.37 17-Apr-2017  uwe Don't hide first = 1 assignment inside for(), that just obscures the
loop. Same object code is generated.
 1.36 23-Feb-2017  nonaka update marks[MARK_DATA] with COUNT_DATA.
 1.35 23-Feb-2017  nonaka fix CTF section symbol size was not counted with COUNT_KERNEL.
 1.34 06-Jan-2017  maxv branches: 1.34.2;
Explain how all that mess works, without actually fixing it yet.
 1.33 03-Dec-2016  maxv Fix a wrong flag and KNF.
 1.32 31-Aug-2016  martin Initialize the marker for the data segment, in case the caller passes not
fully initialized markers to loadfile().
Pointed out by Mark Cave-Ayland.
 1.31 25-Jul-2015  isaki branches: 1.31.2;
white space -> tab.
 1.30 27-Nov-2013  jakllsch branches: 1.30.6;
Fix a use-after-free (well, dealloc actually) issue.
 1.29 17-Feb-2011  christos branches: 1.29.4; 1.29.14; 1.29.18;
revert bad whitespace change.
 1.28 17-Feb-2011  christos fix -Wself-assign warning
 1.27 16-Sep-2010  jym branches: 1.27.2; 1.27.4;
Use standard ELF types for ELF code, instead of paddr_t. paddr_t should
only be used for low level code, like virtual memory internals.
 1.26 02-Sep-2010  christos PR/43830: Valery Ushakov: libsa/loadfile_elf32.c loads .shstrtab into
unallocated memory. Don't load if counting.
 1.25 12-Mar-2010  darran branches: 1.25.2;
DTrace: Add support for CTF sections in the netbsd elf image, load these
at boot.
Add a ksyms_mod_foreach() function to iterate a callback function over the
set of elf symbols for a specific module (netbsd included).
Add kern_ctf.c and mod_ctf_get() to allow the retrieval and decompression
of CTF sections for a specific module.
 1.24 25-Sep-2008  christos branches: 1.24.14;
add a LOAD_NOTE flag to make loading the note optional.
 1.23 20-May-2008  ad branches: 1.23.4;
Extract kernel version from the note section and stuff into a global
netbsd_version.
 1.22 28-Apr-2008  martin branches: 1.22.2;
Remove clause 3 and 4 from TNF licenses
 1.21 29-Dec-2007  tsutsui branches: 1.21.6; 1.21.8; 1.21.10;
ANSIfy.
 1.20 03-Dec-2007  isaki branches: 1.20.6;
Use standard error code (EIO) instead of standalone error code
(ESHORT). Because loadfile_*() is used with or without
_STANDALONE, therefore, don't use error code in "saerrno.h".
Pointed out by and discussed with he@.
 1.19 02-Dec-2007  tsutsui unsigned -> unsigned int
 1.18 23-Nov-2007  isaki loadfile_*() must set errno when it returns -1.
 1.17 05-Jun-2007  martin branches: 1.17.6; 1.17.8; 1.17.14;
Add a MARK_DATA marker containing the effective VA of the first loaded
data segment.
 1.16 06-Apr-2006  cherry branches: 1.16.18; 1.16.20;
Pass by reference to MD_LOADSEG(). Thanks to Matt Thomas for pointing this out.
 1.15 03-Apr-2006  cherry Encapsulated the MD test: phdr[i].p_type & PT_LOPROC out of MI code,
and into MD_LOADSEG() as suggested by Christos.
 1.14 03-Apr-2006  cherry Allows processor ABI specific ELF segment loads.
If the macro MD_LOADSEG defined in
machine/loadfile_machdep.h evaluates to 1, the machine
specific segment is loaded.

See: http://mail-index.netbsd.org/tech-kern/2005/12/30/0003.html
 1.13 25-Jan-2006  christos branches: 1.13.2; 1.13.4; 1.13.6; 1.13.8; 1.13.10;
free -> dealloc
 1.12 11-Dec-2005  christos branches: 1.12.2;
merge ktrace-lwp.
 1.11 14-Jul-2005  christos rearrange free's and add a missing one.
 1.10 26-Feb-2005  perry branches: 1.10.4;
nuke trailing whitespace
 1.9 23-Oct-2003  he branches: 1.9.8; 1.9.10;
The paddr_t type is integral, so no longer compatible with NULL,
so use 0 instead.
 1.8 31-Aug-2003  fvdl Fix signed/unsigned warnings.
 1.7 11-Feb-2002  reinoud branches: 1.7.16;
Not all ports use the `offset' in their calulations and on those platforms
compile errors are generated due to it. By explicitly using `offset=offset'
the variable is used in the compilers view and is optimised away anyway.
 1.6 09-Nov-2001  christos branches: 1.6.2; 1.6.4; 1.6.6;
Remove USB copyrights. The coff and elf loading code did not come with BSD4.4.
 1.5 09-Nov-2001  scw To avoid backwards seeks on sequential devices (eq. QIC tapes), read all
the program headers in one operation into an internal buffer.
 1.4 31-Oct-2001  thorpej Make the ELF loadfile routines byte-order independent when used in
a non-_STANDALONE environment (e.g. installboot(8)): internalize and
externalize the exec, program, and section headers as necessary.

Reviewed and OK'd by Christos.
 1.3 31-Oct-2001  thorpej Split elf32 vs. elf64 handling in loadfile(), including support for
each separately and explicitly. BOOT_ELF is now BOOT_ELF32 and
BOOT_ELF64, and ELFSIZE should no longer be defined in loadfile_machdep.h.
 1.2 31-Oct-2001  thorpej Build the loadfile() a.out, ECOFF, and ELF back-ends as separate
objects.
 1.1 30-Oct-2001  thorpej Split the exec formats included by loadfile() into separate files.
Primary goal: explcitly select which ELF format (elf32 or elf64) to
support for a cross tool which uses loadfile().
 1.6.6.3 16-Mar-2002  jdolecek Catch up with -current.
 1.6.6.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.6.6.1 09-Nov-2001  thorpej file loadfile_elf32.c was added on branch kqueue on 2002-01-10 20:00:40 +0000
 1.6.4.3 28-Feb-2002  nathanw Catch up to -current.
 1.6.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.6.4.1 09-Nov-2001  nathanw file loadfile_elf32.c was added on branch nathanw_sa on 2001-11-14 19:16:52 +0000
 1.6.2.2 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.6.2.1 09-Nov-2001  thorpej file loadfile_elf32.c was added on branch thorpej-mips-cache on 2001-11-12 21:19:05 +0000
 1.7.16.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.7.16.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.7.16.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.16.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.16.1 03-Aug-2004  skrll Sync with HEAD
 1.9.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.9.8.1 29-Apr-2005  kent sync with -current
 1.10.4.4 21-Jan-2008  yamt sync with head
 1.10.4.3 07-Dec-2007  yamt sync with head
 1.10.4.2 03-Sep-2007  yamt sync with head.
 1.10.4.1 21-Jun-2006  yamt sync with head.
 1.12.2.1 01-Feb-2006  yamt sync with head.
 1.13.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.13.8.1 19-Apr-2006  elad sync with head.
 1.13.6.1 11-Apr-2006  yamt sync with head
 1.13.4.1 22-Apr-2006  simonb Sync with head.
 1.13.2.1 09-Sep-2006  rpaulo sync with head
 1.16.20.1 11-Jul-2007  mjf Sync with head.
 1.16.18.1 09-Jun-2007  ad Sync with head.
 1.17.14.2 18-Feb-2008  mjf Sync with HEAD.
 1.17.14.1 08-Dec-2007  mjf Sync with HEAD.
 1.17.8.1 09-Jan-2008  matt sync with HEAD
 1.17.6.2 03-Dec-2007  joerg Sync with HEAD.
 1.17.6.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.20.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.21.10.4 09-Oct-2010  yamt sync with head
 1.21.10.3 11-Aug-2010  yamt sync with head.
 1.21.10.2 04-May-2009  yamt sync with head.
 1.21.10.1 16-May-2008  yamt sync with head.
 1.21.8.2 04-Jun-2008  yamt sync with head
 1.21.8.1 18-May-2008  yamt sync with head.
 1.21.6.2 28-Sep-2008  mjf Sync with HEAD.
 1.21.6.1 02-Jun-2008  mjf Sync with HEAD.
 1.22.2.2 10-Oct-2008  skrll Sync with HEAD.
 1.22.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.23.4.1 19-Oct-2008  haad Sync with HEAD.
 1.24.14.2 22-Oct-2010  uebayasi Sync with HEAD (-D20101022).
 1.24.14.1 30-Apr-2010  uebayasi Sync with HEAD.
 1.25.2.1 05-Mar-2011  rmind sync with head
 1.27.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.27.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.29.18.1 18-May-2014  rmind sync with head
 1.29.14.2 03-Dec-2017  jdolecek update from HEAD
 1.29.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.29.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.30.6.5 28-Aug-2017  skrll Sync with HEAD
 1.30.6.4 05-Feb-2017  skrll Sync with HEAD
 1.30.6.3 05-Dec-2016  skrll Sync with HEAD
 1.30.6.2 05-Oct-2016  skrll Sync with HEAD
 1.30.6.1 22-Sep-2015  skrll Sync with HEAD
 1.31.2.3 26-Apr-2017  pgoyette Sync with HEAD
 1.31.2.2 20-Mar-2017  pgoyette Sync with HEAD
 1.31.2.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.34.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.52.4.2 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.52.4.1 10-Jun-2019  christos Sync with HEAD
 1.52.2.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.55.2.1 23-Oct-2019  martin Pull up following revision(s) (requested by maxv in ticket #361):

sys/lib/libsa/loadfile_elf32.c: revision 1.56

Make sure we're dealing with a static binary. Otherwise we could crash if
the user mistakenly tries to boot a KASLR kernel with 'boot' instead of
'pkboot'. Now we fail cleanly. Reported by cryo@.
 1.1 31-Oct-2001  thorpej branches: 1.1.2; 1.1.4; 1.1.6;
Split elf32 vs. elf64 handling in loadfile(), including support for
each separately and explicitly. BOOT_ELF is now BOOT_ELF32 and
BOOT_ELF64, and ELFSIZE should no longer be defined in loadfile_machdep.h.
 1.1.6.2 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.1.6.1 31-Oct-2001  thorpej file loadfile_elf64.c was added on branch kqueue on 2002-01-10 20:00:40 +0000
 1.1.4.2 14-Nov-2001  nathanw Catch up to -current.
 1.1.4.1 31-Oct-2001  nathanw file loadfile_elf64.c was added on branch nathanw_sa on 2001-11-14 19:16:52 +0000
 1.1.2.2 12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.1.2.1 31-Oct-2001  thorpej file loadfile_elf64.c was added on branch thorpej-mips-cache on 2001-11-12 21:19:05 +0000
 1.3 11-Feb-2010  martin branches: 1.3.2; 1.3.6;
Add a prototype.
 1.2 10-Feb-2010  martin fix includes
 1.1 10-Feb-2010  martin Utility function to lookup a symbol value in an elf symbol table - allows,
for example, a bootloader to access symbols in the just loaded kernel
(or module).
 1.3.6.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.3.6.1 11-Feb-2010  uebayasi file lookup_elf32.c was added on branch uebayasi-xip on 2010-04-30 14:44:15 +0000
 1.3.2.2 11-Mar-2010  yamt sync with head
 1.3.2.1 11-Feb-2010  yamt file lookup_elf32.c was added on branch yamt-nfs-mp on 2010-03-11 15:04:22 +0000
 1.1 10-Feb-2010  martin branches: 1.1.2; 1.1.6;
Utility function to lookup a symbol value in an elf symbol table - allows,
for example, a bootloader to access symbols in the just loaded kernel
(or module).
 1.1.6.2 30-Apr-2010  uebayasi Sync with HEAD.
 1.1.6.1 10-Feb-2010  uebayasi file lookup_elf64.c was added on branch uebayasi-xip on 2010-04-30 14:44:15 +0000
 1.1.2.2 11-Mar-2010  yamt sync with head
 1.1.2.1 10-Feb-2010  yamt file lookup_elf64.c was added on branch yamt-nfs-mp on 2010-03-11 15:04:22 +0000
 1.5 20-Mar-2014  christos reduce size by 1K by sharing the ls code.
 1.4 02-Mar-2012  tsutsui branches: 1.4.2; 1.4.4;
Fix a bug that libsa ls doesn't work in case of filename with directory path.
("ls /path/and/file" always returns not found) From MINIX via Evgeniy Ivanov.
 1.3 25-Dec-2011  tsutsui branches: 1.3.2;
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.2 26-Jan-1994  mycroft branches: 1.2.108; 1.2.112;
Clean up deleted files.
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.2.112.4 06-Mar-2012  mrg sync to -current
 1.2.112.3 06-Mar-2012  mrg sync to -current
 1.2.112.2 04-Mar-2012  mrg sync to latest -current.
 1.2.112.1 18-Feb-2012  mrg merge to -current.
 1.2.108.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.108.1 17-Apr-2012  yamt sync with head
 1.3.2.1 08-Mar-2012  riz Pull up following revision(s) (requested by tsutsui in ticket #96):
sys/lib/libsa/ls.c: revision 1.4
Fix a bug that libsa ls doesn't work in case of filename with directory path.
("ls /path/and/file" always returns not found) From MINIX via Evgeniy Ivanov.
 1.4.4.1 18-May-2014  rmind sync with head
 1.4.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1 20-Mar-2014  christos branches: 1.1.4; 1.1.6; 1.1.10;
new header.
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 20-Mar-2014  tls file ls.h was added on branch tls-maxphys on 2014-08-20 00:04:30 +0000
 1.1.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.1 20-Mar-2014  yamt file ls.h was added on branch yamt-pagecache on 2014-05-22 11:41:04 +0000
 1.1.4.2 18-May-2014  rmind sync with head
 1.1.4.1 20-Mar-2014  rmind file ls.h was added on branch rmind-smpnet on 2014-05-18 17:46:08 +0000
 1.11 02-Dec-2007  tsutsui unsigned -> unsigned int
 1.10 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.9 11-Dec-2005  christos branches: 1.9.44; 1.9.46; 1.9.52;
merge ktrace-lwp.
 1.8 26-Feb-2005  perry branches: 1.8.4;
nuke trailing whitespace
 1.7 07-Aug-2003  agc branches: 1.7.8; 1.7.10;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.6 30-Mar-2000  augustss branches: 1.6.28;
Kill some more register declarations.
 1.5 31-Mar-1999  cgd branches: 1.5.8;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.4 22-Jan-1997  cgd define these functions with an 'o' prepended to their names if
__INTERNAL_LIBSA_CREAD is defined (so that they can be used by the
compressed-read code).
 1.3 21-Jun-1996  pk Allow seeks on raw devices. A `f_offset' field is added to the file structure
which is maintained in lseek(), read() and write(), and passed along to
the device's strategy routine.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.5.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.6.28.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.6.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.28.1 03-Aug-2004  skrll Sync with HEAD
 1.7.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.8.1 29-Apr-2005  kent sync with -current
 1.8.4.1 07-Dec-2007  yamt sync with head
 1.9.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.9.46.1 09-Jan-2008  matt sync with HEAD
 1.9.44.2 03-Dec-2007  joerg Sync with HEAD.
 1.9.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.12 25-Mar-2008  christos - use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.11 24-Nov-2007  isaki branches: 1.11.14;
style, indent, and ANSI-fy.
 1.10 11-Dec-2005  christos branches: 1.10.44; 1.10.46; 1.10.52;
merge ktrace-lwp.
 1.9 01-Sep-2003  dsl branches: 1.9.16;
Another attempt to get libsa to contain the right things.
- put a 'standards conforming' memcmp into memcmp.c
- make bcmp be a second label on the same code
- make bcmp.c be just #include "memcmp.c"
This means that libsa.o might contain both a memcmp.o and a bcmp.o, but
both contain the same code (defining both symbols) so it doesn't matter
which ld uses.
Saves worrying about which of bcmp.c and memcmp.c the architecture specific
Makefile requests.
 1.8 29-Aug-2003  dsl The __strong_alias() seems to have to be in the file with the definition.
So make bcmp.c define bcmp and memcmp.
This should (?) fix the atari build.
(I've now no idea why the previous change defined memcpy for the alpha build.)
 1.7 27-Aug-2003  dsl An ever sneakier way of making memcmp and bcmp use the same code:
__strong_alias(memcmp,bcmp)
 1.6 13-Nov-1999  thorpej branches: 1.6.28;
Backout my libsa changes.
 1.5 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.4 05-Oct-1997  thorpej branches: 1.4.16; 1.4.18; 1.4.22;
Copyright assigned to The NetBSD Foundation.
 1.3 26-Jun-1997  drochner branches: 1.3.4;
Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.2 13-Jun-1997  drochner Bring prototypes into scope.
 1.1 16-Jan-1997  cgd branches: 1.1.2;
add memcmp, implemented as a wrapper around bcmp() (like memcpy() is
implemented as a wrapper around bcopy()).
 1.1.2.2 18-Jan-1997  thorpej Update from trunk.
 1.1.2.1 16-Jan-1997  thorpej file memcmp.c was added on branch thorpej-setroot on 1997-01-18 04:32:09 +0000
 1.3.4.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.4.22.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.4.18.1 15-Nov-1999  fvdl Sync with -current
 1.4.16.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.6.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.6.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.6.28.1 03-Aug-2004  skrll Sync with HEAD
 1.9.16.1 07-Dec-2007  yamt sync with head
 1.10.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.10.46.1 09-Jan-2008  matt sync with HEAD
 1.10.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.11.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.8 25-Mar-2008  christos - use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.7 24-Nov-2007  isaki branches: 1.7.14;
style, indent, and ANSI-fy.
 1.6 11-Dec-2005  christos branches: 1.6.44; 1.6.46; 1.6.52;
merge ktrace-lwp.
 1.5 07-Aug-2003  agc branches: 1.5.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 30-Mar-2000  augustss branches: 1.4.28;
Kill some more register declarations.
 1.3 31-Mar-1999  cgd branches: 1.3.8;
replace memcpy() implementation (which just called bcopy()) with
a small implementation of memcpy(). libsa memcpy() wouldn't
do the right thing if LIBSA_USE_MEMCPY was defined, and the whole
point of that define is to get rid of either bcopy() or memcpy().
(cloned from the bcopy() code.)
 1.2 05-Oct-1997  thorpej Copyright assigned to The NetBSD Foundation.
 1.1 30-Jan-1996  thorpej branches: 1.1.12;
Add a memcpy() function, just a cheezy wrapper around bcopy(). Yes,
it's really true...we didn't have one before, even though the Makefile
thought we did. (Yes, I checked the Attic...)
 1.1.12.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.3.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.4.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.28.1 03-Aug-2004  skrll Sync with HEAD
 1.5.16.1 07-Dec-2007  yamt sync with head
 1.6.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.6.46.1 09-Jan-2008  matt sync with HEAD
 1.6.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.7.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.5 25-Mar-2008  christos - use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.4 24-Nov-2007  isaki branches: 1.4.14;
style, indent, and ANSI-fy.
 1.3 11-Dec-2005  christos branches: 1.3.44; 1.3.46; 1.3.52;
merge ktrace-lwp.
 1.2 07-Aug-2003  agc branches: 1.2.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 02-Sep-2001  tsutsui branches: 1.1.4; 1.1.6; 1.1.24;
Add a small version of memmove() for libsa.
Mostly identical with libsa/bcopy.c.
 1.1.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.24.1 03-Aug-2004  skrll Sync with HEAD
 1.1.6.2 21-Sep-2001  nathanw Catch up to -current.
 1.1.6.1 02-Sep-2001  nathanw file memmove.c was added on branch nathanw_sa on 2001-09-21 22:36:31 +0000
 1.1.4.2 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.1.4.1 02-Sep-2001  thorpej file memmove.c was added on branch kqueue on 2001-09-13 01:16:19 +0000
 1.2.16.1 07-Dec-2007  yamt sync with head
 1.3.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.3.46.1 09-Jan-2008  matt sync with HEAD
 1.3.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.4.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.5 25-Mar-2008  christos - use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.4 24-Nov-2007  isaki branches: 1.4.14;
style, indent, and ANSI-fy.
 1.3 13-Nov-1999  thorpej branches: 1.3.44; 1.3.100; 1.3.102; 1.3.108;
Backout my libsa changes.
 1.2 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.1 30-Mar-1999  cgd branches: 1.1.8; 1.1.10; 1.1.14;
add simple (small) implementations of memset and bzero. the versions
in libkern are fine for the kernel, but the versions here are smaller
and in libsa the point is size.
 1.1.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.1.10.1 15-Nov-1999  fvdl Sync with -current
 1.1.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.3.108.1 08-Dec-2007  mjf Sync with HEAD.
 1.3.102.1 09-Jan-2008  matt sync with HEAD
 1.3.100.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.3.44.1 07-Dec-2007  yamt sync with head
 1.4.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.13 29-Apr-2022  rin Re-introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
used instead of secsize obtained by SAIOSECSIZE ioctl.

This hack avoids divdi3 and friends from being linked, in order to
support variable secsize for some archs.

Should be useful for ancient archs, for which secsize is fixed.

Thanks christos@ for comment.
 1.12 27-Apr-2022  rin Revert previous at the moment.

This is wrong reasoning; 68020 and above (incl. 040 and 060) support
32-bit displacements for PC relative addressing (via "fully extension
addressing mode" with null index register).

I've still not figured out what goes wrong with amiga/boot(8) when
compiled without -l option for gas(1)...

On 2022/04/27 20:48, Rin Okuyama wrote:
> Module Name: src
> Committed By: rin
> Date: Wed Apr 27 11:48:26 UTC 2022
>
> Modified Files:
> src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c
>
> Log Message:
> Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
> used instead of secsize obtained by SAIOSECSIZE ioctl.
>
> This hack avoids divdi3 and friends from being linked, in order to
> support variable secsize.
>
> This is useful for amiga/boot(8); it is loaded by firmware into
> unpredictable address, and therefore all symbols should be
> addressable by PC relative mode with only 16-bit displacements.
>
> See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for
> more details.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/ext2fs.c
> cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/minixfs3.c
> cvs rdiff -u -r1.83 -r1.84 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
 1.11 27-Apr-2022  rin Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
used instead of secsize obtained by SAIOSECSIZE ioctl.

This hack avoids divdi3 and friends from being linked, in order to
support variable secsize.

This is useful for amiga/boot(8); it is loaded by firmware into
unpredictable address, and therefore all symbols should be
addressable by PC relative mode with only 16-bit displacements.

See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for
more details.
 1.10 24-Apr-2022  mlelstv Ask driver about sector size to support reading superblocks from fixed
byte offsets.
 1.9 19-Apr-2022  skrll Typo in comment. avoinds -> avoids
 1.8 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.7 20-Mar-2014  christos branches: 1.7.30;
reduce size by 1K by sharing the ls code.
 1.6 03-Nov-2013  christos make a gcc unitialized variable
 1.5 23-Jun-2013  dholland branches: 1.5.2;
Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

lblkno
lblktosize
lfragtosize
numfrags
blkroundup
fragroundup
 1.4 23-Jun-2013  dholland fsbtodb() -> FFS_FSBTODB(), EXT2_FSBTODB(), or MFS_FSBTODB()
dbtofsb() -> FFS_DBTOFSB() or EXT2_DBTOFSB()

(Christos already did the lfs ones a few days back)
 1.3 19-Jun-2013  dholland blkoff() -> mfs_blkoff()

XXX: this shouldn't be using "mfs" for its symbols as we also have
XXX: sys/ufs/mfs.
 1.2 19-Jun-2013  dholland Rename ambiguous macros:
MAXDIRSIZE -> UFS_MAXDIRSIZE or LFS_MAXDIRSIZE
NINDIR -> FFS_NINDIR, EXT2_NINDIR, LFS_NINDIR, or MFS_NINDIR
INOPB -> FFS_INOPB, LFS_INOPB
INOPF -> FFS_INOPF, LFS_INOPF
blksize -> ffs_blksize, ext2_blksize, or lfs_blksize
sblksize -> ffs_blksize

These are not the only ambiguously defined filesystem macros, of
course, there's a pile more. I may not have found all the ambiguous
definitions of blksize(), too, as there are a lot of other things
called 'blksize' in the system.
 1.1 16-Jan-2012  christos branches: 1.1.4; 1.1.6; 1.1.10;
PR/45796: Evgeniy Ivanov minixfs3 support.
Split out fn_match since we have 3 copies now.
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 23-Jun-2013  tls resync from head
 1.1.6.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.2 17-Apr-2012  yamt sync with head
 1.1.6.1 16-Jan-2012  yamt file minixfs3.c was added on branch yamt-pagecache on 2012-04-17 00:08:33 +0000
 1.1.4.2 18-Feb-2012  mrg merge to -current.
 1.1.4.1 16-Jan-2012  mrg file minixfs3.c was added on branch jmcneill-usbmp on 2012-02-18 07:35:35 +0000
 1.5.2.1 18-May-2014  rmind sync with head
 1.7.30.1 10-Jun-2019  christos Sync with HEAD
 1.5 23-Jun-2013  dholland Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

lblkno
lblktosize
lfragtosize
numfrags
blkroundup
fragroundup
 1.4 23-Jun-2013  dholland fsbtodb() -> FFS_FSBTODB(), EXT2_FSBTODB(), or MFS_FSBTODB()
dbtofsb() -> FFS_DBTOFSB() or EXT2_DBTOFSB()

(Christos already did the lfs ones a few days back)
 1.3 19-Jun-2013  dholland blkoff() -> mfs_blkoff()

XXX: this shouldn't be using "mfs" for its symbols as we also have
XXX: sys/ufs/mfs.
 1.2 19-Jun-2013  dholland Rename ambiguous macros:
MAXDIRSIZE -> UFS_MAXDIRSIZE or LFS_MAXDIRSIZE
NINDIR -> FFS_NINDIR, EXT2_NINDIR, LFS_NINDIR, or MFS_NINDIR
INOPB -> FFS_INOPB, LFS_INOPB
INOPF -> FFS_INOPF, LFS_INOPF
blksize -> ffs_blksize, ext2_blksize, or lfs_blksize
sblksize -> ffs_blksize

These are not the only ambiguously defined filesystem macros, of
course, there's a pile more. I may not have found all the ambiguous
definitions of blksize(), too, as there are a lot of other things
called 'blksize' in the system.
 1.1 16-Jan-2012  christos branches: 1.1.4; 1.1.6; 1.1.10;
PR/45796: Evgeniy Ivanov minixfs3 support.
Split out fn_match since we have 3 copies now.
 1.1.10.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.10.1 23-Jun-2013  tls resync from head
 1.1.6.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.2 17-Apr-2012  yamt sync with head
 1.1.6.1 16-Jan-2012  yamt file minixfs3.h was added on branch yamt-pagecache on 2012-04-17 00:08:33 +0000
 1.1.4.2 18-Feb-2012  mrg merge to -current.
 1.1.4.1 16-Jan-2012  mrg file minixfs3.h was added on branch jmcneill-usbmp on 2012-02-18 07:35:35 +0000
 1.36 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.35 11-Apr-2009  lukem branches: 1.35.64;
fix sign-compare issue
 1.34 31-Jan-2009  isaki branches: 1.34.2;
Revert previous one. It has already fixed in net.h,v 1.25.
 1.33 31-Jan-2009  isaki Fix build error. Declare getsecs() before (re-)defining it.
 1.32 12-Jan-2009  tsutsui Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.31 24-Nov-2007  isaki branches: 1.31.14; 1.31.18; 1.31.26;
style, indent, and ANSI-fy.
 1.30 21-Jan-2006  dsl branches: 1.30.42; 1.30.44; 1.30.50;
Adjust code so that it will work when _STANDALONE isn't defined.
Allows it to be used for mount_nfs when SMALL is set - eg install floppies/
 1.29 11-Dec-2005  christos branches: 1.29.2;
merge ktrace-lwp.
 1.28 31-Aug-2003  fvdl branches: 1.28.16;
Fix signed/unsigned warnings.
 1.27 25-Oct-2000  thorpej branches: 1.27.24;
Split the UDP routines out of net.c.
 1.26 30-Mar-2000  augustss Kill some more register declarations.
 1.25 13-Nov-1999  thorpej Backout my libsa changes.
 1.24 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.23 07-May-1999  drochner branches: 1.23.2; 1.23.4; 1.23.8;
move intoa() from libsa:net.c to libkern, turn inet_ntoa() into a macro,
nuke ip_convertaddr()
 1.22 12-Apr-1999  ross libkern just got an inet_addr(), but it won't compile, no prototype. Cleanup...
* Add prototype to libkern.h.
* Remove the almost-identical-copy from libsa/net.[ch].
* Change its type back to the (wrong, but harmless) historical one. (u_long)
* Kill the XXX local prototype in nfs_bootparam.c
 1.21 11-Feb-1999  pk branches: 1.21.4;
Add missing prototypes.
 1.20 26-Dec-1997  scottr If the send routine returns an error (-1), wait and retry using the same
backoff mechanism we use for receiving the response. This is particularly
helpful when we have transient errors on transmit, e.g. a very busy
network or router.
 1.19 17-Sep-1997  drochner branches: 1.19.2;
Save some bytes by keeping the number of byteswaps minimal.
Allow to switch off UDP checksum generation and check via compile time
option (for the really desperade).
 1.18 06-Sep-1997  drochner -Wall fixes
 1.17 07-Jul-1997  drochner branches: 1.17.2;
Don't use private copy of old netinet/if_ether.h.
Use <net/if_ether.h> for ethernet specific definitions, and insert private
definitions for ARP if needed. (The new ARP macros in <net/if_arp.h> are
not used because they create larger code, and we really don't need more
than ethernet/ip support here.)
 1.16 26-Jun-1997  drochner Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.15 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.14 13-Oct-1996  christos branches: 1.14.6;
backout previous kprintf changes
 1.13 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.12 13-Dec-1995  pk Make `time difference' a signed quantity explicitly.
 1.11 29-Nov-1995  thorpej Use bzero() instead of memset(..., 0, ...).
 1.10 21-Nov-1995  cgd make netinet work on systems where pointers and longs are 64 bits
(like the alpha). Biggest problem: IP headers were overlayed with
structure which included pointers, and which therefore didn't overlay
properly on 64-bit machines. Solution: instead of threading pointers
through IP header overlays, add a "queue element" structure to do
the threading, and point it at the ip headers.
 1.9 23-Sep-1995  thorpej Add an inet_addr() function; return network-order numeric representation
of an IP address from `aa.bb.cc.dd'-style text input.
 1.8 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.7 17-Sep-1995  pk Revert fs_ops read/write declarations; these return error numbers.
Get rid of some more compiler warnings.
Set errno where appropriate.
 1.6 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.5 11-Sep-1995  thorpej Changes from Gordon Ross:
a) check against `my' ethernet or broadcast addresses done in
ether.c
b) changed interface to readether() to provide ethertype info
c) respond to arp requests when appropriate.
First two are clean-up. Last fixes hp300 and presumably mvme68k netboot
code.
 1.4 20-Feb-1995  mycroft Various:
* Fix some misused types.
* Encapsulate the protocols better.
* Rearrange the RPC stuff to work more like the kernel. (Needs more work.)
* Remove a bunch of extra hair when reading a file over NFS.
* Use RPCAUTH_UNIX when talking to the NFS server.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 04-Aug-1994  brezak branches: 1.2.2;
Make libsa compile again by not including sys/errno.h
 1.1 08-May-1994  brezak branches: 1.1.2;
Standalone networking for network boot loaders.
 1.1.2.1 05-Aug-1994  mycroft update from trunk, per Brezak
 1.2.2.2 04-Aug-1994  brezak Make libsa compile again by not including sys/errno.h
 1.2.2.1 04-Aug-1994  brezak file net.c was added on branch netbsd-1-0 on 1994-08-04 19:39:36 +0000
 1.14.6.1 07-Mar-1997  is Use the local copy of the old-style if_ether.h for the moment, til we have
time to modernize the libsa ARP support.
 1.17.2.2 22-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.17.2.1 06-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.19.2.1 26-Dec-1997  perry pull up from trunk (scottr)
 1.21.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.23.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.23.4.1 15-Nov-1999  fvdl Sync with -current
 1.23.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.23.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.27.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.27.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.27.24.1 03-Aug-2004  skrll Sync with HEAD
 1.28.16.2 07-Dec-2007  yamt sync with head
 1.28.16.1 21-Jun-2006  yamt sync with head.
 1.29.2.1 01-Feb-2006  yamt sync with head.
 1.30.50.1 08-Dec-2007  mjf Sync with HEAD.
 1.30.44.1 09-Jan-2008  matt sync with HEAD
 1.30.42.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.31.26.2 28-Apr-2009  skrll Sync with HEAD.
 1.31.26.1 19-Jan-2009  skrll Sync with HEAD.
 1.31.18.1 04-May-2009  yamt sync with head.
 1.31.14.1 17-Jan-2009  mjf Sync with HEAD.
 1.34.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.35.64.1 10-Jun-2019  christos Sync with HEAD
 1.28 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.27 29-Mar-2014  jakllsch branches: 1.27.30;
Obtain and/or use ETHER_ADDR_LEN.
 1.26 11-May-2011  zoltan branches: 1.26.4; 1.26.14; 1.26.18;
Separate the IP and UDP code paths inside libsa, so I can add HTTP booting
later.
 1.25 18-Jan-2009  tsutsui branches: 1.25.6; 1.25.8;
I really hate silly hacks inside #ifndef _STANDALONE in libsa sources...
 1.24 17-Jan-2009  tsutsui Remove __P().
 1.23 12-Jan-2009  tsutsui Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.22 25-Mar-2008  christos branches: 1.22.4; 1.22.12;
fix typo
 1.21 25-Mar-2008  christos - use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.20 24-Nov-2007  isaki branches: 1.20.14;
style, indent, and ANSI-fy.
 1.19 24-Jan-2006  christos branches: 1.19.42; 1.19.44; 1.19.50;
PR/32613: Yves-Emmanuel JUTARD: Incoherencies in file sys/lib/libsa/net.h
- Make prototype of ether_sprintf() match the one in sys/net.
- Rename in_cksum to ip_cksum and fix its prototype. in_cksum() operates
on an mbuf and ip_cksum() operates on a plain buffer. We should not call
functions that operate on different arguments the same name (this is not
c++).
 1.18 22-Jan-2006  dsl If _STANDALONE is defined, #include </lib/libsa/iodesc.h> instead of requiring
that the source that #includes net.h have lib/libsa in its include path.
In the non-_STANDALONE case make it easy for the user to supply their own iodesc.h.
 1.17 21-Jan-2006  dsl Adjust code so that it will work when _STANDALONE isn't defined.
Allows it to be used for mount_nfs when SMALL is set - eg install floppies/
 1.16 11-Dec-2005  christos branches: 1.16.2;
merge ktrace-lwp.
 1.15 26-Feb-2005  perry branches: 1.15.4;
nuke trailing whitespace
 1.14 19-Mar-2003  drochner branches: 1.14.2; 1.14.10; 1.14.12;
remove stuff just moved to bootparam.c and some variables which are
never used.
 1.13 07-May-1999  drochner move intoa() from libsa:net.c to libkern, turn inet_ntoa() into a macro,
nuke ip_convertaddr()
 1.12 12-Apr-1999  ross libkern just got an inet_addr(), but it won't compile, no prototype. Cleanup...
* Add prototype to libkern.h.
* Remove the almost-identical-copy from libsa/net.[ch].
* Change its type back to the (wrong, but harmless) historical one. (u_long)
* Kill the XXX local prototype in nfs_bootparam.c
 1.11 11-Feb-1999  pk branches: 1.11.4;
Add missing prototypes.
 1.10 20-Oct-1995  cgd fix spacing in header 'room to leave' comment
 1.9 23-Sep-1995  thorpej Add an inet_addr() function; return network-order numeric representation
of an IP address from `aa.bb.cc.dd'-style text input.
 1.8 23-Sep-1995  gwr Fix/improve some comments.
 1.7 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.6 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.5 11-Sep-1995  thorpej Changes from Gordon Ross:
a) check against `my' ethernet or broadcast addresses done in
ether.c
b) changed interface to readether() to provide ethertype info
c) respond to arp requests when appropriate.
First two are clean-up. Last fixes hp300 and presumably mvme68k netboot
code.
 1.4 27-Jun-1995  gwr Pad HEADER_SIZE for alignment.
 1.3 20-Feb-1995  mycroft Various:
* Fix some misused types.
* Encapsulate the protocols better.
* Rearrange the RPC stuff to work more like the kernel. (Needs more work.)
* Remove a bunch of extra hair when reading a file over NFS.
* Use RPCAUTH_UNIX when talking to the NFS server.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.11.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.14.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.14.10.1 29-Apr-2005  kent sync with -current
 1.14.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.15.4.2 07-Dec-2007  yamt sync with head
 1.15.4.1 21-Jun-2006  yamt sync with head.
 1.16.2.1 01-Feb-2006  yamt sync with head.
 1.19.50.1 08-Dec-2007  mjf Sync with HEAD.
 1.19.44.1 09-Jan-2008  matt sync with HEAD
 1.19.42.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.20.14.2 17-Jan-2009  mjf Sync with HEAD.
 1.20.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.22.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.22.4.1 04-May-2009  yamt sync with head.
 1.25.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.25.6.1 31-May-2011  rmind sync with head
 1.26.18.1 18-May-2014  rmind sync with head
 1.26.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.27.30.1 10-Jun-2019  christos Sync with HEAD
 1.27 14-Sep-2023  rin netif_open: Fail with ENXIO instead of panic if no netif available

Avoid undesirable freeze for efiboot/x86 when interfaces are really
unavailable, or fail to be configured by buggy UEFI firmware.
 1.26 31-Mar-2019  christos branches: 1.26.30;
fix warnings, printf formats, etc.
 1.25 20-Oct-2013  christos branches: 1.25.30;
remove unused
 1.24 17-Jan-2009  tsutsui branches: 1.24.14; 1.24.24; 1.24.28;
Remove __P().
 1.23 12-Jan-2009  tsutsui Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.22 25-Mar-2008  christos branches: 1.22.4; 1.22.12;
- use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.21 24-Nov-2007  isaki branches: 1.21.14;
style, indent, and ANSI-fy.
 1.20 11-Dec-2005  christos branches: 1.20.44; 1.20.46; 1.20.52;
merge ktrace-lwp.
 1.19 26-Feb-2005  perry branches: 1.19.4;
nuke trailing whitespace
 1.18 12-Mar-2003  drochner branches: 1.18.2; 1.18.10; 1.18.12;
separate the netif interface from the rest of the networking code,
so that it can be replaced easily in md code
 1.17 27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.16 15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.15 30-Mar-2000  augustss branches: 1.15.6; 1.15.8;
Kill some more register declarations.
 1.14 13-Nov-1999  thorpej Backout my libsa changes.
 1.13 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.12 31-Mar-1999  cgd branches: 1.12.8; 1.12.10; 1.12.14;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.11 11-Feb-1999  pk Add missing prototypes.
 1.10 06-Sep-1997  drochner -Wall fixes
 1.9 26-Jun-1997  drochner branches: 1.9.4;
Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.8 13-Jun-1997  drochner -Wall fixes
 1.7 13-Oct-1996  christos backout previous kprintf changes
 1.6 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.5 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.4 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.3 20-Feb-1995  mycroft Define netif_debug in here.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.9.4.1 06-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.12.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.10.1 15-Nov-1999  fvdl Sync with -current
 1.12.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.15.8.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.15.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.6.2 18-Oct-2002  nathanw Catch up to -current.
 1.15.6.1 08-Jan-2002  nathanw Catch up to -current.
 1.18.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.18.10.1 29-Apr-2005  kent sync with -current
 1.18.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.19.4.1 07-Dec-2007  yamt sync with head
 1.20.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.20.46.1 09-Jan-2008  matt sync with HEAD
 1.20.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.21.14.2 17-Jan-2009  mjf Sync with HEAD.
 1.21.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.22.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.22.4.1 04-May-2009  yamt sync with head.
 1.24.28.1 18-May-2014  rmind sync with head
 1.24.24.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.14.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.25.30.1 10-Jun-2019  christos Sync with HEAD
 1.26.30.1 21-Jun-2024  martin Pull up following revision(s) (requested by rin in ticket #716):

sys/lib/libsa/netif.c: revision 1.27

netif_open: Fail with ENXIO instead of panic if no netif available

Avoid undesirable freeze for efiboot/x86 when interfaces are really
unavailable, or fail to be configured by buggy UEFI firmware.
 1.8 27-Feb-2024  christos Put the standard NetBSD copyright on this file. Approved by John Brezak
via a message on LinkedIn.
 1.7 17-Jan-2009  tsutsui Remove __P().
 1.6 12-Jan-2009  tsutsui Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.5 12-Mar-2003  drochner branches: 1.5.100; 1.5.104; 1.5.114;
separate the netif interface from the rest of the networking code,
so that it can be replaced easily in md code
 1.4 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.3 03-Sep-1995  pk Add a driver hook to the `netif' structure.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.5.114.1 19-Jan-2009  skrll Sync with HEAD.
 1.5.104.1 04-May-2009  yamt sync with head.
 1.5.100.1 17-Jan-2009  mjf Sync with HEAD.
 1.53 29-Jun-2024  rin libsa/nfs.c: Add `LIBSA_NFS_IMPLICIT_MOUNT` compile-time option

by which nfs_mount() is automatically called from nfs_open(),
as done for nfs.c in i386/stand.

This is only functional difference b/w two copies of nfs.c.
Now, we can safely retire the latter.

XXX
It would be really nice to drop this option also. However,
unfortunately, it is too much for me at the very moment...
 1.52 14-Dec-2023  rin libsa: nfs: Fix NFS_NOSYMLINK option for previous

Used only by mvme68k.
 1.51 12-Dec-2023  mlelstv Add NFSv3 support. Try NFSv3 and fall back to NFSv2.
 1.50 26-Jan-2020  skrll branches: 1.50.24;
Make a debug printf compile for all platforms
 1.49 31-Mar-2019  christos branches: 1.49.6;
fix warnings, printf formats, etc.
 1.48 20-Mar-2014  christos branches: 1.48.30;
reduce size by 1K by sharing the ls code.
 1.47 25-Dec-2011  tsutsui branches: 1.47.6; 1.47.10;
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.46 16-Jun-2011  joerg branches: 1.46.2; 1.46.6;
Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.45 17-Jan-2009  tsutsui branches: 1.45.12;
Remove __P().
 1.44 19-Nov-2008  ad For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.43 25-Mar-2008  christos branches: 1.43.4; 1.43.10; 1.43.12;
- use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.42 24-Nov-2007  isaki branches: 1.42.14;
style, indent, and ANSI-fy.
 1.41 25-Feb-2007  uwe branches: 1.41.16; 1.41.18; 1.41.24;
Add missing newlines to debug messages.
 1.40 29-Dec-2006  yamt branches: 1.40.2;
remove nqnfs from comments. from Arnaud Lacombe.
(no functional changes.)
 1.39 25-Jan-2006  christos branches: 1.39.18;
free -> dealloc
 1.38 11-Dec-2005  christos branches: 1.38.2;
merge ktrace-lwp.
 1.37 26-Feb-2005  perry branches: 1.37.4;
nuke trailing whitespace
 1.36 04-Sep-2003  he branches: 1.36.8; 1.36.10;
Um, undo last; libsa printf doesn't do %z.
 1.35 04-Sep-2003  he Use the %zu format for size_t printing instead of cast + %lu.
 1.34 03-Sep-2003  he Cast size_t to u_long before printing, and use %lu instead of %d as format.
Fixes compilation on alpha.
 1.33 31-Aug-2003  fvdl Fix signed/unsigned warnings.
 1.32 18-Aug-2003  dsl make 'path' argument to ufs_open 'const char *' and fix the fallout.
 1.31 18-Mar-2003  mycroft branches: 1.31.2;
Move some stuff into .rodata.
 1.30 12-Mar-2003  drochner no need to include "netif.h" anymore
(shared interface stuff is in iodesc.h, included by net.h)
 1.29 30-Mar-2000  augustss Kill some more register declarations.
 1.28 23-Nov-1999  simonb Remove leading '/' from pathnames, using same logic as ufs.c. Allows new
style (but not yet committed) pmax bootblocks to open "/boot.pmax" on an
ISO image. Same problem reported for NFS by Jason Thorpe.
 1.27 13-Nov-1999  thorpej Backout my libsa changes.
 1.26 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.25 31-Mar-1999  cgd branches: 1.25.8; 1.25.10; 1.25.14;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.24 11-Feb-1999  pk Add missing prototypes.
 1.23 23-Jan-1998  thorpej Fix some debugging printf formats.
 1.22 26-Jun-1997  drochner Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.21 16-Jun-1997  drochner Conditionally compile without symlink support (#ifdef NFS_NOSYMLINK).
Saves 708 bytes (i386). (close pr misc/3335)
 1.20 27-Dec-1996  pk Add missing `#ifdef NFS_DEBUG' (from Rolf Grossmann; PR#3061).
 1.19 13-Oct-1996  christos backout previous kprintf changes
 1.18 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.17 02-Oct-1996  cgd fix several endianness bugs that caused name lookup (!!) and symlink
expansion to fail on little-endian machines.
 1.16 30-Sep-1996  ws Add support for booting from cd9660 fs
Support directory traversal and symbolic links for nfs booting
Close device when file opening failed
Plug memory leak in ufs code
 1.15 14-May-1996  leo Fix gcc -Wall warnings about printf arguments.
 1.14 26-Feb-1996  gwr Make this code independent of <sys/nfs> now that we use very little
from there anyway, so we can ignore changes in the NFS code...
 1.13 26-Feb-1996  scottr Make these build again in the wake of the v3 changes
 1.12 23-Sep-1995  gwr More cleanup: change some private types to eliminate casts,
replace some "goto xxx" with return(-1). (mostly cosmetic)
 1.11 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.10 17-Sep-1995  pk Revert fs_ops read/write declarations; these return error numbers.
Get rid of some more compiler warnings.
Set errno where appropriate.
 1.9 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.8 03-Jul-1995  gwr Can not use htonl() in static initializers. (Fixes PR 1188)
 1.7 27-Jun-1995  gwr Re-work for new rpc interface, and simplify a bit.
 1.6 20-Feb-1995  mycroft Various:
* Fix some misused types.
* Encapsulate the protocols better.
* Rearrange the RPC stuff to work more like the kernel. (Needs more work.)
* Remove a bunch of extra hair when reading a file over NFS.
* Use RPCAUTH_UNIX when talking to the NFS server.
 1.5 19-Feb-1995  mycroft Adjust the attribute info size for our NFS code.
 1.4 26-Oct-1994  cgd new RCS ID format.
 1.3 22-Aug-1994  brezak branches: 1.3.2;
Cleanup to make more ANSI compliant; checkpoint
 1.2 20-Jun-1994  glass make it compile w/4.4-lite header file changes
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.3.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.3.2.1 22-Aug-1994  brezak file nfs.c was added on branch netbsd-1-0 on 1994-08-22 21:56:09 +0000
 1.25.14.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.25.10.1 15-Nov-1999  fvdl Sync with -current
 1.25.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.31.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.31.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.31.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.31.2.1 03-Aug-2004  skrll Sync with HEAD
 1.36.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.36.8.1 29-Apr-2005  kent sync with -current
 1.37.4.4 07-Dec-2007  yamt sync with head
 1.37.4.3 26-Feb-2007  yamt sync with head.
 1.37.4.2 30-Dec-2006  yamt sync with head.
 1.37.4.1 21-Jun-2006  yamt sync with head.
 1.38.2.1 01-Feb-2006  yamt sync with head.
 1.39.18.1 12-Jan-2007  ad Sync with head.
 1.40.2.1 27-Feb-2007  yamt - sync with head.
- move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
 1.41.24.1 08-Dec-2007  mjf Sync with HEAD.
 1.41.18.1 09-Jan-2008  matt sync with HEAD
 1.41.16.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.42.14.2 17-Jan-2009  mjf Sync with HEAD.
 1.42.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.43.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.43.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.43.4.1 04-May-2009  yamt sync with head.
 1.45.12.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.46.6.1 18-Feb-2012  mrg merge to -current.
 1.46.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.46.2.1 17-Apr-2012  yamt sync with head
 1.47.10.1 18-May-2014  rmind sync with head
 1.47.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.48.30.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.48.30.1 10-Jun-2019  christos Sync with HEAD
 1.49.6.1 29-Feb-2020  ad Sync with head.
 1.50.24.1 20-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #894):

sys/arch/i386/stand/Makefile.booters: revision 1.98
sys/lib/libsa/nfsv3.h: revision 1.1
sys/lib/libsa/rpcv2.h: revision 1.4
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.23
sys/lib/libsa/nfsv2.h: revision 1.5
sys/lib/libsa/nfs.c: revision 1.51
sys/lib/libsa/nfs.c: revision 1.52
sys/arch/i386/stand/libsa/nfs.c: file removal
sys/lib/libsa/nfs.c: revision 1.53
sys/arch/i386/stand/libsa/nfs.c: revision 1.20
sys/arch/i386/stand/libsa/nfs.c: revision 1.21
sys/arch/i386/stand/pxeboot/Makefile: revision 1.29

Add NFSv3 support. Try NFSv3 and fall back to NFSv2.

Merge with generic libsa NFS code to minimize differences and to learn NFSv3.

libsa: nfs: Fix NFS_NOSYMLINK option for previous
Used only by mvme68k.

Align again with libsa (NFS_NOSYMLINK fix).

libsa/nfs.c: Add `LIBSA_NFS_IMPLICIT_MOUNT` compile-time option
by which nfs_mount() is automatically called from nfs_open(),
as done for nfs.c in i386/stand.

This is only functional difference b/w two copies of nfs.c.
Now, we can safely retire the latter.
XXX
It would be really nice to drop this option also. However,
unfortunately, it is too much for me at the very moment...

i386: stand: Retire its own nfs.c, and switch to libsa/nfs.c. NFC
 1.8 11-Dec-2005  christos merge ktrace-lwp.
 1.7 18-Aug-2003  dsl make 'path' argument to ufs_open 'const char *' and fix the fallout.
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.5 10-Jul-1996  cgd branches: 1.5.62;
nfs_read and nfs_write return 'int' rather than ssize_t.
 1.4 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.3 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.5.62.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.62.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.62.1 03-Aug-2004  skrll Sync with HEAD
 1.5 12-Dec-2023  mlelstv Add NFSv3 support. Try NFSv3 and fall back to NFSv2.
 1.4 11-Dec-2005  christos branches: 1.4.194;
merge ktrace-lwp.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 26-Feb-1996  gwr branches: 1.2.64;
Make this code independent of <sys/nfs> now that we use very little
from there anyway, so we can ignore changes in the NFS code...
 1.1 26-Feb-1996  scottr Needed for NFS booting; we aren't likely to use v3 here any time soon.
 1.2.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.64.1 03-Aug-2004  skrll Sync with HEAD
 1.4.194.1 20-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #894):

sys/arch/i386/stand/Makefile.booters: revision 1.98
sys/lib/libsa/nfsv3.h: revision 1.1
sys/lib/libsa/rpcv2.h: revision 1.4
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.23
sys/lib/libsa/nfsv2.h: revision 1.5
sys/lib/libsa/nfs.c: revision 1.51
sys/lib/libsa/nfs.c: revision 1.52
sys/arch/i386/stand/libsa/nfs.c: file removal
sys/lib/libsa/nfs.c: revision 1.53
sys/arch/i386/stand/libsa/nfs.c: revision 1.20
sys/arch/i386/stand/libsa/nfs.c: revision 1.21
sys/arch/i386/stand/pxeboot/Makefile: revision 1.29

Add NFSv3 support. Try NFSv3 and fall back to NFSv2.

Merge with generic libsa NFS code to minimize differences and to learn NFSv3.

libsa: nfs: Fix NFS_NOSYMLINK option for previous
Used only by mvme68k.

Align again with libsa (NFS_NOSYMLINK fix).

libsa/nfs.c: Add `LIBSA_NFS_IMPLICIT_MOUNT` compile-time option
by which nfs_mount() is automatically called from nfs_open(),
as done for nfs.c in i386/stand.

This is only functional difference b/w two copies of nfs.c.
Now, we can safely retire the latter.
XXX
It would be really nice to drop this option also. However,
unfortunately, it is too much for me at the very moment...

i386: stand: Retire its own nfs.c, and switch to libsa/nfs.c. NFC
 1.1 12-Dec-2023  mlelstv branches: 1.1.4;
Add NFSv3 support. Try NFSv3 and fall back to NFSv2.
 1.1.4.2 20-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #894):

sys/arch/i386/stand/Makefile.booters: revision 1.98
sys/lib/libsa/nfsv3.h: revision 1.1
sys/lib/libsa/rpcv2.h: revision 1.4
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.23
sys/lib/libsa/nfsv2.h: revision 1.5
sys/lib/libsa/nfs.c: revision 1.51
sys/lib/libsa/nfs.c: revision 1.52
sys/arch/i386/stand/libsa/nfs.c: file removal
sys/lib/libsa/nfs.c: revision 1.53
sys/arch/i386/stand/libsa/nfs.c: revision 1.20
sys/arch/i386/stand/libsa/nfs.c: revision 1.21
sys/arch/i386/stand/pxeboot/Makefile: revision 1.29

Add NFSv3 support. Try NFSv3 and fall back to NFSv2.

Merge with generic libsa NFS code to minimize differences and to learn NFSv3.

libsa: nfs: Fix NFS_NOSYMLINK option for previous
Used only by mvme68k.

Align again with libsa (NFS_NOSYMLINK fix).

libsa/nfs.c: Add `LIBSA_NFS_IMPLICIT_MOUNT` compile-time option
by which nfs_mount() is automatically called from nfs_open(),
as done for nfs.c in i386/stand.

This is only functional difference b/w two copies of nfs.c.
Now, we can safely retire the latter.
XXX
It would be really nice to drop this option also. However,
unfortunately, it is too much for me at the very moment...

i386: stand: Retire its own nfs.c, and switch to libsa/nfs.c. NFC
 1.1.4.1 12-Dec-2023  martin file nfsv3.h was added on branch netbsd-10 on 2024-09-20 11:31:31 +0000
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 11-Nov-1999  thorpej Networking routines needed for libsa to be self-contained.
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 11-Nov-1999  thorpej Networking routines needed for libsa to be self-contained.
 1.12 20-Mar-2014  christos reduce size by 1K by sharing the ls code.
 1.11 25-Dec-2011  tsutsui branches: 1.11.6; 1.11.10;
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.10 16-Jun-2011  joerg branches: 1.10.2; 1.10.6;
Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.9 11-Dec-2005  christos branches: 1.9.108;
merge ktrace-lwp.
 1.8 26-Feb-2005  perry nuke trailing whitespace
 1.7 18-Aug-2003  dsl branches: 1.7.8; 1.7.10;
make 'path' argument to ufs_open 'const char *' and fix the fallout.
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.5 10-Apr-2003  dsl branches: 1.5.2;
Fix prototypes of null_read and null_write, change to return errno values.
This code can't actually be used anywhere! I don't think its obvious use
would compile!
 1.4 28-May-2002  bjh21 Implement LIBSA_NO_FS_CLOSE, LIBSA_NO_FS_WRITE and LIBSA_NO_FS_SEEK.
LIBSA_NO_FS_SYMLINK and LIBSA_FS_SINGLECOMPONENT are irrelevant here.
 1.3 28-May-2002  bjh21 KNF.
 1.2 31-Mar-1999  cgd branches: 1.2.20; 1.2.22; 1.2.34;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.1 13-Jan-1996  leo Some files containing more than one function are split. This reduces the
size of the resulting loader. The read_inode() function now returns the
result of the strategy function instead of success in all cases (ufs.c).
Fixes pr#1817
 1.2.34.1 30-May-2002  gehenna Catch up with -current.
 1.2.22.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.2.20.1 20-Jun-2002  nathanw Catch up to -current.
 1.5.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.7.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.7.8.1 29-Apr-2005  kent sync with -current
 1.9.108.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.10.6.1 18-Feb-2012  mrg merge to -current.
 1.10.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.10.2.1 17-Apr-2012  yamt sync with head
 1.11.10.1 18-May-2014  rmind sync with head
 1.11.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.26 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.25 11-Dec-2005  christos branches: 1.25.44; 1.25.46; 1.25.52;
merge ktrace-lwp.
 1.24 26-Feb-2005  perry branches: 1.24.4;
nuke trailing whitespace
 1.23 07-Aug-2003  agc branches: 1.23.8; 1.23.10;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.22 01-Feb-2003  dsl branches: 1.22.2;
Beautify a little
 1.21 23-Feb-2002  thorpej Move files[] from open.c to globals.c, so that it's possible to
use libsa in an application where there are no file systems or
devices.
 1.20 30-Mar-2000  augustss branches: 1.20.6; 1.20.8;
Kill some more register declarations.
 1.19 31-Mar-1999  cgd branches: 1.19.8;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.18 26-Mar-1999  simonb Don't call f_dev->dv_close if it's a null pointer when an open() call
fails.
 1.17 22-Sep-1998  ross Make sure ctags(1) indexes oopen().
 1.16 28-Jan-1997  pk Initialize `f_offset'.
 1.15 25-Jan-1997  cgd Change file system file-open semantics slightly: if file system returns
EINVAL, that error code is ignored, leaving whatever other meaningful
error code that might have previously been returned intact. Stand-alone
file system implementations return EINVAL typically when the file system
is not recognized (i.e. cd9660_open on a UFS file system, ufs_open on a
cd9660 file system, etc.). This meant that if you had multiple file
systems in a file system switch, the first returned ENOENT (because
it recognized the file system type, but the file wasn't there) and
the second returned EINVAL (because it didn't recognize the file system
type), errno would be set to EINVAL. Now it'll be set to ENOENT.

It would probably make sense to have file systems return a special
error code to indicate "this file system is unrecognized," which
could then be special-cased, but that's a fair bit more invasive.
 1.14 22-Jan-1997  cgd define these functions with an 'o' prepended to their names if
__INTERNAL_LIBSA_CREAD is defined (so that they can be used by the
compressed-read code).
 1.13 17-Jan-1997  cgd only call the device close routine on a (fall-through) error if
F_NODEV isn't set in the file flags for the file being opened.
Pointed out by Matthias Drochner in PR 3122. (fix equivalent to
the one he included, but stylistically different.)
 1.12 30-Sep-1996  ws Add support for booting from cd9660 fs
Support directory traversal and symbolic links for nfs booting
Close device when file opening failed
Plug memory leak in ufs code
 1.11 21-Jun-1996  pk Return useful file descriptor when opening a raw device.
 1.10 13-Jan-1996  leo Some files containing more than one function are split. This reduces the
size of the resulting loader. The read_inode() function now returns the
result of the strategy function instead of success in all cases (ufs.c).
Fixes pr#1817
 1.9 19-Sep-1995  thorpej Assume that if devopen() points `file' at a NULL that a raw device was
opened (as opposed to only checking to see if `file' itself is NULL).
 1.8 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.7 06-Sep-1995  pk Avoid calling device-close routine when open() not completed. Otherwise you
lose if this sequence occurs: open()->devopen()->...->panic()->closeall().
 1.6 22-Apr-1995  cgd various attribute poisoning, don't be as quick to specify size of files[]
 1.5 26-Oct-1994  cgd new RCS ID format.
 1.4 18-Jul-1994  pk branches: 1.4.2;
Avoid descriptor leakage.
 1.3 08-May-1994  brezak branches: 1.3.2;
Standalone networking for network boot loaders.
 1.2 01-Mar-1994  pk set errno.
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.3.2.1 27-Jul-1994  cgd update from trunk.
 1.4.2.2 18-Jul-1994  pk Avoid descriptor leakage.
 1.4.2.1 18-Jul-1994  pk file open.c was added on branch netbsd-1-0 on 1994-07-18 18:41:13 +0000
 1.19.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.20.8.1 16-Mar-2002  jdolecek Catch up with -current.
 1.20.6.1 28-Feb-2002  nathanw Catch up to -current.
 1.22.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.22.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.22.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.22.2.1 03-Aug-2004  skrll Sync with HEAD
 1.23.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.23.8.1 29-Apr-2005  kent sync with -current
 1.24.4.1 07-Dec-2007  yamt sync with head
 1.25.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.25.46.1 09-Jan-2008  matt sync with HEAD
 1.25.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.7 17-Jul-2011  joerg Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.6 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.5 11-Dec-2005  christos branches: 1.5.44; 1.5.46; 1.5.52;
merge ktrace-lwp.
 1.4 26-Feb-2005  perry branches: 1.4.4;
nuke trailing whitespace
 1.3 07-Mar-2003  dsl branches: 1.3.2; 1.3.10; 1.3.12;
LIBSA_NO_CLOSE is LIBSA_NO_FS_CLOSE everywhere else.
 1.2 28-Apr-1999  christos Nuke local prototype for closeall(). Add a new define LIBSA_NO_CLOSE so that
we don't try to close files, if we are not using any other I/O.
 1.1 12-Feb-1999  drochner branches: 1.1.4;
We can't prototype exit() publically because it might take an argument or
not, depending on the port-specific environment.
Separate panic() and exit() so that the mi/default panic() can be used
without conflicting with a local exit() definition, move exit(void)
prototype to the default exit() implementation.
Closes PR bin/6990 by Wolfgang Helbig <helbig@Informatik.BA-Stuttgart.DE>.
 1.1.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.3.12.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.3.10.1 29-Apr-2005  kent sync with -current
 1.3.2.1 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.4.1 07-Dec-2007  yamt sync with head
 1.5.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.5.46.1 09-Jan-2008  matt sync with HEAD
 1.5.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.18 17-Jul-2011  joerg Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.17 11-Dec-2005  christos merge ktrace-lwp.
 1.16 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.15 13-Feb-1999  pk branches: 1.15.42;
Split the printf variants into separate files.
 1.14 11-Feb-1999  pk sprintf() now produces a return value, like the standard counterpart does.
Also, implement vsprintf(), snprintf() and vsnprintf().
 1.13 16-Jun-1998  gwr Add support for "%p" format (easy).
 1.12 26-Jun-1997  drochner Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.11 26-Jun-1997  thorpej Don't run off the end of the format string if the caller botched for
format modifier. Pointed out by Daniel G. Pouzzner in PR #2633.
 1.10 30-Nov-1996  gwr Finish the kprintf backout: kvprintf -> vprintf was missed.
 1.9 13-Oct-1996  christos backout previous kprintf changes
 1.8 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.7 08-Feb-1996  gwr Need vprintf() for things like panic().
 1.6 03-Sep-1995  pk branches: 1.6.2;
Merge an sprintf() in.
 1.5 21-Feb-1995  mycroft Add a generic twiddler.
 1.4 26-Oct-1994  cgd new RCS ID format.
 1.3 22-Aug-1994  brezak branches: 1.3.2;
Cleanup to make more ANSI compliant; checkpoint
 1.2 27-Jul-1994  cgd get rid of someone else's bravery (stupidity)
 1.1 26-Jan-1994  brezak branches: 1.1.2;
CMU/4.4 stand-alone library
 1.1.2.1 27-Jul-1994  cgd update from trunk.
 1.3.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.3.2.1 22-Aug-1994  brezak file printf.c was added on branch netbsd-1-0 on 1994-08-22 21:56:11 +0000
 1.6.2.1 08-Feb-1996  gwr Need vprintf() for things like panic().
 1.15.42.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.42.2 18-Sep-2004  skrll Sync with HEAD.
 1.15.42.1 03-Aug-2004  skrll Sync with HEAD
 1.5 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.4 24-Nov-2007  isaki branches: 1.4.106;
style, indent, and ANSI-fy.
 1.3 24-Dec-2005  perry branches: 1.3.44; 1.3.46; 1.3.52;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.2 11-Dec-2005  christos merge ktrace-lwp.
 1.1 19-May-2004  abs branches: 1.1.2; 1.1.4; 1.1.16;
Add qsort to libsa (taken from sys/dev/vinum/vinumqsort.c) and use instead of
bubblesort in acorn32 bootloader. Reduces time to sort memory on A710 equipped
RiscPC from over twenty seconds to effectively instantaneous.
Update boot version to 3.30
 1.1.16.2 07-Dec-2007  yamt sync with head
 1.1.16.1 21-Jun-2006  yamt sync with head.
 1.1.4.4 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.4.3 18-Sep-2004  skrll Sync with HEAD.
 1.1.4.2 03-Aug-2004  skrll Sync with HEAD
 1.1.4.1 19-May-2004  skrll file qsort.c was added on branch ktrace-lwp on 2004-08-03 10:53:53 +0000
 1.1.2.2 22-May-2004  he Pull up revision 1.1 (new, requested by abs in ticket #369):
Add qsort to libsa (taken from sys/dev/vinum/vinumqsort.c)
and use instead of bubblesort in acorn32 bootloader. Reduces
time to sort memory on A710 equipped RiscPC from over twenty
seconds to effectively instantaneous. Update boot version
to 3.30
 1.1.2.1 19-May-2004  he file qsort.c was added on branch netbsd-2-0 on 2004-05-22 17:12:43 +0000
 1.3.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.3.46.1 09-Jan-2008  matt sync with HEAD
 1.3.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.4.106.1 10-Jun-2019  christos Sync with HEAD
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 11-Nov-1999  thorpej Minimal quad routines needed for libsa to be self-contained. The compiler
emits a reference to this one in the UFS code.
 1.34 05-Apr-2019  christos Go back ot using 0x%x instead of %#x because we don't always support the
format. See subr_prf.c
 1.33 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.32 29-Mar-2014  jakllsch branches: 1.32.30;
Obtain and/or use ETHER_ADDR_LEN.
 1.31 11-May-2011  zoltan branches: 1.31.4; 1.31.14; 1.31.18;
Separate the IP and UDP code paths inside libsa, so I can add HTTP booting
later.
 1.30 17-Jan-2009  tsutsui branches: 1.30.6; 1.30.8;
Remove __P().
 1.29 12-Jan-2009  tsutsui Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.28 05-Apr-2008  tsutsui branches: 1.28.4; 1.28.12;
Fix a warning in #ifdef RARP_DEBUG. PR kern/20314
 1.27 25-Mar-2008  christos - use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.26 24-Nov-2007  isaki branches: 1.26.14;
style, indent, and ANSI-fy.
 1.25 11-Dec-2005  christos branches: 1.25.44; 1.25.46; 1.25.52;
merge ktrace-lwp.
 1.24 13-Jun-2005  junyoung branches: 1.24.2;
Remove bcmp(). Use memcmp() instead.
 1.23 26-Feb-2005  perry nuke trailing whitespace
 1.22 31-Aug-2003  fvdl branches: 1.22.8; 1.22.10;
Fix signed/unsigned warnings.
 1.21 12-Mar-2003  drochner branches: 1.21.2;
no need to include "netif.h" anymore
(shared interface stuff is in iodesc.h, included by net.h)
 1.20 30-Mar-2000  augustss Kill some more register declarations.
 1.19 13-Nov-1999  thorpej Backout my libsa changes.
 1.18 12-Nov-1999  lukem fix pointer size in debug message
 1.17 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.16 07-Jul-1997  drochner branches: 1.16.20; 1.16.22; 1.16.26;
Don't use private copy of old netinet/if_ether.h.
Use <net/if_ether.h> for ethernet specific definitions, and insert private
definitions for ARP if needed. (The new ARP macros in <net/if_arp.h> are
not used because they create larger code, and we really don't need more
than ethernet/ip support here.)
 1.15 26-Jun-1997  drochner Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.14 15-Mar-1997  is New ARP system, supports IPv4 over any hardware link.

Some of the stuff (e.g., rarpd, bootpd, dhcpd etc., libsa) still will
only support Ethernet. Tcpdump itself should be ok, but libpcap needs
lot of work.

For the detailed change history, look at the commit log entries for
the is-newarp branch.
 1.13 13-Oct-1996  christos branches: 1.13.6;
backout previous kprintf changes
 1.12 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.11 03-Jun-1996  pk missing semicolon
 1.10 23-Sep-1995  gwr More cleanup: change some private types to eliminate casts,
replace some "goto xxx" with return(-1). (mostly cosmetic)
 1.9 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.8 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.7 11-Sep-1995  thorpej Changes from Gordon Ross:
a) check against `my' ethernet or broadcast addresses done in
ether.c
b) changed interface to readether() to provide ethertype info
c) respond to arp requests when appropriate.
First two are clean-up. Last fixes hp300 and presumably mvme68k netboot
code.
 1.6 27-Jun-1995  gwr Fix ARP opcode, add more debugging prints.
 1.5 20-Feb-1995  mycroft Various:
* Fix some misused types.
* Encapsulate the protocols better.
* Rearrange the RPC stuff to work more like the kernel. (Needs more work.)
* Remove a bunch of extra hair when reading a file over NFS.
* Use RPCAUTH_UNIX when talking to the NFS server.
 1.4 26-Oct-1994  cgd new RCS ID format.
 1.3 04-Aug-1994  brezak branches: 1.3.2;
Make libsa compile again by not including sys/errno.h
 1.2 31-May-1994  hpeyerl branches: 1.2.2;
s/REVARP/ARPOP/
(duh; thanx Gordon)
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.2.2.1 05-Aug-1994  mycroft update from trunk, per Brezak
 1.3.2.2 04-Aug-1994  brezak Make libsa compile again by not including sys/errno.h
 1.3.2.1 04-Aug-1994  brezak file rarp.c was added on branch netbsd-1-0 on 1994-08-04 19:39:38 +0000
 1.13.6.1 07-Mar-1997  is Use the local copy of the old-style if_ether.h for the moment, til we have
time to modernize the libsa ARP support.
 1.16.26.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.16.22.1 15-Nov-1999  fvdl Sync with -current
 1.16.20.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.21.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.21.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.21.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.21.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.21.2.1 03-Aug-2004  skrll Sync with HEAD
 1.22.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.22.8.1 29-Apr-2005  kent sync with -current
 1.24.2.1 07-Dec-2007  yamt sync with head
 1.25.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.25.46.1 09-Jan-2008  matt sync with HEAD
 1.25.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.26.14.3 17-Jan-2009  mjf Sync with HEAD.
 1.26.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.26.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.28.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.28.4.1 04-May-2009  yamt sync with head.
 1.30.8.1 06-Jun-2011  jruoho Sync with HEAD.
 1.30.6.1 31-May-2011  rmind sync with head
 1.31.18.1 18-May-2014  rmind sync with head
 1.31.14.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.31.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.32.30.1 10-Jun-2019  christos Sync with HEAD
 1.15 02-Dec-2007  tsutsui unsigned -> unsigned int
 1.14 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.13 11-Dec-2005  christos branches: 1.13.44; 1.13.46; 1.13.52;
merge ktrace-lwp.
 1.12 26-Feb-2005  perry branches: 1.12.4;
nuke trailing whitespace
 1.11 07-Aug-2003  agc branches: 1.11.8; 1.11.10;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.10 30-Mar-2000  augustss branches: 1.10.28;
Kill some more register declarations.
 1.9 31-Mar-1999  cgd branches: 1.9.8;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.8 22-Jan-1997  cgd define these functions with an 'o' prepended to their names if
__INTERNAL_LIBSA_CREAD is defined (so that they can be used by the
compressed-read code).
 1.7 21-Jun-1996  pk Oh, what's in a name..
 1.6 21-Jun-1996  pk Allow seeks on raw devices. A `f_offset' field is added to the file structure
which is maintained in lseek(), read() and write(), and passed along to
the device's strategy routine.
 1.5 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.4 21-Feb-1995  mycroft Add a generic twiddler.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 22-Aug-1994  brezak branches: 1.2.2;
Cleanup to make more ANSI compliant; checkpoint
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.2.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.2.2.1 22-Aug-1994  brezak file read.c was added on branch netbsd-1-0 on 1994-08-22 21:56:12 +0000
 1.9.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.10.28.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.10.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.28.1 03-Aug-2004  skrll Sync with HEAD
 1.11.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.11.8.1 29-Apr-2005  kent sync with -current
 1.12.4.1 07-Dec-2007  yamt sync with head
 1.13.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.13.46.1 09-Jan-2008  matt sync with HEAD
 1.13.44.2 03-Dec-2007  joerg Sync with HEAD.
 1.13.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.31 05-Apr-2019  christos Go back ot using 0x%x instead of %#x because we don't always support the
format. See subr_prf.c
 1.30 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.29 17-Jan-2009  tsutsui branches: 1.29.66;
Remove __P().
 1.28 12-Jan-2009  tsutsui Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.27 25-Mar-2008  christos branches: 1.27.4; 1.27.12;
- use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.26 24-Nov-2007  isaki branches: 1.26.14;
style, indent, and ANSI-fy.
 1.25 21-Jan-2006  dsl branches: 1.25.42; 1.25.44; 1.25.50;
Adjust code so that it will work when _STANDALONE isn't defined.
Allows it to be used for mount_nfs when SMALL is set - eg install floppies/
 1.24 11-Dec-2005  christos branches: 1.24.2;
merge ktrace-lwp.
 1.23 31-Aug-2003  fvdl branches: 1.23.16;
Fix signed/unsigned warnings.
 1.22 12-Mar-2003  drochner branches: 1.22.2;
no need to include "netif.h" anymore
(shared interface stuff is in iodesc.h, included by net.h)
 1.21 30-Mar-2000  augustss Kill some more register declarations.
 1.20 13-Nov-1999  thorpej Backout my libsa changes.
 1.19 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.18 23-Jan-1998  thorpej branches: 1.18.14; 1.18.16; 1.18.20;
Fix some debugging printf formats.
 1.17 26-Jun-1997  drochner Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.16 13-Oct-1996  christos backout previous kprintf changes
 1.15 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.14 26-Sep-1996  cgd enough 64-bit fixes to make network booting work on the Alpha. In general,
these are hacks (s/long/int/, etc.), but this code really needs a heavy
cleaning (including fixed-size typing) and I don't have time to give it one
now.
 1.13 10-Jul-1996  cgd remove some unnecessary and broken casts on char *'s which are being subtracted
 1.12 26-Feb-1996  gwr Make this code independent of <sys/nfs> now that we use very little
from there anyway, so we can ignore changes in the NFS code...
 1.11 26-Feb-1996  scottr Make these build again in the wake of the v3 changes
 1.10 23-Sep-1995  gwr More cleanup: change some private types to eliminate casts,
replace some "goto xxx" with return(-1). (mostly cosmetic)
 1.9 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.8 17-Sep-1995  pk Revert fs_ops read/write declarations; these return error numbers.
Get rid of some more compiler warnings.
Set errno where appropriate.
 1.7 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.6 03-Jul-1995  gwr Build all RPC requests with AUTH_UNIX (thanks to Chuck Silvers)
 1.5 27-Jun-1995  gwr Modified to do less copying, and to allow determination of
the address from whence the reply has come.
 1.4 20-Feb-1995  mycroft Various:
* Fix some misused types.
* Encapsulate the protocols better.
* Rearrange the RPC stuff to work more like the kernel. (Needs more work.)
* Remove a bunch of extra hair when reading a file over NFS.
* Use RPCAUTH_UNIX when talking to the NFS server.
 1.3 19-Feb-1995  mycroft Add some more diagnostic info. Increment the xid in a better place.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.18.20.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.18.16.1 15-Nov-1999  fvdl Sync with -current
 1.18.14.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.22.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.22.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.22.2.1 03-Aug-2004  skrll Sync with HEAD
 1.23.16.2 07-Dec-2007  yamt sync with head
 1.23.16.1 21-Jun-2006  yamt sync with head.
 1.24.2.1 01-Feb-2006  yamt sync with head.
 1.25.50.1 08-Dec-2007  mjf Sync with HEAD.
 1.25.44.1 09-Jan-2008  matt sync with HEAD
 1.25.42.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.26.14.2 17-Jan-2009  mjf Sync with HEAD.
 1.26.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.27.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.27.4.1 04-May-2009  yamt sync with head.
 1.29.66.1 10-Jun-2019  christos Sync with HEAD
 1.11 17-Jan-2009  tsutsui Remove __P().
 1.10 24-Nov-2007  isaki branches: 1.10.18; 1.10.26;
style, indent, and ANSI-fy.
 1.9 21-Jan-2006  dsl branches: 1.9.42; 1.9.44; 1.9.50;
Adjust code so that it will work when _STANDALONE isn't defined.
Allows it to be used for mount_nfs when SMALL is set - eg install floppies/
 1.8 26-Sep-1996  cgd branches: 1.8.78; 1.8.90;
enough 64-bit fixes to make network booting work on the Alpha. In general,
these are hacks (s/long/int/, etc.), but this code really needs a heavy
cleaning (including fixed-size typing) and I don't have time to give it one
now.
 1.7 23-Sep-1995  gwr More cleanup: change some private types to eliminate casts,
replace some "goto xxx" with return(-1). (mostly cosmetic)
 1.6 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.5 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.4 27-Jun-1995  gwr Modified to do less copying, and to allow determination of
the address from whence the reply has come.
 1.3 20-Feb-1995  mycroft Various:
* Fix some misused types.
* Encapsulate the protocols better.
* Rearrange the RPC stuff to work more like the kernel. (Needs more work.)
* Remove a bunch of extra hair when reading a file over NFS.
* Use RPCAUTH_UNIX when talking to the NFS server.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 08-May-1994  brezak Standalone networking for network boot loaders.
 1.8.90.1 01-Feb-2006  yamt sync with head.
 1.8.78.2 07-Dec-2007  yamt sync with head
 1.8.78.1 21-Jun-2006  yamt sync with head.
 1.9.50.1 08-Dec-2007  mjf Sync with HEAD.
 1.9.44.1 09-Jan-2008  matt sync with HEAD
 1.9.42.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.10.26.1 19-Jan-2009  skrll Sync with HEAD.
 1.10.18.1 04-May-2009  yamt sync with head.
 1.4 12-Dec-2023  mlelstv Add NFSv3 support. Try NFSv3 and fall back to NFSv2.
 1.3 11-Dec-2005  christos branches: 1.3.194;
merge ktrace-lwp.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 26-Feb-1996  gwr branches: 1.1.64;
Make this code independent of <sys/nfs> now that we use very little
from there anyway, so we can ignore changes in the NFS code...
 1.1.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.64.1 03-Aug-2004  skrll Sync with HEAD
 1.3.194.1 20-Sep-2024  martin Pull up following revision(s) (requested by rin in ticket #894):

sys/arch/i386/stand/Makefile.booters: revision 1.98
sys/lib/libsa/nfsv3.h: revision 1.1
sys/lib/libsa/rpcv2.h: revision 1.4
sys/arch/i386/stand/efiboot/Makefile.efiboot: revision 1.23
sys/lib/libsa/nfsv2.h: revision 1.5
sys/lib/libsa/nfs.c: revision 1.51
sys/lib/libsa/nfs.c: revision 1.52
sys/arch/i386/stand/libsa/nfs.c: file removal
sys/lib/libsa/nfs.c: revision 1.53
sys/arch/i386/stand/libsa/nfs.c: revision 1.20
sys/arch/i386/stand/libsa/nfs.c: revision 1.21
sys/arch/i386/stand/pxeboot/Makefile: revision 1.29

Add NFSv3 support. Try NFSv3 and fall back to NFSv2.

Merge with generic libsa NFS code to minimize differences and to learn NFSv3.

libsa: nfs: Fix NFS_NOSYMLINK option for previous
Used only by mvme68k.

Align again with libsa (NFS_NOSYMLINK fix).

libsa/nfs.c: Add `LIBSA_NFS_IMPLICIT_MOUNT` compile-time option
by which nfs_mount() is automatically called from nfs_open(),
as done for nfs.c in i386/stand.

This is only functional difference b/w two copies of nfs.c.
Now, we can safely retire the latter.
XXX
It would be really nice to drop this option also. However,
unfortunately, it is too much for me at the very moment...

i386: stand: Retire its own nfs.c, and switch to libsa/nfs.c. NFC
 1.11 03-Dec-2007  isaki Use standard error code (EIO) instead of standalone error code
(ESHORT). Because loadfile_*() is used with or without
_STANDALONE, therefore, don't use error code in "saerrno.h".
Pointed out by and discussed with he@.
 1.10 23-Nov-2007  isaki loadfile_*() must set errno when it returns -1.
 1.9 11-Dec-2005  christos branches: 1.9.44; 1.9.52;
merge ktrace-lwp.
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.7 12-Jan-1999  kleink branches: 1.7.42;
Separate the userland and libsa errno declarations from <sys/errno.h> into
their canonical places.
 1.6 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.5 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.4 21-Feb-1995  mycroft Add EFTYPE.
 1.3 04-Aug-1994  brezak branches: 1.3.2;
Make libsa compile again by not including sys/errno.h
 1.2 24-Jul-1994  mycroft Add some more constants.
 1.1 26-Jan-1994  brezak branches: 1.1.2;
CMU/4.4 stand-alone library
 1.1.2.2 05-Aug-1994  mycroft update from trunk, per Brezak
 1.1.2.1 24-Jul-1994  cgd from branch.
 1.3.2.2 04-Aug-1994  brezak Make libsa compile again by not including sys/errno.h
 1.3.2.1 04-Aug-1994  brezak file saerrno.h was added on branch netbsd-1-0 on 1994-08-04 19:39:39 +0000
 1.7.42.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.42.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.42.1 03-Aug-2004  skrll Sync with HEAD
 1.9.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.9.44.2 03-Dec-2007  joerg Sync with HEAD.
 1.9.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.5 24-Apr-2022  mlelstv Ask driver about sector size to support reading superblocks from fixed
byte offsets.
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 26-Oct-1994  cgd branches: 1.2.66;
new RCS ID format.
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.2.66.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.66.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.66.1 03-Aug-2004  skrll Sync with HEAD
 1.5 17-Jul-2011  joerg Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.4 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.3 11-Dec-2005  christos branches: 1.3.44; 1.3.46; 1.3.52;
merge ktrace-lwp.
 1.2 07-Aug-2003  agc branches: 1.2.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 13-Feb-1999  pk branches: 1.1.42;
Split the printf variants into separate files.
 1.1.42.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.42.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.42.1 03-Aug-2004  skrll Sync with HEAD
 1.2.16.1 07-Dec-2007  yamt sync with head
 1.3.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.3.46.1 09-Jan-2008  matt sync with HEAD
 1.3.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.6 26-Mar-2014  christos Remove {v,}sprintf
 1.5 17-Jul-2011  joerg branches: 1.5.2; 1.5.12; 1.5.16;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.4 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.3 11-Dec-2005  christos branches: 1.3.44; 1.3.46; 1.3.52;
merge ktrace-lwp.
 1.2 07-Aug-2003  agc branches: 1.2.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 13-Feb-1999  pk branches: 1.1.42;
Split the printf variants into separate files.
 1.1.42.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.42.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.42.1 03-Aug-2004  skrll Sync with HEAD
 1.2.16.1 07-Dec-2007  yamt sync with head
 1.3.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.3.46.1 09-Jan-2008  matt sync with HEAD
 1.3.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.5.16.1 18-May-2014  rmind sync with head
 1.5.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.87 30-Apr-2022  rin Now, NULL is always defined correctly, as we include <sys/param.h> above.
 1.86 29-Apr-2022  rin Re-introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
used instead of secsize obtained by SAIOSECSIZE ioctl.

This hack avoids divdi3 and friends from being linked, in order to
support variable secsize for some archs.

Should be useful for ancient archs, for which secsize is fixed.

Thanks christos@ for comment.
 1.85 27-Apr-2022  rin Revert previous at the moment.

This is wrong reasoning; 68020 and above (incl. 040 and 060) support
32-bit displacements for PC relative addressing (via "fully extension
addressing mode" with null index register).

I've still not figured out what goes wrong with amiga/boot(8) when
compiled without -l option for gas(1)...

On 2022/04/27 20:48, Rin Okuyama wrote:
> Module Name: src
> Committed By: rin
> Date: Wed Apr 27 11:48:26 UTC 2022
>
> Modified Files:
> src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c
>
> Log Message:
> Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
> used instead of secsize obtained by SAIOSECSIZE ioctl.
>
> This hack avoids divdi3 and friends from being linked, in order to
> support variable secsize.
>
> This is useful for amiga/boot(8); it is loaded by firmware into
> unpredictable address, and therefore all symbols should be
> addressable by PC relative mode with only 16-bit displacements.
>
> See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for
> more details.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/ext2fs.c
> cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/minixfs3.c
> cvs rdiff -u -r1.83 -r1.84 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
 1.84 27-Apr-2022  rin Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
used instead of secsize obtained by SAIOSECSIZE ioctl.

This hack avoids divdi3 and friends from being linked, in order to
support variable secsize.

This is useful for amiga/boot(8); it is loaded by firmware into
unpredictable address, and therefore all symbols should be
addressable by PC relative mode with only 16-bit displacements.

See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for
more details.
 1.83 17-May-2021  mrg move bi-endian disklabel support from the kernel and libsa into libkern.

- dkcksum() and dkcksum_sized() move from subr_disk.c and from
libsa into libkern/dkcksum.c (which is missing _sized() version),
using the version from usr.sbin/disklabel.

- swap_disklabel() moves from subr_disk_mbr.c into libkern, now called
disklabel_swap(). (the sh3 version should be updated to use this.)

- DISKLABEL_EI becomes a first-class option with opt_disklabel.h.

- add libkern.h to libsa/disklabel.c.

this enables future work for bi-endian libsa/ufs.c (relevant for ffsv1,
ffsv2, lfsv1, and lfsv2), as well as making it possible for ports not
using subr_disk_mbr.c to include bi-endian disklabel support (which,
afaict, includes any disk on mbr-supporting platforms that do not have
an mbr as well as disklabel.)

builds successsfully on: alpha, i386, amd64, sun2, sun3, evbarm64,
evbarm64-eb, sparc, and sparc64. tested in anita on i386 and sparc,
testing in hardware on evbarm64*.
 1.82 27-Aug-2016  dholland branches: 1.82.32; 1.82.34;
Remove gets() from here too.
 1.81 11-Jun-2016  dholland gets_s -> kgets.

The exact name isn't that important; but it is important not to use
"gets_s" and thereby allow anyone to falsely get the impression we're
implementing Annex K. We aren't.

ok core.
 1.80 05-Jun-2016  maxv Use gets_s instead of gets. The x86 bootloader prompt is easy to
overflow.
 1.79 10-Aug-2014  isaki branches: 1.79.4;
Unify all arch/*/stand's atoi() to MI libsa.
lib/libsa/atoi.c was separated from lib/libsa/bootcfg.c.
PR/49084
 1.78 26-Mar-2014  christos Remove {v,}sprintf
 1.77 05-Jan-2014  jakllsch Make libsa fsmod string pointer const.
 1.76 21-May-2012  dsl branches: 1.76.2; 1.76.4;
Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.75 16-Jan-2012  christos branches: 1.75.2;
PR/45796: Evgeniy Ivanov minixfs3 support.
Split out fn_match since we have 3 copies now.
 1.74 25-Dec-2011  tsutsui Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.73 17-Jul-2011  joerg branches: 1.73.2; 1.73.6;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.72 16-Jun-2011  joerg Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.71 25-Feb-2011  joerg branches: 1.71.2;
Move HEXDIGIT to mvme68k's sboot. It seems to be the only user.
Save a byte by explicitly specifying the size.
 1.70 24-Dec-2010  christos branches: 1.70.2; 1.70.4;
panic takes a printf format too.
 1.69 19-Mar-2009  tsutsui branches: 1.69.4;
Revert previous. MI libsa doesn't provide bcmp().
 1.68 19-Mar-2009  he Add a prototype for the bcmp() function as well.
 1.67 18-Mar-2009  tsutsui - remove bcmp(9), bcopy(9), and bzero(9) from libkern since <sys/systm.h> has
macro which replace them with mem*() functions in #ifdef _KERNEL as noted
in man pages
- move declarations of bcopy(3) and bzero(3) into <lib/libsa/stand.h>
since they are still in libsa for some MD standalone sources
(I guess all bcmp(3) in standalone sources have been replaced with memcmp(3)
but they should be replaced with memcmp() anyway)
 1.66 17-Jan-2009  tsutsui branches: 1.66.2;
Remove __P().
 1.65 19-Nov-2008  ad For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.64 25-Mar-2008  christos branches: 1.64.4; 1.64.10; 1.64.12;
- use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.63 24-Dec-2007  perry branches: 1.63.6;
Remove __attribute__((__noreturn__)) from things already marked __dead
Found by the department of redundancy department.
 1.62 24-Nov-2007  isaki branches: 1.62.2; 1.62.6;
style, indent, and ANSI-fy.
 1.61 25-Jan-2006  uwe branches: 1.61.42; 1.61.44; 1.61.50;
Sync alloc/dealloc prototypes with unsigned int -> size_t change.
 1.60 25-Jan-2006  christos - Add attributes to printf functions
- Fix attributes to noreturn functions
- free -> dealloc
- unsigned -> size_t for alloc, dealloc
 1.59 13-Jan-2006  christos constify write prototype.
 1.58 11-Dec-2005  christos branches: 1.58.2;
merge ktrace-lwp.
 1.57 13-Jun-2005  junyoung branches: 1.57.2;
Remove bcmp(). Use memcmp() instead.
 1.56 23-May-2005  jmc Provide HEXDIGITS as well (needed on mvme68k/stand)
 1.55 17-May-2005  christos Yes, it was a cool trick >20 years ago to use "0123456789abcdef"[a] to
implement, xtoa(), but I think defining the samestring 50 times is a bit
too much. Defined HEXDIGITS and hexdigits in subr_prf.c and use it...
 1.54 26-Feb-2005  perry nuke trailing whitespace
 1.53 30-Jun-2004  christos branches: 1.53.4; 1.53.6;
- multiple inclusion protection.
- constify some prototypes.
 1.52 19-May-2004  abs Add qsort to libsa (taken from sys/dev/vinum/vinumqsort.c) and use instead of
bubblesort in acorn32 bootloader. Reduces time to sort memory on A710 equipped
RiscPC from over twenty seconds to effectively instantaneous.
Update boot version to 3.30
 1.51 30-Oct-2003  he branches: 1.51.2;
Add a prototype for memset().
 1.50 18-Aug-2003  dsl make 'path' argument to ufs_open 'const char *' and fix the fallout.
 1.49 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.48 15-Apr-2003  dsl branches: 1.48.2;
Add interface to boot password checking code that takes password parameter.
 1.47 11-Apr-2003  dsl Put extern definition of bcopy in () to avoid macro expansion when
LIBSA_USE_MEMCPY is defined. Fixes breakage because the return
type of memcpy() is different to that of bcopy.
 1.46 10-Apr-2003  dsl Add FS_DEF() and FS_OPS() defines to save typing (and errors) elsewhere.
Kill __P() and argument names in prototypes.
(approved by christos)
 1.45 01-Apr-2003  mycroft constify a couple of pointers.
 1.44 01-Jun-2002  itojun use exit(int), not exit(void), consistently - even if the arg has no meaning.
 1.43 02-Sep-2001  tsutsui branches: 1.43.12;
Add a small version of memmove() for libsa.
Mostly identical with libsa/bcopy.c.
 1.42 05-Apr-2001  thorpej branches: 1.42.2;
libkern.h now has the ctype routines.
 1.41 21-Oct-2000  takemura branches: 1.41.2;
Add LIBSA_RENAME_PRINTF to solve conflict with prototype definition of
printf() and etc in header files of Windows CE native compiler.
 1.40 03-Feb-2000  cgd provide stat() and fstat() here for standalone programs' use
 1.39 13-Nov-1999  thorpej Backout my libsa changes.
 1.38 12-Nov-1999  simonb Add memset() prototype.
 1.37 12-Nov-1999  simonb Add strncpy().

Add prototypes for bcmp(), bzero() so the libsa compiles with WARNS=1
 1.36 11-Nov-1999  thorpej Small, MI strcat() and strcpy().
 1.35 11-Nov-1999  thorpej Networking routines needed for libsa to be self-contained.
 1.34 11-Nov-1999  thorpej Add small, MI strcmp(), strlen(), and strncmp() functions. Modules within
libsa depend on them, to it seems rather silly to have to build an additional
library (e.g. libkern) to get them.
 1.33 09-Sep-1999  drochner branches: 1.33.2; 1.33.4; 1.33.8;
add a function to verify a password against an in-core md5 sum
 1.32 14-Apr-1999  christos add getopt prototype, and externs
 1.31 31-Mar-1999  cgd branches: 1.31.4;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.30 22-Feb-1999  simonb Define bzero()/bcopy() in terms of memset()/memcpy() if LIBSA_USE_MEMSET
or LIBSA_USE_MEMCPY is defined. Most everything pulls in stand.h so
this should cover ports that only use memset/memcpy but still want to
pull in as much as possible from sys/lib/libsa.
 1.29 12-Feb-1999  drochner We can't prototype exit() publically because it might take an argument or
not, depending on the port-specific environment.
Separate panic() and exit() so that the mi/default panic() can be used
without conflicting with a local exit() definition, move exit(void)
prototype to the default exit() implementation.
Closes PR bin/6990 by Wolfgang Helbig <helbig@Informatik.BA-Stuttgart.DE>.
 1.28 11-Feb-1999  pk sprintf() now produces a return value, like the standard counterpart does.
Also, implement vsprintf(), snprintf() and vsnprintf().
 1.27 11-Feb-1999  pk Add missing prototypes.
 1.26 22-Sep-1998  ross Remove memset() prototype.
 1.25 22-Sep-1998  ross Prototype memset().
 1.24 27-Jul-1998  is back out last change
 1.23 27-Jul-1998  is write prototype: void * -> const void *.
[Else the Amiga bootblock can't be built.]
 1.22 26-Jun-1997  drochner Allow to define the location of the heap at runtime #if HEAP_VARIABLE.
That helps to test libsa code in user space.
 1.21 13-Jun-1997  drochner Add prototype for strerror().
 1.20 22-Jan-1997  cgd prototype lseek(). also, prototype oopen(), oclose(), oread(), and olseek()
if __INTERNAL_LIBSA_CREAD is defined.
 1.19 16-Jan-1997  cgd add memcmp, implemented as a wrapper around bcmp() (like memcpy() is
implemented as a wrapper around bcopy()).
 1.18 30-Nov-1996  gwr branches: 1.18.2;
Oops... get the vprintf prototype right.
 1.17 30-Nov-1996  gwr Add declaration for vprintf.
 1.16 13-Oct-1996  christos backout previous kprintf changes
 1.15 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.14 21-Jun-1996  pk Allow seeks on raw devices. A `f_offset' field is added to the file structure
which is maintained in lseek(), read() and write(), and passed along to
the device's strategy routine.
 1.13 13-Jan-1996  leo Some files containing more than one function are split. This reduces the
size of the resulting loader. The read_inode() function now returns the
result of the strategy function instead of success in all cases (ufs.c).
Fixes pr#1817
 1.12 18-Sep-1995  pk Another round of clean up, including fixes presented by Matthias Drochner
(PR#1404). Things to be noted:
- all IP addresses are now `struct in_addr's.
- the function rarp_getipaddress() no longer return `myip'; in stead
it returns -1 on failure (errno set), 0 on success. `myip' is set
as a size-effect.
 1.11 17-Sep-1995  pk Revert fs_ops read/write declarations; these return error numbers.
Get rid of some more compiler warnings.
Set errno where appropriate.
 1.10 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.9 30-Apr-1995  cgd first arg to open() is a 'const char *'. pointed out by David Brownlee
in pr 1004.
 1.8 22-Apr-1995  cgd various attribute poisoning, don't be as quick to specify size of files[]
 1.7 21-Feb-1995  mycroft Update prototypes.
 1.6 30-Oct-1994  cgd be more careful with types, also pull in headers where necessary.
 1.5 26-Oct-1994  cgd new RCS ID format.
 1.4 22-Aug-1994  brezak branches: 1.4.2;
Cleanup to make more ANSI compliant; checkpoint
 1.3 04-Aug-1994  brezak Make libsa compile again by not including sys/errno.h
 1.2 08-May-1994  brezak branches: 1.2.2;
Standalone networking for network boot loaders.
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.2.2.1 05-Aug-1994  mycroft update from trunk, per Brezak
 1.4.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.4.2.1 22-Aug-1994  brezak file stand.h was added on branch netbsd-1-0 on 1994-08-22 21:56:14 +0000
 1.18.2.1 18-Jan-1997  thorpej Update from trunk.
 1.31.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.33.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.33.4.1 15-Nov-1999  fvdl Sync with -current
 1.33.2.2 21-Apr-2001  bouyer Sync with HEAD
 1.33.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.41.2.3 20-Jun-2002  nathanw Catch up to -current.
 1.41.2.2 21-Sep-2001  nathanw Catch up to -current.
 1.41.2.1 09-Apr-2001  nathanw Catch up with -current.
 1.42.2.2 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.42.2.1 13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.43.12.1 20-Jun-2002  gehenna catch up with -current.
 1.48.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.48.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.48.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.48.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.48.2.1 03-Aug-2004  skrll Sync with HEAD
 1.51.2.1 22-May-2004  he Pull up revision 1.52 (requested by abs in ticket #369):
Add qsort to libsa (taken from sys/dev/vinum/vinumqsort.c)
and use instead of bubblesort in acorn32 bootloader. Reduces
time to sort memory on A710 equipped RiscPC from over twenty
seconds to effectively instantaneous. Update boot version
to 3.30
 1.53.6.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.53.4.1 29-Apr-2005  kent sync with -current
 1.57.2.3 21-Jan-2008  yamt sync with head
 1.57.2.2 07-Dec-2007  yamt sync with head
 1.57.2.1 21-Jun-2006  yamt sync with head.
 1.58.2.2 01-Feb-2006  yamt sync with head.
 1.58.2.1 15-Jan-2006  yamt sync with head.
 1.61.50.2 27-Dec-2007  mjf Sync with HEAD.
 1.61.50.1 08-Dec-2007  mjf Sync with HEAD.
 1.61.44.1 09-Jan-2008  matt sync with HEAD
 1.61.42.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.62.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.62.2.1 26-Dec-2007  ad Sync with head.
 1.63.6.2 17-Jan-2009  mjf Sync with HEAD.
 1.63.6.1 03-Apr-2008  mjf Sync with HEAD.
 1.64.12.2 28-Apr-2009  skrll Sync with HEAD.
 1.64.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.64.10.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.64.4.1 04-May-2009  yamt sync with head.
 1.66.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.69.4.1 05-Mar-2011  rmind sync with head
 1.70.4.1 05-Mar-2011  bouyer Sync with HEAD
 1.70.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.71.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.73.6.2 02-Jun-2012  mrg sync to latest -current.
 1.73.6.1 18-Feb-2012  mrg merge to -current.
 1.73.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.73.2.2 23-May-2012  yamt sync with head.
 1.73.2.1 17-Apr-2012  yamt sync with head
 1.75.2.1 03-Jun-2012  jdc Pull up revisions:
src/sys/arch/i386/stand/lib/exec.c revision 1.50
src/sys/arch/sandpoint/stand/altboot/main.c revision 1.21 via patch
src/sys/lib/libsa/ext2fs.c revision 1.13
src/sys/lib/libsa/ffsv1.c revision 1.6
src/sys/lib/libsa/ffsv2.c revision 1.6
src/sys/lib/libsa/globals.c revision 1.9
src/sys/lib/libsa/lfsv1.c revision 1.5
src/sys/lib/libsa/lfsv2.c revision 1.5
src/sys/lib/libsa/stand.h revision 1.76
src/sys/lib/libsa/ufs.c revision 1.58
(requested by dsl in ticket #279).

Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.76.4.1 18-May-2014  rmind sync with head
 1.76.2.2 03-Dec-2017  jdolecek update from HEAD
 1.76.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.79.4.2 05-Oct-2016  skrll Sync with HEAD
 1.79.4.1 09-Jul-2016  skrll Sync with HEAD
 1.82.34.1 31-May-2021  cjep sync with head
 1.82.32.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.7 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.6 11-Dec-2005  christos branches: 1.6.44; 1.6.46; 1.6.52;
merge ktrace-lwp.
 1.5 07-Aug-2003  agc branches: 1.5.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 13-Jan-1996  leo branches: 1.4.64;
Some files containing more than one function are split. This reduces the
size of the resulting loader. The read_inode() function now returns the
result of the strategy function instead of success in all cases (ufs.c).
Fixes pr#1817
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 22-Aug-1994  brezak branches: 1.2.2;
Cleanup to make more ANSI compliant; checkpoint
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.2.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.2.2.1 22-Aug-1994  brezak file stat.c was added on branch netbsd-1-0 on 1994-08-22 21:56:15 +0000
 1.4.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.64.1 03-Aug-2004  skrll Sync with HEAD
 1.5.16.1 07-Dec-2007  yamt sync with head
 1.6.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.6.46.1 09-Jan-2008  matt sync with HEAD
 1.6.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 11-Nov-1999  thorpej Small, MI strcat() and strcpy().
 1.3 25-Mar-2008  christos - use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.2 21-Mar-2008  rtr branches: 1.2.2; 1.2.4;
when the char being searched for is not found strchr() must return NULL
not a pointer to the terminating '\0'. the only time we return a pointer
to the terminating '\0' is when the char being searched for is '\0'.

fixes problem observed booting -current install
http://mail-index.netbsd.org/current-users/2008/03/20/msg001445.html
 1.1 14-Mar-2008  dsl branches: 1.1.2;
Add a strchr() - for dosfs in particular.
The i386 asm version in src/common is rather larger than this one.
 1.1.2.3 24-Mar-2008  yamt sync with head.
 1.1.2.2 17-Mar-2008  yamt sync with head.
 1.1.2.1 14-Mar-2008  yamt file strchr.c was added on branch yamt-lazymbuf on 2008-03-17 09:15:40 +0000
 1.2.4.2 24-Mar-2008  keiichi sync with head.
 1.2.4.1 21-Mar-2008  keiichi file strchr.c was added on branch keiichi-mipv6 on 2008-03-24 07:16:22 +0000
 1.2.2.2 23-Mar-2008  matt sync with HEAD
 1.2.2.1 21-Mar-2008  matt file strchr.c was added on branch matt-armv6 on 2008-03-23 02:05:02 +0000
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 11-Nov-1999  thorpej Add small, MI strcmp(), strlen(), and strncmp() functions. Modules within
libsa depend on them, to it seems rather silly to have to build an additional
library (e.g. libkern) to get them.
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 11-Nov-1999  thorpej Small, MI strcat() and strcpy().
 1.20 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.19 11-Dec-2005  christos branches: 1.19.44; 1.19.46; 1.19.52;
merge ktrace-lwp.
 1.18 01-Jul-2004  christos branches: 1.18.12;
DECONST -> UNCONST
 1.17 30-Jun-2004  christos constification fixes.
 1.16 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.15 11-Mar-2003  drochner branches: 1.15.2;
translate EACCES (happens with NFS)
 1.14 01-Feb-2003  dsl Save some space
(agreed by christos)
 1.13 17-Feb-2002  thorpej Add EOFFSET.
 1.12 25-Jan-1997  cgd branches: 1.12.38; 1.12.40;
add EINVAL and ENOTDIR, as suggested by Matthias Drochner
 1.11 13-Oct-1996  christos backout previous kprintf changes
 1.10 10-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.9 13-Jan-1996  leo Some files containing more than one function are split. This reduces the
size of the resulting loader. The read_inode() function now returns the
result of the strategy function instead of success in all cases (ufs.c).
Fixes pr#1817
 1.8 17-Sep-1995  pk Revert fs_ops read/write declarations; these return error numbers.
Get rid of some more compiler warnings.
Set errno where appropriate.
 1.7 03-Sep-1995  pk Fix bogus numerical conversion by using sprintf();
 1.6 22-Apr-1995  cgd various attribute poisoning, don't be as quick to specify size of files[]
 1.5 21-Feb-1995  mycroft Correct some error strings, and add a few more. Don't print error messages in
exec(); let the caller do it.
 1.4 26-Oct-1994  cgd new RCS ID format.
 1.3 04-Aug-1994  brezak branches: 1.3.2;
Make libsa compile again by not including sys/errno.h
 1.2 26-Feb-1994  pk branches: 1.2.2;
Don't use aggregate initialization;
Add memcpy().
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.2.2.1 05-Aug-1994  mycroft update from trunk, per Brezak
 1.3.2.2 04-Aug-1994  brezak Make libsa compile again by not including sys/errno.h
 1.3.2.1 04-Aug-1994  brezak file strerror.c was added on branch netbsd-1-0 on 1994-08-04 19:39:42 +0000
 1.12.40.1 16-Mar-2002  jdolecek Catch up with -current.
 1.12.38.1 28-Feb-2002  nathanw Catch up to -current.
 1.15.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.15.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.15.2.1 03-Aug-2004  skrll Sync with HEAD
 1.18.12.1 07-Dec-2007  yamt sync with head
 1.19.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.19.46.1 09-Jan-2008  matt sync with HEAD
 1.19.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 11-Nov-1999  thorpej Add small, MI strcmp(), strlen(), and strncmp() functions. Modules within
libsa depend on them, to it seems rather silly to have to build an additional
library (e.g. libkern) to get them.
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 11-Nov-1999  thorpej Add small, MI strcmp(), strlen(), and strncmp() functions. Modules within
libsa depend on them, to it seems rather silly to have to build an additional
library (e.g. libkern) to get them.
 1.2 13-Nov-1999  thorpej Backout my libsa changes.
 1.1 12-Nov-1999  simonb Add strncpy().

Add prototypes for bcmp(), bzero() so the libsa compiles with WARNS=1
 1.31 31-Aug-2024  mlelstv Only a leading '0' in a format width marks zero-padding, otherwise
it's a regular digit.
 1.30 29-May-2023  rin branches: 1.30.6;
libsa/printf: Do not fetch long va_arg as long long.

This does real harm iff all of the following conditions are satisfied:

(1) On ILP32 architectures.
(2) Both LIBSA_PRINTF_LONGLONG_SUPPORT and LIBSA_PRINTF_WIDTH_SUPPORT
compile-time options are enabled.
(3) Width field is used with 'l' modifier.

This is an implicit-fallthrough bug, but unfortunately, GCC 10.4 cannot
find this out somehow...

XXX
Pull up to netbsd-10 and netbsd-9. netbsd-8 is not affected.
 1.29 06-Jun-2020  thorpej branches: 1.29.20;
Make libsa's vsnprintf() work as expected when passed a NULL
destinatino buffer.
 1.28 03-Feb-2019  mrg branches: 1.28.4;
- remove unreachable code
 1.27 30-Aug-2014  tsutsui branches: 1.27.20;
Revert stupid and untested changes. There was no extra copy in the macros.

Christos, you should reread our commit guideline as a Core member.
 1.26 30-Aug-2014  christos remove extra copy of the macro.
 1.25 30-Aug-2014  tsutsui Rename padding macros to reflect and clarify the original intention.

No binary changes on luna68k (which has -DLIBSA_PRINTF_WIDTH_SUPPORT).
 1.24 22-Mar-2014  hkenken for LIBSA_PRINTF_WIDTH_SUPPORT,
Fix right and left-adjusting padding.
 1.23 24-Dec-2013  jakllsch intmax_t might be long long, handle accordingly. from christos
 1.22 24-Dec-2013  jakllsch Add 'j' format modifier for intmax_t.
 1.21 17-Jul-2011  joerg branches: 1.21.2; 1.21.12; 1.21.16;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.20 20-May-2011  tsutsui KNF a bit.
 1.19 25-Feb-2011  joerg No trailing 0 byte for hexdigits.
 1.18 25-Feb-2011  joerg Move HEXDIGIT to mvme68k's sboot. It seems to be the only user.
Save a byte by explicitly specifying the size.
 1.17 19-Jan-2010  tsutsui branches: 1.17.4; 1.17.6; 1.17.8;
Add long long (%lld etc.) support and width (%02x etc.) support
in libsa printf(3). Disabled by default but enabled by
-DLIBSA_PRINTF_LONGLONG_SUPPORT and -DLIBSA_PRINTF_WIDTH_SUPPORT.
Provided by tnozaki@ for my libsa debugging. Thanks!
 1.16 24-Nov-2007  isaki branches: 1.16.18;
style, indent, and ANSI-fy.
 1.15 27-Jan-2006  uwe branches: 1.15.42; 1.15.44; 1.15.50;
/* fall through */ -> /* FALLTHROUGH */
 1.14 27-Jan-2006  uwe Support 'z' (size_t) and 't' (ptrdiff_t) specifiers.

XXX: ptrdiff_t is only ever defined in <stddef.h> and is defined
unconditionally, without the ifndef dance. Until we have an expert
opinion, abuse intptr_t for the 't' size check.
 1.13 11-Dec-2005  christos branches: 1.13.2;
merge ktrace-lwp.
 1.12 23-May-2005  jmc branches: 1.12.2;
Provide HEXDIGITS as well (needed on mvme68k/stand)
 1.11 17-May-2005  christos Yes, it was a cool trick >20 years ago to use "0123456789abcdef"[a] to
implement, xtoa(), but I think defining the samestring 50 times is a bit
too much. Defined HEXDIGITS and hexdigits in subr_prf.c and use it...
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.9 27-Apr-2003  tron branches: 1.9.2;
Remove two unused variable to fix a build problem.
 1.8 26-Apr-2003  bjh21 Remove %b support.
Encouraged by thorpej.
 1.7 20-Apr-2003  bjh21 If the format string ends with "%" or "%l", print those characters, just
as we would if they were part of an invalid conversion specification.
Code-size neutral on ARM; not tested elsewhere.
 1.6 20-Apr-2003  bjh21 ANSIfy, assume __STDC__, un-__P, KNF.
Generated code unchanged.
 1.5 17-Feb-2002  thorpej Add a missing "static".
 1.4 24-Sep-2001  wiz va_{start,end} audit:
Make sure that each va_start has one and only one matching va_end,
especially in error cases.
If the va_list is used multiple times, do multiple va_starts/va_ends.
If a function gets va_list as argument, don't let it use va_end (since
it's the callers responsibility).

Improved by comments from enami and christos -- thanks!

Heimdal/krb4/KAME changes already fed back, rest to follow.

Inspired by, but not not based on, OpenBSD.
 1.3 30-Mar-2000  augustss branches: 1.3.6; 1.3.8; 1.3.10;
Kill some more register declarations.
 1.2 20-Apr-1999  cgd branches: 1.2.2;
set lflag when printing pointers with %p
 1.1 13-Feb-1999  pk branches: 1.1.4;
Split the printf variants into separate files.
 1.1.4.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.3.10.1 01-Oct-2001  fvdl Catch up with -current.
 1.3.8.2 16-Mar-2002  jdolecek Catch up with -current.
 1.3.8.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.3.6.2 28-Feb-2002  nathanw Catch up to -current.
 1.3.6.1 26-Sep-2001  nathanw Catch up to -current.
Again.
 1.9.2.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.2.1 03-Aug-2004  skrll Sync with HEAD
 1.12.2.2 07-Dec-2007  yamt sync with head
 1.12.2.1 21-Jun-2006  yamt sync with head.
 1.13.2.1 01-Feb-2006  yamt sync with head.
 1.15.50.1 08-Dec-2007  mjf Sync with HEAD.
 1.15.44.1 09-Jan-2008  matt sync with HEAD
 1.15.42.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.16.18.1 11-Mar-2010  yamt sync with head
 1.17.8.1 05-Mar-2011  bouyer Sync with HEAD
 1.17.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.17.4.2 31-May-2011  rmind sync with head
 1.17.4.1 05-Mar-2011  rmind sync with head
 1.21.16.1 18-May-2014  rmind sync with head
 1.21.12.2 03-Dec-2017  jdolecek update from HEAD
 1.21.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.21.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.27.20.1 10-Jun-2019  christos Sync with HEAD
 1.28.4.1 03-Jun-2023  martin Pull up following revision(s) (requested by rin in ticket #1636):

sys/lib/libsa/subr_prf.c: revision 1.30

libsa/printf: Do not fetch long va_arg as long long.

This does real harm iff all of the following conditions are satisfied:
(1) On ILP32 architectures.
(2) Both LIBSA_PRINTF_LONGLONG_SUPPORT and LIBSA_PRINTF_WIDTH_SUPPORT
compile-time options are enabled.
(3) Width field is used with 'l' modifier.

This is an implicit-fallthrough bug, but unfortunately, GCC 10.4 cannot
find this out somehow...
 1.29.20.1 03-Jun-2023  martin Pull up following revision(s) (requested by rin in ticket #185):

sys/lib/libsa/subr_prf.c: revision 1.30

libsa/printf: Do not fetch long va_arg as long long.

This does real harm iff all of the following conditions are satisfied:
(1) On ILP32 architectures.
(2) Both LIBSA_PRINTF_LONGLONG_SUPPORT and LIBSA_PRINTF_WIDTH_SUPPORT
compile-time options are enabled.
(3) Width field is used with 'l' modifier.

This is an implicit-fallthrough bug, but unfortunately, GCC 10.4 cannot
find this out somehow...
 1.30.6.1 02-Aug-2025  perseant Sync with HEAD
 1.2 24-Sep-1998  ross tfs -> ustarfs
 1.1 22-Sep-1998  ross Add `tfs', a USTAR-format FS, featuring fast floppy loads, 5% better
space efficiency, and (the real reason) multiple-volume files.
 1.2 24-Sep-1998  ross tfs -> ustarfs
 1.1 22-Sep-1998  ross Add `tfs', a USTAR-format FS, featuring fast floppy loads, 5% better
space efficiency, and (the real reason) multiple-volume files.
 1.38 07-Aug-2022  rin Consistently use ntohs() instead of htons() when converting from
network to host byte order.

No binary changes both for big and little endian.
 1.37 26-Mar-2021  rin Twiddle also for data transfer for seek.
 1.36 31-Mar-2019  christos branches: 1.36.12; 1.36.14;
fix warnings, printf formats, etc.
 1.35 20-Mar-2014  christos branches: 1.35.30;
reduce size by 1K by sharing the ls code.
 1.34 25-Dec-2011  tsutsui branches: 1.34.6; 1.34.10;
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.33 30-Jul-2011  jakllsch branches: 1.33.2; 1.33.6;
Fix printf formating in ifdef DEBUG sections.
 1.32 16-Jun-2011  joerg Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.31 11-May-2011  zoltan branches: 1.31.2;
Separate the IP and UDP code paths inside libsa, so I can add HTTP booting
later.
 1.30 13-Jan-2010  drochner branches: 1.30.4; 1.30.6;
RFC783 says the ErrMsg sent with an ERROR packet needs to be
NUL-terminated
 1.29 17-Jan-2009  tsutsui Remove __P().
 1.28 12-Jan-2009  tsutsui Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.27 19-Nov-2008  ad For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.26 11-May-2008  chris branches: 1.26.4; 1.26.6;
Extend tftp_stat to return the size of the file, rather than -1.

It's not very efficient, as it has to read the whole file, and count the
block sizes. However, this is the only way to work out the size using the
tftp protocol.

This is needed to support loading modules from a tftp server with pxeboot.
 1.25 25-Mar-2008  christos branches: 1.25.2; 1.25.4; 1.25.6;
- use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.24 02-Dec-2007  tsutsui branches: 1.24.14;
unsigned -> unsigned int
 1.23 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.22 05-Mar-2007  he branches: 1.22.14; 1.22.16; 1.22.22;
We need char* for pointer arithmetic.
 1.21 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.20 25-Jan-2006  christos branches: 1.20.24;
free -> dealloc
 1.19 11-Dec-2005  christos branches: 1.19.2;
merge ktrace-lwp.
 1.18 26-Feb-2005  perry branches: 1.18.4;
nuke trailing whitespace
 1.17 24-Mar-2004  drochner branches: 1.17.8; 1.17.10;
remove license clauses 3 and 4 from my cpoyright notices
 1.16 31-Aug-2003  fvdl Fix signed/unsigned warnings.
 1.15 18-Aug-2003  dsl make 'path' argument to ufs_open 'const char *' and fix the fallout.
 1.14 18-Mar-2003  mycroft branches: 1.14.2;
Move some stuff into .rodata.
 1.13 12-Mar-2003  drochner no need to include "netif.h" anymore
(shared interface stuff is in iodesc.h, included by net.h)
 1.12 12-Jan-2003  christos PR/19607: Bernd Ernesti: libsa does not have access to arpa/tftp.h. Put a
copy of it in our tftp.h
 1.11 16-Sep-2002  thorpej Do not #include "/usr/include/arpa/tftp.h" directly. Doing so is
VERY BAD for cross-compiling.
 1.10 30-Mar-2000  augustss branches: 1.10.6; 1.10.8; 1.10.22;
Kill some more register declarations.
 1.9 13-Nov-1999  thorpej Backout my libsa changes.
 1.8 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.7 12-Jul-1999  drochner branches: 1.7.2; 1.7.4; 1.7.8;
fix damage in error handling crept in in 1.4
 1.6 31-Mar-1999  cgd branches: 1.6.4;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.5 26-Mar-1999  dbj Changes to compile the next68k bootblocks with
egcs -Wpointer-arith -Wstrict-prototypes
This closes pr 6653
 1.4 28-Feb-1999  kim Made this compile:
- fifth arg to recvtftp should be size_t (not ssize_t)
- the path is passed tftp_makereq as a part of the handle structure
 1.3 26-Feb-1999  christos Add missing prototypes for static functions.
 1.2 25-Feb-1999  ross XXX include libkern.h for strlen() XXX
 1.1 24-Feb-1999  drochner move TFTP filesystem from i386/stand/libsa here, it is mi
 1.6.4.1 02-Aug-1999  thorpej Update from trunk.
 1.7.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.7.4.1 15-Nov-1999  fvdl Sync with -current
 1.7.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.10.22.1 01-Dec-2002  he Pull up revision 1.11 (requested by thorpej in ticket #836):
Do not #include "/usr/incloude/arpa/tftph" directly.
Fixes problem for cross-compiling.
 1.10.8.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.10.6.2 15-Jan-2003  thorpej Sync with HEAD.
 1.10.6.1 17-Sep-2002  nathanw Catch up to -current.
 1.14.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.14.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.2.1 03-Aug-2004  skrll Sync with HEAD
 1.17.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.17.8.1 29-Apr-2005  kent sync with -current
 1.18.4.3 07-Dec-2007  yamt sync with head
 1.18.4.2 03-Sep-2007  yamt sync with head.
 1.18.4.1 21-Jun-2006  yamt sync with head.
 1.19.2.1 01-Feb-2006  yamt sync with head.
 1.20.24.1 12-Mar-2007  rmind Sync with HEAD.
 1.22.22.1 08-Dec-2007  mjf Sync with HEAD.
 1.22.16.1 09-Jan-2008  matt sync with HEAD
 1.22.14.2 03-Dec-2007  joerg Sync with HEAD.
 1.22.14.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.24.14.3 17-Jan-2009  mjf Sync with HEAD.
 1.24.14.2 02-Jun-2008  mjf Sync with HEAD.
 1.24.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.25.6.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.25.4.3 11-Mar-2010  yamt sync with head
 1.25.4.2 04-May-2009  yamt sync with head.
 1.25.4.1 16-May-2008  yamt sync with head.
 1.25.2.1 18-May-2008  yamt sync with head.
 1.26.6.1 19-Jan-2009  skrll Sync with HEAD.
 1.26.4.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.30.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.30.4.1 31-May-2011  rmind sync with head
 1.31.2.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.33.6.1 18-Feb-2012  mrg merge to -current.
 1.33.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.33.2.1 17-Apr-2012  yamt sync with head
 1.34.10.1 18-May-2014  rmind sync with head
 1.34.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.30.1 10-Jun-2019  christos Sync with HEAD
 1.36.14.1 03-Apr-2021  thorpej Sync with HEAD.
 1.36.12.1 03-Apr-2021  thorpej Sync with HEAD.
 1.6 11-Dec-2005  christos merge ktrace-lwp.
 1.5 24-Mar-2004  drochner remove license clauses 3 and 4 from my cpoyright notices
 1.4 18-Aug-2003  dsl make 'path' argument to ufs_open 'const char *' and fix the fallout.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 12-Jan-2003  christos branches: 1.2.2;
PR/19607: Bernd Ernesti: libsa does not have access to arpa/tftp.h. Put a
copy of it in our tftp.h
 1.1 24-Feb-1999  drochner branches: 1.1.20;
move TFTP filesystem from i386/stand/libsa here, it is mi
 1.1.20.1 15-Jan-2003  thorpej Sync with HEAD.
 1.2.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9 29-Sep-2020  simonb Add a slow twiddle option. This speeds up a pmax netboot by 15% and
is only 1% slower than no twiddle.
 1.8 30-Apr-2008  ad Let twiddle() be disabled at runtime.
 1.7 24-Nov-2007  isaki branches: 1.7.14; 1.7.16; 1.7.18;
style, indent, and ANSI-fy.
 1.6 11-Dec-2005  christos branches: 1.6.44; 1.6.46; 1.6.52;
merge ktrace-lwp.
 1.5 07-Aug-2003  agc branches: 1.5.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 22-Jun-1999  christos branches: 1.4.36;
Nuke obsolete printf comment.
 1.3 23-Mar-1999  simonb branches: 1.3.4;
Revert SA_NOPUTCHAR - the pmax was the only port using it and the new
pmax bootblocks provide a putchar().
 1.2 22-Feb-1999  simonb Use printf() instead of putchar() if SA_NOPUTCHAR is defined (for the
pmax).
Also don't include stdarg.h/varargs.h - we don't use them here.
 1.1 13-Feb-1999  pk Split the printf variants into separate files.
 1.3.4.1 01-Jul-1999  thorpej Sync w/ -current.
 1.4.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.36.1 03-Aug-2004  skrll Sync with HEAD
 1.5.16.1 07-Dec-2007  yamt sync with head
 1.6.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.6.46.1 09-Jan-2008  matt sync with HEAD
 1.6.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.7.18.1 16-May-2008  yamt sync with head.
 1.7.16.1 18-May-2008  yamt sync with head.
 1.7.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.13 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.12 31-Mar-2019  mlelstv correct debug message, d->myport has network byte order.
 1.11 11-May-2011  zoltan branches: 1.11.56;
Separate the IP and UDP code paths inside libsa, so I can add HTTP booting
later.
 1.10 26-Dec-2010  christos branches: 1.10.2;
fix slightly wrong format.
 1.9 26-Dec-2010  he Print size_t and ssize_t with %zd, not just %d.
(How did this build before?)
 1.8 12-Jan-2009  tsutsui branches: 1.8.6;
Replace time_t values in libsa sources with the following two types
to avoid unnecessary 64 bit ops which would make binaries larger:

satime_t (currently unsigned int):
numbers in seconds returned by the machine dependent getsecs() function
which are used to measure relative time

saseconds_t (currently int):
numbers in seconds used to specify timeout to network drivers

Per discussion on current-users.
 1.7 25-Mar-2008  christos branches: 1.7.4; 1.7.12;
- use mem* instead of b* routines, and kill the b* routines.
- use the mem* routines from libc.
XXX: There will be some lossage, but I am fixing it.
 1.6 24-Nov-2007  isaki branches: 1.6.14;
style, indent, and ANSI-fy.
 1.5 24-Jan-2006  christos branches: 1.5.42; 1.5.44; 1.5.50;
PR/32613: Yves-Emmanuel JUTARD: Incoherencies in file sys/lib/libsa/net.h
- Make prototype of ether_sprintf() match the one in sys/net.
- Rename in_cksum to ip_cksum and fix its prototype. in_cksum() operates
on an mbuf and ip_cksum() operates on a plain buffer. We should not call
functions that operate on different arguments the same name (this is not
c++).
 1.4 11-Dec-2005  christos branches: 1.4.2;
merge ktrace-lwp.
 1.3 31-Aug-2003  fvdl branches: 1.3.16;
Fix signed/unsigned warnings.
 1.2 23-Apr-2002  ragge branches: 1.2.10;
Someone had a braino here; IP_TTL != IPDEFTTL. This caused the standalone
udp traffic to only have a ttl of 4.
Found by Jens Nilsson, jens@rockstorm.se.
 1.1 25-Oct-2000  thorpej branches: 1.1.2; 1.1.4; 1.1.6;
Split the UDP routines out of net.c.
 1.1.6.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.4.1 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.2 22-Nov-2000  bouyer Sync with HEAD.
 1.1.2.1 25-Oct-2000  bouyer file udp.c was added on branch thorpej_scsipi on 2000-11-22 16:05:43 +0000
 1.2.10.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.10.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.10.1 03-Aug-2004  skrll Sync with HEAD
 1.3.16.2 07-Dec-2007  yamt sync with head
 1.3.16.1 21-Jun-2006  yamt sync with head.
 1.4.2.1 01-Feb-2006  yamt sync with head.
 1.5.50.1 08-Dec-2007  mjf Sync with HEAD.
 1.5.44.1 09-Jan-2008  matt sync with HEAD
 1.5.42.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.6.14.2 17-Jan-2009  mjf Sync with HEAD.
 1.6.14.1 03-Apr-2008  mjf Sync with HEAD.
 1.7.12.1 19-Jan-2009  skrll Sync with HEAD.
 1.7.4.1 04-May-2009  yamt sync with head.
 1.8.6.2 31-May-2011  rmind sync with head
 1.8.6.1 05-Mar-2011  rmind sync with head
 1.10.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.11.56.1 10-Jun-2019  christos Sync with HEAD
 1.88 01-Dec-2022  christos fix clang build
 1.87 17-Nov-2022  chs Restore backward compatibility of UFS2 with previous NetBSD releases by
disabling support in UFS2 for extended attributes (including ACLs).
Add a new variant of UFS2 called "UFS2ea" that does support extended attributes.
Add new fsck_ffs operations "-c ea" and "-c no-ea" to convert file systems
from UFS2 to UFS2ea and vice-versa (both of which delete all existing extended
attributes in the process).
 1.86 29-Apr-2022  rin Re-introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
used instead of secsize obtained by SAIOSECSIZE ioctl.

This hack avoids divdi3 and friends from being linked, in order to
support variable secsize for some archs.

Should be useful for ancient archs, for which secsize is fixed.

Thanks christos@ for comment.
 1.85 27-Apr-2022  rin Revert previous at the moment.

This is wrong reasoning; 68020 and above (incl. 040 and 060) support
32-bit displacements for PC relative addressing (via "fully extension
addressing mode" with null index register).

I've still not figured out what goes wrong with amiga/boot(8) when
compiled without -l option for gas(1)...

On 2022/04/27 20:48, Rin Okuyama wrote:
> Module Name: src
> Committed By: rin
> Date: Wed Apr 27 11:48:26 UTC 2022
>
> Modified Files:
> src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c
>
> Log Message:
> Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
> used instead of secsize obtained by SAIOSECSIZE ioctl.
>
> This hack avoids divdi3 and friends from being linked, in order to
> support variable secsize.
>
> This is useful for amiga/boot(8); it is loaded by firmware into
> unpredictable address, and therefore all symbols should be
> addressable by PC relative mode with only 16-bit displacements.
>
> See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for
> more details.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/ext2fs.c
> cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/minixfs3.c
> cvs rdiff -u -r1.83 -r1.84 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
 1.84 27-Apr-2022  rin Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
used instead of secsize obtained by SAIOSECSIZE ioctl.

This hack avoids divdi3 and friends from being linked, in order to
support variable secsize.

This is useful for amiga/boot(8); it is loaded by firmware into
unpredictable address, and therefore all symbols should be
addressable by PC relative mode with only 16-bit displacements.

See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for
more details.
 1.83 24-Apr-2022  mlelstv Don't load filessytem module for filesystem that was found but isn't used
for booting.
 1.82 24-Apr-2022  mlelstv Ask driver about sector size to support reading superblocks from fixed
byte offsets.
 1.81 19-Apr-2022  skrll Typo in comment. avoinds -> avoids
 1.80 27-May-2021  mrg add bi-endian support to the libsa ufs reader and enable it in efiboot.

ffs frontends to "ufs.c" now also define ufs_dinode_swap, ufs_indp_swap,
and FS_MAGIC (moved from ufs.c #if segments.) these are used to call
the right (32/64 bit) ffsv1/v2 version.

ufs.c 'struct file' gains f_swapped member. accessors for d_magic,
d_reclen, and d_ino are introduced (they need to be swapped.) sfter
reading an inode from disk, read_inode() may call ufs_dinode_swap().
indirect block number and caches may be swapped.

error handling in ffs_find_superblock() is cleaned up. (size is slightly
reduced on some ports with this part.)

defaults for new defines added to ufs.c. (XXX: we build ufs.c but i think
all the consumers don't use it, and we can stop building it.)

LFS support is not included.

add a cut-down copy of ffs_bswap.c from the kernel.

also enable bi-endian disklabel support in efiboot.

most ports build and sizes compared for platforms that don't enable this
code and all but one saw reduced code size. booted several platforms with
new boot code.
 1.79 12-May-2021  mrg push the FFSv1 superblock code into ffs_find_superblock() and
hide all the ugliness in this function, out of ufs_open().

NFC, objects same size if not identical.
 1.78 19-Dec-2020  rin branches: 1.78.4; 1.78.6;
Fix previous; define missing lfs_version.
 1.77 19-Dec-2020  rin ufs_open(): Check fs->lfs_version ifdef LIBSA_*L*FS, not LIBSA_*F*FS.

This was harmless for FFS variants, that define LIBSA_FFSv[12], not LIBSA_FFS.
 1.76 02-Apr-2019  christos branches: 1.76.12;
fix sign-compare and sign-passing errors.
 1.75 31-Mar-2019  christos fix warnings, printf formats, etc.
 1.74 01-Sep-2015  dholland branches: 1.74.18;
Add new accessors for the d_type and d_namlen fields of struct lfs_direct.
Napalm the old byteswap access logic for these.
 1.73 01-Sep-2015  dholland The ifile's inode number is constant. (it is always 1)

Therefore, storing the value in the superblock and reading it out
again is silly and offers the opportunity for it to become corrupted.
So, don't do that (most of the code already didn't) and use the
existing constant instead. Initialize new 32-bit superblocks with
the value for the sake of old userland programs, but don't keep the
value in the 64-bit superblock at all.

(approved by Margo Seltzer)
 1.72 12-Aug-2015  dholland Hack up dinode usage to be 64 vs. 32 as needed. Part 1.

(This part changes the native lfs code; the ufs-derived code already
has 64 vs. 32 logic, but as aspects of it are unsafe, and don't
entirely interoperate cleanly with the lfs 64/32 stuff, pass 2 will be
rehashing that.)
 1.71 12-Aug-2015  dholland Add IFILE32 and IFILE64 structures for the on-disk ifile entries.
Add and use accessors. There are also a bunch of places that cast and
I hope I've found them all...
 1.70 02-Aug-2015  dholland Add a (draft) 64-bit superblock. Make things build again.

Add pieces of support for using both superblock types where
convenient, and specifically to the superblock accessors, but don't
actually enable it anywhere.

First substantive step on PR 50000.
 1.69 28-Jul-2015  dholland Move struct salfs back inside libsa now that lfs_accessors.h is separate.
 1.68 28-Jul-2015  dholland Add a new lfs header file: lfs_accessors.h.

This contains all the accessor functions and macros out of lfs.h.
Add an include of lfs_accessors.h after all uses of lfs.h... except
for code that wants to define its own struct lfs-alike that the
accessors are supposed to play along with. For these, set STRUCT_LFS
and include lfs_accessors.h after the necessary structure has been
defined, so that lfs_accessors.h can emit functions in terms of it.
 1.67 24-Jul-2015  dholland Switch to accessor functions for elements of the LFS on-disk
superblock. This will allow switching between 32/64 bit forms on the
fly; it will also allow handling LFS_EI reasonably tidily. (That
currently doesn't work on the superblock.)

It also gets rid of cpp abuse in the form of fake structure member
macros.

Also, instead of doing sleep/wakeup on &lfs_avail and &lfs_nextseg
inside the on-disk superblock, add extra elements to the in-memory
struct lfs for this. (XXX: these should be changed to condvars, but
not right now)

XXX: this migrates a structure needed by the lfs code in libsa (struct
salfs) into lfs.h, where it doesn't belong, but for the time being
this is necessary in order to allow the accessors (and the various
lfs macros and other goop that relies on them) to compile.
 1.66 24-Jul-2015  dholland Rearrange the structures in the lfs bootbollocks slightly.
This generates the same output (at least on amd64) but will be more
robust until we're ready to deploy lfs64 bootblocks too.

XXX: I don't think these actually work right now, and the logic for
picking between v1 and v2 lfs formats (which is not related to ffsv1
vs. ffsv2) is definitely broken. But I haven't made it any worse.
 1.65 20-Mar-2014  christos branches: 1.65.6;
reduce size by 1K by sharing the ls code.
 1.64 20-Oct-2013  christos XXX: gcc initializations
 1.63 23-Jun-2013  dholland branches: 1.63.2;
Stick ffs_, ext2_, chfs_, filecore_, cd9660_, or mfs_ in front of
the following symbols so as to disambiguate fully. (Christos already
did the lfs ones.)

lblkno
lblktosize
lfragtosize
numfrags
blkroundup
fragroundup
 1.62 23-Jun-2013  dholland fsbtodb() -> FFS_FSBTODB(), EXT2_FSBTODB(), or MFS_FSBTODB()
dbtofsb() -> FFS_DBTOFSB() or EXT2_DBTOFSB()

(Christos already did the lfs ones a few days back)
 1.61 19-Jun-2013  dholland Rename ambiguous macros:
MAXDIRSIZE -> UFS_MAXDIRSIZE or LFS_MAXDIRSIZE
NINDIR -> FFS_NINDIR, EXT2_NINDIR, LFS_NINDIR, or MFS_NINDIR
INOPB -> FFS_INOPB, LFS_INOPB
INOPF -> FFS_INOPF, LFS_INOPF
blksize -> ffs_blksize, ext2_blksize, or lfs_blksize
sblksize -> ffs_blksize

These are not the only ambiguously defined filesystem macros, of
course, there's a pile more. I may not have found all the ambiguous
definitions of blksize(), too, as there are a lot of other things
called 'blksize' in the system.
 1.60 09-Jun-2013  dholland Stick UFS_ in front of these symbols:
DIRBLKSIZ
DIRECTSIZ
DIRSIZ
OLDDIRFMT
NEWDIRFMT

Part of PR 47909.
 1.59 22-Jan-2013  dholland Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.
 1.58 21-May-2012  dsl branches: 1.58.2;
Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.57 16-Jan-2012  christos branches: 1.57.2;
PR/45796: Evgeniy Ivanov minixfs3 support.
Split out fn_match since we have 3 copies now.
 1.56 25-Dec-2011  tsutsui Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.55 16-Jun-2011  joerg branches: 1.55.2; 1.55.6;
Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.54 19-Nov-2008  ad branches: 1.54.14;
For the x86 boot loader, autoload a kernel module corresponding to the
root file system type.
 1.53 02-Jan-2008  ad branches: 1.53.6; 1.53.10; 1.53.16; 1.53.18;
Merge vmlocking2 to head.
 1.52 01-Dec-2007  tsutsui branches: 1.52.2; 1.52.6;
Use "uint" rather than "unsigned" without a type.
 1.51 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.50 29-Sep-2007  martin branches: 1.50.4;
When compiled with COMPAT_SOLARIS_UFS, always calculate fs_qbmask and
fs_qfmask on the fly. This allows libsa to read newer Solaris ufs
filesystems (which have a slightly incompatible superblock).
Suggested by Antti Kantee when discussing PR kern/37000.
 1.49 11-May-2006  mrg branches: 1.49.18; 1.49.32; 1.49.34; 1.49.36;
ssize_t -> size_t to match variable and functions.
 1.48 25-Jan-2006  christos branches: 1.48.2; 1.48.4; 1.48.6; 1.48.8; 1.48.10;
free -> dealloc
 1.47 18-Jan-2006  uwe Define indp_t as signed int32_t, like ffsv1.c does.
 1.46 11-Dec-2005  christos branches: 1.46.2;
merge ktrace-lwp.
 1.45 19-Aug-2005  christos 64 bit inode changes.
 1.44 26-Feb-2005  perry branches: 1.44.4;
nuke trailing whitespace
 1.43 20-Mar-2004  dsl branches: 1.43.8; 1.43.10;
When searching for the superblock, check that the fs_sblockloc field
matches the location we read it from to ensure we don't have one of the
alternate superblocks.
Fixes part of PR kern/24809
 1.42 31-Aug-2003  fvdl Fix signed/unsigned warnings.
 1.41 27-Aug-2003  dsl Use memset not bzero to help shrink alpha bootxx_lfs
(sys/arch/alpha/stand/common/start.S also uses bzero, I don't know
any alpha opcodes so cant change that one...)
 1.40 22-Aug-2003  dsl Reduce memory footprint:
- use file buffer for all block reads
- only save a small amount of the indirect block list
Allows i386 bootxx_ufs code to load /boot from a filesystem with 32k blocks
while still fitting inside 64k of memory.
Code size reduced as well (by ~1k on i386).
It ought to be possible to use a buffer that is smaller than a filesystem
block. This might be needed in order to boot from filesystems with larger
block sizes.
 1.39 21-Aug-2003  elric Should call ufs_close() if it isn't being built in.
 1.38 18-Aug-2003  dsl make 'path' argument to ufs_open 'const char *' and fix the fallout.
 1.37 18-Aug-2003  dsl KNF, fix a comment or two
 1.36 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.35 11-Apr-2003  dsl branches: 1.35.2;
Merge in lfs.c, use defines to build ffsv1, ffsv2, lfsv1 or lfsv2.
(removes the ability to build a single ufs.o that supports ffs v1 and v2,
that animal was too large for some of the boot code.)
Use shifts and masks to avoid pulling in 64bit divide.
 1.34 02-Apr-2003  he Conditionalize declaration of local variable ``i'', now that the
code which uses it is also conditionalized.
 1.33 02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.32 23-Feb-2003  simonb Use the MAX() macro from <sys/param.h> instead of a local inline. Results
in same code size in ufs.c and removes an unused inline function in lfs.c.
 1.31 24-Jan-2003  fvdl Bump daddr_t to 64 bits. Replace it with int32_t in all places where
it was used on-disk, so that on-disk formats remain the same.
Remove ufs_daddr_t and ufs_lbn_t for the time being.
 1.30 30-Mar-2000  augustss Kill some more register declarations.
 1.29 13-Nov-1999  thorpej Backout my libsa changes.
 1.28 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.27 18-Aug-1999  cgd branches: 1.27.2; 1.27.4; 1.27.8;
note that these files should be easily diffable (until they share common code
 1.26 17-Aug-1999  cgd set f_seekp to 0 in ufs_open() before returning. It ended up being 0
in most situations, but not always: if the terminal path name component
being opened couldn't be found in the first fs block of the directory
that contained it, f_seekp would be non-zero (and Bad Things would result).
 1.25 01-Apr-1999  simonb branches: 1.25.2;
Don't compile in sanity checks for old file systems if
LIBSA_NO_COMPAT_UFS is defined.
 1.24 31-Mar-1999  simonb G/C UFS_NOSYMLINK, UFS_NOCLOSE and UFS_NOWRITE and use new LIBSA_NO_FS_*.
 1.23 31-Mar-1999  cgd Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.22 22-Feb-1999  simonb Drop support for symlinks of UFS_NOSYMLINK is defined.
Don't compile in ufs_close/ufs_write if UFS_NOCLOSE/UFS_NOWRITE is defined.
Remove trailing whitespace.
 1.21 11-Feb-1999  pk Add missing prototypes.
 1.20 01-Mar-1998  ross Sweep up some miscellaneous leftover lite2 integration shrapnel.
 1.19 26-Jun-1997  drochner Avoid user space headers for standalone programs.
Don't use sys/lib/libkern or sys/lib/libz if not standalone
(ie, user space test programs).
 1.18 13-Jun-1997  drochner Don't #include <string.h>, needed prototypes are in libkern.h.
 1.17 17-Jan-1997  cgd fix file system buffer leak that occurs if an error occurs (e.g. file not
found) during the file system open function after having read some data
from the disk. From Matthias Drochner (PR 3120).
 1.16 30-Sep-1996  ws Add support for booting from cd9660 fs
Support directory traversal and symbolic links for nfs booting
Close device when file opening failed
Plug memory leak in ufs code
 1.15 02-Jun-1996  ragge Fix include file order to confirm to KNF in master tree also.
 1.14 13-Jan-1996  leo branches: 1.14.4;
Some files containing more than one function are split. This reduces the
size of the resulting loader. The read_inode() function now returns the
result of the strategy function instead of success in all cases (ufs.c).
Fixes pr#1817
 1.13 20-Oct-1995  cgd add prototypes for static functions. make ffs_oldfscompat static.
fix some arguments and structure members, in recognition of the fact
that (u_int == u_long == size_t) is not true on all systems.
 1.12 17-Sep-1995  pk Revert fs_ops read/write declarations; these return error numbers.
Get rid of some more compiler warnings.
Set errno where appropriate.
 1.11 21-Feb-1995  mycroft Add a generic twiddler.
 1.10 07-Jan-1995  ws Better fix for the last.
Worked this out together with Darren Reed.
This one fixes several bugs, plus it's closer to the original
 1.9 06-Jan-1995  pk Update symbolic-link handling, from Darren Reed.
 1.8 26-Oct-1994  cgd new RCS ID format.
 1.7 22-Aug-1994  brezak branches: 1.7.2;
Cleanup to make more ANSI compliant; checkpoint
 1.6 27-Jul-1994  cgd include libkern.h
 1.5 27-Jul-1994  cgd get rid of someone else's bravery (stupidity)
 1.4 18-Jul-1994  pk Include ffs_oldfscompat() from ffs_vfsops.c; enables booting from pre-44
filesystems (on big-endian machines).
 1.3 20-Jun-1994  pk branches: 1.3.2;
Further adaptions to 4.4-lite header files.
 1.2 20-Jun-1994  glass make it compile w/4.4-lite header file changes
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.3.2.2 27-Jul-1994  cgd update from trunk.
 1.3.2.1 19-Jul-1994  cgd update from trunk, per pk.
 1.7.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.7.2.1 22-Aug-1994  brezak file ufs.c was added on branch netbsd-1-0 on 1994-08-22 21:56:16 +0000
 1.14.4.1 02-Jun-1996  ragge Fix include file order to confirm to KNF.
 1.25.2.1 20-Aug-1999  cgd pull up rev 1.26 from trunk (cgd)
 1.27.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.27.4.1 15-Nov-1999  fvdl Sync with -current
 1.27.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.35.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.35.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.35.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.35.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.35.2.1 03-Aug-2004  skrll Sync with HEAD
 1.43.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.43.8.1 29-Apr-2005  kent sync with -current
 1.44.4.4 21-Jan-2008  yamt sync with head
 1.44.4.3 07-Dec-2007  yamt sync with head
 1.44.4.2 27-Oct-2007  yamt sync with head.
 1.44.4.1 21-Jun-2006  yamt sync with head.
 1.46.2.1 01-Feb-2006  yamt sync with head.
 1.48.10.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.48.8.1 11-May-2006  elad sync with head
 1.48.6.1 24-May-2006  yamt sync with head.
 1.48.4.1 01-Jun-2006  kardel Sync with head.
 1.48.2.1 09-Sep-2006  rpaulo sync with head
 1.49.36.1 06-Oct-2007  yamt sync with head.
 1.49.34.2 09-Jan-2008  matt sync with HEAD
 1.49.34.1 06-Nov-2007  matt sync with HEAD
 1.49.32.3 03-Dec-2007  joerg Sync with HEAD.
 1.49.32.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.49.32.1 02-Oct-2007  joerg Sync with HEAD.
 1.49.18.1 09-Oct-2007  ad Sync with head.
 1.50.4.2 18-Feb-2008  mjf Sync with HEAD.
 1.50.4.1 08-Dec-2007  mjf Sync with HEAD.
 1.52.6.1 02-Jan-2008  bouyer Sync with HEAD
 1.52.2.1 28-Dec-2007  ad Make it build.
 1.53.18.1 19-Jan-2009  skrll Sync with HEAD.
 1.53.16.1 13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.53.10.1 04-May-2009  yamt sync with head.
 1.53.6.1 17-Jan-2009  mjf Sync with HEAD.
 1.54.14.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.55.6.2 02-Jun-2012  mrg sync to latest -current.
 1.55.6.1 18-Feb-2012  mrg merge to -current.
 1.55.2.4 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.55.2.3 23-Jan-2013  yamt sync with head
 1.55.2.2 23-May-2012  yamt sync with head.
 1.55.2.1 17-Apr-2012  yamt sync with head
 1.57.2.1 03-Jun-2012  jdc Pull up revisions:
src/sys/arch/i386/stand/lib/exec.c revision 1.50
src/sys/arch/sandpoint/stand/altboot/main.c revision 1.21 via patch
src/sys/lib/libsa/ext2fs.c revision 1.13
src/sys/lib/libsa/ffsv1.c revision 1.6
src/sys/lib/libsa/ffsv2.c revision 1.6
src/sys/lib/libsa/globals.c revision 1.9
src/sys/lib/libsa/lfsv1.c revision 1.5
src/sys/lib/libsa/lfsv2.c revision 1.5
src/sys/lib/libsa/stand.h revision 1.76
src/sys/lib/libsa/ufs.c revision 1.58
(requested by dsl in ticket #279).

Remove the code that tries to load the "ffs" kernel module during boot.
This is in line with the core decision than even modular kernels should
contain the ffs code.
I've left in the code that tries to load "nfs" and "ext2fs", but it
isn't clear that is necessary.
Removes a warning message that (usually) flashes past to fast to read.
AFAICT all the relevant kernels contain ffs (and nfs for that matter).
 1.58.2.4 03-Dec-2017  jdolecek update from HEAD
 1.58.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.58.2.2 23-Jun-2013  tls resync from head
 1.58.2.1 25-Feb-2013  tls resync with head
 1.63.2.1 18-May-2014  rmind sync with head
 1.65.6.1 22-Sep-2015  skrll Sync with HEAD
 1.74.18.1 10-Jun-2019  christos Sync with HEAD
 1.76.12.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.78.6.1 31-May-2021  cjep sync with head
 1.78.4.2 17-Jun-2021  thorpej Sync w/ HEAD.
 1.78.4.1 13-May-2021  thorpej Sync with HEAD.
 1.11 27-May-2021  mrg add bi-endian support to the libsa ufs reader and enable it in efiboot.

ffs frontends to "ufs.c" now also define ufs_dinode_swap, ufs_indp_swap,
and FS_MAGIC (moved from ufs.c #if segments.) these are used to call
the right (32/64 bit) ffsv1/v2 version.

ufs.c 'struct file' gains f_swapped member. accessors for d_magic,
d_reclen, and d_ino are introduced (they need to be swapped.) sfter
reading an inode from disk, read_inode() may call ufs_dinode_swap().
indirect block number and caches may be swapped.

error handling in ffs_find_superblock() is cleaned up. (size is slightly
reduced on some ports with this part.)

defaults for new defines added to ufs.c. (XXX: we build ufs.c but i think
all the consumers don't use it, and we can stop building it.)

LFS support is not included.

add a cut-down copy of ffs_bswap.c from the kernel.

also enable bi-endian disklabel support in efiboot.

most ports build and sizes compared for platforms that don't enable this
code and all but one saw reduced code size. booted several platforms with
new boot code.
 1.10 25-Dec-2011  tsutsui branches: 1.10.64; 1.10.66;
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.9 11-Dec-2005  christos branches: 1.9.110; 1.9.114;
merge ktrace-lwp.
 1.8 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.7 11-Apr-2003  dsl branches: 1.7.2;
Add externs for ffsv1_xxx and ffsv2_xxx
 1.6 14-Apr-1999  drochner move "ls" utility from i386/stand/libsa here
 1.5 20-Oct-1995  cgd branches: 1.5.26;
oops; i forgot these u_int -> size_t conversions.
 1.4 20-Oct-1995  cgd fix prototypes here, to match u_int->size_t changes in ufs.c
 1.3 17-Sep-1995  pk Revert fs_ops read/write declarations; these return error numbers.
Get rid of some more compiler warnings.
Set errno where appropriate.
 1.2 26-Oct-1994  cgd new RCS ID format.
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.5.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.7.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.2.1 03-Aug-2004  skrll Sync with HEAD
 1.9.114.1 18-Feb-2012  mrg merge to -current.
 1.9.110.1 17-Apr-2012  yamt sync with head
 1.10.66.1 31-May-2021  cjep sync with head
 1.10.64.1 17-Jun-2021  thorpej Sync w/ HEAD.
 1.15 25-Dec-2011  tsutsui Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.14 24-Nov-2007  isaki branches: 1.14.52; 1.14.56;
style, indent, and ANSI-fy.
 1.13 25-Jan-2006  christos branches: 1.13.42; 1.13.44; 1.13.50;
free -> dealloc
 1.12 11-Dec-2005  christos branches: 1.12.2;
merge ktrace-lwp.
 1.11 19-Aug-2005  christos 64 bit inode changes.
 1.10 09-Apr-2005  dsl branches: 1.10.2;
Use std form for a multi-line comment
 1.9 26-Feb-2005  perry nuke trailing whitespace
 1.8 24-Mar-2004  drochner branches: 1.8.8; 1.8.10;
I was told I'm just an "author", not a "regent"
 1.7 24-Mar-2004  drochner remove license clauses 3 and 4 from my copyright notice
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.5 18-Mar-2003  mycroft branches: 1.5.2;
Move some stuff into .rodata.
 1.4 23-Feb-2003  simonb We can't use <string.h> for standalone programs;
use <lib/libkern/libkern.h> for str*() prototypes instead.
 1.3 01-Feb-2003  dsl Support limited filename globbing
- agreed by christos
 1.2 09-May-2002  simonb Don't bother testing if a uint8_t is > 256 -- that test is always false.
 1.1 14-Apr-1999  drochner branches: 1.1.2; 1.1.16; 1.1.18;
move "ls" utility from i386/stand/libsa here
 1.1.18.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.16.1 20-Jun-2002  nathanw Catch up to -current.
 1.1.2.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.5.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1 03-Aug-2004  skrll Sync with HEAD
 1.8.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.8.8.1 29-Apr-2005  kent sync with -current
 1.10.2.2 07-Dec-2007  yamt sync with head
 1.10.2.1 21-Jun-2006  yamt sync with head.
 1.12.2.1 01-Feb-2006  yamt sync with head.
 1.13.50.1 08-Dec-2007  mjf Sync with HEAD.
 1.13.44.1 09-Jan-2008  matt sync with HEAD
 1.13.42.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.14.56.1 18-Feb-2012  mrg merge to -current.
 1.14.52.1 17-Apr-2012  yamt sync with head
 1.37 21-Nov-2019  mrg apply the strncmp hack only to !clang. requested by tnn.
 1.36 21-Nov-2019  mrg from the new comment:

* XXX Hack alert. GCC 8.3 mis-compiles this function and calls
* strncmp() with the wrong second pointer, as seen in PR#54703.
*
* Until the real cause is located, work around it by using -O1
* for this function.

this hack is restricted to i386.
 1.35 20-Mar-2014  christos branches: 1.35.30;
reduce size by 1K by sharing the ls code.
 1.34 25-Dec-2011  tsutsui branches: 1.34.6; 1.34.10;
Apply the following patch submitted by Evgeniy Ivanov:
http://mail-index.NetBSD.org/tech-kern/2011/12/15/msg012226.html
http://mail-index.NetBSD.org/tech-kern/2011/12/17/msg012229.html

- add 'ls' op to struct fs_ops to support ls command on each fs,
enabled by -DLIBSA_ENABLE_LS_OP and SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
in libsa
- split sys/lib/libsa/ufs_ls.c into UFS specific part and MI part (ls.c)
that opens the target fs and calls fs-depedent XXX_ls() functions
- add a ls op for ext2fs
(all other fs than ufs and ext2fs don't have actual ls ops yet)
- replace existing MD ufs_ls() calls with this new MI ls()

The original patch was written for i386 and ext2fs.
zaurus zboot has been tested by nonaka@.
ews4800mips and x68k loaders have been tested by me (with several fixes).
landisk might be okay since it was almost copied from i386.

XXX1: "ls" op in fs_ops looks a bit inconsistent, but we will be able to
replace it with real fs ops like readdir if it's really worth
XXX2: someone might have to check sys/arch/ia64/stand/efi/libefi/efifs_ls.c
 1.33 16-Jun-2011  joerg branches: 1.33.2; 1.33.6;
Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.
 1.32 17-Jan-2009  tsutsui branches: 1.32.12;
Remove __P().
 1.31 24-Nov-2007  isaki branches: 1.31.18; 1.31.26;
style, indent, and ANSI-fy.
 1.30 11-Nov-2007  isaki x68k's floppy is 8*2 sect/cyl, not 18*2 sect/cyl.
 1.29 05-Mar-2007  he branches: 1.29.14; 1.29.16; 1.29.20; 1.29.22;
We need char* for pointer arithmetic.
 1.28 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.27 27-Jan-2006  uwe branches: 1.27.24;
Don't omit int arguments in the K&R style function definitions.
 1.26 25-Jan-2006  christos free -> dealloc
 1.25 11-Dec-2005  christos branches: 1.25.2;
merge ktrace-lwp.
 1.24 26-Feb-2005  perry branches: 1.24.4;
nuke trailing whitespace
 1.23 31-Aug-2003  fvdl branches: 1.23.8; 1.23.10;
Fix signed/unsigned warnings.
 1.22 18-Aug-2003  dsl make 'path' argument to ufs_open 'const char *' and fix the fallout.
 1.21 18-Mar-2003  mycroft branches: 1.21.2;
Move some stuff into .rodata.
 1.20 11-Mar-2003  jmmv After the "insert disk <number>, and press return..." message, check only
for the return keypress.
 1.19 10-May-2002  lukem fix comment
 1.18 30-Mar-2002  matt Add a 1byte pad to make the ustar_t word aligned so the uas_1cyl after it
will also be word aligned. This makes the VAX VMB bootrom happy since it
doesn't support odd-aligned buffers.
 1.17 22-Feb-2002  lukem fix spelos
 1.16 28-Sep-2001  minoura Add changedisk_hook().
Machine-dependent code can eject the floppy to prompt the next volume in it.
(Or add another method in devsw?)
 1.15 02-Oct-2000  lukem branches: 1.15.2; 1.15.4; 1.15.6;
show "press return" instead of "type return", since it's a key name and
not the actual word...
 1.14 13-Nov-1999  thorpej branches: 1.14.4;
Backout my libsa changes.
 1.13 11-Nov-1999  thorpej Update for the improvements to libsa, and don't reference libkern.h.
 1.12 20-Sep-1999  ross branches: 1.12.2; 1.12.4; 1.12.8;
Fix error flow that was broken 10 days ago in the previous commit.
Fixes the broken i386 boot blocks and closes port-i386/8432.
 1.11 10-Sep-1999  ross * Fix the volume zero recognition bug; it was interacting with a
feature to avoid rereads (which was added to work around bugs in
old SRM versions that wouldn't rewind DATs, but would return no
error on rewind callbacks)
* Initialize the volzero signature in ustarfs_open(), rather than as a
side effect of the first read.
* Centralize error retry.
 1.10 01-Sep-1999  ross Fix read retry error case. Closes kern/8300.
While here, add automatic error retry up to 3 times.
 1.9 22-Jun-1999  christos bring back my friend the twiddle.
 1.8 31-Mar-1999  cgd branches: 1.8.4;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.7 26-Mar-1999  dbj Changes to compile the next68k bootblocks with
egcs -Wpointer-arith -Wstrict-prototypes
This closes pr 6653
 1.6 19-Dec-1998  he Retry ustarfs_cylinder_read after disk change, apparently required on i386.
 1.5 30-Oct-1998  matt Conditionalize include of <lib/libkern/libkern.h> with _STANDALONE (like
libsa/nfs.c does). Fixes VAX libsa build problem.
 1.4 15-Oct-1998  bad Work around gcc warning.
 1.3 15-Oct-1998  ross 1. Avoid snarfing label areas unless necessary; read with monotonically
increasing block numbers and don't reread cylinder 0.

2. Recognize the USTAR.... meta-info file...kind of like a super-block,
it makes the volume size and label info programmable.
 1.2 05-Oct-1998  ross Reserve an 8K label area on every disk, not just the first. Rewrite the block
addressing and disk changing code. Separate disk addressing into three layers.
(virtual: ustar format space spanning volumes, logical: format space relative
to current volume, and physical: standard meaning). Compute a checksum of the
disk 0 8k label area, and define a label for disk 2, 3.... Detect incorrect
disk changing order and attempt to recognize our disk 0 from its checksum.
 1.1 24-Sep-1998  ross tfs -> ustarfs
 1.8.4.1 01-Jul-1999  thorpej Sync w/ -current.
 1.12.8.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.12.4.1 15-Nov-1999  fvdl Sync with -current
 1.12.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.14.4.1 03-Oct-2000  lukem pull up rev 1.15 (approved by thorpej):
fix a prompt to say `press return' instead of `type return'
 1.15.6.1 01-Oct-2001  fvdl Catch up with -current.
 1.15.4.3 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.15.4.2 16-Mar-2002  jdolecek Catch up with -current.
 1.15.4.1 10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.15.2.4 20-Jun-2002  nathanw Catch up to -current.
 1.15.2.3 17-Apr-2002  nathanw Catch up to -current.
 1.15.2.2 28-Feb-2002  nathanw Catch up to -current.
 1.15.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.21.2.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.21.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.21.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.21.2.1 03-Aug-2004  skrll Sync with HEAD
 1.23.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.23.8.1 29-Apr-2005  kent sync with -current
 1.24.4.4 07-Dec-2007  yamt sync with head
 1.24.4.3 15-Nov-2007  yamt sync with head.
 1.24.4.2 03-Sep-2007  yamt sync with head.
 1.24.4.1 21-Jun-2006  yamt sync with head.
 1.25.2.1 01-Feb-2006  yamt sync with head.
 1.27.24.1 12-Mar-2007  rmind Sync with HEAD.
 1.29.22.2 08-Dec-2007  mjf Sync with HEAD.
 1.29.22.1 19-Nov-2007  mjf Sync with HEAD.
 1.29.20.1 13-Nov-2007  bouyer Sync with HEAD
 1.29.16.1 09-Jan-2008  matt sync with HEAD
 1.29.14.2 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.29.14.1 11-Nov-2007  joerg Sync with HEAD.
 1.31.26.1 19-Jan-2009  skrll Sync with HEAD.
 1.31.18.1 04-May-2009  yamt sync with head.
 1.32.12.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.33.6.1 18-Feb-2012  mrg merge to -current.
 1.33.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.33.2.1 17-Apr-2012  yamt sync with head
 1.34.10.1 18-May-2014  rmind sync with head
 1.34.6.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.35.30.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 18-Aug-2003  dsl make 'path' argument to ufs_open 'const char *' and fix the fallout.
 1.1 24-Sep-1998  ross branches: 1.1.46;
tfs -> ustarfs
 1.1.46.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.46.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.46.1 03-Aug-2004  skrll Sync with HEAD
 1.6 26-Mar-2014  christos Remove {v,}sprintf
 1.5 17-Jul-2011  joerg branches: 1.5.2; 1.5.12; 1.5.16;
Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
 1.4 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.3 11-Dec-2005  christos branches: 1.3.44; 1.3.46; 1.3.52;
merge ktrace-lwp.
 1.2 07-Aug-2003  agc branches: 1.2.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 13-Feb-1999  pk branches: 1.1.42;
Split the printf variants into separate files.
 1.1.42.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.42.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.42.1 03-Aug-2004  skrll Sync with HEAD
 1.2.16.1 07-Dec-2007  yamt sync with head
 1.3.52.1 08-Dec-2007  mjf Sync with HEAD.
 1.3.46.1 09-Jan-2008  matt sync with HEAD
 1.3.44.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.5.16.1 18-May-2014  rmind sync with head
 1.5.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.5.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15 02-Dec-2007  tsutsui unsigned -> unsigned int
 1.14 24-Nov-2007  isaki style, indent, and ANSI-fy.
 1.13 13-Jan-2006  christos branches: 1.13.42; 1.13.44; 1.13.50;
constify write prototype.
 1.12 11-Dec-2005  christos branches: 1.12.2;
merge ktrace-lwp.
 1.11 26-Feb-2005  perry branches: 1.11.4;
nuke trailing whitespace
 1.10 07-Aug-2003  agc branches: 1.10.8; 1.10.10;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.9 30-Mar-2000  augustss branches: 1.9.28;
Kill some more register declarations.
 1.8 31-Mar-1999  cgd branches: 1.8.8;
Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified
by compiling one of the alpha boot blocks which uses all of the code
before and after, diffing the object files, and manually verifying that
the differences were 'correct'. some differences were "unavoidable,"
it wanting to avoid a double-commit, because e.g. local variables which
were previously used were no longer used.) a README which describes
supported options (or at least the ones mentioned below) is forthcoming.

add support for the preprocessor macro LIBSA_NO_TWIDDLE, which
causes calls to twiddle() to be omitted if it's defined.
add support for the preprocessor macros:
LIBSA_NO_FS_CLOSE
LIBSA_NO_FS_WRITE
LIBSA_NO_FS_SEEK
which, if defined, cause the corresponding file system operations
in the individual file system implementations to be omitted. (note
that all of those macros are not supported by all file systems at
this point. comments were added to individual file system files
to indicate lack of support, and should be cleaned up later. Backward
compatibility options e.g. UFS_NOCLOSE, etc., are supported.)
add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which
removes support for symbolic links from the file system support
functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which
removes all subdirectory and symlink support from the file system
support functions. (same notes as for the macros above apply.)
add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which
causes code relating to libsa file descriptor checks (e.g. range
checking and checking that a file descriptor is valid) to be
omitted if it's defined.
add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which
causes code relating to raw device access to be omitted if it's
defined.
change some structure copies to use bcopy() instead. that way
use of bcopy vs. memcpy() can easily be selected by
LIBSA_USE_MEMCPY. (without changes like these, you could end up
having both bcopy() and memcpy() included. eventually, all
calls to bcopy should be changed to calls to memcpy() or memmove()
as appropriate -- hopefully never the latter -- with an option to
use bcopy instead.)
add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which
causes disklabel() to return '1' as msg rather than a string. Can
be used if the boot blocks don't care about the string, and need to
save the space.
add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which
if defined causes all of the file system switch code to be removed.
Its value should be the name of the file system supported by the
boot block, e.g. "ufs" for the FFS file system. calls to the
file system functions open, close, etc., which were previously
done through a function switch are then done via direct invocation
of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...).
add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which
does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device
switch table. Device entry pointes are expected to be named
<dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE
is set to 'disk' is diskstrategy.
make ufs.c f_nindir array be unsigned ints. the fact that it was signed
caused ufs.c to require signed division routines (which were otherwise
unnecessary for a small boot block).
 1.7 21-Jun-1996  pk Oh, what's in a name..
 1.6 21-Jun-1996  pk Allow seeks on raw devices. A `f_offset' field is added to the file structure
which is maintained in lseek(), read() and write(), and passed along to
the device's strategy routine.
 1.5 14-Sep-1995  pk Clear up some size_t/ssize_t confusion.
 1.4 21-Feb-1995  mycroft Add a generic twiddler.
 1.3 26-Oct-1994  cgd new RCS ID format.
 1.2 22-Aug-1994  brezak branches: 1.2.2;
Cleanup to make more ANSI compliant; checkpoint
 1.1 26-Jan-1994  brezak CMU/4.4 stand-alone library
 1.2.2.2 22-Aug-1994  brezak Cleanup to make more ANSI compliant; checkpoint
 1.2.2.1 22-Aug-1994  brezak file write.c was added on branch netbsd-1-0 on 1994-08-22 21:56:18 +0000
 1.8.8.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
 1.9.28.4 04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.9.28.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.28.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.28.1 03-Aug-2004  skrll Sync with HEAD
 1.10.10.1 19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.10.8.1 29-Apr-2005  kent sync with -current
 1.11.4.2 07-Dec-2007  yamt sync with head
 1.11.4.1 21-Jun-2006  yamt sync with head.
 1.12.2.1 15-Jan-2006  yamt sync with head.
 1.13.50.1 08-Dec-2007  mjf Sync with HEAD.
 1.13.44.1 09-Jan-2008  matt sync with HEAD
 1.13.42.2 03-Dec-2007  joerg Sync with HEAD.
 1.13.42.1 27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.

RSS XML Feed