From nobody Sun Sep 25 20:36:35 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MbHjc0bf0z4ctSN; Sun, 25 Sep 2022 20:36:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MbHjc03xFz3V6p; Sun, 25 Sep 2022 20:36:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664138196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2QqDKNIioFHxbF5MjXJOoLq+qUWS7avvbX9c+NFFreg=; b=bd48F9szJAVLSVAc0A8gwiw0nkwH0/khuwl1MJbY9R4DW0326K+moQmdDP92JlyPR80PB+ sKuWLux4ujii2Fj4+AMYJyt9owau9BndzbMvijGLkT6lZZakQehmc2KcqvfBpz1+w6Rkgz rn0yfFOrTPqTdygjiNzADj9XHY2NkBR6/vUCthc/2Lo7ZGrTo1XnOqboTbPOhptTMQDYY3 3dwQ0MG8gON/wcyMRIsPiMIK3/nbcsCCufGrYGyeuxst3F8Mla160IeundnMl8qi4cBp0Y lkUKL3Styz1AqsJqjTmHemE120l0rgEx6JqOXAdtJMYiDSFE7Cn8ZGTG7afLbg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MbHjb6HrczXjN; Sun, 25 Sep 2022 20:36:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 28PKaZ3r029954; Sun, 25 Sep 2022 20:36:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28PKaZRr029953; Sun, 25 Sep 2022 20:36:35 GMT (envelope-from git) Date: Sun, 25 Sep 2022 20:36:35 GMT Message-Id: <202209252036.28PKaZRr029953@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 550e01c55247 - main - snp(4): implement detach List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 550e01c552474babae468011191ecc5130cc153e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664138196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2QqDKNIioFHxbF5MjXJOoLq+qUWS7avvbX9c+NFFreg=; b=bO8NOFIbSfUbkZa3r6Y/ONtFjTcw2zvJH6QomvFEiLmJZIUHwQ39p0OwlN+HMjDL9RF3F4 82d8lna48uyUHyihfc5Rg1osnsKTKWlGxK2u4pdPCPh9rDgUvIg0rTVybN+6pktCZ4vjPi bCjEd+aPvjdox4NdgsZu01lxWSGNxr+Sf6L+y8ZOZDikPVrjXOVjDv1izWD2z1ouel3xqh rSt4BYiN7gpd+Eh46cX+S0Q9izJVmGKGDppvD6SpfxvSjvPb4d5BuqsQ+aWyAboT1rxW6Z vk3bNiqMClQPvhEhF8hvWri8ARcfX6+FilJQb3L3LiSrAEZv3/VlGE8py0LSmw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664138196; a=rsa-sha256; cv=none; b=aVYZLKmVn7IaxC7dF1N7JGL8E6xzXOQD0jP8B5JNRnl+wCAXTaSRluaJiIjHMTetvZizZz OLBgt9AHq0pjNfzn9BOftZRc3mfgSlVhvekRGe194UutghUj8jw2KyJLhplkmzRiR0u6Ga 3Gxo76ypk8ltvYkm5AjafgRa8RIOdgkOflKINNj8Ov+ftjhdFcoylwwfxSPo+GF+wOS754 Z8aM6tBR9/kh2u38e1/IIVSqx82ErIW5frWYUp4MeeXHrZ+lM+6odbEm9ZaWicqiNj3/nd rltDzOj1DUSwa3hFYlHphqis/l0Z/6fleFUCIIAwXKz05JxqUr4KcMVkvARaYA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=550e01c552474babae468011191ecc5130cc153e commit 550e01c552474babae468011191ecc5130cc153e Author: Konstantin Belousov AuthorDate: 2022-09-25 11:34:17 +0000 Commit: Konstantin Belousov CommitDate: 2022-09-25 20:36:16 +0000 snp(4): implement detach PR: 257964 Reported by: Bertrand Petit Reviewed by: imp, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D36690 --- share/man/man4/snp.4 | 6 ------ sys/dev/snp/snp.c | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/share/man/man4/snp.4 b/share/man/man4/snp.4 index 524e779ce081..3422b9ca5d6f 100644 --- a/share/man/man4/snp.4 +++ b/share/man/man4/snp.4 @@ -87,9 +87,3 @@ Previous versions of .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 allow -.Dv SNPSTTY -to detach itself from the TTY. diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c index 3bcd2263809b..37c1c075a76e 100644 --- a/sys/dev/snp/snp.c +++ b/sys/dev/snp/snp.c @@ -125,6 +125,7 @@ snp_dtor(void *data) tty_lock(tp); ttyoutq_free(&ss->snp_outq); ttyhook_unregister(tp); + ss->snp_tty = NULL; } cv_destroy(&ss->snp_outwait); @@ -252,9 +253,19 @@ snp_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, 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.