summaryrefslogtreecommitdiffstats
path: root/sys/dev/snp
diff options
context:
space:
mode:
authorugen <ugen@FreeBSD.org>1995-02-15 18:41:57 +0000
committerugen <ugen@FreeBSD.org>1995-02-15 18:41:57 +0000
commit62bf834d197b90c91a29df2fb90102092ea9b476 (patch)
tree64290d4c56e50e389748f8ec3709c66bc954783b /sys/dev/snp
parent868b16fdda6736719292daa6beab7e1199f6f11e (diff)
downloadFreeBSD-src-62bf834d197b90c91a29df2fb90102092ea9b476.zip
FreeBSD-src-62bf834d197b90c91a29df2fb90102092ea9b476.tar.gz
More changes to support user calls.
It's 22:00 here,utility still to come(hopefully tomorrow morning..)
Diffstat (limited to 'sys/dev/snp')
-rw-r--r--sys/dev/snp/snp.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c
index f852a81..eaee544 100644
--- a/sys/dev/snp/snp.c
+++ b/sys/dev/snp/snp.c
@@ -203,6 +203,7 @@ snpin(snp, buf, n)
printf("Snoop: more data to down interface.\n");
return 0;
}
+
if (snp->snp_flags & SNOOP_OFLOW) {
printf("Snoop: buffer overflow.\n");
/*
@@ -212,13 +213,7 @@ snpin(snp, buf, n)
* snooping and retry...
*/
- snp->snp_blen = SNOOP_MINLEN;
- free(snp->snp_buf, M_TTYS);
- snp->snp_buf = malloc(SNOOP_MINLEN, M_TTYS, M_WAITOK);
- snp->snp_flags |= SNOOP_DOWN;
- snp->snp_flags &= ~SNOOP_OFLOW;
-
- return (snp_detach(snp));
+ return (snpdown(snp));
}
s_tail = snp->snp_blen - (snp->snp_len + snp->snp_base);
s_free = snp->snp_blen - snp->snp_len;
@@ -323,7 +318,7 @@ snp_detach(snp)
*/
if (snp->snp_unit == -1)
- goto destroy_notty;
+ goto detach_notty;
l_tty = &tty_tabs[snp->snp_type];
@@ -338,7 +333,7 @@ snp_detach(snp)
snp->snp_unit = -1;
-destroy_notty:
+detach_notty:
selwakeup(&snp->snp_sel);
snp->snp_sel.si_pid = 0;
@@ -360,7 +355,17 @@ snpclose(dev, flag)
return (snp_detach(snp));
}
+int
+snpdown(snp)
+ struct snoop *snp;
+{
+ snp->snp_blen = SNOOP_MINLEN;
+ free(snp->snp_buf, M_TTYS);
+ snp->snp_buf = malloc(SNOOP_MINLEN, M_TTYS, M_WAITOK);
+ snp->snp_flags |= SNOOP_DOWN;
+ return (snp_detach(snp));
+}
int
@@ -381,6 +386,9 @@ snpioctl(dev, cmd, data, flag)
tunit = ((struct snptty *) data)->st_unit;
ttype = ((struct snptty *) data)->st_type;
+ if (ttype == -1 || tunit == -1)
+ return (snpdown(snp));
+
if (ttype < 0 || ttype > ST_MAXTYPE)
return (EINVAL);
@@ -409,6 +417,11 @@ snpioctl(dev, cmd, data, flag)
tp->t_state |= TS_SNOOP;
snp->snp_unit = tunit;
snp->snp_type = ttype;
+ /*
+ * Clean overflow and down flags -
+ * we'll have a chance to get them in the future :)))
+ */
+ snp->snp_flags &= ~SNOOP_OFLOW;
snp->snp_flags &= ~SNOOP_DOWN;
splx(s);
@@ -434,10 +447,15 @@ snpioctl(dev, cmd, data, flag)
s = spltty();
if (snp->snp_unit != -1)
*(int *) data = snp->snp_len;
- else if (snp->snp_flags & SNOOP_DOWN)
- *(int *) data = -1;
- else
- *(int *) data = 0;
+ else
+ if (snp->snp_flags&SNOOP_DOWN) {
+ if (snp->snp_flags&SNOOP_OFLOW)
+ *(int *) data = SNP_OFLOW;
+ else
+ *(int *) data = SNP_TTYCLOSE;
+ } else {
+ *(int *) data = SNP_DETACH;
+ }
splx(s);
break;
default:
OpenPOWER on IntegriCloud