From nobody Mon Feb 9 07:06:01 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+69039+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+69039+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608156262; cv=none; d=zohomail.com; s=zohoarc; b=APehprYTzxuCUP9Har3UV6QMSXEoQkdGFueZECD3vR8djIDYtyRiIU6W1Sln5oX63Gcp/sGJD9AJOU+WN+iuPCXBfGIYeoTAPhuejD3H0jtQYl4Wo3Z+LQPLDgxeMwCNs+dTf0P4FVEtLyfYI15BV+QTS6fLFe/yrEDbMp0Z1xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608156262; 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=dFnYQEODUUEmXrtPmXpiRQQ1HgHQ/4alxycrcJVPG6I=; b=OwcrLJpAUAnGbFTVLjwnfx20qkZV25Xgrw7Y9F2oSeUlUoi6Zenb3xl3rODm1JjU9ljZPv03JJjVC43i4FLiyIi//qCshnL8MbTYthNbnWzXJSc46d0j7+pWiZ+0YNok+9siFw+Nivv46FuXF19d0DkXnNzDcP1ATsCtIM34MbE= 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+69039+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 160815626241510.456129784611107; Wed, 16 Dec 2020 14:04:22 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id kd0rYY1788612x5GtAQ9MQSW; Wed, 16 Dec 2020 14:04:21 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.groups.io with SMTP id smtpd.web09.4181.1608156255632202800 for ; Wed, 16 Dec 2020 14:04:15 -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-532-GAuqssMqOoihV3Gh8yUUBQ-1; Wed, 16 Dec 2020 17:04:09 -0500 X-MC-Unique: GAuqssMqOoihV3Gh8yUUBQ-1 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A134C107ACE8; Wed, 16 Dec 2020 22:04:08 +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 C663819CAC; Wed, 16 Dec 2020 22:04:03 +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 25/48] OvmfPkg/VirtioFsDxe: implement the wrapper function for FUSE_GETATTR Date: Wed, 16 Dec 2020 22:11:02 +0100 Message-Id: <20201216211125.19496-26-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.11 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: efGnEoaDw1pL9j9nD1IgMmvfx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608156261; bh=dFnYQEODUUEmXrtPmXpiRQQ1HgHQ/4alxycrcJVPG6I=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=kGgbPEEZIpZLDn3aF5SMyX63x84liCO3lCDj3j2UP0Z5WXOUOSJXNFbJ87X7iPsjaZR qb7oHd92J3pXbmgbhcU3tCvSfQK5R9VoAlqqeLYReYtCHXp/g9sXU7GAxO14IgpTVUmfz mlVCCNcmQWz0I3HGraptNwu0+ndXo+kuA7Y= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add the VirtioFsFuseGetAttr() function, for sending the FUSE_GETATTR command to the Virtio Filesystem device. 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/Include/IndustryStandard/VirtioFs.h | 16 +++ OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf | 1 + OvmfPkg/VirtioFsDxe/VirtioFsDxe.h | 7 ++ OvmfPkg/VirtioFsDxe/FuseGetAttr.c | 116 ++++++++++++++++++++ 4 files changed, 140 insertions(+) diff --git a/OvmfPkg/Include/IndustryStandard/VirtioFs.h b/OvmfPkg/Include/= IndustryStandard/VirtioFs.h index f49452830abc..efcf57941c59 100644 --- a/OvmfPkg/Include/IndustryStandard/VirtioFs.h +++ b/OvmfPkg/Include/IndustryStandard/VirtioFs.h @@ -109,16 +109,17 @@ typedef struct { #define VIRTIO_FS_FUSE_OPEN_REQ_F_RDWR 2 =20 // // FUSE operation codes. // typedef enum { VirtioFsFuseOpLookup =3D 1, VirtioFsFuseOpForget =3D 2, + VirtioFsFuseOpGetAttr =3D 3, VirtioFsFuseOpMkDir =3D 9, VirtioFsFuseOpUnlink =3D 10, VirtioFsFuseOpRmDir =3D 11, VirtioFsFuseOpOpen =3D 14, VirtioFsFuseOpRelease =3D 18, VirtioFsFuseOpFsync =3D 20, VirtioFsFuseOpFlush =3D 25, VirtioFsFuseOpInit =3D 26, @@ -190,16 +191,31 @@ typedef struct { =20 // // Header for VirtioFsFuseOpForget. // typedef struct { UINT64 NumberOfLookups; } VIRTIO_FS_FUSE_FORGET_REQUEST; =20 +// +// Headers for VirtioFsFuseOpGetAttr. +// +typedef struct { + UINT32 GetAttrFlags; + UINT32 Dummy; + UINT64 FileHandle; +} VIRTIO_FS_FUSE_GETATTR_REQUEST; + +typedef struct { + UINT64 AttrValid; + UINT32 AttrValidNsec; + UINT32 Dummy; +} VIRTIO_FS_FUSE_GETATTR_RESPONSE; + // // Header for VirtioFsFuseOpMkDir. // typedef struct { UINT32 Mode; UINT32 Umask; } VIRTIO_FS_FUSE_MKDIR_REQUEST; =20 diff --git a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf b/OvmfPkg/VirtioFsDxe/Virt= ioFsDxe.inf index 2332aa3ee551..233c0c5c0f9a 100644 --- a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf +++ b/OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf @@ -81,16 +81,17 @@ [Packages] MdePkg/MdePkg.dec OvmfPkg/OvmfPkg.dec =20 [Sources] DriverBinding.c FuseFlush.c FuseForget.c FuseFsync.c + FuseGetAttr.c FuseInit.c FuseLookup.c FuseMkDir.c FuseOpen.c FuseOpenDir.c FuseOpenOrCreate.c FuseRelease.c FuseUnlink.c diff --git a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h b/OvmfPkg/VirtioFsDxe/Virtio= FsDxe.h index 0e4f2109eb02..3bf64c0146fa 100644 --- a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h +++ b/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h @@ -254,16 +254,23 @@ VirtioFsFuseLookup ( ); =20 EFI_STATUS VirtioFsFuseForget ( IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId ); =20 +EFI_STATUS +VirtioFsFuseGetAttr ( + IN OUT VIRTIO_FS *VirtioFs, + IN UINT64 NodeId, + OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr + ); + EFI_STATUS VirtioFsFuseMkDir ( IN OUT VIRTIO_FS *VirtioFs, IN UINT64 ParentNodeId, IN CHAR8 *Name, OUT UINT64 *NodeId ); =20 diff --git a/OvmfPkg/VirtioFsDxe/FuseGetAttr.c b/OvmfPkg/VirtioFsDxe/FuseGe= tAttr.c new file mode 100644 index 000000000000..29d8ec8190e1 --- /dev/null +++ b/OvmfPkg/VirtioFsDxe/FuseGetAttr.c @@ -0,0 +1,116 @@ +/** @file + FUSE_GETATTR wrapper for the Virtio Filesystem device. + + Copyright (C) 2020, Red Hat, Inc. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "VirtioFsDxe.h" + +/** + Send a FUSE_GETATTR request to the Virtio Filesystem device, for fetchin= g the + attributes of an inode. + + The function may only be called after VirtioFsFuseInitSession() returns + successfully and before VirtioFsUninit() is called. + + @param[in,out] VirtioFs The Virtio Filesystem device to send the + FUSE_GETATTR request to. On output, the FUSE re= quest + counter "VirtioFs->RequestId" will have been + incremented. + + @param[in] NodeId The inode number for which the attributes shoul= d be + retrieved. + + @param[out] FuseAttr The VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE object + describing the properties of the inode. + + @retval EFI_SUCCESS FuseAttr has been filled in. + + @return The "errno" value mapped to an EFI_STATUS code, if = the + Virtio Filesystem device explicitly reported an err= or. + + @return Error codes propagated from VirtioFsSgListsValidate= (), + VirtioFsFuseNewRequest(), VirtioFsSgListsSubmit(), + VirtioFsFuseCheckResponse(). +**/ +EFI_STATUS +VirtioFsFuseGetAttr ( + IN OUT VIRTIO_FS *VirtioFs, + IN UINT64 NodeId, + OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr + ) +{ + VIRTIO_FS_FUSE_REQUEST CommonReq; + VIRTIO_FS_FUSE_GETATTR_REQUEST GetAttrReq; + VIRTIO_FS_IO_VECTOR ReqIoVec[2]; + VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList; + VIRTIO_FS_FUSE_RESPONSE CommonResp; + VIRTIO_FS_FUSE_GETATTR_RESPONSE GetAttrResp; + VIRTIO_FS_IO_VECTOR RespIoVec[3]; + VIRTIO_FS_SCATTER_GATHER_LIST RespSgList; + EFI_STATUS Status; + + // + // Set up the scatter-gather lists. + // + ReqIoVec[0].Buffer =3D &CommonReq; + ReqIoVec[0].Size =3D sizeof CommonReq; + ReqIoVec[1].Buffer =3D &GetAttrReq; + ReqIoVec[1].Size =3D sizeof GetAttrReq; + ReqSgList.IoVec =3D ReqIoVec; + ReqSgList.NumVec =3D ARRAY_SIZE (ReqIoVec); + + RespIoVec[0].Buffer =3D &CommonResp; + RespIoVec[0].Size =3D sizeof CommonResp; + RespIoVec[1].Buffer =3D &GetAttrResp; + RespIoVec[1].Size =3D sizeof GetAttrResp; + RespIoVec[2].Buffer =3D FuseAttr; + RespIoVec[2].Size =3D sizeof *FuseAttr; + RespSgList.IoVec =3D RespIoVec; + RespSgList.NumVec =3D ARRAY_SIZE (RespIoVec); + + // + // Validate the scatter-gather lists; calculate the total transfer sizes. + // + Status =3D VirtioFsSgListsValidate (VirtioFs, &ReqSgList, &RespSgList); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Populate the common request header. + // + Status =3D VirtioFsFuseNewRequest (VirtioFs, &CommonReq, ReqSgList.Total= Size, + VirtioFsFuseOpGetAttr, NodeId); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Populate the FUSE_GETATTR-specific fields. + // + GetAttrReq.GetAttrFlags =3D 0; + GetAttrReq.Dummy =3D 0; + GetAttrReq.FileHandle =3D 0; + + // + // Submit the request. + // + Status =3D VirtioFsSgListsSubmit (VirtioFs, &ReqSgList, &RespSgList); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Verify the response (all response buffers are fixed size). + // + Status =3D VirtioFsFuseCheckResponse (&RespSgList, CommonReq.Unique, NUL= L); + if (Status =3D=3D EFI_DEVICE_ERROR) { + DEBUG ((DEBUG_ERROR, "%a: Label=3D\"%s\" NodeId=3D%Lu Errno=3D%d\n", + __FUNCTION__, VirtioFs->Label, NodeId, CommonResp.Error)); + Status =3D VirtioFsErrnoToEfiStatus (CommonResp.Error); + } + 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 (#69039): https://edk2.groups.io/g/devel/message/69039 Mute This Topic: https://groups.io/mt/79023626/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-