On Thu, Aug 8, 2019 at 7:16 PM Warner Losh <imp@bsdimp.com> wrote:


On Thu, Aug 8, 2019, 7:47 PM Grant Taylor via TUHS <tuhs@minnie.tuhs.org> wrote:
On 8/7/19 7:04 AM, Clem Cole wrote:
> FWIW: V7 had /stand which was a funky UNIX-like standalone system that
> some applications could be compiled.

I've seen /stand on a few systems (I think SCO OpenServer and / or
UnixWare) but never really knew what it was for.  I think I had naively
assumed it was associated with the kernel and / or booting.

Now I'm somewhat more curious what it was.  Was it a simplified version
of the OS with minimal utilities with fewer dependencies so that the
system could boot and load more features.

Yes. There was a library that implemented much of the unix API in a simplified way that ran on bare metal.

I thought that Linux's initramfs / initrd had the usual suspect files /
utilities copied from /.  So the idea that a utility in /stand would be
different from the same utility in / seems strange to me.

They are because there was no kernel for them to run under. They were similar, but if you go look at the sources, they are different. 

> The problem was that it was a little different so you would end up
> seeing #ifdef STAND in code for things like fsck, fsdb, even cat.
> At Masscomp we ended up with three target environments for a couple of
> the system maintenance utilities: the OS, /stand and the boot ROMS.
> This was expensive/a PITA to maintain and keep straight, and in the
> case of the boot ROM, space was a huge problem.

Ya.  I can see how that would be a PITA to maintain.

FreeBSD, NetBSD and OpenBSD all implement some version of this. FreeBSD has it in src/stand in honor of V7 stand. I did that when I integrate / rewrote the GSoC project to bring Lua scripting to the boot loader. The other BSDs have it split between sys/boot and lib/libs. FreeBSD uses it to implement the rich boot loader which knows how to load off a lot of different file systems and BIOS interfaces. Net/OpenBSD use it more modestly in their boot loaders, but have a few standalone programs for things like bootstrapping VAXen.

Yeah NetBSD has little gadgets in the ports stand directory for booting odd hardware.  It would be preferable to have something like FreeBSD’s loader everywhere, but that would be hard to cover to the swath of ports NetBSD has, and would still require chain loading gadgets for many platforms.