From nobody Mon Feb 9 14:33:35 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+98326+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+98326+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1673481570; cv=none; d=zohomail.com; s=zohoarc; b=Rfmv2/nnZEVPSpmYjBOk51iGf1Kif7BiQCALt0Zd5HlAvaUXQTAMf5wDMi9P5VSu2Th7aDKfCoEKWjoM59mSN9Ll5THIUwIPugE/CaOiKnQpIEI12Jwum9AccvOdll31n1eG8eL6ZOkZ5E2/qghf+Ztrr5DE2ed82ZPHGYGXxQA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673481570; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=qvnLAX/WyoBJnHZ48mgXWhH7zfycHU/RrSIKlo9/HsM=; b=MoAiH3SqFd1KEjDeG5oal8WdiJmeOUifdUo+KFAXaQJXhn2GI1cx9HFNrJFh7dNTAoxfZJ8Fj51PhvgsE42KEgG53vIW1Ki75vB2jllfM1m7QswoGm88S/A5BA5i+WMuxJ3EfXU9spDuLX0NKQNg2h+edKPyztJ6qv+LEYHV3X4= 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+98326+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1673481570332575.127019626558; Wed, 11 Jan 2023 15:59:30 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id EjI4YY1788612xE32KOBrixC; Wed, 11 Jan 2023 15:59:30 -0800 X-Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by mx.groups.io with SMTP id smtpd.web11.41667.1673481569361860548 for ; Wed, 11 Jan 2023 15:59:29 -0800 X-Received: by mail-wm1-f51.google.com with SMTP id g19-20020a05600c4ed300b003d9eb1dbc0aso10893886wmq.3 for ; Wed, 11 Jan 2023 15:59:29 -0800 (PST) X-Gm-Message-State: UTKbBmTLbTtms46xJw7OFfWRx1787277AA= X-Google-Smtp-Source: AMrXdXtY8+rhhpHHJk6Sr74OdSQK2Aabdea2qpyfmfgJ3bvKsCFo3R4PRFpxVbiA98CBDn23TRU2+Q== X-Received: by 2002:a05:600c:3ca2:b0:3d9:da3a:ef9b with SMTP id bg34-20020a05600c3ca200b003d9da3aef9bmr16376934wmb.31.1673481567506; Wed, 11 Jan 2023 15:59:27 -0800 (PST) X-Received: from PC-PEDRO-ARCH.lan ([2001:8a0:7280:5801:9441:3dce:686c:bfc7]) by smtp.gmail.com with ESMTPSA id p21-20020a7bcc95000000b003c65c9a36dfsm19276102wma.48.2023.01.11.15.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 15:59:27 -0800 (PST) From: "Pedro Falcato" To: devel@edk2.groups.io Cc: Pedro Falcato , =?UTF-8?q?Marvin=20H=C3=A4user?= Subject: [edk2-devel] [PATCH 2/3] Ext4Pkg: Add documentation surrounding ext4 directory entries Date: Wed, 11 Jan 2023 23:59:18 +0000 Message-Id: <20230111235920.252317-4-pedro.falcato@gmail.com> In-Reply-To: <20230111235920.252317-1-pedro.falcato@gmail.com> References: <20230111235920.252317-1-pedro.falcato@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,pedro.falcato@gmail.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1673481570; bh=KBplvUT6ibL/cGu7jeKJj1zF+6lo8kBWImB8iDRQiI8=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=ASsF+mwL1w98zDm6T81OkBIwQINUNn67Q4Atmc12Fhe13uwEAYlS6xlLKnFUItpo5we T77GlfseM9Kx0qc+7KENXE7HvXl2uoeS6gPFTlLJUWEAs2Dlt8zYZNMpNsTBJw21gms9b Ejs8m9vZ7v5mhUgAoEHn4pxOpPKkF0wFwtU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1673481571811100011 Several questions have popped up regarding the ext4 directory entry layout and contents off-list. Attempt to clarify these issues by adding some explanatory comments. Signed-off-by: Pedro Falcato Cc: Marvin H=C3=A4user Reviewed-by: Marvin H=C3=A4user > --- Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h | 21 +++++++++++++++++++-- Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 5 ++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h b/Features/Ext4Pkg/Ext4Dxe= /Ext4Disk.h index 4fd91a423324..d0a455d0e572 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h @@ -1,7 +1,7 @@ /** @file Raw filesystem data structures =20 - Copyright (c) 2021 Pedro Falcato All rights reserved. + Copyright (c) 2021 - 2023 Pedro Falcato All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent =20 Layout of an EXT2/3/4 filesystem: @@ -397,12 +397,29 @@ typedef struct _Ext4Inode { UINT32 i_projid; } EXT4_INODE; =20 +#define EXT4_NAME_MAX 255 + typedef struct { + // offset 0x0: inode number (if 0, unused entry, should skip.) UINT32 inode; + // offset 0x4: Directory entry's length. + // Note: rec_len >=3D name_len + EXT4_MIN_DIR_ENTRY_LEN and = rec_len % 4 =3D=3D 0. UINT16 rec_len; + // offset 0x6: Directory entry's name's length UINT8 name_len; + // offset 0x7: Directory entry's file type indicator UINT8 file_type; - CHAR8 name[255]; + // offset 0x8: name[name_len]: Variable length character array; not null= -terminated. + CHAR8 name[EXT4_NAME_MAX]; + // Further notes on names: + // 1) We use EXT4_NAME_MAX here instead of flexible arrays for ease of u= se around the driver. + // + // 2) ext4 directories are defined, as the documentation puts it, as: + // "a directory is more or less a flat file that maps an arbitrary byte = string + // (usually ASCII) to an inode number on the filesystem". So, they are n= ot + // necessarily encoded with ASCII, UTF-8, or any of the sort. We must tr= eat it + // as a bag of bytes. When interacting with EFI interfaces themselves (w= hich expect UCS-2) + // we skip any directory entry that is not valid UTF-8. } EXT4_DIR_ENTRY; =20 #define EXT4_MIN_DIR_ENTRY_LEN 8 diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.h index adf3c13f6ea9..466e49523030 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h @@ -1,7 +1,7 @@ /** @file Common header for the driver =20 - Copyright (c) 2021 - 2022 Pedro Falcato All rights reserved. + Copyright (c) 2021 - 2023 Pedro Falcato All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 @@ -31,8 +31,7 @@ =20 #include "Ext4Disk.h" =20 -#define SYMLOOP_MAX 8 -#define EXT4_NAME_MAX 255 +#define SYMLOOP_MAX 8 // // We need to specify path length limit for security purposes, to prevent = possible // overflows and dead-loop conditions. Originally this limit is absent in = FS design, --=20 2.39.0 -=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 (#98326): https://edk2.groups.io/g/devel/message/98326 Mute This Topic: https://groups.io/mt/96212633/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-