From nobody Mon Feb 9 16:51:03 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+69062+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+69062+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608159164; cv=none; d=zohomail.com; s=zohoarc; b=Ik14TqT+zeui44XK+xv9UpPPeSm+Q3WO08vN/YQAAtBazBQwTgiOJU1cdYmT/xEkFMXrrdhhei3wFsV3Ai9Y0i9Kg/RYd1dO83oQSEsJgz3nOir8u01VieQ1CpfdavarTuAX3VCOofAHVQvLdKsQ35Ykqntjrpz3/6k+X/fBdcw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608159164; 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=DN+EicQ4UnBuyCCaCYTkXWFvaK+vrMcB7QkCeV1zWSk=; b=GJJEX6RD22bnTISpI66R//I6YGM+9y6r7XPO79FUs5qI6tbv7lqo9kdesxe+1Mw7yaTAwzH6UYkL0wycoPE9NzUIiCJTDdFpnzokR7rsu2oki0+bUYtq/2HpNbWamQDYwGs6DqFKVnuEGKG0yKmqzihpXZBkjSDqB78YELnIZbg= 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+69062+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 1608159164754454.67284188451424; Wed, 16 Dec 2020 14:52:44 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id uOwxYY1788612xQfsF8GKELn; Wed, 16 Dec 2020 14:52: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.web11.5217.1608159158748979519 for ; Wed, 16 Dec 2020 14:52:38 -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-507-gaaCmfP_OZaP6ab-p8ixZA-1; Wed, 16 Dec 2020 17:52:34 -0500 X-MC-Unique: gaaCmfP_OZaP6ab-p8ixZA-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 193AB107ACE4; Wed, 16 Dec 2020 22:52:33 +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 433AD10013C0; Wed, 16 Dec 2020 22:52:28 +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 48/48] OvmfPkg/VirtioFsDxe: handle attribute updates in EFI_FILE_PROTOCOL.SetInfo Date: Wed, 16 Dec 2020 22:11:25 +0100 Message-Id: <20201216211125.19496-49-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.22 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: jBVzfzsYhxw6PdnE91ZiTXqex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1608159164; bh=DN+EicQ4UnBuyCCaCYTkXWFvaK+vrMcB7QkCeV1zWSk=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=dxX9y4pPaKZNQea7WjVj92bks7vbYX0sGnmCADWdeihN09NMGlvsg1kdtsGRrjkFEMX C7LmmrK/h8SrRT+tpfFotLR4eGXZRSXRF6oXfoFENT9082f8S5LH22LlexDp2UqOH9IKD h2/GzuzVWBC8OsTd6NCyWu7W+tkVRsxAb+w= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Using the functions introduced previously, we can now update file attributes in VirtioFsSimpleFileSetInfo(). 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/SimpleFsSetInfo.c | 107 +++++++++++++++++++- 1 file changed, 106 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/VirtioFsDxe/SimpleFsSetInfo.c b/OvmfPkg/VirtioFsDxe/Si= mpleFsSetInfo.c index 55169dde78b7..e7cc3d5dc399 100644 --- a/OvmfPkg/VirtioFsDxe/SimpleFsSetInfo.c +++ b/OvmfPkg/VirtioFsDxe/SimpleFsSetInfo.c @@ -303,16 +303,121 @@ Rename ( =20 FreeDestination: if (Destination !=3D NULL) { FreePool (Destination); } return Status; } =20 +/** + Update the attributes of a VIRTIO_FS_FILE as requested in EFI_FILE_INFO. + + @param[in,out] VirtioFsFile The VIRTIO_FS_FILE to update the attributes= of. + + @param[in] NewFileInfo The new attributes requested by + EFI_FILE_PROTOCOL.SetInfo(). NewFileInfo->S= ize + and NewFileInfo->FileName are ignored. + + @retval EFI_SUCCESS No attributes had to be updated. + + @retval EFI_SUCCESS The required set of attribute updates has been + determined and performed successfully. + + @retval EFI_ACCESS_DENIED NewFileInfo requests an update to a property + different from the EFI_FILE_READ_ONLY bit in = the + Attribute field, but VirtioFsFile is not open= for + writing. + + @return Error codes propagated from underlying functi= ons. +**/ +STATIC +EFI_STATUS +UpdateAttributes ( + IN OUT VIRTIO_FS_FILE *VirtioFsFile, + IN EFI_FILE_INFO *NewFileInfo + ) +{ + VIRTIO_FS *VirtioFs; + EFI_STATUS Status; + VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE FuseAttr; + EFI_FILE_INFO FileInfo; + BOOLEAN UpdateFileSize; + UINT64 FileSize; + BOOLEAN UpdateAtime; + BOOLEAN UpdateMtime; + UINT64 Atime; + UINT64 Mtime; + BOOLEAN UpdateMode; + UINT32 Mode; + + VirtioFs =3D VirtioFsFile->OwnerFs; + + // + // Fetch the current attributes first, so we can build the difference be= tween + // them and NewFileInfo. + // + Status =3D VirtioFsFuseGetAttr (VirtioFs, VirtioFsFile->NodeId, &FuseAtt= r); + if (EFI_ERROR (Status)) { + return Status; + } + Status =3D VirtioFsFuseAttrToEfiFileInfo (&FuseAttr, &FileInfo); + if (EFI_ERROR (Status)) { + return Status; + } + // + // Collect the updates. + // + if (VirtioFsFile->IsDirectory) { + UpdateFileSize =3D FALSE; + } else { + VirtioFsGetFuseSizeUpdate (&FileInfo, NewFileInfo, &UpdateFileSize, + &FileSize); + } + + Status =3D VirtioFsGetFuseTimeUpdates (&FileInfo, NewFileInfo, &UpdateAt= ime, + &UpdateMtime, &Atime, &Mtime); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D VirtioFsGetFuseModeUpdate (&FileInfo, NewFileInfo, &UpdateMod= e, + &Mode); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // If no attribute updates are necessary, we're done. + // + if (!UpdateFileSize && !UpdateAtime && !UpdateMtime && !UpdateMode) { + return EFI_SUCCESS; + } + // + // If the file is not open for writing, then only Mode may be updated (f= or + // toggling EFI_FILE_READ_ONLY). + // + if (!VirtioFsFile->IsOpenForWriting && + (UpdateFileSize || UpdateAtime || UpdateMtime)) { + return EFI_ACCESS_DENIED; + } + // + // Send the FUSE_SETATTR request now. + // + Status =3D VirtioFsFuseSetAttr ( + VirtioFs, + VirtioFsFile->NodeId, + UpdateFileSize ? &FileSize : NULL, + UpdateAtime ? &Atime : NULL, + UpdateMtime ? &Mtime : NULL, + UpdateMode ? &Mode : NULL + ); + return Status; +} + /** Process an EFI_FILE_INFO setting request. **/ STATIC EFI_STATUS SetFileInfo ( IN EFI_FILE_PROTOCOL *This, IN UINTN BufferSize, @@ -345,17 +450,17 @@ SetFileInfo ( // Status =3D Rename (VirtioFsFile, FileInfo->FileName); if (EFI_ERROR (Status)) { return Status; } // // Update any attributes requested. // - Status =3D EFI_UNSUPPORTED; + Status =3D UpdateAttributes (VirtioFsFile, FileInfo); // // The UEFI spec does not speak about partial failure in // EFI_FILE_PROTOCOL.SetInfo(); we won't try to roll back the rename (if // there was one) in case the attribute updates fail. // return Status; } =20 --=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 (#69062): https://edk2.groups.io/g/devel/message/69062 Mute This Topic: https://groups.io/mt/79024765/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-