Skip to contentSkip to conversation

serial console _after_ boot ? - was: Redirect kernel console

DISCUSSION [email protected] 2 participants 2 messages Jan 3, 2008

lore
Share & tools
lore
#0 lore raw

fantastic, thanks!

unfortunately......

opensuse103:/home/roland/serialcons # ./mytioccons
ioctl: Device or resource busy

but, it`s not userspace:

opensuse103:/home/roland # lsof |egrep "console|ttyS0" opensuse103:/home/roland #

in tty_io.c -> ticoccons() there is

        if (redirect) {
                spin_unlock(&redirect_lock);
                return -EBUSY;
        }

but i`m not deep enough into programming to understand this.

-------------------
mytioccons.c

#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <libio.h>
#include <errno.h>
#include <stdio.h>

int main(void)
{
int fd = open("/dev/ttyS0", O_RDWR);
int errno;

ioctl(0, TIOCCONS, NULL);

if (ioctl(fd, TIOCCONS, NULL) < 0)

        printf("ioctl: %s\n", strerror(errno));
}

-------------------

Quoted 31 lines

-----Ursprüngliche Nachricht-----
Von: "Jan Engelhardt" <[email protected]>
Gesendet: 03.01.08 14:28:45
An: [email protected]
CC: [email protected]
Betreff: Re: serial console _after_ boot ? - was: Redirect kernel console

Quoted 4 lines · On Jan 3 2008 13:43, [email protected] wrote:

hi !

i was wondering how to make kernel messages appear on /dev/ttyS0 without a reboot, i.e. kernelparam "console=ttyS0"

The solution is simple... the following piece of code is inside opensuse-10.3/src/sysvinit-2.86-115.src.rpm#showconsole-1.08.tar.bz2#showconsole-1.08/blogd.c

(void)ioctl(0, TIOCCONS, NULL); /* Undo any current map if any */ if (ioctl(pts, TIOCCONS, NULL) < 0)
error("can not set console device to %s: %s\n", ptsname, strerror(errno));

so I suppose that's it. Write up a new program that calls the ioctl on a tty, and you should be done. IOW:

#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>

Quoted 7 lines

int main(void)

{
	int fd = open("/dev/ttyS0", O_RDWR);
	ioctl(0, TIOCCONS, NULL);
	ioctl(fd, TIOCCONS, NULL);
}

__________________________________________________________________________
Erweitern Sie FreeMail zu einem noch leistungsstärkeren E-Mail-Postfach! Mehr Infos unter http://produkte.web.de/club/?mc=021131

#1 lore raw
Quoted 7 lines · On Jan 3 2008 15:39, [email protected] wrote:

fantastic, thanks!

unfortunately......

opensuse103:/home/roland/serialcons # ./mytioccons
ioctl: Device or resource busy

Quoted 7 lines

but i`m not deep enough into programming to understand this.

int main(void)
{
int fd = open("/dev/ttyS0", O_RDWR);
int errno;

This errno is so out of place.

Quoted 6 lines

ioctl(0, TIOCCONS, NULL);

if (ioctl(fd, TIOCCONS, NULL) < 0)

       printf("ioctl: %s\n", strerror(errno));
}