[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e8726b52b576c04bf4dc41ccfd324ef8f29d17c9.camel@t-2.net>
Date: Tue, 13 Apr 2021 17:22:46 +0200
From: Samo Pogačnik <samo_pogacnik@....net>
To: Petr Mladek <pmladek@...e.com>
Cc: Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>,
Jiri Slaby <jirislaby@...nel.org>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
John Ogness <john.ogness@...utronix.de>,
linux-kernel@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: How to handle concurrent access to /dev/ttyprintk ?
Dne 13.04.2021 (tor) ob 16:32 +0200 je Petr Mladek napisal(a):
> On Tue 2021-04-13 13:10:50, Samo Pogačnik wrote:
> > Dne 13.04.2021 (tor) ob 11:41 +0200 je Petr Mladek napisal(a):
> > > On Mon 2021-04-12 14:41:27, Samo Pogačnik wrote:
> > > > Dne 12.04.2021 (pon) ob 19:39 +0900 je Tetsuo Handa napisal(a):
> > > > > What is the intended usage of /dev/ttyprintk ?
> > > > >
> > > >
> > > > The intended use of 'ttyprintk' is to redirect console to /dev/ttyprintk
> > > > via the TIOCCONS ioctl. After successfull redirection, all console
> > > > messages get "merged" with kernel messages and as such automatically
> > > > processed
> > > > (stored/transferred) by the syslog service for example.
> > >
> > > The same can be achieved by /dev/kmsg that was created by systemd
> > > developers.
> > >
> >
> > 'kmsg' and 'ttyprintk' are different types of drivers and as such rather
> > complementary than exclusive. The 'ttyprintk' being a tty driver allows
> > for a system wide automatic redirection of anything written to the
> > console.
>
> I might miss something. But how can one setup ttyprintk as the system
> wide console? I do not see any code that would use ttyprintk
> in struct console.
>
You can compile this simple code below and call:
# ./tioccons /dev/ttyprintk
... from now on all console output interleaves the kernel log (you can check
dmesg or logs)
# ./tioccons /dev/console
... sets things back they were.
You will be able to recognize console messages by preceding "[U]" tag (meaning
User).
-------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
int main(int argc, char **argv)
{
int fd;
if (argc != 2) {
printf("Wrong usage!\n");
exit(1);
}
if ((fd = open(argv[1], O_WRONLY)) == -1) {
perror(argv[1]);
exit(1);
}
if (ioctl(fd, TIOCCONS, NULL) == -1) {
printf("ioctl: %s\n", strerror(errno));
exit(1);
}
exit(0);
}
--------------------
best regards, Samo
Powered by blists - more mailing lists