Bug#827718: init: open /dev/console on GNU/kFreeBSD
Package: busybox
Version: 1.22.0-19
Tags: patch
FreeBSD kernel doesn't tell PID 1 the pathname of /dev/console through CONSOLE environment variable like Linux does. Instead it expects PID 1 to always open /dev/console.
This patch is tested on ubuntuBSD but I think it should work on Debian too (I haven't tested the whole init yet, but I verified that with my patch it can print to stdout).
I've also sent it to BusyBox bugzilla: https://bugs.busybox.net/show_bug.cgi?id=9031
--
Jon Boden
ubuntuBSD -- The power of FreeBSD kernel with familiarity of Ubuntu OS!
http://www.ubuntubsd.org/ -- https://twitter.com/ubuntuBSD
Index: busybox-1.22.0/init/init.c
===================================================================
--- busybox-1.22.0.orig/init/init.c
+++ busybox-1.22.0/init/init.c
@@ -277,11 +277,19 @@ static void console_init(void)
#ifdef VT_OPENQRY
int vtno;
#endif
- char *s;
+#if defined(__linux__)
+ char *s;
s = getenv("CONSOLE");
if (!s)
s = getenv("console");
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ const char *s;
+ s = "/dev/console";
+#else
+#error "we don't know how to open the console on this system"
+#endif
+
if (s) {
int fd = open(s, O_RDWR | O_NONBLOCK | O_NOCTTY);
if (fd >= 0) {
Reply to: