From nobody Sun Oct 02 00:52:13 2022 X-Original-To: dev-commits-src-all@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 4Mg55n5xp8z4cy1c; Sun, 2 Oct 2022 00:52:13 +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 4Mg55n5K4Yz3fvd; Sun, 2 Oct 2022 00:52:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664671933; 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=3b7Tz6dYV/KwWrsulD0e+uYdTMBFhL6eIBdo+/zRLzw=; b=O7s3HGr/kCIPrxwEdboBDrGQ8p6xH07NFNZRKL8Kl5LnY+S+mB1VqwtmObcHY8yoShHLY2 ZChlstLdYF5rbgWcBcYAENMFlLS1LYX0IsXpht2ZIE+bttzjDOUZHAhvYlR13HXja5I8Bv Vs+nBmoh5BjZ8aI7+CuXkRcLd+rhnlnB3mZttpCxOrIh1DdWbXIKD5Qd9PZM38+SdVxGZk 6YOM7QxZzxvk5zZujFE+JGK7p/+9wm4pK3F13SO67YiIDYpWUKx6QIKKCGPWIIKWultGgl t0SoQ/7Omg42Rvb0nL9ikLczrI4XPNcQi3qm1Vaa5cKBNIFSmkl5l5CTAz4y4g== 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 4Mg55n4NTQzhpX; Sun, 2 Oct 2022 00:52:13 +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 2920qDRO094412; Sun, 2 Oct 2022 00:52:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2920qDPC094411; Sun, 2 Oct 2022 00:52:13 GMT (envelope-from git) Date: Sun, 2 Oct 2022 00:52:13 GMT Message-Id: <202210020052.2920qDPC094411@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: 40860e6bf222 - stable/13 - snp(4): properly report detached/revoked ttys List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: 40860e6bf2221efb3840b380d6b5d6f3f768a633 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664671933; 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=3b7Tz6dYV/KwWrsulD0e+uYdTMBFhL6eIBdo+/zRLzw=; b=t+IMxdFHZ131BkVPmiPlXR+71x7F2875te/X/HswMhCQgg/mIBDCVBQEUCxifCHGtzjC4f wQD3LuYditm/jH5IU6AeadQOPdfdKT1mNoUXq7nPb/Gy/EazbJiDrJ2Dl4qDAgtkjHihul N35Hp6tJxmzFSZ97EUZa7SiVcmidMzsoDegrQ/UFrsO2No/1NMv1uFVB1WTWaL0sNwq2xB nfGhRZMODQRPb7IPrSlHzbRBBncViUym/ppWq5xDAqbASCELzl3kcNtJozmAsKt6n9ee2S IsIForeiIr9iX9GYnkUgS8qJdWnIZjor81OrTkM0NyGca/s7GuHXX3OUdLhIvw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664671933; a=rsa-sha256; cv=none; b=GgJUGKehusFYmRqaQHGCyqRUdLtwAX2iMGdB3UM5QVg6yihDqVtjQLcy/hQSYI/5eTbL0s pZSsLy2lZfoN96wloDo3jsEi8tJUQL1ZgV8mkQ4pgqrxJDi7X5ZQAK4lQegyDtnddWxZhC h7MpNpdafbmTMC7dv9fObVVxmDflyAVVYTJ3A9zcO0NPzzfHBmtz9evTujXNdmE9UKYQZi yNJkvbgK+kIulC3cAZdOZIbH2pD+GaDr2q3EXqusdaixjDws/UKH2xBLKUbP3hB7K3zBho uPmh+c8Y4rjVOfslvVKlvnHcLKtjm1WoXs65/D5m39GqErq7DhlgQSmcWR5VVQ== 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=40860e6bf2221efb3840b380d6b5d6f3f768a633 commit 40860e6bf2221efb3840b380d6b5d6f3f768a633 Author: Konstantin Belousov AuthorDate: 2022-09-24 20:23:31 +0000 Commit: Konstantin Belousov CommitDate: 2022-10-02 00:51:47 +0000 snp(4): properly report detached/revoked ttys PR: 257964 (cherry picked from commit bb4be76cf358246ef04ea8a67f38ff2a25b6c580) --- share/man/man4/snp.4 | 8 ++------ sys/dev/snp/snp.c | 7 +++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/share/man/man4/snp.4 b/share/man/man4/snp.4 index ce0ef66c5721..524e779ce081 100644 --- 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 @@ ioctl returns a positive value equal to the number of characters 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 @@ -92,8 +90,6 @@ were based on code written by .Sh BUGS This version of .Nm -does not return proper error codes when calling -.Dv FIONREAD . -It also does not allow +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 64e2d0f64537..3bcd2263809b 100644 --- a/sys/dev/snp/snp.c +++ b/sys/dev/snp/snp.c @@ -289,10 +289,13 @@ snp_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, 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: