* Re: serial console _after_ boot ? - was: Redirect kernel console
@ 2008-01-03 12:43 devzero
2008-01-03 13:27 ` Jan Engelhardt
0 siblings, 1 reply; 7+ messages in thread
From: devzero @ 2008-01-03 12:43 UTC (permalink / raw)
To: linux-kernel; +Cc: jengelh
hi !
i was wondering how to make kernel messages appear on /dev/ttyS0 without a reboot, i.e. kernelparam "console=ttyS0"
after playing for a while with setconsole, setterm and klogconsole i didn`t find a way to make that happen.
i can do "setconsole /dev/tty1 </dev/console" and then "echo test >/dev/console" and see "test" on tty1
"setterm -msg on -msglevel 8 >/dev/console" (or >/dev/tty1), modprobe loop;rmmod loop - and i see the kernel message there
i can do "setconsole /dev/ttyS0 </dev/console" and then "echo test >/dev/console" and see "test" on ttyS0
BUT :
"setterm -msg on -msglevel 8 >/dev/console" (or >/dev/ttyS0), modprobe loop;rmmod loop ...... nothing!
since i came across jan`s posting from 2005, which didn`t get a reply i think it`s not that stupid to ask again...
any clue how to do that at runtime or what`s the issue here ? (see excerpts below)
i can set
regards
roland
List: linux-kernel
Subject: Redirect kernel console
From: Jan Engelhardt <jengelh () linux01 ! gwdg ! de>
Date: 2005-08-13 12:48:22
Message-ID: Pine.LNX.4.61.0508131447220.4457 () yvahk01 ! tjqt ! qr
[Download message RAW]
Hi,
there is a klogconsole utiltity that allows to change the console to which
kernel messages are printed. However, is it possible to redirect to ttyS0
without a reboot?
Jan Engelhardt
-------
>> Subject: Re: serial console _after_ boot ?
>> > Setterm outputs the correct escape sequences to stdout. You can
>> > configure another tty using 'setterm -msglevel 8 -msg on > /dev/ttyS0'.
>> > I tested this on the standard kernel consoles (/dev/tty1-9), and it
>> > worked. You obviously need root access to write the escape sequences to
>> > the tty's.
>>
>> oh - yes, this works! but with tty1-9 only.
>> not with ttyS0 :(
>
>.....as the docs tell.....
>
> Some options however (marked "virtual consoles only" below) do not correspond to a terminfo(5) capability.
>
> -msg [on|off] (virtual consoles only)
> Enables or disables the sending of kernel printk() messages to the console.
>
> -msglevel 1-8 (virtual consoles only)
> Sets the console logging level for kernel printk() messages. All messages strictly more important than this
> will be printed, so a logging level of 0 has the same effect as -msg on and a logging level of 8 will print
> all kernel messages. klogd(8) may be a more convenient interface to the logging of kernel messages.
> > > but i don`t have change_console.
> > > searched the net and found that this eventually should be part of sysvinit package.
> > > but mine doesn`t provide that tool.
> > >
> > > found "setconsole" which looks like something similar, but "setconsole /dev/ttyS0 < /dev/console"
> > > doesn`t have any effect
> >
> > What distribution do you use? I have change_console on gentoo, yet I
> > cannot find the tool on a debian etch. But that's a vserver, so it's
> > probably not a reference.
>
> i have opensuse 10.3
_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: serial console _after_ boot ? - was: Redirect kernel console
2008-01-03 12:43 serial console _after_ boot ? - was: Redirect kernel console devzero
@ 2008-01-03 13:27 ` Jan Engelhardt
2008-01-03 17:55 ` Miquel van Smoorenburg
0 siblings, 1 reply; 7+ messages in thread
From: Jan Engelhardt @ 2008-01-03 13:27 UTC (permalink / raw)
To: devzero; +Cc: linux-kernel
On Jan 3 2008 13:43, devzero@web.de 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>
int main(void)
{
int fd = open("/dev/ttyS0", O_RDWR);
ioctl(0, TIOCCONS, NULL);
ioctl(fd, TIOCCONS, NULL);
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: serial console _after_ boot ? - was: Redirect kernel console
@ 2008-01-03 14:39 devzero
2008-01-03 15:04 ` Jan Engelhardt
0 siblings, 1 reply; 7+ messages in thread
From: devzero @ 2008-01-03 14:39 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: linux-kernel
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));
}
-------------------
> -----Ursprüngliche Nachricht-----
> Von: "Jan Engelhardt" <jengelh@computergmbh.de>
> Gesendet: 03.01.08 14:28:45
> An: devzero@web.de
> CC: linux-kernel@vger.kernel.org
> Betreff: Re: serial console _after_ boot ? - was: Redirect kernel console
>
>
> On Jan 3 2008 13:43, devzero@web.de 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>
>
> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: serial console _after_ boot ? - was: Redirect kernel console
2008-01-03 14:39 devzero
@ 2008-01-03 15:04 ` Jan Engelhardt
0 siblings, 0 replies; 7+ messages in thread
From: Jan Engelhardt @ 2008-01-03 15:04 UTC (permalink / raw)
To: devzero; +Cc: linux-kernel
On Jan 3 2008 15:39, devzero@web.de wrote:
>fantastic, thanks!
>
>unfortunately......
>
>opensuse103:/home/roland/serialcons # ./mytioccons
>ioctl: Device or resource busy
>
>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.
>
>ioctl(0, TIOCCONS, NULL);
>
>if (ioctl(fd, TIOCCONS, NULL) < 0)
> printf("ioctl: %s\n", strerror(errno));
>}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: serial console _after_ boot ? - was: Redirect kernel console
@ 2008-01-03 16:02 devzero
0 siblings, 0 replies; 7+ messages in thread
From: devzero @ 2008-01-03 16:02 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: linux-kernel
> This errno is so out of place.
yes, that was stupid.
anyway:
# strace ./mytiocons
--snipp--
open("/dev/ttyS0", O_RDWR) = 3
ioctl(0, TIOCCONS) = -1 EBUSY (Device or resource busy)
ioctl(3, TIOCCONS) = -1 EBUSY (Device or resource busy)
--snipp--
man tty_ioctl is telling:
Redirecting console output
TIOCCONS void
Redirect output that would have gone to
/dev/console or /dev/tty0 to the given tty. If that was a pty master, send it to the slave. Anybody can do this as long as the output was not redirected yet. If it was redirected already EBUSY is returned, but root may stop redirection by using this ioctl with fd pointing at /dev/console or /dev/tty0.
but it doesn`t seem to make any difference if i do that ioctl on /dev/console or /dev/tty0 , because i`m getting EBUSY there, too
>
>
> On Jan 3 2008 15:39, devzero@web.de wrote:
> >fantastic, thanks!
> >
> >unfortunately......
> >
> >opensuse103:/home/roland/serialcons # ./mytioccons
> >ioctl: Device or resource busy
> >
> >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.
>
> >
> >ioctl(0, TIOCCONS, NULL);
> >
> >if (ioctl(fd, TIOCCONS, NULL) < 0)
> > printf("ioctl: %s\n", strerror(errno));
> >}
>
_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: serial console _after_ boot ? - was: Redirect kernel console
2008-01-03 13:27 ` Jan Engelhardt
@ 2008-01-03 17:55 ` Miquel van Smoorenburg
0 siblings, 0 replies; 7+ messages in thread
From: Miquel van Smoorenburg @ 2008-01-03 17:55 UTC (permalink / raw)
To: linux-kernel
In article <Pine.LNX.4.64.0801031423070.26693@fbirervta.pbzchgretzou.qr>,
Jan Engelhardt <jengelh@computergmbh.de> wrote:
>
>On Jan 3 2008 13:43, devzero@web.de 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:
TIOCCONS only works for pseudo terminals.
Besides, it only redirects stuff you send to /dev/console. It
doesn't change what devices printk() prints to. Currently there
is no way to change that on a running kernel.
Mike.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: serial console _after_ boot ? - was: Redirect kernel console
@ 2008-01-03 20:29 devzero
0 siblings, 0 replies; 7+ messages in thread
From: devzero @ 2008-01-03 20:29 UTC (permalink / raw)
To: Miquel van Smoorenburg; +Cc: linux-kernel
>>>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:
>
>TIOCCONS only works for pseudo terminals.
>
>Besides, it only redirects stuff you send to /dev/console. It
>doesn't change what devices printk() prints to. Currently there
>is no way to change that on a running kernel.
>
>Mike.
too bad, but thanks for the info.
_______________________________________________________________________
Jetzt neu! Schützen Sie Ihren PC mit McAfee und WEB.DE. 30 Tage
kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=022220
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-01-03 20:29 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-03 12:43 serial console _after_ boot ? - was: Redirect kernel console devzero
2008-01-03 13:27 ` Jan Engelhardt
2008-01-03 17:55 ` Miquel van Smoorenburg
-- strict thread matches above, loose matches on Subject: below --
2008-01-03 14:39 devzero
2008-01-03 15:04 ` Jan Engelhardt
2008-01-03 16:02 devzero
2008-01-03 20:29 devzero
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox