strange behaviour with /sbin/init and serial console

From: Thierry Herbelot <thierry.herbelot_at_free.fr>
Date: Fri, 31 Oct 2008 17:46:23 +0100
Hello,

with the following patch on /sbin/init, I have two different behaviours 
depending on the console type (on a i386/32 PC) :
- on a video console, I see the expected two messages,
- on a serial console, the messages are not displayed (init silently finishes 
its job and gets to start /etc/rc and everything)

I assume that the writev system call is implemented in 
src/sys/kern/tty_cons.c::cnwrite(), but I could not parse the code to find an 
explanation.

	any taker ?

	TfH

PS : this is initially for a RELENG_6 machine, but the code is quite similar 
under RELENG_7 or Current

--- usr/src/sbin/init/init.c.ori    2008-10-31 14:20:48.294794898 +0100
+++ usr/src/sbin/init/init.c        2008-10-31 14:12:16.168062031 +0100
_at__at_ -44,6 +44,8 _at__at_
   "$FreeBSD: src/sbin/init/init.c,v 1.60.2.2 2006/07/08 15:34:27 kib Exp $";
 #endif /* not lint */

+#include <sys/types.h>
+
 #include <sys/param.h>
 #include <sys/ioctl.h>
 #include <sys/mount.h>
_at__at_ -239,6 +241,23 _at__at_
         */
        openlog("init", LOG_CONS|LOG_ODELAY, LOG_AUTH);

+       warning("warning after openlog");
+{
+int fd;
+          if ((fd = open("/dev/console", O_WRONLY|O_NONBLOCK, 0)) >= 0) {
+               struct iovec iov[2];
+               struct iovec *v = iov;
+
+               v->iov_base = (void *)"iov direct write test";
+               v->iov_len = 21;
+               ++v;
+               v->iov_base = (void *)"\r\n";
+               v->iov_len = 2;
+               (void)writev(fd, iov, 2);
+               (void)close(fd);
+       }
+
+}
        /*
         * Create an initial session.
         */
Received on Fri Oct 31 2008 - 16:14:47 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:36 UTC