From nobody Mon Feb 9 09:24: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+69045+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+69045+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608157016; cv=none; d=zohomail.com; s=zohoarc; b=dBi27yd2XcyFhMLgHa5ej+75BQztfghDHTL8tn8YY4jHqiVtCCe+DbwgTYsd+YH6hq5+WXGIspKf33A+PNjQ9AoqVqLyHEBS9lQEvM0AO8ndPbiY0iwLZHsTR4DxuTWQjaEUJXYjygXC0KfDUU34K+uLqpBJ8s7xkO5Oidwtqng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608157016; 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=j69Z7L6ICM9Ik0OyL9MonG1crujlG5HIeyE7bQFe70g=; b=IkLqQWG7d5pNMgW6CFrwdWmNDnBQsYdcNtOANVVL9+MGvgZQf5iBrSA9gADQpLXTpX47avlcnAUTbnuQpEej84t9bJWFa/aEq51Yp8zkhvw008fivzSwVziNeofk+ymxwS6DJ4IHunlBPNcpz8e9JB79VJZ4my8WK22U+hC0vww= 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+69045+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 1608157016673236.10870161846958; Wed, 16 Dec 2020 14:16:56 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8m1cYY1788612xSn1dT002EY; Wed, 16 Dec 2020 14:16:56 -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.4609.1608157015614290733 for ; Wed, 16 Dec 2020 14:16:55 -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-483-wSsW0N-qPOSr8RMfOUg9ug-1; Wed, 16 Dec 2020 17:16:53 -0500 X-MC-Unique: wSsW0N-qPOSr8RMfOUg9ug-1 X-Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C753A801B13; Wed, 16 Dec 2020 22:16:51 +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 ED63619D9F; Wed, 16 Dec 2020 22:16:46 +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 31/48] OvmfPkg/VirtioFsDxe: implement EFI_FILE_PROTOCOL.GetPosition, .SetPosition Date: Wed, 16 Dec 2020 22:11:08 +0100 Message-Id: <20201216211125.19496-32-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.84 on 10.5.11.23 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: EHXddXMaEgbFCIjcKVCAgfu8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608157016; bh=j69Z7L6ICM9Ik0OyL9MonG1crujlG5HIeyE7bQFe70g=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=byLUcpRWybmFJygcez2vE+/pxN2dRb+0Bdw7hwZzSHJPZzsCvS4jbrt4fL40EPbUdlq jXMxQySY7GGK9IlO25IMAuM/xpJfWkzhZ+jOAqkYpuNk5OTBQt553xTk9EeL/oMgmIlnx 1adaD4bN5CClhDZM833gDhF3cma/V7Giga0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Using the functions introduced previously, we can now implement VirtioFsSimpleFileGetPosition() and VirtioFsSimpleFileSetPosition(). 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/VirtioFsDxe.h | 1 + OvmfPkg/VirtioFsDxe/SimpleFsGetPosition.c | 9 ++++- OvmfPkg/VirtioFsDxe/SimpleFsOpen.c | 1 + OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c | 1 + OvmfPkg/VirtioFsDxe/SimpleFsSetPosition.c | 40 +++++++++++++++++++- 5 files changed, 50 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h b/OvmfPkg/VirtioFsDxe/Virtio= FsDxe.h index d1b746c0d8cf..948fcfb6b6f3 100644 --- a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h +++ b/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h @@ -134,16 +134,17 @@ typedef struct { typedef struct { UINT64 Signature; EFI_FILE_PROTOCOL SimpleFile; BOOLEAN IsDirectory; BOOLEAN IsOpenForWriting; VIRTIO_FS *OwnerFs; LIST_ENTRY OpenFilesEntry; CHAR8 *CanonicalPathname; + UINT64 FilePosition; // // In the FUSE wire protocol, every request except FUSE_INIT refers to a // file, namely by the "VIRTIO_FS_FUSE_REQUEST.NodeId" field; that is, b= y the // inode number of the file. However, some of the FUSE requests that we = need // for some of the EFI_FILE_PROTOCOL member functions require an open fi= le // handle *in addition* to the inode number. For simplicity, whenever a // VIRTIO_FS_FILE object is created, primarily defined by its NodeId fie= ld, // we also *open* the referenced file at once, and save the returned file diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsGetPosition.c b/OvmfPkg/VirtioFsDx= e/SimpleFsGetPosition.c index 2f40d2be2693..53212621e970 100644 --- a/OvmfPkg/VirtioFsDxe/SimpleFsGetPosition.c +++ b/OvmfPkg/VirtioFsDxe/SimpleFsGetPosition.c @@ -11,10 +11,17 @@ =20 EFI_STATUS EFIAPI VirtioFsSimpleFileGetPosition ( IN EFI_FILE_PROTOCOL *This, OUT UINT64 *Position ) { - return EFI_DEVICE_ERROR; + VIRTIO_FS_FILE *VirtioFsFile; + + VirtioFsFile =3D VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This); + if (VirtioFsFile->IsDirectory) { + return EFI_UNSUPPORTED; + } + *Position =3D VirtioFsFile->FilePosition; + return EFI_SUCCESS; } diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c b/OvmfPkg/VirtioFsDxe/Simpl= eFsOpen.c index 2649c796ac97..7c50ce9c0e76 100644 --- a/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c +++ b/OvmfPkg/VirtioFsDxe/SimpleFsOpen.c @@ -474,16 +474,17 @@ VirtioFsSimpleFileOpen ( NewVirtioFsFile->SimpleFile.SetPosition =3D VirtioFsSimpleFileSetPositio= n; NewVirtioFsFile->SimpleFile.GetInfo =3D VirtioFsSimpleFileGetInfo; NewVirtioFsFile->SimpleFile.SetInfo =3D VirtioFsSimpleFileSetInfo; NewVirtioFsFile->SimpleFile.Flush =3D VirtioFsSimpleFileFlush; NewVirtioFsFile->IsDirectory =3D NewNodeIsDirectory; NewVirtioFsFile->IsOpenForWriting =3D OpenForWriting; NewVirtioFsFile->OwnerFs =3D VirtioFs; NewVirtioFsFile->CanonicalPathname =3D NewCanonicalPath; + NewVirtioFsFile->FilePosition =3D 0; NewVirtioFsFile->NodeId =3D NewNodeId; NewVirtioFsFile->FuseHandle =3D NewFuseHandle; =20 // // One more file is now open for the filesystem. // InsertTailList (&VirtioFs->OpenFiles, &NewVirtioFsFile->OpenFilesEntry); =20 diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c b/OvmfPkg/VirtioFsDxe= /SimpleFsOpenVolume.c index 9c0ab434c186..1181191d271b 100644 --- a/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c +++ b/OvmfPkg/VirtioFsDxe/SimpleFsOpenVolume.c @@ -67,16 +67,17 @@ VirtioFsOpenVolume ( VirtioFsFile->SimpleFile.SetPosition =3D VirtioFsSimpleFileSetPosition; VirtioFsFile->SimpleFile.GetInfo =3D VirtioFsSimpleFileGetInfo; VirtioFsFile->SimpleFile.SetInfo =3D VirtioFsSimpleFileSetInfo; VirtioFsFile->SimpleFile.Flush =3D VirtioFsSimpleFileFlush; VirtioFsFile->IsDirectory =3D TRUE; VirtioFsFile->IsOpenForWriting =3D FALSE; VirtioFsFile->OwnerFs =3D VirtioFs; VirtioFsFile->CanonicalPathname =3D CanonicalPathname; + VirtioFsFile->FilePosition =3D 0; VirtioFsFile->NodeId =3D VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID; VirtioFsFile->FuseHandle =3D RootDirHandle; =20 // // One more file open for the filesystem. // InsertTailList (&VirtioFs->OpenFiles, &VirtioFsFile->OpenFilesEntry); =20 diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsSetPosition.c b/OvmfPkg/VirtioFsDx= e/SimpleFsSetPosition.c index ee8cb1f4e465..ac6285302652 100644 --- a/OvmfPkg/VirtioFsDxe/SimpleFsSetPosition.c +++ b/OvmfPkg/VirtioFsDxe/SimpleFsSetPosition.c @@ -11,10 +11,48 @@ =20 EFI_STATUS EFIAPI VirtioFsSimpleFileSetPosition ( IN EFI_FILE_PROTOCOL *This, IN UINT64 Position ) { - return EFI_DEVICE_ERROR; + VIRTIO_FS_FILE *VirtioFsFile; + VIRTIO_FS *VirtioFs; + EFI_STATUS Status; + VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr; + + VirtioFsFile =3D VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This); + + // + // Directories can only be rewound, per spec. + // + if (VirtioFsFile->IsDirectory) { + if (Position !=3D 0) { + return EFI_UNSUPPORTED; + } + VirtioFsFile->FilePosition =3D 0; + return EFI_SUCCESS; + } + + // + // Regular file. + // + if (Position < MAX_UINT64) { + // + // Caller is requesting absolute file position. + // + VirtioFsFile->FilePosition =3D Position; + return EFI_SUCCESS; + } + + // + // Caller is requesting a seek to EOF. + // + VirtioFs =3D VirtioFsFile->OwnerFs; + Status =3D VirtioFsFuseGetAttr (VirtioFs, VirtioFsFile->NodeId, &FuseAtt= r); + if (EFI_ERROR (Status)) { + return Status; + } + VirtioFsFile->FilePosition =3D FuseAttr.Size; + return EFI_SUCCESS; } --=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 (#69045): https://edk2.groups.io/g/devel/message/69045 Mute This Topic: https://groups.io/mt/79023920/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-