From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by mx.groups.io with SMTP id smtpd.web10.40929.1673480087604867790 for ; Wed, 11 Jan 2023 15:34:48 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.de header.s=2017 header.b=kGzd4YD8; spf=pass (domain: posteo.de, ip: 185.67.36.65, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 21E7B24002B for ; Thu, 12 Jan 2023 00:34:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1673480085; bh=FRS+GPRCUulccsz5sbP7tK1+4jW3BxnC0CLv8Vt40PU=; h=From:Subject:Date:Cc:To:From; b=kGzd4YD8HVS5S82BLlQtArBIcAE46pREzn0QpcPzUnwB205ARbQCAxo9S1PDmpBCX 1ECUjb3iwF/ylas6YlS2L/x44u5+EpC2cGnL4jjk2LrJ9/zQwnIZ0Y1vrbJfm6POoh R/MLY6zmviWPSnG9rCAAuYZegkuLXn1yNt452KSUFTsMgGf1U8ApkupyD9QQIw/vQY YCsbNMxu3etO49Z0uGzEPRzJejqFX5bv8zLFGP4Q2Cdo//4bLbsRihBLzKXHtxPsud 5HT1EWhH66cGfR+/e0FTUrtAdiu6jkikzFHBwm5vVguUzz7p+KOlwIDJA4ztNJZsYY r6JP1q/E7QBAQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4NskYJ25X9z6tm4; Thu, 12 Jan 2023 00:34:44 +0100 (CET) From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= Mime-Version: 1.0 (1.0) Subject: Re: [PATCH 1/1] Ext4Pkg: Add documentation surrounding ext4 directory entries Date: Wed, 11 Jan 2023 23:34:43 +0000 Message-Id: <6B939CBC-0E8F-4BBD-98EE-051C88DEF238@posteo.de> References: <20230111232131.244584-1-pedro.falcato@gmail.com> Cc: devel@edk2.groups.io In-Reply-To: <20230111232131.244584-1-pedro.falcato@gmail.com> To: Pedro Falcato Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > On 12. Jan 2023, at 00:21, Pedro Falcato wrote: >=20 > =EF=BB=BFSeveral questions have popped up regarding the ext4 directory ent= ry > layout and contents off-list. Attempt to clarify these issues by adding > some explanatory comments. >=20 > Signed-off-by: Pedro Falcato > Cc: Marvin H=C3=A4user > --- > Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h | 18 +++++++++++++++++- > Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 3 +-- > 2 files changed, 18 insertions(+), 3 deletions(-) >=20 > diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h b/Features/Ext4Pkg/Ext4Dx= e/Ext4Disk.h > index 4fd91a423324..2dad967e575d 100644 > --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h > +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h > @@ -397,12 +397,28 @@ typedef struct _Ext4Inode { > UINT32 i_projid; > } EXT4_INODE; >=20 > +#define EXT4_NAME_MAX 255 > + > typedef struct { > + // ext4 directory entries are layed out in the laid out > following fashion: > + // offset 0x0: UINT32 inode number (if 0, unused entry, should skip.) > + // offset 0x4: UINT16 rec_len: Dir entry's length. > + // Note: rec_len >=3D name_len + EXT4_MIN_DIR_ENTRY_LEN and= rec_len % 4 =3D=3D 0. > + // offset 0x6: UINT8 name_len: Dir entry's name's length > + // offset 0x7: UINT8 file_type Dir entry's file type indicator > + // offset 0x8: CHAR8 name[name_len]: Variable length character array; n= ot null-terminated. Why not document all that right above the member names? Would remove redunda= nt info and be more Doxygen-friendly. > + // > + // Further note: ext4 directories are defined, as the documentation put= s 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 t= reat it > + // as a bag of bytes. When interacting with EFI interfaces themselves (= which expect UCS-2) > + // we skip any directory entry that is not valid UTF-8. > UINT32 inode; > UINT16 rec_len; > UINT8 name_len; > UINT8 file_type; > - CHAR8 name[255]; > + CHAR8 name[EXT4_NAME_MAX]; > } 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..81ba568c5947 100644 > --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h > +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h > @@ -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 p= ossible > // overflows and dead-loop conditions. Originally this limit is absent in = FS design, > --=20 > 2.39.0 >=20