snp(4): implement detach
PR: 257964 Reported by: Bertrand Petit <bsdpr@phoe.frmug.org> Reviewed by: imp, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D36690
This commit is contained in:
parent
bb4be76cf3
commit
550e01c552
@ -87,9 +87,3 @@ Previous versions of
|
|||||||
.Nm
|
.Nm
|
||||||
were based on code written by
|
were based on code written by
|
||||||
.An Ugen J.S. Antsilevich Aq Mt ugen@NetVision.net.il .
|
.An Ugen J.S. Antsilevich Aq Mt ugen@NetVision.net.il .
|
||||||
.Sh BUGS
|
|
||||||
This version of
|
|
||||||
.Nm
|
|
||||||
does not allow
|
|
||||||
.Dv SNPSTTY
|
|
||||||
to detach itself from the TTY.
|
|
||||||
|
@ -125,6 +125,7 @@ snp_dtor(void *data)
|
|||||||
tty_lock(tp);
|
tty_lock(tp);
|
||||||
ttyoutq_free(&ss->snp_outq);
|
ttyoutq_free(&ss->snp_outq);
|
||||||
ttyhook_unregister(tp);
|
ttyhook_unregister(tp);
|
||||||
|
ss->snp_tty = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cv_destroy(&ss->snp_outwait);
|
cv_destroy(&ss->snp_outwait);
|
||||||
@ -252,9 +253,19 @@ snp_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags,
|
|||||||
case SNPSTTY:
|
case SNPSTTY:
|
||||||
/* Bind TTY to snoop instance. */
|
/* Bind TTY to snoop instance. */
|
||||||
SNP_LOCK();
|
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();
|
SNP_UNLOCK();
|
||||||
return (EBUSY);
|
return (error);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* XXXRW / XXXJA: no capability check here.
|
* XXXRW / XXXJA: no capability check here.
|
||||||
|
Loading…
Reference in New Issue
Block a user