From nobody Sun Oct 02 00:52:14 2022 X-Original-To: dev-commits-src-branches@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 4Mg55q05Sxz4cyGN; Sun, 2 Oct 2022 00:52:15 +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 4Mg55p6m6Qz3gCS; Sun, 2 Oct 2022 00:52:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664671934; 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=w6B5BEtwXJLs5I8vakYBI9nRWPke9/qf+oYtsfC0c6A=; b=m29R+ZTCPAOE9xivG10tLE40HelLsyOwOzKedHVC+QAYrIGH7CHCGjbKITnLnTzOMsDgWB mx5QfZALLuK78Ftj+AEQx2ONLKYhWLO6/3yjDpfXctA/M/bUmoQLL3zQU3YRGdcwKTMpMc ne5TYFMceNExY5pQC2fZSl03y3MVmOmvRz9DvN7nwgcVLK9fLXPTAyPSwyUkQkzx0UeSa3 DT3kdn3eWuYzA2N2qw3UPsHvGcGr0L4/pAxXNRYEsMglWJyZyizl3KExgTI1AcbEO9+oQZ P3g6Ump3pMh9avTDEYG777H4xzKw+INtkOfNOMU+XVvAhGPOcY4Lwx6dGRFcmQ== 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 4Mg55p5NX7zhrq; Sun, 2 Oct 2022 00:52:14 +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 2920qEJA094436; Sun, 2 Oct 2022 00:52:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2920qEPE094435; Sun, 2 Oct 2022 00:52:14 GMT (envelope-from git) Date: Sun, 2 Oct 2022 00:52:14 GMT Message-Id: <202210020052.2920qEPE094435@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: ff1993be35d6 - stable/13 - snp(4): implement detach List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: ff1993be35d643a55c00d301628bfe1bfaeeffc4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664671934; 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=w6B5BEtwXJLs5I8vakYBI9nRWPke9/qf+oYtsfC0c6A=; b=ji+C6wO6qfc9aVVU29oJPx041SMl6uWOiQxZXVG/leQbtHAfN4PpJ4g2/K6z4kGnHssBda D7a0Gyv34aNPTEWskBvpRlOTfK7oTFYXyxMRwV+z44zhe0LYmNo3TGcS4sKA2RlJ01ltC6 bx8uvkdFLrqlyjvsGJ2af6MpFoGDdjORMItP4k874469v9PlyDQ5EHF4GrvPphUj9HJury 94oWx/QkLbvS5kBCcoR3I1qFFX3wv7gb7E4A7eXPr3xuTs6s7VwgWyU6Zr3qO2dOnNYAn5 0kyIi8ICNkWCevJEU68GLPczTVgyHBs7T64w1Qv2fu6UNVittR47o5Xoi7IKLA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664671934; a=rsa-sha256; cv=none; b=BLoyt2PLy+DVMoYtqTYq73zAddeeo4qsQAmss/yt/C6thXzzTPhi5u87i+AgYgaZGDOi4Y e/TVT+MllC2YVuJJ67ISBAyeH97naxZTouVN8AmS1QXdIx+t/XLRJiOr7ikmsNTuuTxccs TMf/Kd8i1QhXcOYha+tsquEaT86yzZMq4qSAhiQj1tx5krF/P2TqGU+499iSLxOxUyOSaG qx4MSOmh1bgeCHl0RkJRb4TLHpbjcJCQ93g8pf3ljfPYFivd7tB5cVk3/CrUXz6A1+SZ/B KVkAIp/+JoXOEN1WYXx8SuNLl3xvBAkzcPvItPhAXURNWlVy3P4SHjLVeR6KgA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ff1993be35d643a55c00d301628bfe1bfaeeffc4 commit ff1993be35d643a55c00d301628bfe1bfaeeffc4 Author: Konstantin Belousov AuthorDate: 2022-09-25 11:34:17 +0000 Commit: Konstantin Belousov CommitDate: 2022-10-02 00:51:47 +0000 snp(4): implement detach PR: 257964 (cherry picked from commit 550e01c552474babae468011191ecc5130cc153e) --- 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.