From nobody Mon Feb 9 09:09:09 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+69042+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+69042+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608156640; cv=none; d=zohomail.com; s=zohoarc; b=S7xo/HIufDJwwb4XU0Zda9I6R6Kvxqh+rrXxDPItywYHtnVlwJbjP7O3ZmrKdnfuxS3TJtPtbM1rpKmAFvuJOWFdeCCvoMvRZ9sIJDOoIoqZmoUe0mBhK9djmGb0LSpQQttIKzAraoZB+pTu7M3yVS/0gL6MS6Sr6IKYZk2zuWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608156640; 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=4F6WPmO6Q+h3yfYBdD21O8Hs6KqvSKYllUJXWph37u0=; b=hAL94u8B8G7GKHN6GPNlTPm0UndQl9aZcwd59URZTmUbPK3a8RiS+CvYYOGx7YSGw4eHuOf7dN5SW7UU1bVOvSwAj5zIU5Ad9Vb1STxFdsjKV5nHDpyIl2xPDpFWnzykrcUqBg77itR4sdKuOos6R6U2L3OGC6kcOONq8PJ8Q4k= 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+69042+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 1608156640119454.8362571632754; Wed, 16 Dec 2020 14:10:40 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8NSeYY1788612xTH7CGrFAk0; Wed, 16 Dec 2020 14:10:39 -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.web10.4509.1608156634069821965 for ; Wed, 16 Dec 2020 14:10:34 -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-420-ZCxL6Zi5Mty-CuhO2eid7Q-1; Wed, 16 Dec 2020 17:10:31 -0500 X-MC-Unique: ZCxL6Zi5Mty-CuhO2eid7Q-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 0481C800D55; Wed, 16 Dec 2020 22:10:29 +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 490CF1A49B; Wed, 16 Dec 2020 22:10:24 +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 28/48] OvmfPkg/VirtioFsDxe: implement the wrapper function for FUSE_STATFS Date: Wed, 16 Dec 2020 22:11:05 +0100 Message-Id: <20201216211125.19496-29-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: Ye4883rdeGX0Y4k23dW73EAhx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608156639; bh=4F6WPmO6Q+h3yfYBdD21O8Hs6KqvSKYllUJXWph37u0=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=LPLhDnrrFoWvm6zBHMSmhfDmiVOE+keAA/Z/BItxNvmaT/E9C7xpTGDM1AdjbrzLqJu X8DRCENvq+EeOdw1hxiUe6Hv1umQgKwZcfyvQuk6Dxd19PdM68AdeSnNem4UTQhKlKvJ7 SaXCtMqrk6hcuU+p01P70dNxteMZEQWehKI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add the VirtioFsFuseStatFs() function, for sending the FUSE_STATFS 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 | 17 ++++ OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf | 1 + OvmfPkg/VirtioFsDxe/VirtioFsDxe.h | 7 ++ OvmfPkg/VirtioFsDxe/FuseStatFs.c | 102 ++++++++++++++++++++ 4 files changed, 127 insertions(+) diff --git a/OvmfPkg/Include/IndustryStandard/VirtioFs.h b/OvmfPkg/Include/= IndustryStandard/VirtioFs.h index efcf57941c59..800d3651e12b 100644 --- a/OvmfPkg/Include/IndustryStandard/VirtioFs.h +++ b/OvmfPkg/Include/IndustryStandard/VirtioFs.h @@ -114,16 +114,17 @@ typedef struct { typedef enum { VirtioFsFuseOpLookup =3D 1, VirtioFsFuseOpForget =3D 2, VirtioFsFuseOpGetAttr =3D 3, VirtioFsFuseOpMkDir =3D 9, VirtioFsFuseOpUnlink =3D 10, VirtioFsFuseOpRmDir =3D 11, VirtioFsFuseOpOpen =3D 14, + VirtioFsFuseOpStatFs =3D 17, VirtioFsFuseOpRelease =3D 18, VirtioFsFuseOpFsync =3D 20, VirtioFsFuseOpFlush =3D 25, VirtioFsFuseOpInit =3D 26, VirtioFsFuseOpOpenDir =3D 27, VirtioFsFuseOpReleaseDir =3D 29, VirtioFsFuseOpFsyncDir =3D 30, VirtioFsFuseOpCreate =3D 35, @@ -228,16 +229,32 @@ typedef struct { } VIRTIO_FS_FUSE_OPEN_REQUEST; =20 typedef struct { UINT64 FileHandle; UINT32 OpenFlags; UINT32 Padding; } VIRTIO_FS_FUSE_OPEN_RESPONSE; =20 +// +// Header for VirtioFsFuseOpStatFs. +// +typedef struct { + UINT64 Blocks; + UINT64 Bfree; + UINT64 Bavail; + UINT64 Files; + UINT64 Ffree; + UINT32 Bsize; + UINT32 Namelen; + UINT32 Frsize; + UINT32 Padding; + UINT32 Spare[6]; +} VIRTIO_FS_FUSE_STATFS_RESPONSE; + // // Header for VirtioFsFuseOpRelease and VirtioFsFuseOpReleaseDir. // typedef struct { UINT64 FileHandle; UINT32 Flags; UINT32 ReleaseFlags; UINT64 LockOwner; diff --git a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf b/OvmfPkg/VirtioFsDxe/Virt= ioFsDxe.inf index 233c0c5c0f9a..318449db3e63 100644 --- a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf +++ b/OvmfPkg/VirtioFsDxe/VirtioFsDxe.inf @@ -89,16 +89,17 @@ [Sources] FuseGetAttr.c FuseInit.c FuseLookup.c FuseMkDir.c FuseOpen.c FuseOpenDir.c FuseOpenOrCreate.c FuseRelease.c + FuseStatFs.c FuseUnlink.c Helpers.c SimpleFsClose.c SimpleFsDelete.c SimpleFsFlush.c SimpleFsGetInfo.c SimpleFsGetPosition.c SimpleFsOpen.c diff --git a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h b/OvmfPkg/VirtioFsDxe/Virtio= FsDxe.h index 3bf64c0146fa..029c568b39c7 100644 --- a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h +++ b/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h @@ -285,16 +285,23 @@ VirtioFsFuseRemoveFileOrDir ( EFI_STATUS VirtioFsFuseOpen ( IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN BOOLEAN ReadWrite, OUT UINT64 *FuseHandle ); =20 +EFI_STATUS +VirtioFsFuseStatFs ( + IN OUT VIRTIO_FS *VirtioFs, + IN UINT64 NodeId, + OUT VIRTIO_FS_FUSE_STATFS_RESPONSE *FilesysAttr + ); + EFI_STATUS VirtioFsFuseReleaseFileOrDir ( IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN UINT64 FuseHandle, IN BOOLEAN IsDir ); =20 diff --git a/OvmfPkg/VirtioFsDxe/FuseStatFs.c b/OvmfPkg/VirtioFsDxe/FuseSta= tFs.c new file mode 100644 index 000000000000..e794f8977a48 --- /dev/null +++ b/OvmfPkg/VirtioFsDxe/FuseStatFs.c @@ -0,0 +1,102 @@ +/** @file + FUSE_STATFS wrapper for the Virtio Filesystem device. + + Copyright (C) 2020, Red Hat, Inc. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include "VirtioFsDxe.h" + +/** + Send the FUSE_STATFS request to the Virtio Filesysem device, for retriev= ing + the attributes of the host-side filesystem that contains NodeId. + + 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_S= TATFS + request to. On output, the FUSE request counter + "VirtioFs->RequestId" will have been incremente= d. + + @param[in] NodeId The inode whose containing filesystem is to be + queried for its attributes. + + @param[out] FilesysAttr The VIRTIO_FS_FUSE_STATFS_RESPONSE object descr= ibing + the filesystem that underlies NodeId. + + @retval EFI_SUCCESS FilesysAttr 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 +VirtioFsFuseStatFs ( + IN OUT VIRTIO_FS *VirtioFs, + IN UINT64 NodeId, + OUT VIRTIO_FS_FUSE_STATFS_RESPONSE *FilesysAttr + ) +{ + VIRTIO_FS_FUSE_REQUEST CommonReq; + VIRTIO_FS_IO_VECTOR ReqIoVec[1]; + VIRTIO_FS_SCATTER_GATHER_LIST ReqSgList; + VIRTIO_FS_FUSE_RESPONSE CommonResp; + VIRTIO_FS_IO_VECTOR RespIoVec[2]; + 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; + 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 FilesysAttr; + RespIoVec[1].Size =3D sizeof *FilesysAttr; + 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, + VirtioFsFuseOpStatFs, NodeId); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // 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 (#69042): https://edk2.groups.io/g/devel/message/69042 Mute This Topic: https://groups.io/mt/79023749/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-