From nobody Mon Feb 9 16:50: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+69043+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+69043+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608156765; cv=none; d=zohomail.com; s=zohoarc; b=Y7qWzDTkBNYACxKYirFw0vxhdrjJVM3BhplvRBoIbKTR6SpuPo48k2b00FWstfBscB7KkHOjgJ2pxTQejwhfQ/9UjmsUk4Ub7V39t0omrph2odEscF7f7b5aj4fr66O10KRuEdjxRFAPOSFQYdiDukyzTxNqzkO6U0r96C/HMqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608156765; 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=enQzXzCaqmzwyG5oh6iFPwEVtmQZ5r2qscSFYalG+HI=; b=MkiKGjlzgUm9sst/jOkmO8Z3gixUoJQtH946TN4Rej30YJgPjwtKlxRG5tFbXcodX8zdCyOoE90Fioox0D8Ld+3ynouykzStjabwBf8rNOoRvNO+KQy631KXuqsp/5cjxikAwpSTpZkaA3VwGoikxDmcInBr4h0u1IPvBJxO+ZA= 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+69043+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 1608156765109361.70763583702546; Wed, 16 Dec 2020 14:12:45 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id a5vQYY1788612x2VZZ5l72Ml; Wed, 16 Dec 2020 14:12: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.4536.1608156758850008660 for ; Wed, 16 Dec 2020 14:12:39 -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-341-GAb2xRw6POuine2qmgedDw-1; Wed, 16 Dec 2020 17:12:36 -0500 X-MC-Unique: GAb2xRw6POuine2qmgedDw-1 X-Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BA08A8144F4; Wed, 16 Dec 2020 22:12:34 +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 39BAB60CCD; Wed, 16 Dec 2020 22:12:30 +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 29/48] OvmfPkg/VirtioFsDxe: add helper for formatting UEFI basenames Date: Wed, 16 Dec 2020 22:11:06 +0100 Message-Id: <20201216211125.19496-30-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.13 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: UmLWUGiVmVUFZEJ2MOSmVraMx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608156764; bh=enQzXzCaqmzwyG5oh6iFPwEVtmQZ5r2qscSFYalG+HI=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=L8m/nwA2Bt2Dy/fzBqnDUdxzZd+9jAGn78RFTFiC7iejmdv5scdlcySrzJZ4BsKe7P/ LlptPWF+TG+aGRvFGHZ/0dvYZWKDlwyI/2Qb95cpAMwkOeVq0//YS/NnmvMWSJK/DGLcE YeUTJjFZLLBy2eGQOOFM7sEgaL7nPuURFeA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The EFI_FILE_INFO structure, which is output by EFI_FILE_PROTOCOL.GetInfo(), ends with a flexible CHAR16 array called "FileName". Add the VirtioFsGetBasename() function, for determining the required array size, and for filling the array as well. 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 | 7 +++ OvmfPkg/VirtioFsDxe/Helpers.c | 61 ++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h b/OvmfPkg/VirtioFsDxe/Virtio= FsDxe.h index 029c568b39c7..d1b746c0d8cf 100644 --- a/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h +++ b/OvmfPkg/VirtioFsDxe/VirtioFsDxe.h @@ -229,16 +229,23 @@ VirtioFsAppendPath ( EFI_STATUS VirtioFsLookupMostSpecificParentDir ( IN OUT VIRTIO_FS *VirtioFs, IN OUT CHAR8 *Path, OUT UINT64 *DirNodeId, OUT CHAR8 **LastComponent ); =20 +EFI_STATUS +VirtioFsGetBasename ( + IN CHAR8 *Path, + OUT CHAR16 *Basename OPTIONAL, + IN OUT UINTN *BasenameSize + ); + EFI_STATUS VirtioFsFuseAttrToEfiFileInfo ( IN VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr, OUT EFI_FILE_INFO *FileInfo ); =20 // // Wrapper functions for FUSE commands (primitives). diff --git a/OvmfPkg/VirtioFsDxe/Helpers.c b/OvmfPkg/VirtioFsDxe/Helpers.c index 6adc0341dee6..77f718e91233 100644 --- a/OvmfPkg/VirtioFsDxe/Helpers.c +++ b/OvmfPkg/VirtioFsDxe/Helpers.c @@ -1717,16 +1717,77 @@ VirtioFsLookupMostSpecificParentDir ( *LastComponent =3D Slash + 1; return EFI_SUCCESS; =20 ForgetNextDirNodeId: VirtioFsFuseForget (VirtioFs, NextDirNodeId); return Status; } =20 +/** + Format the last component of a canonical pathname into a caller-provided + CHAR16 array. + + @param[in] Path The canonical pathname (as defined in the + description of VirtioFsAppendPath()) to for= mat + the last component of. + + @param[out] Basename If BasenameSize is zero on input, Basename = may + be NULL. Otherwise, Basename is allocated b= y the + caller. On successful return, Basename cont= ains + the last component of Path, formatted as a + NUL-terminated CHAR16 string. When Path is = "/" + on input, Basename is L"" on output. + + @param[in,out] BasenameSize On input, the number of bytes the caller + provides in Basename. On output, regardless= of + return value, the number of bytes required = for + formatting Basename, including the terminat= ing + L'\0'. + + @retval EFI_SUCCESS Basename has been filled in. + + @retval EFI_BUFFER_TOO_SMALL BasenameSize was too small on input; Basen= ame + has not been modified. +**/ +EFI_STATUS +VirtioFsGetBasename ( + IN CHAR8 *Path, + OUT CHAR16 *Basename OPTIONAL, + IN OUT UINTN *BasenameSize + ) +{ + UINTN AllocSize; + UINTN LastComponent; + UINTN Idx; + UINTN PathSize; + + AllocSize =3D *BasenameSize; + + LastComponent =3D MAX_UINTN; + for (Idx =3D 0; Path[Idx] !=3D '\0'; Idx++) { + if (Path[Idx] =3D=3D '/') { + LastComponent =3D Idx; + } + } + PathSize =3D Idx + 1; + ASSERT (LastComponent < MAX_UINTN); + LastComponent++; + *BasenameSize =3D (PathSize - LastComponent) * sizeof Basename[0]; + + if (*BasenameSize > AllocSize) { + return EFI_BUFFER_TOO_SMALL; + } + + for (Idx =3D LastComponent; Idx < PathSize; Idx++) { + Basename[Idx - LastComponent] =3D Path[Idx]; + } + return EFI_SUCCESS; +} + /** Convert select fields of a VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE object to corresponding fields in EFI_FILE_INFO. =20 @param[in] FuseAttr The VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE object to convert the relevant fields from. =20 @param[out] FileInfo The EFI_FILE_INFO structure to modify. Importantly= , the --=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 (#69043): https://edk2.groups.io/g/devel/message/69043 Mute This Topic: https://groups.io/mt/79023796/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-