All of lore.kernel.org
 help / color / mirror / Atom feed
From: devzero@web.de
To: Jan Engelhardt <jengelh@computergmbh.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: serial console _after_ boot ? - was: Redirect kernel console
Date: Thu, 03 Jan 2008 15:39:43 +0100	[thread overview]
Message-ID: <83783877@web.de> (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));
}
-------------------




> -----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


             reply	other threads:[~2008-01-03 14:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-03 14:39 devzero [this message]
2008-01-03 15:04 ` serial console _after_ boot ? - was: Redirect kernel console Jan Engelhardt
  -- strict thread matches above, loose matches on Subject: below --
2008-01-03 20:29 devzero
2008-01-03 16:02 devzero
2008-01-03 12:43 devzero
2008-01-03 13:27 ` Jan Engelhardt
2008-01-03 17:55   ` Miquel van Smoorenburg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83783877@web.de \
    --to=devzero@web.de \
    --cc=jengelh@computergmbh.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.