From nobody Sun Sep 25 20:36:34 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 4MbHjb0pWNz4ctVX; Sun, 25 Sep 2022 20:36:35 +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 4MbHjb0Gs4z3Txc; Sun, 25 Sep 2022 20:36:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664138195; 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=TWe22QUKChzeux8ZqKtwFJsJSZkrIK5Yp8d1tNn4i5w=; b=UL/rdPmUSmu4cuMlhPvU2kmWBpikOAbKfngyMl7O2QlrSDMLNXD8zCuPu0EFPobABacgw5 NRLulLNjraU6SLyWtdmiyVnaIeDljjDx9gB9EXmur0cQFKbvbCzbxA/L7coJezcn0Nrbyi VkMByQdEhYl25zX/RpJtAB5byd3iw6hhNZ/1qkrtA1FTp83DkyhLVwj+4Yubx+RfuDaOg3 BHrtSOZE15zK1q7vgcQk9Qz4+rV9MIqNHFeJca4//rj/KTuOjBOzAgvWfD48pn85UllHlp slY6tZ+cZpjFpzb5nmuMXi0hb+cUPaLuyosewcafrqX2KSXBtZ1cNVT8qwRpnQ== 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 4MbHjZ6B8mzXwx; Sun, 25 Sep 2022 20:36:34 +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 28PKaYIS029926; Sun, 25 Sep 2022 20:36:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28PKaYki029925; Sun, 25 Sep 2022 20:36:34 GMT (envelope-from git) Date: Sun, 25 Sep 2022 20:36:34 GMT Message-Id: <202209252036.28PKaYki029925@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: bb4be76cf358 - main - snp(4): properly report detached/revoked ttys 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: bb4be76cf358246ef04ea8a67f38ff2a25b6c580 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664138195; 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=TWe22QUKChzeux8ZqKtwFJsJSZkrIK5Yp8d1tNn4i5w=; b=oNWhMVoRBoK+DAJPmS6ZO0VLrsgw/tgpNaKCavh0TlgePPoWkb/Q20EK/pJP9xDw8yluEx 2vCh5QpVCmZ421W5W4DLV/6mtZWQy/4DFDzduY59eqenJOekQFe4Ywgx996idAgRG5LR0l 0A/XmMUMzVI8eQg+SgFtMAdDI36Dk4WiOLUdLMjzBrsfIrRY4B8zm7Pta70yW90D7piEqd FKIUvYdsGjFd3BskzDtvg2D2m38ZtDijOBsvyXjRTmZvDKd1eYHPLdpU4po9+LT//JaOz7 fLSZuyoCA8iehZw6KS9C3Ezk6uNjn1dLZZ8+5YIY5mjtCC3Lbof92SAFuaKprA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664138195; a=rsa-sha256; cv=none; b=GevCcKBm+isxET1BNwRnu3knaM8WAy1166nfmjNGq2B6wR6g5fQa8L1rnyIhpB/SWgEb// 4d6ZxkzW9fozsKRK6hg4idBekwZooNdtRCD5vMoigNx53rRgyNogBJ4zS8UUt1DC7nXewp WYVh/xGtZNc6380pr1Qvk+MIflE8Wi23ry/PbUB9d9j2/Qvoqtq+Qn24EbV1869jQ90eRi a3jFE9aar+FRJEz2BcYOzq3keAa05I9Ecb2xKk/JRAX4hVsOLH4tZc5waIqklToSSNtxHM 9tGw9snPPqumLr7VFRRNni3ckLD1VTZmcQVBPYzxvH9YznHIC+K39PEaHi0w3g== 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=bb4be76cf358246ef04ea8a67f38ff2a25b6c580 commit bb4be76cf358246ef04ea8a67f38ff2a25b6c580 Author: Konstantin Belousov AuthorDate: 2022-09-24 20:23:31 +0000 Commit: Konstantin Belousov CommitDate: 2022-09-25 20:36:16 +0000 snp(4): properly report detached/revoked ttys 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 | 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: