From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mx.groups.io with SMTP id smtpd.web08.11574.1629557302664911308 for ; Sat, 21 Aug 2021 07:48:23 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XsmspA34; spf=pass (domain: gmail.com, ip: 209.85.221.49, mailfrom: pedro.falcato@gmail.com) Received: by mail-wr1-f49.google.com with SMTP id r7so18669211wrs.0 for ; Sat, 21 Aug 2021 07:48:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4BHFTA06gB07AMflPWqjsdoErTIT/tO4a7YHMb8wGkc=; b=XsmspA34Xjiv+QbfdqmvnFIfdjTVawNRNfbHxK84d3t0UrdR+Wq6AaRlwYk1X76rh0 TmEuNyHN/Bv0G+l4WJyoh8aC2bdtoRKxOEREaKwL2KP0FSEgS7zuKg+qL6LecaWJ44oY fIw71hQHb9K4J3XLsGtL9xOKfgRG+9FE5A26yLcBvIq61IEOfg3vRm7R/vfbEHjqsA+n 1i7MLlagUPaiwunOlGoAFk+VUPYuqulGS1kMzwr0o0kmjGfrsLIaz24IEItcmf6Taihf ungUY95w/AGIOOMoAxLoPIqzJZlHAvqMPGvnd8KQzkTpBktzPlFJJhNcoLaxIp5Qp8PT P8gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4BHFTA06gB07AMflPWqjsdoErTIT/tO4a7YHMb8wGkc=; b=A9eREJogjpDhAHhara0itZ9HYPPEP3N7uPHfJIbM7mVBqyY6pmpBKmxXgzV1sEhVeo lkcZIz1ssRldRl0Qdcv2cxOhxy9ZeSOKMMea/y0YAe6ltGrQUM+OifqkeN+jJvKRNsho H7T/9TM0AkhqNWcdy1qF7uOF+I8Q+W30AOpVMH0BvMOqPKj7RJVLVPWv2adRh4nr8orJ 81CnET8J7SuuCbPdO1zVMPfoSFO60Xo+o74Eg2aShqsDGz7t4cwH4C4j6nuF9YsMxRSC s0YmE84D/yoeEj8LMEh6KlEnki7eUiGCvBvXmKoGml1zTdgeIX9qXb8eze6yA+Xp82QF vPkQ== X-Gm-Message-State: AOAM532qlFzzt7OjDpQMeAEiX4UdxG0peOh/ibFlL5eshNGLkknkt7YF KEHU0gf2/gn/pMKi2DqM7MnW2ima8edjj23x X-Google-Smtp-Source: ABdhPJwRj3SDl8YAUKGiP71URGcbrhsios26tv7J+n6eewBRBtF4Qo1pg4ufgPdduQEdCHJveTfI3w== X-Received: by 2002:adf:f7cf:: with SMTP id a15mr4341863wrq.53.1629557301057; Sat, 21 Aug 2021 07:48:21 -0700 (PDT) Return-Path: Received: from PC-PEDRO.lan (bl8-253-151.dsl.telepac.pt. [85.241.253.151]) by smtp.gmail.com with ESMTPSA id j17sm9118036wrt.69.2021.08.21.07.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 07:48:20 -0700 (PDT) From: "Pedro Falcato" To: devel@edk2.groups.io Cc: Pedro Falcato , Leif Lindholm , Michael D Kinney , Bret Barkelew Subject: [edk2-platforms PATCH v2 4/5] Ext4Pkg: Add handling of EFI_FILE_SYSTEM_VOLUME_LABEL GetInfo(). Date: Sat, 21 Aug 2021 15:47:09 +0100 Message-Id: <20210821144711.39546-5-pedro.falcato@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210821144711.39546-1-pedro.falcato@gmail.com> References: <20210821144711.39546-1-pedro.falcato@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable This commit adds support for EFI_FILE_SYSTEM_VOLUME_LABEL requests in GetInfo(). Cc: Leif Lindholm Cc: Michael D Kinney Cc: Bret Barkelew Signed-off-by: Pedro Falcato --- Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c | 1 - Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 17 ++++ Features/Ext4Pkg/Ext4Dxe/File.c | 155 ++++++++++++++++++++++------- 3 files changed, 138 insertions(+), 35 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.c index 71360ea894d2..ea2e048d7762 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c @@ -6,7 +6,6 @@ **/=0D =0D #include "Ext4Dxe.h"=0D -#include "Uefi/UefiBaseType.h"=0D =0D GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mExt4DriverNameTab= le[] =3D {=0D {=0D diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.h index db938c25244d..64eab455db4a 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h @@ -1100,4 +1100,21 @@ Ext4CalculateBlockGroupDescChecksum ( #define EXT4_HAS_GDT_CSUM(Partition) \=0D EXT4_HAS_RO_COMPAT (Partition, EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)=0D =0D +/**=0D + Retrieves the volume name.=0D +=0D + @param[in] Part Pointer to the opened partition.=0D + @param[out] Info Pointer to a CHAR16*.=0D + @param[out] BufferSize Pointer to a UINTN, where the string len= gth=0D + of the name will be put.=0D +=0D + @return Status of the volume name request.=0D +**/=0D +EFI_STATUS=0D +Ext4GetVolumeName (=0D + IN EXT4_PARTITION *Partition,=0D + OUT CHAR16 **OutVolName,=0D + OUT UINTN *VolNameLen=0D + );=0D +=0D #endif=0D diff --git a/Features/Ext4Pkg/Ext4Dxe/File.c b/Features/Ext4Pkg/Ext4Dxe/Fil= e.c index 021d10b1edfb..4ad7cad8dcf5 100644 --- a/Features/Ext4Pkg/Ext4Dxe/File.c +++ b/Features/Ext4Pkg/Ext4Dxe/File.c @@ -35,7 +35,9 @@ Ext4DuplicateFile ( STATIC=0D EFI_STATUS=0D GetPathSegment (=0D - IN CONST CHAR16 *Path, OUT CHAR16 *PathSegment, OUT UINTN *Length=0D + IN CONST CHAR16 *Path,=0D + OUT CHAR16 *PathSegment,=0D + OUT UINTN *Length=0D )=0D {=0D CONST CHAR16 *Start;=0D @@ -514,7 +516,9 @@ Ext4SetPosition ( **/=0D EFI_STATUS=0D Ext4GetFileInfo (=0D - IN EXT4_FILE *File, OUT EFI_FILE_INFO *Info, IN OUT UINTN *BufferSize=0D + IN EXT4_FILE *File,=0D + OUT EFI_FILE_INFO *Info,=0D + IN OUT UINTN *BufferSize=0D )=0D {=0D UINTN FileNameLen;=0D @@ -557,35 +561,33 @@ Ext4GetFileInfo ( }=0D =0D /**=0D - Retrieves information about the filesystem and stores it in the EFI_FIL= E_SYSTEM_INFO format.=0D + Retrieves the volume name.=0D =0D @param[in] Part Pointer to the opened partition.=0D - @param[out] Info Pointer to a EFI_FILE_SYSTEM_INFO.=0D - @param[in out] BufferSize Pointer to the buffer size=0D + @param[out] Info Pointer to a CHAR16*.=0D + @param[out] BufferSize Pointer to a UINTN, where the string len= gth=0D + of the name will be put.=0D =0D - @return Status of the file information request.=0D + @return Status of the volume name request.=0D **/=0D -STATIC=0D EFI_STATUS=0D -Ext4GetFilesystemInfo (=0D - IN EXT4_PARTITION *Part, OUT EFI_FILE_SYSTEM_INFO *Info, IN OUT UINTN *B= ufferSize=0D +Ext4GetVolumeName (=0D + IN EXT4_PARTITION *Partition,=0D + OUT CHAR16 **OutVolName,=0D + OUT UINTN *VolNameLen=0D )=0D {=0D - // Length of s_volume_name + null terminator=0D - CHAR8 TempVolName[16 + 1];=0D - CHAR16 *VolumeName;=0D - UINTN VolNameLength;=0D - EFI_STATUS Status;=0D - UINTN NeededLength;=0D - EXT4_BLOCK_NR TotalBlocks;=0D - EXT4_BLOCK_NR FreeBlocks;=0D + CHAR8 TempVolName[16 + 1];=0D + CHAR16 *VolumeName;=0D + UINTN VolNameLength;=0D + EFI_STATUS Status;=0D =0D VolNameLength =3D 0;=0D VolumeName =3D NULL;=0D =0D // s_volume_name is only valid on dynamic revision; old filesystems don'= t support this=0D - if (Part->SuperBlock.s_rev_level =3D=3D EXT4_DYNAMIC_REV) {=0D - CopyMem (TempVolName, (CONST CHAR8 *)Part->SuperBlock.s_volume_name, 1= 6);=0D + if (Partition->SuperBlock.s_rev_level =3D=3D EXT4_DYNAMIC_REV) {=0D + CopyMem (TempVolName, (CONST CHAR8 *)Partition->SuperBlock.s_volume_na= me, 16);=0D TempVolName[16] =3D '\0';=0D =0D Status =3D UTF8StrToUCS2 (TempVolName, &VolumeName);=0D @@ -595,23 +597,56 @@ Ext4GetFilesystemInfo ( }=0D =0D VolNameLength =3D StrLen (VolumeName);=0D + } else {=0D + VolumeName =3D AllocateZeroPool (sizeof (CHAR16));=0D + VolNameLength =3D 0;=0D + }=0D +=0D + *OutVolName =3D VolumeName;=0D + *VolNameLen =3D VolNameLength;=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Retrieves information about the filesystem and stores it in the EFI_FIL= E_SYSTEM_INFO format.=0D +=0D + @param[in] Part Pointer to the opened partition.=0D + @param[out] Info Pointer to a EFI_FILE_SYSTEM_INFO.=0D + @param[in out] BufferSize Pointer to the buffer size=0D +=0D + @return Status of the file information request.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +Ext4GetFilesystemInfo (=0D + IN EXT4_PARTITION *Part,=0D + OUT EFI_FILE_SYSTEM_INFO *Info,=0D + IN OUT UINTN *BufferSize=0D + )=0D +{=0D + // Length of s_volume_name + null terminator=0D + EFI_STATUS Status;=0D + UINTN NeededLength;=0D + EXT4_BLOCK_NR TotalBlocks;=0D + EXT4_BLOCK_NR FreeBlocks;=0D + CHAR16 *VolumeName;=0D + UINTN VolNameLength;=0D +=0D + Status =3D Ext4GetVolumeName (Part, &VolumeName, &VolNameLength);=0D +=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D }=0D =0D NeededLength =3D SIZE_OF_EFI_FILE_SYSTEM_INFO;=0D =0D - if (VolumeName !=3D NULL) {=0D - NeededLength +=3D StrSize (VolumeName);=0D - } else {=0D - // If we don't have a volume name, we set VolumeLabel to a single null= terminator=0D - NeededLength +=3D sizeof (CHAR16);=0D - }=0D + NeededLength +=3D StrSize (VolumeName);=0D =0D if (*BufferSize < NeededLength) {=0D *BufferSize =3D NeededLength;=0D =0D - if (VolumeName !=3D NULL) {=0D - FreePool (VolumeName);=0D - }=0D + FreePool (VolumeName);=0D =0D return EFI_BUFFER_TOO_SMALL;=0D }=0D @@ -630,16 +665,60 @@ Ext4GetFilesystemInfo ( Info->VolumeSize =3D MultU64x32 (TotalBlocks, Part->BlockSize);=0D Info->FreeSpace =3D MultU64x32 (FreeBlocks, Part->BlockSize);=0D =0D - if (VolumeName !=3D NULL) {=0D - StrCpyS (Info->VolumeLabel, VolNameLength + 1, VolumeName);=0D - } else {=0D - Info->VolumeLabel[0] =3D L'\0';=0D + StrCpyS (Info->VolumeLabel, VolNameLength + 1, VolumeName);=0D +=0D + FreePool (VolumeName);=0D +=0D + *BufferSize =3D NeededLength;=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Retrieves the volume label and stores it in the EFI_FILE_SYSTEM_VOLUME_= LABEL format.=0D +=0D + @param[in] Part Pointer to the opened partition.=0D + @param[out] Info Pointer to a EFI_FILE_SYSTEM_VOLUME_LABE= L.=0D + @param[in out] BufferSize Pointer to the buffer size=0D +=0D + @return Status of the file information request.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +Ext4GetVolumeLabelInfo (=0D + IN EXT4_PARTITION *Part,=0D + OUT EFI_FILE_SYSTEM_VOLUME_LABEL *Info,=0D + IN OUT UINTN *BufferSize=0D + )=0D +{=0D + // Length of s_volume_name + null terminator=0D + CHAR16 *VolumeName;=0D + UINTN VolNameLength;=0D + EFI_STATUS Status;=0D + UINTN NeededLength;=0D +=0D + Status =3D Ext4GetVolumeName (Part, &VolumeName, &VolNameLength);=0D +=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D }=0D =0D - if (VolumeName !=3D NULL) {=0D + NeededLength =3D (VolNameLength + 1) * sizeof (CHAR16);=0D +=0D + if (NeededLength > *BufferSize) {=0D + *BufferSize =3D NeededLength;=0D +=0D FreePool (VolumeName);=0D +=0D + return EFI_BUFFER_TOO_SMALL;=0D }=0D =0D + Status =3D StrCpyS (Info->VolumeLabel, VolNameLength + 1, VolumeName);=0D +=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + FreePool (VolumeName);=0D +=0D *BufferSize =3D NeededLength;=0D =0D return EFI_SUCCESS;=0D @@ -674,12 +753,20 @@ Ext4GetInfo ( OUT VOID *Buffer=0D )=0D {=0D + EXT4_PARTITION *Partition;=0D +=0D + Partition =3D ((EXT4_FILE *)This)->Partition;=0D +=0D if (CompareGuid (InformationType, &gEfiFileInfoGuid)) {=0D return Ext4GetFileInfo ((EXT4_FILE *)This, Buffer, BufferSize);=0D }=0D =0D if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {=0D - return Ext4GetFilesystemInfo (((EXT4_FILE *)This)->Partition, Buffer, = BufferSize);=0D + return Ext4GetFilesystemInfo (Partition, Buffer, BufferSize);=0D + }=0D +=0D + if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid))= {=0D + return Ext4GetVolumeLabelInfo (Partition, Buffer, BufferSize);=0D }=0D =0D return EFI_UNSUPPORTED;=0D --=20 2.33.0