From nobody Mon Feb 9 04:29:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+69053+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69053+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608158024; cv=none; d=zohomail.com; s=zohoarc; b=dpJ3DNwH+YFMbKE+mP534uLq7xYHnGKAIbS8kCcdnl+KE9B3KV/9q96f3Ase2x72X5CG0j5aHnk8XeRdYAbA4QizpDppHciPQdgQAuJwKNCQlahO7gdM/0IrfgA2iU8uyIqjamkybmNl1yQ+9eTD8N+VkI9PT2TV/a62brlxL74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608158024; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=AI5mG4ekEptycAFdFrbdhZ8j4hUt/4uP6E2++6Eb/kw=; b=eoj0lZbgFyFMHwjzYiEE+8JpiBwCr5fO+uHmSII+fdAYc1Y7maoqtckU3WTji+60GKTgJzpGSUFw8M+IyDABzkTNISJhbZIXtYTCkMDSypwJnfhd+dDMbCnBbq7VLIVRc4OJQ8uN0HWJ581OmSKVk+P+/WX619taxldBvQcRxqU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69053+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16081580245261021.1812205272477; Wed, 16 Dec 2020 14:33:44 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id bqmUYY1788612xPcvaLf93vA; Wed, 16 Dec 2020 14:33:44 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web10.4908.1608158023521573541 for ; Wed, 16 Dec 2020 14:33:43 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-103-ESZiJYpiP1mz_RiB57YpwA-1; Wed, 16 Dec 2020 17:33:40 -0500 X-MC-Unique: ESZiJYpiP1mz_RiB57YpwA-1 X-Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 731B2107ACE4; Wed, 16 Dec 2020 22:33:39 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-152.ams2.redhat.com [10.36.114.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E6FA60C15; Wed, 16 Dec 2020 22:33:34 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io, virtio-fs@redhat.com, lersek@redhat.com Cc: Ard Biesheuvel , Jordan Justen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [edk2-devel] [edk2 PATCH 39/48] OvmfPkg/VirtioFsDxe: implement EFI_FILE_PROTOCOL.Write() Date: Wed, 16 Dec 2020 22:11:16 +0100 Message-Id: <20201216211125.19496-40-lersek@redhat.com> In-Reply-To: <20201216211125.19496-1-lersek@redhat.com> References: <20201216211125.19496-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: UB01EPi8wnDZxLguPFvRvi9Qx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608158024; bh=AI5mG4ekEptycAFdFrbdhZ8j4hUt/4uP6E2++6Eb/kw=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=H7JL/+iMw1IoSS4bz9AEEWs3BxIIg2y7kwhsjuhxOigW7KHI/esNZBpETSzZZBGbU4d J5l171q9M8sSCycNwWhBNd8C5hWqqX7y6j83UEzpMTRCxBQiScl7DydDETdXgJWy8lXl5 KF3kGUe4wUN5tYOWW7+68B0QLji8LV7By/E= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Using the functions introduced previously, we can now implement VirtioFsSimpleFileWrite(). Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Philippe Mathieu-Daud=C3=A9 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3097 Signed-off-by: Laszlo Ersek --- OvmfPkg/VirtioFsDxe/SimpleFsWrite.c | 63 +++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsWrite.c b/OvmfPkg/VirtioFsDxe/Simp= leFsWrite.c index 90d82bd722b1..8ae317c88e43 100644 --- a/OvmfPkg/VirtioFsDxe/SimpleFsWrite.c +++ b/OvmfPkg/VirtioFsDxe/SimpleFsWrite.c @@ -11,10 +11,71 @@ EFI_STATUS EFIAPI VirtioFsSimpleFileWrite ( IN EFI_FILE_PROTOCOL *This, IN OUT UINTN *BufferSize, IN VOID *Buffer ) { - return EFI_NO_MEDIA; + VIRTIO_FS_FILE *VirtioFsFile; + VIRTIO_FS *VirtioFs; + EFI_STATUS Status; + UINTN Transferred; + UINTN Left; + + VirtioFsFile =3D VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This); + VirtioFs =3D VirtioFsFile->OwnerFs; + + if (VirtioFsFile->IsDirectory) { + return EFI_UNSUPPORTED; + } + if (!VirtioFsFile->IsOpenForWriting) { + return EFI_ACCESS_DENIED; + } + + Status =3D EFI_SUCCESS; + Transferred =3D 0; + Left =3D *BufferSize; + while (Left > 0) { + UINT32 WriteSize; + + // + // Honor the write buffer size limit. + // + WriteSize =3D (UINT32)MIN ((UINTN)VirtioFs->MaxWrite, Left); + Status =3D VirtioFsFuseWrite ( + VirtioFs, + VirtioFsFile->NodeId, + VirtioFsFile->FuseHandle, + VirtioFsFile->FilePosition + Transferred, + &WriteSize, + (UINT8 *)Buffer + Transferred + ); + if (!EFI_ERROR (Status) && WriteSize =3D=3D 0) { + // + // Progress should have been made. + // + Status =3D EFI_DEVICE_ERROR; + } + if (EFI_ERROR (Status)) { + break; + } + Transferred +=3D WriteSize; + Left -=3D WriteSize; + } + + *BufferSize =3D Transferred; + VirtioFsFile->FilePosition +=3D Transferred; + // + // According to the UEFI spec, + // + // - 'Partial writes only occur when there has been a data error during = the + // write attempt (such as "file space full")', and + // + // - (as an example) EFI_VOLUME_FULL is returned when 'The volume is ful= l'. + // + // These together imply that after a partial write, we have to return an + // error. In other words, (Transferred > 0) is inconsequential for the r= eturn + // value. + // + return Status; } --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#69053): https://edk2.groups.io/g/devel/message/69053 Mute This Topic: https://groups.io/mt/79024319/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-