Am I correct in assuming on boot, /etc/tty is read and then init spawns serials consoles if the corresponding serial console exists under /dev?
Context is https://github.com/OpenRC/openrc/issues/1039
Thoughts/comments would be appreciated.
Also would be interested if anyone runs a #BSD with OpenRC.
CC @mirabilos
@werdahias highly depends on which BSD.
For example, FreeBSD and derivatives vs. normal BSDs. But then, NetBSD and OpenBSD may also have diverged from each other, and OpenBSD’s init procedure has changed from since when MirBSD forked…
Quick look at MirBSD:
there’s no
/etc/gettyat all/etc/gettytabcontains a few entries for serially attached hardware consoles but is mostly historicalthere is a
/etc/ttyswhich contains a list of things like:# name getty type status comments ttyC0 "/usr/libexec/getty Pc" wsvt25 on secure ttyC1 "/usr/libexec/getty Pc" wsvt25 on secure ttyC2 "/usr/libexec/getty Pc" wsvt25 on secure […] tty00 "/usr/libexec/getty std.9600" unknown on tty01 "/usr/libexec/getty std.9600" unknown off […] ttyp0 none network ttyp1 none network […]These list the virtual, serial and pseudo terminals, respectively; it’s comparable to the same section in
inittab(5)in sysvinit. (There’s also an entry for “console” where I did some baudrate autodetection magic for MirBSD. One can use either that or the entries for ttyC0/tty00/both.)the
ttys(5)file is read byinit(8)after/etc/rchas run, with the functions from<ttyent.h>(libc), so the format is actually defined therebynew_session()insrc/sbin/init/init.cprepares theargv[]for each getty for each line enabled inttys(the “on” vs. “off”)multi_user()actually starts the gettys then viastart_getty()but interrupts if there is “serious” trouble getting a getty to runthe fork child opens the device with
O_NONBLOCKbeforeexecing getty;(fd == -1 && (errno == ENXIO || errno == ENOENT || errno == EISDIR))is considered “session shutdown”, not “serious trouble”;fd == -1in other cases is not even considered an error (let getty handle that; the fd (or-1) is justclosed, then gettyexecd); failure topipe,fork, etc. is “serious trouble”if
gettyreturns too quickly too often, the session on that terminal is put idle, with a huge warning, for a few minutes, then is retried
So it boils down to which devices are enabled in ttys and then either return ENXIO on open(2) or work.
@werdahias ah, and the device nodes under /dev always exist (in a normal setup), they are created by MAKEDEV at installation time.
@werdahias AIUI this is different for FreeBSD which has some kind of devfs.
@werdahias nah, the nodes always exist
@werdahias it’s like pre-dev{,tmp}fs Linux, the installer or MAKEDEV script creates a bunch of known nodes statically and some in reserve.
Again, not speaking for FreeBSD, only classic BSD.