aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2008-03-19 13:26:18 -0400
committerBill Nottingham <notting@redhat.com>2008-03-19 13:26:18 -0400
commit1b13b011cf799297fbd42e0378ec6f8cd99d5644 (patch)
tree8f2c22be9da70e8329ff7393c00ad28a239f3edc /src
parentf892674d525dde82da15ff1beb38e8e1e448e1d1 (diff)
downloadinitscripts-1b13b011cf799297fbd42e0378ec6f8cd99d5644.tar
initscripts-1b13b011cf799297fbd42e0378ec6f8cd99d5644.tar.gz
initscripts-1b13b011cf799297fbd42e0378ec6f8cd99d5644.tar.bz2
initscripts-1b13b011cf799297fbd42e0378ec6f8cd99d5644.tar.xz
initscripts-1b13b011cf799297fbd42e0378ec6f8cd99d5644.zip
handle non-16550 serial ports, somewhat (<dwmw2@infradead.org>)
Diffstat (limited to 'src')
-rw-r--r--src/console_check.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/console_check.c b/src/console_check.c
index 60dc89e2..e188ebe5 100644
--- a/src/console_check.c
+++ b/src/console_check.c
@@ -9,6 +9,7 @@
#include <sys/ioctl.h>
#include <linux/serial.h>
+#include <linux/serial_core.h>
struct speeds
{
@@ -91,11 +92,29 @@ int compare_termios_to_console(char *dev, int *speed) {
return 0;
}
+char *serial_tty_name(int type) {
+ switch (type) {
+ case PORT_8250...PORT_MAX_8250:
+ return "ttyS";
+ case PORT_PMAC_ZILOG:
+ return "ttyPZ";
+ case PORT_MPSC:
+ return "ttyMM";
+ case PORT_CPM:
+ return "ttyCPM";
+ case PORT_MPC52xx:
+ return "ttyPSC";
+ default:
+ return NULL;
+ }
+}
+
char *check_serial_console(int *speed) {
int fd;
char *ret = NULL, *device;
char twelve = 12;
struct serial_struct si, si2;
+ char *tty_name;
memset(&si, 0, sizeof(si));
memset(&si2, 0, sizeof(si));
@@ -108,7 +127,11 @@ char *check_serial_console(int *speed) {
goto out;
close(fd);
- asprintf(&device, "ttyS%d", si.line);
+ tty_name = serial_tty_name(si.type);
+ if (!tty_name)
+ goto out;
+
+ asprintf(&device, "%s%d", tty_name, si.line);
fd = open(device, O_RDWR|O_NONBLOCK);
if (fd == -1)
goto out;