Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157512919
D36690.id110952.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D36690.id110952.diff
View Options
diff --git a/share/man/man4/snp.4 b/share/man/man4/snp.4
--- a/share/man/man4/snp.4
+++ b/share/man/man4/snp.4
@@ -1,7 +1,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 5, 2008
+.Dd September 24, 2022
.Dt SNP 4
.Os
.Sh NAME
@@ -58,8 +58,6 @@
in a read buffer.
Special values defined are:
.Bl -tag -width ".Dv SNP_TTYCLOSE"
-.It Dv SNP_OFLOW
-device overflow occurred, device detached.
.It Dv SNP_TTYCLOSE
tty not attached.
.It Dv SNP_DETACH
@@ -89,11 +87,3 @@
.Nm
were based on code written by
.An Ugen J.S. Antsilevich Aq Mt ugen@NetVision.net.il .
-.Sh BUGS
-This version of
-.Nm
-does not return proper error codes when calling
-.Dv FIONREAD .
-It also does not allow
-.Dv SNPSTTY
-to detach itself from the TTY.
diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c
--- a/sys/dev/snp/snp.c
+++ b/sys/dev/snp/snp.c
@@ -125,6 +125,7 @@
tty_lock(tp);
ttyoutq_free(&ss->snp_outq);
ttyhook_unregister(tp);
+ ss->snp_tty = NULL;
}
cv_destroy(&ss->snp_outwait);
@@ -252,9 +253,19 @@
case SNPSTTY:
/* Bind TTY to snoop instance. */
SNP_LOCK();
- if (ss->snp_tty != NULL) {
+ tp = ss->snp_tty;
+ if (tp != NULL) {
+ if (*(int *)data == -1) {
+ tty_lock(tp);
+ ss->snp_tty = NULL;
+ ttyoutq_free(&ss->snp_outq);
+ ttyhook_unregister(tp);
+ error = 0;
+ } else {
+ error = EBUSY;
+ }
SNP_UNLOCK();
- return (EBUSY);
+ return (error);
}
/*
* XXXRW / XXXJA: no capability check here.
@@ -289,10 +300,13 @@
tp = ss->snp_tty;
if (tp != NULL) {
tty_lock(tp);
- *(int *)data = ttyoutq_bytesused(&ss->snp_outq);
+ if (tty_gone(tp))
+ *(int *)data = SNP_TTYCLOSE;
+ else
+ *(int *)data = ttyoutq_bytesused(&ss->snp_outq);
tty_unlock(tp);
} else {
- *(int *)data = 0;
+ *(int *)data = SNP_DETACH;
}
return (0);
default:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, May 23, 6:20 AM (17 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33442615
Default Alt Text
D36690.id110952.diff (1 KB)
Attached To
Mode
D36690: snp(4): properly report detached/revoked ttys and implement detach
Attached
Detach File
Event Timeline
Log In to Comment