summaryrefslogtreecommitdiffstats
path: root/usr.sbin/watch
diff options
context:
space:
mode:
authordd <dd@FreeBSD.org>2001-11-24 15:41:38 +0000
committerdd <dd@FreeBSD.org>2001-11-24 15:41:38 +0000
commit91fc5ccdb5892fe64f31ed8703e562019b47227d (patch)
tree6af76854f2ab8eb9654fb9baa8667b702127f5e6 /usr.sbin/watch
parente652be39ea1df2c3312eb29c4cfad9a33aa66c55 (diff)
downloadFreeBSD-src-91fc5ccdb5892fe64f31ed8703e562019b47227d.zip
FreeBSD-src-91fc5ccdb5892fe64f31ed8703e562019b47227d.tar.gz
Add an -f option which allows one to specify a snp device to use.
Previously, watch would always use the first device it could successfully open, but this isn't always desired. Specifically, it may not be desired during debugging (of snp), or if a particular snp device has different permissions (which makes since after snp.c 1.64).
Diffstat (limited to 'usr.sbin/watch')
-rw-r--r--usr.sbin/watch/watch.816
-rw-r--r--usr.sbin/watch/watch.c22
2 files changed, 30 insertions, 8 deletions
diff --git a/usr.sbin/watch/watch.8 b/usr.sbin/watch/watch.8
index 56b7343..4b75dd5 100644
--- a/usr.sbin/watch/watch.8
+++ b/usr.sbin/watch/watch.8
@@ -2,7 +2,7 @@
.\" @(#)watch.8 1.1 (FreeBSD) 2/17/95
.\" $FreeBSD$
.\"
-.Dd February 17, 1995
+.Dd November 24, 2001
.Dt WATCH 8
.Os
.Sh NAME
@@ -11,6 +11,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl ciotnW
+.Op Fl f Ar snpdev
.Op Ar tty
.\" watch [-ciotnW] [<tty name>]
.Sh DESCRIPTION
@@ -29,6 +30,19 @@ If this option is not specified,
.Nm
will request a new tty if running in interactive mode or exit if running
without a controlling tty.
+.It Fl f Ar snpdev
+If this option is specified,
+.Nm
+will use
+.Ar snpdev
+as the
+.Xr snp 4
+device.
+Without this option,
+.Nm
+will attempt to find the next available
+.Xr snp 4
+device.
.It Fl i
Force interactive mode.
Interactive mode is a default if
diff --git a/usr.sbin/watch/watch.c b/usr.sbin/watch/watch.c
index 4d1c38d..d594ee0 100644
--- a/usr.sbin/watch/watch.c
+++ b/usr.sbin/watch/watch.c
@@ -71,6 +71,7 @@ int opt_interactive = 1;
int opt_timestamp = 0;
int opt_write = 0;
int opt_no_switch = 0;
+const char *opt_snpdev;
char dev_name[DEV_NAME_LEN];
int snp_io;
@@ -164,12 +165,16 @@ open_snp()
else
mode = O_RDONLY;
- for (c = '0'; c <= '9'; c++) {
- snp[8] = c;
- if ((f = open(snp, mode)) < 0)
- continue;
- return f;
- }
+ if (opt_snpdev == NULL)
+ for (c = '0'; c <= '9'; c++) {
+ snp[8] = c;
+ if ((f = open(snp, mode)) < 0)
+ continue;
+ return f;
+ }
+ else
+ if ((f = open(opt_snpdev, mode)) != -1)
+ return (f);
fatal(EX_OSFILE, "cannot open snoop device");
return (0);
}
@@ -302,7 +307,7 @@ main(ac, av)
opt_interactive = 0;
- while ((ch = getopt(ac, av, "Wciotn")) != -1)
+ while ((ch = getopt(ac, av, "Wciotnf:")) != -1)
switch (ch) {
case 'W':
opt_write = 1;
@@ -322,6 +327,9 @@ main(ac, av)
case 'n':
opt_no_switch = 1;
break;
+ case 'f':
+ opt_snpdev = optarg;
+ break;
case '?':
default:
usage();
OpenPOWER on IntegriCloud