From ab121f379a3cff458c90e6f480ba4bb68c8733dd Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sat, 27 Nov 2010 07:49:17 +0100 Subject: Linux Device Drivers 3 examples --- misc-progs/setconsole.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 misc-progs/setconsole.c (limited to 'misc-progs/setconsole.c') diff --git a/misc-progs/setconsole.c b/misc-progs/setconsole.c new file mode 100644 index 0000000..04bc11d --- /dev/null +++ b/misc-progs/setconsole.c @@ -0,0 +1,42 @@ +/* + * setconsole.c -- choose a console to receive kernel messages + * + * Copyright (C) 1998,2000,2001 Alessandro Rubini + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#include +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + char bytes[2] = {11,0}; /* 11 is the TIOCLINUX cmd number */ + + if (argc==2) bytes[1] = atoi(argv[1]); /* the chosen console */ + else { + fprintf(stderr, "%s: need a single arg\n",argv[0]); exit(1); + } + if (ioctl(STDIN_FILENO, TIOCLINUX, bytes)<0) { /* use stdin */ + fprintf(stderr,"%s: ioctl(stdin, TIOCLINUX): %s\n", + argv[0], strerror(errno)); + exit(1); + } + exit(0); +} -- cgit v1.2.1-18-gbd029