From nobody Thu Feb 22 16:32:14 2024 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 4Tgdvz21Bkz59wY7; Thu, 22 Feb 2024 16:32: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 4Tgdvz0Xvmz4Ls7; Thu, 22 Feb 2024 16:32:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708619535; 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=Ewl9Dbi/5xiHm2/h2NKQkE2VFaj6uDwhXEAtqAXRTwY=; b=BLZVLHg437+ViKbayAuTIUDl7wE5Eyn4LzSoqFPLP7ND2gNhjSFEl3/NZsCC0KdSnc7jOU h663MyzBFr4m0uPC92q2z60c9BsiMSXoqbOciqKFhzUfJh/EY3YFDVzxpthlYIwM11AQJI fcauXpMO56YRmGHPQlIgngz9GHYjPkOj6HMho98GY97e0iMjrTvG0aKIPk/GH4EJ6XFVxI wyQ/sk5ioQP97SnF0lXeKwonzbpgpkjLvvZARECSfEZ63h/ErEF05j8uxojR2nMy3TxURr BRRbnm3MuaBYg0IaxR1daOdr0QBrkTZIU0Ewr1QdusaimeX9itSqs50ziMYgvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708619535; 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=Ewl9Dbi/5xiHm2/h2NKQkE2VFaj6uDwhXEAtqAXRTwY=; b=S9iGm0dISTAt/mU+ytYIli9D3KlYveBrj58oOELits6PdYH8ak2udRooVEu5Ts4xv/7H9E tOM+gZ2bB0DiaCmqc3v9kaK7rkFUOex4BmcR2DMr5o6UmEQGT5eSBID0e1sE924EkLoWjN T/off2vqHf8gvF1q6surRdr07tyYHXc5mwhkMYqRMXNAQIi7bkgSo5S+5efGRQWKYfMJCd O5/lPtz2ICOCqkH2d+lEwqJhL6ctnQjzdKJ9sf1f5yxMfqqN8CWDkv9YZ9IKFURAQZ0/v0 qwm2CFTSDNlUMmDYsj2CWwn9nD05bu622Gg/+GrV2sdthM0jegt5f47RrqedlQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708619535; a=rsa-sha256; cv=none; b=Cbn1q4pc1VDpPuG/8jVcvQKWHKoY3PcLIl1QTH3whe1C2jkZhNc3aLqKIUNcImvy4HKu+P 2HDZjCzMt5EZDPwbBGjl5KOkNibzb0UrZDnuufC9X4DyRBhYstc5I9c6oAW/fgRIjvkgnU /HySEKEzoSgpLUFrRgOj7BHq8/VsM81pT5f4b6iSGiotRoEe524JkGwCgTI0EnTxPyvu8w 140kyoBzRQ9PBvc4psWAaBYNlSPIBSKPJGrZoXVsc+2UnZeAA/jK/Xql+q7XIhUiSDqEq8 pgHq9sd2uhsQsnvYJ72htT1zBC2XFvOgbLGKodAgZs0vcLNf66PLaAuq9dJENQ== 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 4Tgdvy6S4Vzfdr; Thu, 22 Feb 2024 16:32:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41MGWEnt031860; Thu, 22 Feb 2024 16:32:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41MGWEU0031857; Thu, 22 Feb 2024 16:32:14 GMT (envelope-from git) Date: Thu, 22 Feb 2024 16:32:14 GMT Message-Id: <202402221632.41MGWEU0031857@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: b3e76e3d9e22 - main - kboot: Implement write support for hostdisk 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b3e76e3d9e2262c4b79e81e63e09bfe62c1f6baa Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=b3e76e3d9e2262c4b79e81e63e09bfe62c1f6baa commit b3e76e3d9e2262c4b79e81e63e09bfe62c1f6baa Author: Warner Losh AuthorDate: 2024-02-22 15:17:48 +0000 Commit: Warner Losh CommitDate: 2024-02-22 16:31:55 +0000 kboot: Implement write support for hostdisk Don't assume that strategy is only called for read. Check the passed flag for F_READ or F_WRITE and fail if it is neither. Open the disks for writing and call host_read/host_write depending on that flag. Sponsored by: Netflix Reviewed by: kevans, gallatin Differential Revision: https://reviews.freebsd.org/D44016 --- stand/kboot/kboot/hostdisk.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/stand/kboot/kboot/hostdisk.c b/stand/kboot/kboot/hostdisk.c index 423151983523..a9117d4c1c9d 100644 --- a/stand/kboot/kboot/hostdisk.c +++ b/stand/kboot/kboot/hostdisk.c @@ -305,7 +305,6 @@ hostdisk_strategy(void *devdata, int flag, daddr_t dblk, size_t size, struct devdesc *desc = devdata; daddr_t pos; int n; - int64_t off; uint64_t res; uint32_t posl, posh; @@ -313,12 +312,14 @@ hostdisk_strategy(void *devdata, int flag, daddr_t dblk, size_t size, posl = pos & 0xffffffffu; posh = (pos >> 32) & 0xffffffffu; - if ((off = host_llseek(desc->d_unit, posh, posl, &res, 0)) < 0) { - printf("Seek error on fd %d to %ju (dblk %ju) returns %jd\n", - desc->d_unit, (uintmax_t)pos, (uintmax_t)dblk, (intmax_t)off); + if (host_llseek(desc->d_unit, posh, posl, &res, 0) < 0) return (EIO); - } - n = host_read(desc->d_unit, buf, size); + if (flag & F_READ) + n = host_read(desc->d_unit, buf, size); + else if (flag & F_WRITE) + n = host_write(desc->d_unit, buf, size); + else + return (EINVAL); if (n < 0) return (EIO); @@ -339,7 +340,7 @@ hostdisk_open(struct open_file *f, ...) va_end(vl); fn = dev2hd(desc)->hd_dev; - desc->d_unit = host_open(fn, O_RDONLY, 0); + desc->d_unit = host_open(fn, O_RDWR, 0); if (desc->d_unit <= 0) { printf("hostdisk_open: couldn't open %s: %d\n", fn, errno); return (ENOENT);