Subject: Null console (was: Re: Help me defend NetBSD's honor!)
To: Perry E. Metzger <perry@piermont.com>
From: Quentin Garnier <netbsd@quatriemek.com>
List: current-users
Date: 03/10/2003 13:19:15
This is a multi-part message in MIME format.
--Multipart_Mon__10_Mar_2003_13:19:15_+0100_08837200
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Le 09 Mar 2003 10:57:59 -0500
Perry E. Metzger a écrit :
>
> Martin Husemann <martin@duskware.de> writes:
> > On Sun, Mar 09, 2003 at 05:01:10AM -0600, Peter Seebach wrote:
> > > Unfortunately, the 4521 only has one physical serial port.
> >
> > I didn't try but shouldn't it be a no brainer to add a new /dev/null
> > cnattach to sys/arch/x86/x86/consinit.c, enabled by a config option?
>
> Not even any need to do that -- we should simply create an option that
> replaces the consinit() in init_main.c:main() with a call that
> initializes the function pointers to dummys. Then it will be MI and
> all ports can have the functionality.
>
> Shouldn't take more than ten minutes to write.
FWIW, here's a patch. It actually took a lot more that 10 minutes, because
if the kernel part is indeed trivial, when init starts it needs some kind
of tty emulation (TIOCSCTTY for libutil's login_tty), and just returning 0
for that ioctl is not enough (setting s_ttyp to non NULL prevent a
segfault later when the very first process that init creates exits).
And you know, debugging with no console... Not easy.
I prefer to zero the nulltty struct at each TIOCSCTTY ioctl to avoid any
side effect from the garbage left by the previous controlling process.
To use the patch as it is, add 'options CONS_OVERRIDE' and 'options
CONSDEVNAME="\"null\""' (null or at least neither pc nor com). If it's
worth it, a 'NULLCONSOLE' option could be added that simply #ifdef out the
relevant code and keep only the call to nullcnattach().
Changing other consinit.c should be trivial, just make sure it's actually
/dev/null's dev_t you pass to nullcnattach().
--
Quentin Garnier - cube@cubidou.net
"Feels like I'm fiddling while Rome is burning down.
Should I lay my fiddle down and take a rifle from the ground ?"
Leigh Nash/Sixpence None The Richer, Paralyzed, Divine Discontents, 2002.
--Multipart_Mon__10_Mar_2003_13:19:15_+0100_08837200
Content-Type: application/octet-stream;
name="diff"
Content-Disposition: attachment;
filename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