strange behaviour with /sbin/init and serial console
Thierry Herbelot
thierry.herbelot at free.fr
Fri Oct 31 10:14:48 PDT 2008
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
@@ -44,6 +44,8 @@
"$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>
@@ -239,6 +241,23 @@
*/
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.
*/
More information about the freebsd-hackers
mailing list