From nobody Thu Jul 25 04:49:07 2024 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 4WTz1c0p3Rz5RFlf; Thu, 25 Jul 2024 04:49:08 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WTz1b57Xvz4X4b; Thu, 25 Jul 2024 04:49:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721882947; 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=PrMd70UsYWwGCK/XT1Zo0HIuJwAt3Ne3d4BCmwMRB7k=; b=dk2tED0P8Hw12nami29PblB3wB/tHsOZQEFX8okp8VOOHofMinedI27uARezShQZs4xiYT TP4JEnM9nIH6bz5YrjsBFIwINDSRGzuLG32xu5HNHdmhyfogTB21oMz+w3Hcowg2Rhubmx vmgykzkJDWnEnZssahY5GVNw/yBeScKXS+boXi1ZAFuedyVQjW1zh0Q2FMRFK4JH/uJZ/p 8hpyydU206ywGTHQZZrcrNirKhQo2pnyD3vw2abTRcAeBNFrei64bRcDKmJkZGBPIY5oOO m2/A/jhp1j1o9Enk2D31oRBLYYu0Ldf1uNpTz2XZu8nERZMwnjjbtkeJ17fglg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721882947; a=rsa-sha256; cv=none; b=gLw8+Wan9rO3P+MQyl8Us8wpvUCwDrFEi0P9rJmQRrHX9gZTg8Slbxe7GjHjrHBjqvhyz+ bS64HDDL99ysNGPfmjE2KJTW7e1UZFobjnWq7C6IVHZTTE9INuE56zhjHXo83t5/pf8CIf K5HHaKmXb+KiDCLys/Uo/E9FdAWOwMB8iLB66JR8r4OXQNekkcJPWKxOfEfcDot0qmddb8 SHQuZtSKV9EtNALnCUGZM8I85jli3RT/HEjwh49nZ9zkZ8n3mtSKlwf1ICF7Qh97V2GNsv 03qhbnsIv8209WDfTUTb88aBaBF0aa0vulbnzoYQbnEQwtH0pmpBrWUn25JSdQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721882947; 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=PrMd70UsYWwGCK/XT1Zo0HIuJwAt3Ne3d4BCmwMRB7k=; b=fk5fnm5aGu1hGd6j35nmk8CeRoxHR9QPscGuWhW3aoit0cZE/A/GUVetCU+LVY+ttw3ndf PMHbVDpss9WiQzpgqhUib4rkk1t8Hqfx1wqZJIuB281+rgLABPBY9CCIiw/imBho9+k1dT oO1sYa8CszNKnYXERiJE25A5y6Gdu7oJq2koGdkI37Ov6XrM2RRfP0dq8HzbbJMXBD0gKF zI5P2CxmcUkNhBPfbnHpLsOVhgGov93/xlA5qhZArSgempfm7rQzfrx6+bVVLeKpUkugin l/FwhVrtQTYE+RgevLe+BvX0ZuwYc0ISBcHLPODwRycetwyHzlh7XrmGJYRf4Q== 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 4WTz1b4hn8zhKq; Thu, 25 Jul 2024 04:49:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46P4n7L9032146; Thu, 25 Jul 2024 04:49:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46P4n7ZO032143; Thu, 25 Jul 2024 04:49:07 GMT (envelope-from git) Date: Thu, 25 Jul 2024 04:49:07 GMT Message-Id: <202407250449.46P4n7ZO032143@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 028b16e2088a - main - cam: better ioctl compatibility for cd 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 028b16e2088a682c1abfb74fa5eb7ff64405ffff Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=028b16e2088a682c1abfb74fa5eb7ff64405ffff commit 028b16e2088a682c1abfb74fa5eb7ff64405ffff Author: Warner Losh AuthorDate: 2024-07-25 04:47:45 +0000 Commit: Warner Losh CommitDate: 2024-07-25 04:47:45 +0000 cam: better ioctl compatibility for cd Unlike xpt and pass driver, there's no test for ENOTTY in cdioctl to try the compatbility ioctls. Add one. However, this is a disk ioctl, not a cdev ioctl. To get around this, we cast the struct disk * to a struct cdev * to pass through. We cast it back in a simple wrapper function. PR: 198336 Sponsored by: Netflix MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D42666 Differential Revision: https://reviews.freebsd.org/D35312 --- sys/cam/cam_compat.c | 6 ++++++ sys/cam/cam_periph.c | 22 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/sys/cam/cam_compat.c b/sys/cam/cam_compat.c index fdb4ee8717ec..896b071f86dc 100644 --- a/sys/cam/cam_compat.c +++ b/sys/cam/cam_compat.c @@ -49,6 +49,12 @@ #include +/* + * Note: struct cdev *dev parameter here is simply passed through. For cdioctl + * we need to pass down a struct periph * which has been cast to a cdev and that + * is cast back again in cdioctl_dev(). + */ + static int cam_compat_handle_0x17(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td, d_ioctl_t *cbfnp); static int cam_compat_handle_0x18(struct cdev *dev, u_long cmd, caddr_t addr, diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index e957edee67f1..ed90ef91abce 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -1122,6 +1122,20 @@ cam_periph_unmapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo) return (error); } +static int +cam_periph_ioctl_compat(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td) +{ + struct cam_periph *periph; + + /* + * For compat, we need to cast struct periph * into struct cdev *dev and + * then back again. + */ + periph = (struct cam_periph *)(void *)dev; + cam_periph_assert(periph, MA_OWNED); + return (cam_periph_ioctl(periph, cmd, addr, cderror)); +} + int cam_periph_ioctl(struct cam_periph *periph, u_long cmd, caddr_t addr, int (*error_routine)(union ccb *ccb, @@ -1178,7 +1192,13 @@ cam_periph_ioctl(struct cam_periph *periph, u_long cmd, caddr_t addr, break; default: - error = ENOTTY; + /* + * We assume that the compat layer doesn't care about + * the dev parameter. It just passes it through, so + * cheat a little. + */ + error = cam_compat_ioctl((struct cdev *)(void *)periph, + cmd, addr, flag, td, cam_periph_ioctl_compat); break; } return(error);