NetBSD Problem Report #45420
From woods@once.weird.com Tue Oct 4 18:33:55 2011
Return-Path: <woods@once.weird.com>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id BB0A763B85F
for <gnats-bugs@gnats.NetBSD.org>; Tue, 4 Oct 2011 18:33:55 +0000 (UTC)
Message-Id: <m1RB9oM-001EBeC@once.weird.com>
Date: Tue, 4 Oct 2011 11:33:50 -0700 (PDT)
From: "Greg A. Woods" <woods@planix.com>
Sender: "Greg A. Woods" <woods@once.weird.com>
Reply-To: "Greg A. Woods" <woods@planix.com>
To: gnats-bugs@gnats.NetBSD.org
Subject: kernel should verify both /dev/constty and /dev/console
X-Send-Pr-Version: 3.95
>Number: 45420
>Category: kern
>Synopsis: kernel should verify both /dev/constty and /dev/console
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Tue Oct 04 18:35:00 +0000 2011
>Originator: Greg A. Woods
>Release: -current 2011/10/04
>Organization:
Planix, Inc.; Kelowna, BC; Canada
>Environment:
System: NetBSD
Architecture: all
Machine: all
>Description:
the kernel checks to see if /dev/console exits, but fails to
also check if /dev/constty exits
both should exist for constty to be used properly
also note the updated comment -- is it really that much more
work to craft up open file descriptors for the active console
device?
>How-To-Repeat:
>Fix:
--- init_main.c 28 Sep 2011 16:06:27 -0700 1.436
+++ init_main.c 04 Oct 2011 10:56:04 -0700
@@ -832,6 +832,15 @@
printf("warning: no /dev/console\n");
else
printf("warning: lookup /dev/console: error %d\n", error);
+
+ error = namei_simple_kernel("/dev/constty",
+ NSM_FOLLOW_NOEMULROOT, &vp);
+ if (error == 0)
+ vrele(nd.ni_vp);
+ else if (error == ENOENT)
+ printf("warning: no /dev/constty\n");
+ else
+ printf("warning: lookup /dev/constty: error %d\n", error);
}
/*
@@ -881,10 +890,16 @@
mutex_exit(proc_lock);
/*
- * This is not the right way to do this. We really should
- * hand-craft a descriptor onto /dev/console to hand to init,
- * but that's a _lot_ more work, and the benefit from this easy
- * hack makes up for the "good is the enemy of the best" effect.
+ * This is not the right way to do this. We really should hand-craft
+ * descriptors onto the active console device we're using internally in
+ * the kernel, just as if they were open on /dev/constty, and pass
+ * those to init as its STDIO descriptors, but apparently that's a
+ * _lot_ more work.
+ *
+ * This easy hack at least leaves hints on the real console whenever
+ * there's a potential problem with the /dev/console and/or
+ * /dev/constty files; and init's attempts to hook on to the console
+ * will hopefully do for now.
*/
check_console(l);
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.