summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpst <pst@FreeBSD.org>1995-02-25 20:14:31 +0000
committerpst <pst@FreeBSD.org>1995-02-25 20:14:31 +0000
commit309dab67e72a522777126250a606d6d0cc24bee3 (patch)
treeb0aabf8b1ae3c35baede26d77113ced0de183118
parent1dcb420b646ff6fd0ab578e340fd7f26b32ed79d (diff)
downloadFreeBSD-src-309dab67e72a522777126250a606d6d0cc24bee3.zip
FreeBSD-src-309dab67e72a522777126250a606d6d0cc24bee3.tar.gz
Update to use new calling conventions
-rw-r--r--usr.sbin/watch/watch.84
-rw-r--r--usr.sbin/watch/watch.c72
2 files changed, 17 insertions, 59 deletions
diff --git a/usr.sbin/watch/watch.8 b/usr.sbin/watch/watch.8
index eca7aa8..9ce6567 100644
--- a/usr.sbin/watch/watch.8
+++ b/usr.sbin/watch/watch.8
@@ -46,8 +46,8 @@ For more info see
.It Fl t
Print the date and time when observation of a given tty is started.
.It Ar tty
-Tty may be specified as a remote pseudo tty device, a virtual console, or
-a serial line.
+Tty may be specified as an tty-style device, such as a pseudo tty device,
+a virtual console, or a serial line, etc.
Names may be preceded by "/dev/".
.Sh OPERATION
While running in interactive mode, all user input is discarded except for:
diff --git a/usr.sbin/watch/watch.c b/usr.sbin/watch/watch.c
index f5e4007..3c717dc 100644
--- a/usr.sbin/watch/watch.c
+++ b/usr.sbin/watch/watch.c
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <sys/time.h>
#include <sys/select.h>
#include <sys/fcntl.h>
@@ -27,12 +28,12 @@
#define MSG_INIT "Snoop started."
-#define MSG_OFLOW "Snoop stopped due to overflow.Reconnecting."
-#define MSG_CLOSED "Snoop stopped due to tty close.Reconnecting."
+#define MSG_OFLOW "Snoop stopped due to overflow. Reconnecting."
+#define MSG_CLOSED "Snoop stopped due to tty close. Reconnecting."
#define MSG_CHANGE "Snoop device change by user request."
-#define DEV_NAME_LEN 12 /* for /dev/ttyXX++ */
+#define DEV_NAME_LEN 1024 /* for /dev/ttyXX++ */
#define MIN_SIZE 256
#define CHR_SWITCH 24 /* Ctrl+X */
@@ -46,7 +47,7 @@ int opt_timestamp = 0;
char dev_name[DEV_NAME_LEN];
int snp_io;
-struct snptty snp_tty;
+dev_t snp_tty;
int std_in = 0, std_out = 1;
@@ -111,7 +112,7 @@ fatal(buf)
int
open_snp()
{
- char snp[DEV_NAME_LEN] = "/dev/snpX";
+ char *snp = "/dev/snpX";
char c;
int f;
for (c = '0'; c <= '9'; c++) {
@@ -174,10 +175,10 @@ ctoh(c)
void
detach_snp()
{
- struct snptty st;
- st.st_type = -1;
- st.st_unit = -1;
- ioctl(snp_io, SNPSTTY, &st);
+ dev_t dev;
+
+ dev = -1;
+ ioctl(snp_io, SNPSTTY, &dev);
}
void
@@ -194,62 +195,19 @@ void
set_dev(name)
char *name;
{
- char buf[DEV_NAME_LEN], num[DEV_NAME_LEN];
- int unitbase = 0;
+ char buf[DEV_NAME_LEN];
+ struct stat sb;
if (strlen(name) > 5 && !strncmp(name, "/dev/", 5))
strcpy(buf, &(name[5]));
else
strcpy(buf, name);
- if (strlen(buf) < 4)
- fatal("Bad tty name.");
-
- if (!strncmp(buf, "tty", 3))
- switch (buf[3]) {
- case 'v':
- snp_tty.st_unit = ctoh(buf[4]);
- snp_tty.st_type = ST_VTY;
- goto got_num;
- case 'r':
- unitbase += 16;
- case 'q':
- unitbase += 16;
- case 'p':
- snp_tty.st_unit = ctoh(buf[4]) + unitbase;
- snp_tty.st_type = ST_PTY;
- goto got_num;
- case '0':
- case 'd':
- snp_tty.st_unit = ctoh(buf[4]);
- snp_tty.st_type = ST_SIO;
- goto got_num;
- default:
- fatal("Bad tty name.");
-
- }
+ if (stat(buf, &sb) < 0)
+ fatal("Bad device name.");
- if (!strncmp(buf, "vty", 3)) {
- strcpy(num, &(buf[3]));
- snp_tty.st_unit = atoi(num);
- snp_tty.st_type = ST_VTY;
- goto got_num;
- }
- if (!strncmp(buf, "pty", 3)) {
- strcpy(num, &(buf[3]));
- snp_tty.st_unit = atoi(num);
- snp_tty.st_type = ST_PTY;
- goto got_num;
- }
- if (!strncmp(buf, "sio", 3) || !strncmp(buf, "cua", 3)) {
- strcpy(num, &(buf[3]));
- snp_tty.st_unit = atoi(num);
- snp_tty.st_type = ST_SIO;
- goto got_num;
- }
- fatal("Bad tty name.");
-got_num:
+ snp_tty = sb.st_rdev;
attach_snp();
}
OpenPOWER on IntegriCloud