summaryrefslogtreecommitdiff
path: root/usr/src/cmd/ttymon
diff options
context:
space:
mode:
authorlq150181 <none@none>2006-01-12 18:17:46 -0800
committerlq150181 <none@none>2006-01-12 18:17:46 -0800
commitfea9cb91bd8e12d84069b4dab1268363668b4bff (patch)
treed85e9d76b706af6edb661df8be1b8fae9303393a /usr/src/cmd/ttymon
parentf910463c4a607ed249460744e54e7ec6ca8dd078 (diff)
downloadillumos-joyent-fea9cb91bd8e12d84069b4dab1268363668b4bff.tar.gz
PSARC 2003/432 Coherent Console
PSARC 2004/105 Simplified Visual_io Versioning PSARC 2004/118 Change how $TERM is set for console PSARC 2004/236 Update to Coherent Console 4873799 SPARC console should be weaned from OBP 4927198 Integrate Coherent Console --HG-- rename : usr/src/uts/common/io/terminal-emulator.c => usr/src/uts/common/io/tem.c rename : usr/src/uts/common/sys/terminal-emulator.h => usr/src/uts/common/sys/tem.h rename : usr/src/uts/intel/terminal-emulator/Makefile => usr/src/uts/intel/tem/Makefile
Diffstat (limited to 'usr/src/cmd/ttymon')
-rw-r--r--usr/src/cmd/ttymon/tmexpress.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/usr/src/cmd/ttymon/tmexpress.c b/usr/src/cmd/ttymon/tmexpress.c
index f9bc5363e2..79c140c2cb 100644
--- a/usr/src/cmd/ttymon/tmexpress.c
+++ b/usr/src/cmd/ttymon/tmexpress.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -43,6 +43,9 @@
#include <dirent.h>
#include <sys/param.h>
#include <sys/acl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/console.h>
#include "ttymon.h"
#include "tmextern.h"
#include "tmstruct.h"
@@ -165,6 +168,8 @@ parse_args(int argc, char **argv, struct pmtab *pmtab)
static char p_server[] = "/usr/bin/login";
extern char *lastname();
extern void getty_account();
+ static char termbuf[MAX_TERM_TYPE_LEN];
+ static struct cons_getterm cnterm = {sizeof (termbuf), termbuf};
/* initialize fields to some default first */
pmtab->p_tag = "";
@@ -190,9 +195,34 @@ parse_args(int argc, char **argv, struct pmtab *pmtab)
pmtab->p_ttylabel = "300";
getty_options(argc, argv, pmtab);
} else {
+ int cn_fd;
+
pmtab->p_ttylabel = "9600";
ttymon_options(argc, argv, pmtab);
+
+ /*
+ * The following code is only reached if -g was specified.
+ * It attempts to determine a suitable terminal type for
+ * the console login process.
+ *
+ * If -d /dev/console also specified, we send an ioctl
+ * to the console device to query the TERM type.
+ *
+ * If any of the tests, system calls, or ioctls fail
+ * then pmtab->p_termtype retains its default value
+ * of "". otherwise it is set to a term type value
+ * that was returned.
+ */
+ if ((strlen(pmtab->p_termtype) == 0) &&
+ (strcmp(pmtab->p_device, "/dev/console") == 0) &&
+ ((cn_fd = open("/dev/console", O_RDONLY)) != -1)) {
+
+ if (ioctl(cn_fd, CONS_GETTERM, &cnterm) != -1)
+ pmtab->p_termtype = cnterm.cn_term_type;
+ (void) close(cn_fd);
+ }
}
+
if ((pmtab->p_device != NULL) && (*(pmtab->p_device) != '\0'))
getty_account(pmtab->p_device); /* utmp accounting */
return (0);