From nobody Fri May 17 05:54:40 2024 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+88556+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+88556+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1649368912; cv=none; d=zohomail.com; s=zohoarc; b=brd9JmYpPDP8wZx3MHwRCUObBAHZxI0vgrWdxYl+hvljHWzUqUwf5OJD8x9c8ERQTQaMONKFyhU6BCy5fFCNyXqj/Bd6amlKTcdl4cNUDNdqqZzqSK+tIucSRV+fLnbGqMO1vw+2GAtPH89F5dAw3uXYSk+pPgEME1Sx129KOb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649368912; h=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=av/bWoom97HqrZzH89HYUH+b7v4FD13UKA2BwPaH+nA=; b=Y6nO1NXxeTtPsyvjivgjFASHIOyHYrBn5/P195bQm8M5F9jlRbu+/iXilzjzeddqk3woocYE+KDExkTrvL3XCrZ+BoeYVUSCUAuyqPH2zpxhW2rZGRDOuZRQ3zy63K2tvdVfUUdLJnrl4/UrnfXRsMSIHJFNxh47JYMsXcEXNWg= 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+88556+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 164936891290655.198064385880116; Thu, 7 Apr 2022 15:01:52 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id apUPYY1788612xPXklj2pFnS; Thu, 07 Apr 2022 15:01:52 -0700 X-Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mx.groups.io with SMTP id smtpd.web10.462.1649368911308016071 for ; Thu, 07 Apr 2022 15:01:51 -0700 X-Received: by mail-wr1-f51.google.com with SMTP id k23so9965216wrd.8 for ; Thu, 07 Apr 2022 15:01:51 -0700 (PDT) X-Gm-Message-State: 44iMzd5OIy8osJJ6pq4tUtzKx1787277AA= X-Google-Smtp-Source: ABdhPJzvJvry6+mAVg5B+aTBoeSJFD3w0s05h8UghRwyhdJgNk7sJ3/OYJ6CJVu1rYbUQHKiugjEKQ== X-Received: by 2002:a05:600c:3b25:b0:38e:a249:d308 with SMTP id m37-20020a05600c3b2500b0038ea249d308mr206142wms.135.1649368909281; Thu, 07 Apr 2022 15:01:49 -0700 (PDT) X-Received: from PC-PEDRO-ARCH.lan ([2001:8a0:7280:5801:9441:3dce:686c:bfc7]) by smtp.gmail.com with ESMTPSA id m18-20020a05600c4f5200b0038e8f9d7b57sm2813379wmq.42.2022.04.07.15.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 15:01:48 -0700 (PDT) From: "Pedro Falcato" To: devel@edk2.groups.io Cc: Leif Lindholm , Michael D Kinney Subject: [edk2-devel] [PATCH edk2-platforms 1/3] Ext4Pkg: Replace the CRC implementations with BaseLib Date: Thu, 7 Apr 2022 23:01:44 +0100 Message-Id: <20220407220146.149580-2-pedro.falcato@gmail.com> In-Reply-To: <20220407220146.149580-1-pedro.falcato@gmail.com> References: <20220407220146.149580-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-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1649368912; bh=WzIsr15ljfjTUk4vBnyjYi9+5kfcxDSB4aETQLbnDSY=; h=Cc:Date:From:Reply-To:Subject:To; b=OMlI/cAdpGpceAiPaOqu68dgLzw17r3Udvt2zYbporkWCqDu1xww+6PgxkE6b6qQtXC j2a5mO+xXeojPqCy3cV/GWxFc96Up6AAcqFm5Ch/ZaSq2B43Ct5A7o7ZbtMJACi/Hl9WA M04PVtPWMCVgdVH1pAkP0LON0XLzWe9O7g4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1649368914243100005 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3871 Since the existing CRC16/CRC32c implementations have been/will be a part of BaseLib, use BaseLib and remove the Crc16.c/Crc32c.c. Cc: Leif Lindholm Cc: Michael D Kinney Signed-off-by: Pedro Falcato --- Features/Ext4Pkg/Ext4Dxe/BlockGroup.c | 10 ++-- Features/Ext4Pkg/Ext4Dxe/Crc16.c | 75 ------------------------ Features/Ext4Pkg/Ext4Dxe/Crc32c.c | 84 --------------------------- Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 34 +---------- Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf | 2 - 5 files changed, 6 insertions(+), 199 deletions(-) delete mode 100644 Features/Ext4Pkg/Ext4Dxe/Crc16.c delete mode 100644 Features/Ext4Pkg/Ext4Dxe/Crc32c.c diff --git a/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c b/Features/Ext4Pkg/Ext4D= xe/BlockGroup.c index abfeff52b139..9a1a41901f36 100644 --- a/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c +++ b/Features/Ext4Pkg/Ext4Dxe/BlockGroup.c @@ -168,12 +168,12 @@ Ext4CalculateBlockGroupDescChecksumGdtCsum ( =20 Dummy =3D 0; =20 - Csum =3D CalculateCrc16 (Partition->SuperBlock.s_uuid, 16, 0); - Csum =3D CalculateCrc16 (&BlockGroupNum, sizeof (BlockGroupNum), Csum); - Csum =3D CalculateCrc16 (BlockGroupDesc, OFFSET_OF (EXT4_BLOCK_GROUP_DES= C, bg_checksum), Csum); - Csum =3D CalculateCrc16 (&Dummy, sizeof (Dummy), Csum); + Csum =3D CalculateCrc16Ansi (Partition->SuperBlock.s_uuid, 16, 0); + Csum =3D CalculateCrc16Ansi (&BlockGroupNum, sizeof (BlockGroupNum), Csu= m); + Csum =3D CalculateCrc16Ansi (BlockGroupDesc, OFFSET_OF (EXT4_BLOCK_GROUP= _DESC, bg_checksum), Csum); + Csum =3D CalculateCrc16Ansi (&Dummy, sizeof (Dummy), Csum); Csum =3D - CalculateCrc16 ( + CalculateCrc16Ansi ( &BlockGroupDesc->bg_block_bitmap_hi, Partition->DescSize - OFFSET_OF (EXT4_BLOCK_GROUP_DESC, bg_block_bit= map_hi), Csum diff --git a/Features/Ext4Pkg/Ext4Dxe/Crc16.c b/Features/Ext4Pkg/Ext4Dxe/Cr= c16.c deleted file mode 100644 index 58d0220e4d30..000000000000 --- a/Features/Ext4Pkg/Ext4Dxe/Crc16.c +++ /dev/null @@ -1,75 +0,0 @@ -/** @file - CRC16 calculation routines. - - Copyright (c) 2021 Pedro Falcato All rights reserved. - - SPDX-License-Identifier: BSD-2-Clause-Patent -**/ - -#include - -STATIC CONST UINT16 gCrc16LookupTable[256] =3D -{ - 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, - 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, - 0x0919, 0x1890, 0x2a0b, 0x3b82, 0x4f3d, 0x5eb4, 0x6c2f, 0x7da6, - 0x8551, 0x94d8, 0xa643, 0xb7ca, 0xc375, 0xd2fc, 0xe067, 0xf1ee, - 0x1232, 0x03bb, 0x3120, 0x20a9, 0x5416, 0x459f, 0x7704, 0x668d, - 0x9e7a, 0x8ff3, 0xbd68, 0xace1, 0xd85e, 0xc9d7, 0xfb4c, 0xeac5, - 0x1b2b, 0x0aa2, 0x3839, 0x29b0, 0x5d0f, 0x4c86, 0x7e1d, 0x6f94, - 0x9763, 0x86ea, 0xb471, 0xa5f8, 0xd147, 0xc0ce, 0xf255, 0xe3dc, - 0x2464, 0x35ed, 0x0776, 0x16ff, 0x6240, 0x73c9, 0x4152, 0x50db, - 0xa82c, 0xb9a5, 0x8b3e, 0x9ab7, 0xee08, 0xff81, 0xcd1a, 0xdc93, - 0x2d7d, 0x3cf4, 0x0e6f, 0x1fe6, 0x6b59, 0x7ad0, 0x484b, 0x59c2, - 0xa135, 0xb0bc, 0x8227, 0x93ae, 0xe711, 0xf698, 0xc403, 0xd58a, - 0x3656, 0x27df, 0x1544, 0x04cd, 0x7072, 0x61fb, 0x5360, 0x42e9, - 0xba1e, 0xab97, 0x990c, 0x8885, 0xfc3a, 0xedb3, 0xdf28, 0xcea1, - 0x3f4f, 0x2ec6, 0x1c5d, 0x0dd4, 0x796b, 0x68e2, 0x5a79, 0x4bf0, - 0xb307, 0xa28e, 0x9015, 0x819c, 0xf523, 0xe4aa, 0xd631, 0xc7b8, - 0x48c8, 0x5941, 0x6bda, 0x7a53, 0x0eec, 0x1f65, 0x2dfe, 0x3c77, - 0xc480, 0xd509, 0xe792, 0xf61b, 0x82a4, 0x932d, 0xa1b6, 0xb03f, - 0x41d1, 0x5058, 0x62c3, 0x734a, 0x07f5, 0x167c, 0x24e7, 0x356e, - 0xcd99, 0xdc10, 0xee8b, 0xff02, 0x8bbd, 0x9a34, 0xa8af, 0xb926, - 0x5afa, 0x4b73, 0x79e8, 0x6861, 0x1cde, 0x0d57, 0x3fcc, 0x2e45, - 0xd6b2, 0xc73b, 0xf5a0, 0xe429, 0x9096, 0x811f, 0xb384, 0xa20d, - 0x53e3, 0x426a, 0x70f1, 0x6178, 0x15c7, 0x044e, 0x36d5, 0x275c, - 0xdfab, 0xce22, 0xfcb9, 0xed30, 0x998f, 0x8806, 0xba9d, 0xab14, - 0x6cac, 0x7d25, 0x4fbe, 0x5e37, 0x2a88, 0x3b01, 0x099a, 0x1813, - 0xe0e4, 0xf16d, 0xc3f6, 0xd27f, 0xa6c0, 0xb749, 0x85d2, 0x945b, - 0x65b5, 0x743c, 0x46a7, 0x572e, 0x2391, 0x3218, 0x0083, 0x110a, - 0xe9fd, 0xf874, 0xcaef, 0xdb66, 0xafd9, 0xbe50, 0x8ccb, 0x9d42, - 0x7e9e, 0x6f17, 0x5d8c, 0x4c05, 0x38ba, 0x2933, 0x1ba8, 0x0a21, - 0xf2d6, 0xe35f, 0xd1c4, 0xc04d, 0xb4f2, 0xa57b, 0x97e0, 0x8669, - 0x7787, 0x660e, 0x5495, 0x451c, 0x31a3, 0x202a, 0x12b1, 0x0338, - 0xfbcf, 0xea46, 0xd8dd, 0xc954, 0xbdeb, 0xac62, 0x9ef9, 0x8f70 -}; - -/** - Calculates the CRC16 checksum of the given buffer. - - @param[in] Buffer Pointer to the buffer. - @param[in] Length Length of the buffer, in bytes. - @param[in] InitialValue Initial value of the CRC. - - @return The CRC16 checksum. -**/ -UINT16 -CalculateCrc16 ( - IN CONST VOID *Buffer, - IN UINTN Length, - IN UINT16 InitialValue - ) -{ - CONST UINT8 *Buf; - UINT16 Crc; - - Buf =3D Buffer; - - Crc =3D ~InitialValue; - - while (Length-- !=3D 0) { - Crc =3D gCrc16LookupTable[(Crc & 0xFF) ^ *(Buf++)] ^ (Crc >> 8); - } - - return ~Crc; -} diff --git a/Features/Ext4Pkg/Ext4Dxe/Crc32c.c b/Features/Ext4Pkg/Ext4Dxe/C= rc32c.c deleted file mode 100644 index 9601316240d7..000000000000 --- a/Features/Ext4Pkg/Ext4Dxe/Crc32c.c +++ /dev/null @@ -1,84 +0,0 @@ -/** @file - CRC32c calculation routines. - - Copyright (c) 2021 Pedro Falcato All rights reserved. - - SPDX-License-Identifier: BSD-2-Clause-Patent -**/ - -#include - -STATIC CONST UINT32 gCrc32cLookupTable[256] =3D { - 0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, 0xc79a971f, 0x35f1141c, - 0x26a1e7e8, 0xd4ca64eb, 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b, - 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24, 0x105ec76f, 0xe235446c, - 0xf165b798, 0x030e349b, 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384, - 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54, 0x5d1d08bf, 0xaf768bbc, - 0xbc267848, 0x4e4dfb4b, 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a, - 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35, 0xaa64d611, 0x580f5512, - 0x4b5fa6e6, 0xb93425e5, 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa, - 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, 0xf779deae, 0x05125dad, - 0x1642ae59, 0xe4292d5a, 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a, - 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595, 0x417b1dbc, 0xb3109ebf, - 0xa0406d4b, 0x522bee48, 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957, - 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, 0x0c38d26c, 0xfe53516f, - 0xed03a29b, 0x1f682198, 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927, - 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38, 0xdbfc821c, 0x2997011f, - 0x3ac7f2eb, 0xc8ac71e8, 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7, - 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096, 0xa65c047d, 0x5437877e, - 0x4767748a, 0xb50cf789, 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859, - 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46, 0x7198540d, 0x83f3d70e, - 0x90a324fa, 0x62c8a7f9, 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6, - 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, 0x3cdb9bdd, 0xceb018de, - 0xdde0eb2a, 0x2f8b6829, 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c, - 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93, 0x082f63b7, 0xfa44e0b4, - 0xe9141340, 0x1b7f9043, 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c, - 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, 0x55326b08, 0xa759e80b, - 0xb4091bff, 0x466298fc, 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c, - 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033, 0xa24bb5a6, 0x502036a5, - 0x4370c551, 0xb11b4652, 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d, - 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d, 0xef087a76, 0x1d63f975, - 0x0e330a81, 0xfc588982, 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d, - 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622, 0x38cc2a06, 0xcaa7a905, - 0xd9f75af1, 0x2b9cd9f2, 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed, - 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, 0x0417b1db, 0xf67c32d8, - 0xe52cc12c, 0x1747422f, 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff, - 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0, 0xd3d3e1ab, 0x21b862a8, - 0x32e8915c, 0xc083125f, 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540, - 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, 0x9e902e7b, 0x6cfbad78, - 0x7fab5e8c, 0x8dc0dd8f, 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee, - 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1, 0x69e9f0d5, 0x9b8273d6, - 0x88d28022, 0x7ab90321, 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e, - 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, 0x34f4f86a, 0xc69f7b69, - 0xd5cf889d, 0x27a40b9e, 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e, - 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351 -}; - -/** - Calculates the CRC32c checksum of the given buffer. - - @param[in] Buffer Pointer to the buffer. - @param[in] Length Length of the buffer, in bytes. - @param[in] InitialValue Initial value of the CRC. - - @return The CRC32c checksum. -**/ -UINT32 -CalculateCrc32c ( - IN CONST VOID *Buffer, - IN UINTN Length, - IN UINT32 InitialValue - ) -{ - CONST UINT8 *Buf; - UINT32 Crc; - - Buf =3D Buffer; - Crc =3D ~InitialValue; - - while (Length-- !=3D 0) { - Crc =3D gCrc32cLookupTable[(Crc & 0xFF) ^ *(Buf++)] ^ (Crc >> 8); - } - - return ~Crc; -} diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.h index 1d9a4ac6bad3..fbdffd21f918 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 Pedro Falcato All rights reserved. + Copyright (c) 2021 - 2022 Pedro Falcato All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 @@ -929,38 +929,6 @@ Ext4FreeExtentsMap ( IN EXT4_FILE *File ); =20 -/** - Calculates the CRC32c checksum of the given buffer. - - @param[in] Buffer Pointer to the buffer. - @param[in] Length Length of the buffer, in bytes. - @param[in] InitialValue Initial value of the CRC. - - @return The CRC32c checksum. -**/ -UINT32 -CalculateCrc32c ( - IN CONST VOID *Buffer, - IN UINTN Length, - IN UINT32 InitialValue - ); - -/** - Calculates the CRC16 checksum of the given buffer. - - @param[in] Buffer Pointer to the buffer. - @param[in] Length Length of the buffer, in bytes. - @param[in] InitialValue Initial value of the CRC. - - @return The CRC16 checksum. -**/ -UINT16 -CalculateCrc16 ( - IN CONST VOID *Buffer, - IN UINTN Length, - IN UINT16 InitialValue - ); - /** Calculates the checksum of the given buffer. @param[in] Partition Pointer to the opened EXT4 partition. diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf b/Features/Ext4Pkg/Ext4Dx= e/Ext4Dxe.inf index 6533de6247dc..12e89bf1fdfc 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf @@ -109,8 +109,6 @@ Extents.c File.c Collation.c - Crc32c.c - Crc16.c Ext4Disk.h Ext4Dxe.h =20 --=20 2.35.1 -=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 (#88556): https://edk2.groups.io/g/devel/message/88556 Mute This Topic: https://groups.io/mt/90324100/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- From nobody Fri May 17 05:54:40 2024 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+88558+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+88558+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1649368924; cv=none; d=zohomail.com; s=zohoarc; b=m0jTgo/vO2x5BcHO444bQIpoPFZonshVXFdTlYFgEUe+xP85GTuNjOWvLILuWMZP7PTD3GXSJql81jUIoi0B0bvfmtLpEIjqdMHI/O/z38f7inEVxfwGFZiGzjni90dsDE5zvyZ109N7LeK2uSDt9jQjkBatQOZ5TiYrG1SXT4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649368924; h=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=z14XhhtojJ0jfQkra9/3UWLm29jGt8+cB18SY8PEWIs=; b=Wial8lZNoWTzEQYsx92u+1V7MrXmpXd9EsHiSczcYuYBBzHN+tJSU98Yik9PXilHQm4S7rUYUKNgaYMb1TGXyS4fbdxTtuhPYLvlzIfWqSozTd+6AJlYfIMypCLeS4xqtgXlNzZ9HBrJIDouNnqfwLRXnKfu8UCRVjINbMPh4eY= 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+88558+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 1649368924772535.0898815866487; Thu, 7 Apr 2022 15:02:04 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id z0IAYY1788612xS5QD2Cg1WW; Thu, 07 Apr 2022 15:02:04 -0700 X-Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mx.groups.io with SMTP id smtpd.web11.455.1649368913103342577 for ; Thu, 07 Apr 2022 15:02:03 -0700 X-Received: by mail-wr1-f45.google.com with SMTP id w4so9925907wrg.12 for ; Thu, 07 Apr 2022 15:01:52 -0700 (PDT) X-Gm-Message-State: g1t8flFWPptmNV2waYrKPLBmx1787277AA= X-Google-Smtp-Source: ABdhPJxuFO9FVzjMe98QoTc30GAoMnxSS1AzvZsgL3xWXhL4KUjUra7Vys4F/3IOy1ApnE/cS5AT3Q== X-Received: by 2002:a5d:6890:0:b0:206:1ac9:7844 with SMTP id h16-20020a5d6890000000b002061ac97844mr11792780wru.114.1649368910380; Thu, 07 Apr 2022 15:01:50 -0700 (PDT) X-Received: from PC-PEDRO-ARCH.lan ([2001:8a0:7280:5801:9441:3dce:686c:bfc7]) by smtp.gmail.com with ESMTPSA id m18-20020a05600c4f5200b0038e8f9d7b57sm2813379wmq.42.2022.04.07.15.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 15:01:49 -0700 (PDT) From: "Pedro Falcato" To: devel@edk2.groups.io Cc: Leif Lindholm , Michael D Kinney Subject: [edk2-devel] [PATCH edk2-platforms 2/3] Ext4Pkg: Format using uncrustify Date: Thu, 7 Apr 2022 23:01:45 +0100 Message-Id: <20220407220146.149580-3-pedro.falcato@gmail.com> In-Reply-To: <20220407220146.149580-1-pedro.falcato@gmail.com> References: <20220407220146.149580-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-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1649368924; bh=tsX9UZuJ8DU+EnPZFIye4Wvj7xgqYgpmDE7cqQIu2YY=; h=Cc:Date:From:Reply-To:Subject:To; b=MPOB1ej7UtKIW3AUWpIXgT4mICWX9iikRNEjNGJcI3qSmmlc4r+y29g7Laz2X6InHFa wOtEzD+a1RYYGdGqtrekktc+X9HoshS4sMpxk2F76zeJwD6ICcBHXTGE70dyrQgYDaFbb BjyclW99ckxpvcjBbh8i7xbcDLzx1rS8h7w= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1649368926390100002 Content-Type: text/plain; charset="utf-8" Previously, Ext4Pkg was formatted using uncrustify with an older config fil= e. Re-format it using the upstream edk2 uncrustify config file. Cc: Leif Lindholm Cc: Michael D Kinney Signed-off-by: Pedro Falcato --- Features/Ext4Pkg/Ext4Dxe/Collation.c | 4 +- Features/Ext4Pkg/Ext4Dxe/Directory.c | 13 +- Features/Ext4Pkg/Ext4Dxe/DiskUtil.c | 6 +- Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h | 28 +- Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c | 95 +++---- Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 365 ++++++++++++++------------ Features/Ext4Pkg/Ext4Dxe/Extents.c | 10 +- Features/Ext4Pkg/Ext4Dxe/File.c | 19 +- Features/Ext4Pkg/Ext4Dxe/Inode.c | 24 +- Features/Ext4Pkg/Ext4Dxe/Partition.c | 12 +- Features/Ext4Pkg/Ext4Dxe/Superblock.c | 13 +- 11 files changed, 316 insertions(+), 273 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/Collation.c b/Features/Ext4Pkg/Ext4Dx= e/Collation.c index 510ab24ebdf3..91d172b1cb89 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Collation.c +++ b/Features/Ext4Pkg/Ext4Dxe/Collation.c @@ -58,7 +58,7 @@ Ext4InitialiseUnicodeCollationInternal ( CHAR8 *BestLanguage; =20 Iso639Language =3D (BOOLEAN)(ProtocolGuid =3D=3D &gEfiUnicodeCollationPr= otocolGuid); - RetStatus =3D EFI_UNSUPPORTED; + RetStatus =3D EFI_UNSUPPORTED; GetEfiGlobalVariable2 (VariableName, (VOID **)&Language, NULL); =20 Status =3D gBS->LocateHandleBuffer ( @@ -96,7 +96,7 @@ Ext4InitialiseUnicodeCollationInternal ( if (BestLanguage !=3D NULL) { FreePool (BestLanguage); gUnicodeCollationInterface =3D Uci; - RetStatus =3D EFI_SUCCESS; + RetStatus =3D EFI_SUCCESS; break; } } diff --git a/Features/Ext4Pkg/Ext4Dxe/Directory.c b/Features/Ext4Pkg/Ext4Dx= e/Directory.c index 9e003ea43719..682f66ad5525 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Directory.c +++ b/Features/Ext4Pkg/Ext4Dxe/Directory.c @@ -121,7 +121,7 @@ Ext4RetrieveDirent ( =20 Off =3D 0; =20 - Inode =3D Directory->Inode; + Inode =3D Directory->Inode; DirInoSize =3D EXT4_INODE_SIZE (Inode); =20 DivU64x32Remainder (DirInoSize, Partition->BlockSize, &BlockRemainder); @@ -141,7 +141,7 @@ Ext4RetrieveDirent ( } =20 for (BlockOffset =3D 0; BlockOffset < Partition->BlockSize; ) { - Entry =3D (EXT4_DIR_ENTRY *)(Buf + BlockOffset); + Entry =3D (EXT4_DIR_ENTRY *)(Buf + BlockOffset); RemainingBlock =3D Partition->BlockSize - BlockOffset; // Check if the minimum directory entry fits inside [BlockOffset, En= dOfBlock] if (RemainingBlock < EXT4_MIN_DIR_ENTRY_LEN) { @@ -154,7 +154,7 @@ Ext4RetrieveDirent ( return EFI_VOLUME_CORRUPTED; } =20 - if (Entry->name_len > RemainingBlock || Entry->rec_len > RemainingBl= ock) { + if ((Entry->name_len > RemainingBlock) || (Entry->rec_len > Remainin= gBlock)) { // Corrupted filesystem FreePool (Buf); return EFI_VOLUME_CORRUPTED; @@ -191,8 +191,9 @@ Ext4RetrieveDirent ( continue; } =20 - if (Entry->name_len =3D=3D StrLen (Name) && - !Ext4StrCmpInsensitive (DirentUcs2Name, (CHAR16 *)Name)) { + if ((Entry->name_len =3D=3D StrLen (Name)) && + !Ext4StrCmpInsensitive (DirentUcs2Name, (CHAR16 *)Name)) + { ToCopy =3D MIN (Entry->rec_len, sizeof (EXT4_DIR_ENTRY)); =20 CopyMem (Result, Entry, ToCopy); @@ -595,7 +596,7 @@ Ext4AddDentry ( **/ EXT4_DENTRY * Ext4CreateDentry ( - IN CONST CHAR16 *Name, + IN CONST CHAR16 *Name, IN OUT EXT4_DENTRY *Parent OPTIONAL ) { diff --git a/Features/Ext4Pkg/Ext4Dxe/DiskUtil.c b/Features/Ext4Pkg/Ext4Dxe= /DiskUtil.c index da8120374772..32da35f7d9f5 100644 --- a/Features/Ext4Pkg/Ext4Dxe/DiskUtil.c +++ b/Features/Ext4Pkg/Ext4Dxe/DiskUtil.c @@ -60,11 +60,11 @@ Ext4ReadBlocks ( // Check for overflow on the block -> byte conversions. // Partition->BlockSize is never 0, so we don't need to check for that. =20 - if (Offset > DivU64x32 ((UINT64)- 1, Partition->BlockSize)) { + if (Offset > DivU64x32 ((UINT64)-1, Partition->BlockSize)) { return EFI_INVALID_PARAMETER; } =20 - if (Length > (UINTN)- 1/Partition->BlockSize) { + if (Length > (UINTN)-1/Partition->BlockSize) { return EFI_INVALID_PARAMETER; } =20 @@ -94,7 +94,7 @@ Ext4AllocAndReadBlocks ( =20 Length =3D NumberBlocks * Partition->BlockSize; =20 - if (Length > (UINTN)- 1/Partition->BlockSize) { + if (Length > (UINTN)-1/Partition->BlockSize) { return NULL; } =20 diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h b/Features/Ext4Pkg/Ext4Dxe= /Ext4Disk.h index 756b1bbe1087..5f812215fbb8 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h @@ -130,16 +130,16 @@ =20 #define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 #define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 -#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 // Unused +#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004// Unused #define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008 #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010 #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020 #define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040 -#define EXT4_FEATURE_RO_COMPAT_HAS_SNAPSHOT 0x0080 // Not implemente= d in ext4 +#define EXT4_FEATURE_RO_COMPAT_HAS_SNAPSHOT 0x0080// Not implemented in = ext4 #define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100 #define EXT4_FEATURE_RO_COMPAT_BIGALLOC 0x0200 #define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400 -#define EXT4_FEATURE_RO_COMPAT_REPLICA 0x0800 // Not used +#define EXT4_FEATURE_RO_COMPAT_REPLICA 0x0800// Not used =20 // We explicitly don't recognise this, so we get read only. #define EXT4_FEATURE_RO_COMPAT_READONLY 0x1000 @@ -149,7 +149,7 @@ * Absolutely needed features: * 1) Every incompat, because we might want to mount root filesystems * 2) Relevant RO_COMPATs(I'm not sure of what to do wrt quota, project) -**/ + **/ =20 #define EXT4_INO_TYPE_FIFO 0x1000 #define EXT4_INO_TYPE_CHARDEV 0x2000 @@ -259,7 +259,7 @@ typedef struct { UINT64 s_mmp_block; UINT32 s_raid_stride_width; UINT8 s_log_groups_per_flex; - UINT8 s_checksum_type; // Only valid value is 1 - CRC32C + UINT8 s_checksum_type; // Only valid value is 1 - CRC32C UINT16 s_reserved_pad; UINT64 s_kbytes_written; =20 @@ -283,7 +283,7 @@ typedef struct { UINT32 s_usr_quota_inum; UINT32 s_grp_quota_inum; UINT32 s_overhead_blocks; - UINT32 s_backup_bgs[2]; // sparse_super2 + UINT32 s_backup_bgs[2]; // sparse_super2 UINT8 s_encrypt_algos[4]; UINT8 s_encrypt_pw_salt[16]; UINT32 s_lpf_ino; @@ -293,7 +293,10 @@ typedef struct { UINT32 s_checksum; } EXT4_SUPERBLOCK; =20 -STATIC_ASSERT (sizeof (EXT4_SUPERBLOCK) =3D=3D 1024, "ext4 superblock stru= ct has incorrect size"); +STATIC_ASSERT ( + sizeof (EXT4_SUPERBLOCK) =3D=3D 1024, + "ext4 superblock struct has incorrect size" + ); =20 typedef struct { UINT32 bg_block_bitmap_lo; @@ -355,7 +358,8 @@ typedef struct _Ext4_I_OSD2_Hurd { } EXT4_OSD2_HURD; =20 typedef union { - // Note: Toolchain-specific defines (such as "linux") stops us from usin= g simpler names down here. + // Note: Toolchain-specific defines (such as "linux") stops us from using + // simpler names down here. EXT4_OSD2_LINUX data_linux; EXT4_OSD2_HURD data_hurd; } EXT4_OSD2; @@ -418,7 +422,8 @@ typedef struct { typedef struct { // This index covers logical blocks from 'ei_block' UINT32 ei_block; - // Block of the next level of the extent tree, similarly split in a high= and low portion. + // Block of the next level of the extent tree, similarly split in a high= and + // low portion. UINT32 ei_leaf_lo; UINT16 ei_leaf_hi; =20 @@ -451,8 +456,9 @@ typedef struct { /** * EXT4 has this feature called uninitialized extents: * An extent has a maximum of 32768 blocks (2^15 or 1 << 15). - * When we find an extent with > 32768 blocks, this extent is called unini= tialized. - * Long story short, it's an extent that behaves as a file hole but has bl= ocks already allocated. + * When we find an extent with > 32768 blocks, this extent is called + * uninitialized. Long story short, it's an extent that behaves as a file = hole + * but has blocks already allocated. */ #define EXT4_EXTENT_MAX_INITIALIZED (1 << 15) =20 diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.c index d9fbe9ea78e1..43b9340d3956 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.c @@ -104,11 +104,11 @@ Ext4ComponentNameGetDriverName ( EFI_STATUS EFIAPI Ext4ComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE Control= lerHandle, - IN EFI_HANDLE ChildHandle OPTIONA= L, - IN CHAR8 *Langua= ge, - OUT CHAR16 **Contr= ollerName + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName ); =20 extern EFI_COMPONENT_NAME_PROTOCOL gExt4ComponentName; @@ -175,9 +175,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTO= COL gExt4ComponentName2 EFI_STATUS EFIAPI Ext4IsBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL + IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL ); =20 /** @@ -218,9 +218,9 @@ Ext4IsBindingSupported ( EFI_STATUS EFIAPI Ext4Bind ( - IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL + IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL ); =20 /** @@ -252,10 +252,10 @@ Ext4Bind ( EFI_STATUS EFIAPI Ext4Stop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer OPTIONAL + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ); =20 EFI_DRIVER_BINDING_PROTOCOL gExt4BindingProtocol =3D @@ -309,11 +309,11 @@ EFI_DRIVER_BINDING_PROTOCOL gExt4BindingProtocol =3D EFI_STATUS EFIAPI Ext4ComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE Control= lerHandle, - IN EFI_HANDLE ChildHandle OPTIONA= L, - IN CHAR8 *Langua= ge, - OUT CHAR16 **Contr= ollerName + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName ) { EFI_STATUS Status; @@ -410,10 +410,10 @@ Ext4ComponentNameGetDriverName ( EFI_STATUS EFIAPI Ext4Stop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer OPTIONAL + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { EFI_STATUS Status; @@ -637,16 +637,16 @@ Ext4Unload ( EFI_STATUS EFIAPI Ext4IsBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL + IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL ) { - EFI_STATUS Status; - EFI_DISK_IO_PROTOCOL *DiskIo; - EFI_BLOCK_IO_PROTOCOL *BlockIo; + EFI_STATUS Status; + EFI_DISK_IO_PROTOCOL *DiskIo; + EFI_BLOCK_IO_PROTOCOL *BlockIo; =20 - DiskIo =3D NULL; + DiskIo =3D NULL; BlockIo =3D NULL; =20 // @@ -655,7 +655,7 @@ Ext4IsBindingSupported ( Status =3D gBS->OpenProtocol ( ControllerHandle, &gEfiDiskIoProtocolGuid, - (VOID **) &DiskIo, + (VOID **)&DiskIo, BindingProtocol->DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_BY_DRIVER @@ -664,13 +664,14 @@ Ext4IsBindingSupported ( if (EFI_ERROR (Status)) { return Status; } + // // Open the IO Abstraction(s) needed to perform the supported test // Status =3D gBS->OpenProtocol ( ControllerHandle, &gEfiBlockIoProtocolGuid, - (VOID **) &BlockIo, + (VOID **)&BlockIo, BindingProtocol->DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL @@ -687,20 +688,22 @@ Ext4IsBindingSupported ( // if (DiskIo !=3D NULL) { gBS->CloseProtocol ( - ControllerHandle, - &gEfiDiskIoProtocolGuid, - BindingProtocol->DriverBindingHandle, - ControllerHandle - ); + ControllerHandle, + &gEfiDiskIoProtocolGuid, + BindingProtocol->DriverBindingHandle, + ControllerHandle + ); } + if (BlockIo !=3D NULL) { gBS->CloseProtocol ( - ControllerHandle, - &gEfiBlockIoProtocolGuid, - BindingProtocol->DriverBindingHandle, - ControllerHandle - ); + ControllerHandle, + &gEfiBlockIoProtocolGuid, + BindingProtocol->DriverBindingHandle, + ControllerHandle + ); } + return Status; } =20 @@ -742,9 +745,9 @@ Ext4IsBindingSupported ( EFI_STATUS EFIAPI Ext4Bind ( - IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL + IN EFI_DRIVER_BINDING_PROTOCOL *BindingProtocol, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL ) { EFI_DISK_IO_PROTOCOL *DiskIo; diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.h index fbdffd21f918..03e0586cbb05 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h @@ -18,16 +18,16 @@ #include #include =20 -#include -#include -#include #include #include +#include #include -#include +#include +#include #include +#include +#include #include -#include =20 #include "Ext4Disk.h" =20 @@ -40,7 +40,8 @@ =20 @param[in] DeviceHandle Handle to the block device. @param[in] DiskIo Pointer to an EFI_DISK_IO_PROTOCOL. - @param[in opt] DiskIo2 Pointer to an EFI_DISK_IO2_PROTOCOL,= if supported. + @param[in opt] DiskIo2 Pointer to an EFI_DISK_IO2_PROTOCOL, +if supported. @param[in] BlockIo Pointer to an EFI_BLOCK_IO_PROTOCOL. =20 @retval EFI_SUCCESS The opening was successful. @@ -54,8 +55,8 @@ Ext4OpenPartition ( IN EFI_BLOCK_IO_PROTOCOL *BlockIo ); =20 -typedef struct _Ext4File EXT4_FILE; -typedef struct _Ext4_Dentry EXT4_DENTRY; +typedef struct _Ext4File EXT4_FILE; +typedef struct _Ext4_Dentry EXT4_DENTRY; =20 typedef struct _Ext4_PARTITION { EFI_SIMPLE_FILE_SYSTEM_PROTOCOL Interface; @@ -88,12 +89,12 @@ typedef struct _Ext4_PARTITION { =20 /** This structure represents a directory entry inside our directory entry = tree. - For now, it will be used as a way to track file names inside our openin= g code, - but it may very well be used as a directory cache in the future. + For now, it will be used as a way to track file names inside our opening + code, but it may very well be used as a directory cache in the future. Because it's not being used as a directory cache right now, an EXT4_DENTRY structure is not necessarily unique name-wise in the lis= t of - children. Therefore, the dentry tree does not accurately reflect the fi= lesystem - structure. + children. Therefore, the dentry tree does not accurately reflect the + filesystem structure. */ struct _Ext4_Dentry { UINTN RefCount; @@ -104,7 +105,7 @@ struct _Ext4_Dentry { LIST_ENTRY ListNode; }; =20 -#define EXT4_DENTRY_FROM_DENTRY_LIST(Node) BASE_CR (Node, EXT4_DENTRY, Li= stNode) +#define EXT4_DENTRY_FROM_DENTRY_LIST(Node) BASE_CR(Node, EXT4_DENTRY, Lis= tNode) =20 /** Creates a new dentry object. @@ -118,7 +119,7 @@ struct _Ext4_Dentry { EXT4_DENTRY * Ext4CreateDentry ( IN CONST CHAR16 *Name, - IN OUT EXT4_DENTRY *Parent OPTIONAL + IN OUT EXT4_DENTRY *Parent OPTIONAL ); =20 /** @@ -147,7 +148,8 @@ Ext4UnrefDentry ( /** Opens and parses the superblock. =20 - @param[out] Partition Partition structure to fill with filesystem d= etails. + @param[out] Partition Partition structure to fill with filesystem +details. @retval EFI_SUCCESS Parsing was succesful and the partition is a valid ext4 partition. **/ @@ -219,15 +221,15 @@ Ext4ReadDiskIo ( **/ EFI_STATUS Ext4ReadBlocks ( - IN EXT4_PARTITION *Partition, - OUT VOID *Buffer, - IN UINTN NumberBlocks, - IN EXT4_BLOCK_NR BlockNumber + IN EXT4_PARTITION *Partition, + OUT VOID *Buffer, + IN UINTN NumberBlocks, + IN EXT4_BLOCK_NR BlockNumber ); =20 /** - Allocates a buffer and reads blocks from the partition's disk using the= DISK_IO protocol. - This function is deprecated and will be removed in the future. + Allocates a buffer and reads blocks from the partition's disk using the +DISK_IO protocol. This function is deprecated and will be removed in the f= uture. =20 @param[in] Partition Pointer to the opened ext4 partition. @param[in] NumberBlocks Length of the read, in filesystem blocks. @@ -244,13 +246,15 @@ Ext4AllocAndReadBlocks ( ); =20 /** - Checks if the opened partition has the 64-bit feature (see EXT4_FEATURE= _INCOMPAT_64BIT). + Checks if the opened partition has the 64-bit feature (see +EXT4_FEATURE_INCOMPAT_64BIT). =20 @param[in] Partition Pointer to the opened ext4 partition. =20 @return TRUE if EXT4_FEATURE_INCOMPAT_64BIT is enabled, else FALSE. **/ -#define EXT4_IS_64_BIT(Partition) ((Partition->FeaturesIncompat & EXT4_FE= ATURE_INCOMPAT_64BIT) !=3D 0) +#define EXT4_IS_64_BIT(Partition) = \ + ((Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_64BIT) !=3D 0) =20 /** Composes an EXT4_BLOCK_NR safely, from two halfs. @@ -261,8 +265,8 @@ Ext4AllocAndReadBlocks ( =20 @return The block number formed by Low, and if 64 bit is enabled, High. **/ -#define EXT4_BLOCK_NR_FROM_HALFS(Partition, Low, High) \ - EXT4_IS_64_BIT (Partition) ? (Low | LShiftU64 (High, 32)) : Low +#define EXT4_BLOCK_NR_FROM_HALFS(Partition, Low, High) = \ + EXT4_IS_64_BIT(Partition) ? (Low | LShiftU64(High, 32)) : Low =20 /** Retrieves a block group descriptor of the ext4 filesystem. @@ -283,15 +287,16 @@ Ext4GetBlockGroupDesc ( =20 @param[in] Partition Pointer to the opened partition. @param[in] InodeNum Number of the desired Inode - @param[out] OutIno Pointer to where it will be stored a pointer t= o the read inode. + @param[out] OutIno Pointer to where it will be stored a pointer t= o the +read inode. =20 @return Status of the inode read. **/ EFI_STATUS Ext4ReadInode ( - IN EXT4_PARTITION *Partition, - IN EXT4_INO_NR InodeNum, - OUT EXT4_INODE **OutIno + IN EXT4_PARTITION *Partition, + IN EXT4_INO_NR InodeNum, + OUT EXT4_INODE **OutIno ); =20 /** @@ -302,7 +307,8 @@ Ext4ReadInode ( =20 @return The number of bytes. **/ -#define EXT4_BLOCK_TO_BYTES(Partition, Block) MultU64x32 (Block, Partitio= n->BlockSize) +#define EXT4_BLOCK_TO_BYTES(Partition, Block) = \ + MultU64x32(Block, Partition->BlockSize) =20 /** Reads from an EXT4 inode. @@ -311,17 +317,18 @@ Ext4ReadInode ( @param[out] Buffer Pointer to the buffer. @param[in] Offset Offset of the read. @param[in out] Length Pointer to the length of the buffer, in b= ytes. - After a succesful read, it's updated to t= he number of read bytes. + After a succesful read, it's updated to t= he +number of read bytes. =20 @return Status of the read operation. **/ EFI_STATUS Ext4Read ( - IN EXT4_PARTITION *Partition, - IN EXT4_FILE *File, - OUT VOID *Buffer, - IN UINT64 Offset, - IN OUT UINTN *Length + IN EXT4_PARTITION *Partition, + IN EXT4_FILE *File, + OUT VOID *Buffer, + IN UINT64 Offset, + IN OUT UINTN *Length ); =20 /** @@ -331,24 +338,27 @@ Ext4Read ( =20 @return The size of the inode, in bytes. **/ -#define EXT4_INODE_SIZE(Inode) (LShiftU64 (Inode->i_size_hi, 32) | Inode-= >i_size_lo) +#define EXT4_INODE_SIZE(Inode) = \ + (LShiftU64(Inode->i_size_hi, 32) | Inode->i_size_lo) =20 /** Retrieves an extent from an EXT4 inode. @param[in] Partition Pointer to the opened EXT4 partition. @param[in] File Pointer to the opened file. - @param[in] LogicalBlock Block number which the returned extent mu= st cover. - @param[out] Extent Pointer to the output buffer, where the e= xtent will be copied to. + @param[in] LogicalBlock Block number which the returned extent mu= st +cover. + @param[out] Extent Pointer to the output buffer, where the e= xtent +will be copied to. =20 @retval EFI_SUCCESS Retrieval was succesful. @retval EFI_NO_MAPPING Block has no mapping. **/ EFI_STATUS Ext4GetExtent ( - IN EXT4_PARTITION *Partition, - IN EXT4_FILE *File, - IN EXT4_BLOCK_NR LogicalBlock, - OUT EXT4_EXTENT *Extent + IN EXT4_PARTITION *Partition, + IN EXT4_FILE *File, + IN EXT4_BLOCK_NR LogicalBlock, + OUT EXT4_EXTENT *Extent ); =20 struct _Ext4File { @@ -369,7 +379,8 @@ struct _Ext4File { EXT4_DENTRY *Dentry; }; =20 -#define EXT4_FILE_FROM_OPEN_FILES_NODE(Node) BASE_CR (Node, EXT4_FILE, Op= enFilesListNode) +#define EXT4_FILE_FROM_OPEN_FILES_NODE(Node) = \ + BASE_CR(Node, EXT4_FILE, OpenFilesListNode) =20 /** Retrieves a directory entry. @@ -383,9 +394,9 @@ struct _Ext4File { **/ EFI_STATUS Ext4RetrieveDirent ( - IN EXT4_FILE *Directory, - IN CONST CHAR16 *NameUnicode, - IN EXT4_PARTITION *Partition, + IN EXT4_FILE *Directory, + IN CONST CHAR16 *NameUnicode, + IN EXT4_PARTITION *Partition, OUT EXT4_DIR_ENTRY *Result ); =20 @@ -402,11 +413,11 @@ Ext4RetrieveDirent ( **/ EFI_STATUS Ext4OpenFile ( - IN EXT4_FILE *Directory, - IN CONST CHAR16 *Name, - IN EXT4_PARTITION *Partition, - IN UINT64 OpenMode, - OUT EXT4_FILE **OutFile + IN EXT4_FILE *Directory, + IN CONST CHAR16 *Name, + IN EXT4_PARTITION *Partition, + IN UINT64 OpenMode, + OUT EXT4_FILE **OutFile ); =20 /** @@ -422,11 +433,11 @@ Ext4OpenFile ( **/ EFI_STATUS Ext4OpenDirent ( - IN EXT4_PARTITION *Partition, - IN UINT64 OpenMode, - OUT EXT4_FILE **OutFile, - IN EXT4_DIR_ENTRY *Entry, - IN EXT4_FILE *Directory + IN EXT4_PARTITION *Partition, + IN UINT64 OpenMode, + OUT EXT4_FILE **OutFile, + IN EXT4_DIR_ENTRY *Entry, + IN EXT4_FILE *Directory ); =20 /** @@ -447,20 +458,22 @@ Ext4AllocateInode ( Open the root directory on a volume. =20 @param[in] This A pointer to the volume to open the root directory. - @param[out] Root A pointer to the location to return the opened file ha= ndle for the - root directory. + @param[out] Root A pointer to the location to return the opened file ha= ndle +for the root directory. =20 @retval EFI_SUCCESS The device was opened. - @retval EFI_UNSUPPORTED This volume does not support the requested = file system type. + @retval EFI_UNSUPPORTED This volume does not support the requested = file +system type. @retval EFI_NO_MEDIA The device has no medium. @retval EFI_DEVICE_ERROR The device reported an error. @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. @retval EFI_ACCESS_DENIED The service denied access to the file. - @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of re= sources. - @retval EFI_MEDIA_CHANGED The device has a different medium in it or = the medium is no - longer supported. Any existing file handles= for this volume are - no longer valid. To access the files on the= new medium, the - volume must be reopened with OpenVolume(). + @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of +resources. + @retval EFI_MEDIA_CHANGED The device has a different medium in it or = the +medium is no longer supported. Any existing file handles for this volume a= re no +longer valid. To access the files on the new medium, the volume must be re= opened +with OpenVolume(). =20 **/ EFI_STATUS @@ -501,30 +514,32 @@ Ext4CloseInternal ( /** Opens a new file relative to the source file's location. =20 - @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that = is the file - handle to the source location. This would typical= ly be an open - handle to a directory. - @param[out] NewHandle A pointer to the location to return the opened ha= ndle for the new - file. - @param[in] FileName The Null-terminated string of the name of the fil= e to be opened. - The file name may contain the following path modi= fiers: "\", ".", - and "..". - @param[in] OpenMode The mode to open the file. The only valid combina= tions that the - file may be opened with are: Read, Read/Write, or= Create/Read/Write. - @param[in] Attributes Only valid for EFI_FILE_MODE_CREATE, in which cas= e these are the - attribute bits for the newly created file. + @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that = is the +file handle to the source location. This would typically be an open handle= to a +directory. + @param[out] NewHandle A pointer to the location to return the opened ha= ndle +for the new file. + @param[in] FileName The Null-terminated string of the name of the fil= e to +be opened. The file name may contain the following path modifiers: "\", ".= ", and +"..". + @param[in] OpenMode The mode to open the file. The only valid combina= tions +that the file may be opened with are: Read, Read/Write, or Create/Read/Wri= te. + @param[in] Attributes Only valid for EFI_FILE_MODE_CREATE, in which case +these are the attribute bits for the newly created file. =20 @retval EFI_SUCCESS The file was opened. - @retval EFI_NOT_FOUND The specified file could not be found on th= e device. + @retval EFI_NOT_FOUND The specified file could not be found on the +device. @retval EFI_NO_MEDIA The device has no medium. - @retval EFI_MEDIA_CHANGED The device has a different medium in it or = the medium is no - longer supported. + @retval EFI_MEDIA_CHANGED The device has a different medium in it or = the +medium is no longer supported. @retval EFI_DEVICE_ERROR The device reported an error. @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. - @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or op= en a file for write - when the media is write-protected. + @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or op= en a +file for write when the media is write-protected. @retval EFI_ACCESS_DENIED The service denied access to the file. - @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open= the file. + @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open= the +file. @retval EFI_VOLUME_FULL The volume is full. =20 **/ @@ -541,8 +556,8 @@ Ext4Open ( /** Closes a specified file handle. =20 - @param[in] This A pointer to the EFI_FILE_PROTOCOL instance th= at is the file - handle to close. + @param[in] This A pointer to the EFI_FILE_PROTOCOL instance th= at is +the file handle to close. =20 @retval EFI_SUCCESS The file was closed. =20 @@ -556,11 +571,13 @@ Ext4Close ( /** Close and delete the file handle. =20 - @param[in] This A pointer to the EFI_FILE_PROTOCOL = instance that is the - handle to the file to delete. + @param[in] This A pointer to the EFI_FILE_PROTOCOL +instance that is the handle to the file to delete. =20 - @retval EFI_SUCCESS The file was closed and deleted, and th= e handle was closed. - @retval EFI_WARN_DELETE_FAILURE The handle was closed, but the file was= not deleted. + @retval EFI_SUCCESS The file was closed and deleted, and the +handle was closed. + @retval EFI_WARN_DELETE_FAILURE The handle was closed, but the file was= not +deleted. =20 **/ EFI_STATUS @@ -572,21 +589,23 @@ Ext4Delete ( /** Reads data from a file. =20 - @param[in] This A pointer to the EFI_FILE_PROTOCOL inst= ance that is the file - handle to read data from. - @param[in out] BufferSize On input, the size of the Buffer. On ou= tput, the amount of data - returned in Buffer. In both cases, the = size is measured in bytes. + @param[in] This A pointer to the EFI_FILE_PROTOCOL inst= ance +that is the file handle to read data from. + @param[in out] BufferSize On input, the size of the Buffer. On ou= tput, +the amount of data returned in Buffer. In both cases, the size is measured= in +bytes. @param[out] Buffer The buffer into which the data is read. =20 @retval EFI_SUCCESS Data was read. @retval EFI_NO_MEDIA The device has no medium. @retval EFI_DEVICE_ERROR The device reported an error. @retval EFI_DEVICE_ERROR An attempt was made to read from a deleted = file. - @retval EFI_DEVICE_ERROR On entry, the current file position is beyo= nd the end of the file. + @retval EFI_DEVICE_ERROR On entry, the current file position is beyo= nd the +end of the file. @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. - @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the cur= rent directory - entry. BufferSize has been updated with the= size - needed to complete the request. + @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the cur= rent +directory entry. BufferSize has been updated with the size needed to compl= ete +the request. =20 **/ EFI_STATUS @@ -600,10 +619,10 @@ Ext4ReadFile ( /** Writes data to a file. =20 - @param[in] This A pointer to the EFI_FILE_PROTOCOL instance = that is the file - handle to write data to. - @param[in out] BufferSize On input, the size of the Buffer. On output,= the amount of data - actually written. In both cases, the size is= measured in bytes. + @param[in] This A pointer to the EFI_FILE_PROTOCOL instance = that +is the file handle to write data to. + @param[in out] BufferSize On input, the size of the Buffer. On output,= the +amount of data actually written. In both cases, the size is measured in by= tes. @param[in] Buffer The buffer of data to write. =20 @retval EFI_SUCCESS Data was written. @@ -628,13 +647,15 @@ Ext4WriteFile ( /** Returns a file's current position. =20 - @param[in] This A pointer to the EFI_FILE_PROTOCOL instance= that is the file - handle to get the current position on. - @param[out] Position The address to return the file's current po= sition value. + @param[in] This A pointer to the EFI_FILE_PROTOCOL instance= that +is the file handle to get the current position on. + @param[out] Position The address to return the file's current po= sition +value. =20 @retval EFI_SUCCESS The position was returned. @retval EFI_UNSUPPORTED The request is not valid on open directories. - @retval EFI_DEVICE_ERROR An attempt was made to get the position from a = deleted file. + @retval EFI_DEVICE_ERROR An attempt was made to get the position from a +deleted file. =20 **/ EFI_STATUS @@ -647,14 +668,16 @@ Ext4GetPosition ( /** Sets a file's current position. =20 - @param[in] This A pointer to the EFI_FILE_PROTOCOL instance = that is the - file handle to set the requested position on. - @param[in] Position The byte position from the start of the file = to set. + @param[in] This A pointer to the EFI_FILE_PROTOCOL instance = that +is the file handle to set the requested position on. + @param[in] Position The byte position from the start of the file = to +set. =20 @retval EFI_SUCCESS The position was set. @retval EFI_UNSUPPORTED The seek request for nonzero is not valid on op= en directories. - @retval EFI_DEVICE_ERROR An attempt was made to set the position of a de= leted file. + @retval EFI_DEVICE_ERROR An attempt was made to set the position of a de= leted +file. =20 **/ EFI_STATUS @@ -667,21 +690,22 @@ Ext4SetPosition ( /** Returns information about a file. =20 - @param[in] This A pointer to the EFI_FILE_PROTOCOL insta= nce that is the file - handle the requested information is for. - @param[in] InformationType The type identifier for the information = being requested. - @param[in out] BufferSize On input, the size of Buffer. On output,= the amount of data - returned in Buffer. In both cases, the s= ize is measured in bytes. - @param[out] Buffer A pointer to the data buffer to return. = The buffer's type is - indicated by InformationType. + @param[in] This A pointer to the EFI_FILE_PROTOCOL insta= nce +that is the file handle the requested information is for. + @param[in] InformationType The type identifier for the information = being +requested. + @param[in out] BufferSize On input, the size of Buffer. On output,= the +amount of data returned in Buffer. In both cases, the size is measured in = bytes. + @param[out] Buffer A pointer to the data buffer to return. = The +buffer's type is indicated by InformationType. =20 @retval EFI_SUCCESS The information was returned. @retval EFI_UNSUPPORTED The InformationType is not known. @retval EFI_NO_MEDIA The device has no medium. @retval EFI_DEVICE_ERROR The device reported an error. @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. - @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the cur= rent directory entry. - BufferSize has been updated with the size n= eeded to complete + @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the cur= rent +directory entry. BufferSize has been updated with the size needed to compl= ete the request. **/ EFI_STATUS @@ -696,35 +720,36 @@ Ext4GetInfo ( /** Sets information about a file. =20 - @param[in] This A pointer to the EFI_FILE_PROTOCOL instance = that is the file - handle the information is for. + @param[in] This A pointer to the EFI_FILE_PROTOCOL instance = that +is the file handle the information is for. @param[in] InformationType The type identifier for the information bein= g set. @param[in] BufferSize The size, in bytes, of Buffer. - @param[in] Buffer A pointer to the data buffer to write. The b= uffer's type is - indicated by InformationType. + @param[in] Buffer A pointer to the data buffer to write. The +buffer's type is indicated by InformationType. =20 @retval EFI_SUCCESS The information was set. @retval EFI_UNSUPPORTED The InformationType is not known. @retval EFI_NO_MEDIA The device has no medium. @retval EFI_DEVICE_ERROR The device reported an error. @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. - @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_INFO_ID and the= media is - read-only. - @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_PROTOCOL_SYSTEM= _INFO_ID - and the media is read only. - @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_SYSTEM_VOLUME_L= ABEL_ID - and the media is read-only. - @retval EFI_ACCESS_DENIED An attempt is made to change the name of a = file to a - file that is already present. - @retval EFI_ACCESS_DENIED An attempt is being made to change the EFI_= FILE_DIRECTORY - Attribute. - @retval EFI_ACCESS_DENIED An attempt is being made to change the size= of a directory. - @retval EFI_ACCESS_DENIED InformationType is EFI_FILE_INFO_ID and the= file was opened - read-only and an attempt is being made to m= odify a field - other than Attribute. + @retval EFI_WRITE_PROTECTED InformationType is EFI_FILE_INFO_ID and the= media +is read-only. + @retval EFI_WRITE_PROTECTED InformationType is +EFI_FILE_PROTOCOL_SYSTEM_INFO_ID and the media is read only. + @retval EFI_WRITE_PROTECTED InformationType is +EFI_FILE_SYSTEM_VOLUME_LABEL_ID and the media is read-only. + @retval EFI_ACCESS_DENIED An attempt is made to change the name of a = file +to a file that is already present. + @retval EFI_ACCESS_DENIED An attempt is being made to change the +EFI_FILE_DIRECTORY Attribute. + @retval EFI_ACCESS_DENIED An attempt is being made to change the size= of a +directory. + @retval EFI_ACCESS_DENIED InformationType is EFI_FILE_INFO_ID and the= file +was opened read-only and an attempt is being made to modify a field other = than +Attribute. @retval EFI_VOLUME_FULL The volume is full. - @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the size of the = type indicated - by InformationType. + @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the size of the = type +indicated by InformationType. =20 **/ EFI_STATUS @@ -760,8 +785,8 @@ Ext4FileIsReg ( IN CONST EXT4_FILE *File ); =20 -// In EFI we can't open FIFO pipes, UNIX sockets, character/block devices = since these concepts are -// at the kernel level and are OS dependent. +// In EFI we can't open FIFO pipes, UNIX sockets, character/block devices = since +// these concepts are at the kernel level and are OS dependent. =20 /** Checks if a file is openable. @@ -772,11 +797,11 @@ Ext4FileIsReg ( it's a regular file or a directory, since most other file types don't make sense under UEFI. **/ -#define Ext4FileIsOpenable(File) (Ext4FileIsReg (File) || Ext4FileIsDir (= File)) +#define Ext4FileIsOpenable(File) (Ext4FileIsReg(File) || Ext4FileIsDir(Fi= le)) =20 -#define EXT4_INODE_HAS_FIELD(Inode, \ - Field) (Inode->i_extra_isize + EXT4_GOOD_OLD= _INODE_SIZE >=3D OFFSET_OF (EXT4_INODE, Field) + \ - sizeof (((EXT4_INODE *)NULL)->Field)) +#define EXT4_INODE_HAS_FIELD(Inode, Field) = \ + (Inode->i_extra_isize + EXT4_GOOD_OLD_INODE_SIZE >=3D = \ + OFFSET_OF(EXT4_INODE, Field) + sizeof(((EXT4_INODE *)NULL)->Field)) =20 /** Calculates the physical space used by a file. @@ -815,8 +840,8 @@ Ext4FileMTime ( Gets the file's creation time, if possible. @param[in] File Pointer to the opened file. @param[out] Time Pointer to an EFI_TIME structure. - In the case where the the creation time isn't re= corded, - Time is zeroed. + In the case where the the creation time isn't +recorded, Time is zeroed. **/ VOID Ext4FileCreateTime ( @@ -825,8 +850,9 @@ Ext4FileCreateTime ( ); =20 /** - Initialises Unicode collation, which is needed for case-insensitive str= ing comparisons - within the driver (a good example of an application of this is filename= comparison). + Initialises Unicode collation, which is needed for case-insensitive str= ing +comparisons within the driver (a good example of an application of this is +filename comparison). =20 @param[in] DriverHandle Handle to the driver image. =20 @@ -839,8 +865,8 @@ Ext4InitialiseUnicodeCollation ( ); =20 /** - Does a case-insensitive string comparison. Refer to EFI_UNICODE_COLLATI= ON_PROTOCOL's StriColl - for more details. + Does a case-insensitive string comparison. Refer to +EFI_UNICODE_COLLATION_PROTOCOL's StriColl for more details. =20 @param[in] Str1 Pointer to a null terminated string. @param[in] Str2 Pointer to a null terminated string. @@ -859,7 +885,8 @@ Ext4StrCmpInsensitive ( Retrieves the filename of the directory entry and converts it to UTF-16= /UCS-2 =20 @param[in] Entry Pointer to a EXT4_DIR_ENTRY. - @param[out] Ucs2FileName Pointer to an array of CHAR16's, of siz= e EXT4_NAME_MAX + 1. + @param[out] Ucs2FileName Pointer to an array of CHAR16's, of size +EXT4_NAME_MAX + 1. =20 @retval EFI_SUCCESS Unicode collation was successfully initialised. @retval !EFI_SUCCESS Failure. @@ -871,7 +898,8 @@ Ext4GetUcs2DirentName ( ); =20 /** - Retrieves information about the file and stores it in the EFI_FILE_INFO= format. + Retrieves information about the file and stores it in the EFI_FILE_INFO +format. =20 @param[in] File Pointer to an opened file. @param[out] Info Pointer to a EFI_FILE_INFO. @@ -881,9 +909,9 @@ Ext4GetUcs2DirentName ( **/ EFI_STATUS Ext4GetFileInfo ( - IN EXT4_FILE *File, - OUT EFI_FILE_INFO *Info, - IN OUT UINTN *BufferSize + IN EXT4_FILE *File, + OUT EFI_FILE_INFO *Info, + IN OUT UINTN *BufferSize ); =20 /** @@ -893,8 +921,8 @@ Ext4GetFileInfo ( @param[in] File Pointer to the open directory. @param[out] Buffer Pointer to the output buffer. @param[in] Offset Initial directory position. - @param[in out] OutLength Pointer to a UINTN that contains the length= of the buffer, - and the length of the actual EFI_FILE_INFO = after the call. + @param[in out] OutLength Pointer to a UINTN that contains the length= of +the buffer, and the length of the actual EFI_FILE_INFO after the call. =20 @return Result of the operation. **/ @@ -1025,7 +1053,7 @@ Ext4CalculateBlockGroupDescChecksum ( =20 @return TRUE if all features are supported, else FALSE. **/ -#define EXT4_HAS_RO_COMPAT(Partition, RoCompatFeatureSet) \ +#define EXT4_HAS_RO_COMPAT(Partition, RoCompatFeatureSet) = \ ((Partition->FeaturesRoCompat & RoCompatFeatureSet) =3D=3D RoCompatFeatu= reSet) =20 /** @@ -1035,7 +1063,7 @@ Ext4CalculateBlockGroupDescChecksum ( =20 @return TRUE if all features are supported, else FALSE. **/ -#define EXT4_HAS_COMPAT(Partition, CompatFeatureSet) \ +#define EXT4_HAS_COMPAT(Partition, CompatFeatureSet) = \ ((Partition->FeaturesCompat & CompatFeatureSet) =3D=3D CompatFeatureSet) =20 /** @@ -1045,10 +1073,11 @@ Ext4CalculateBlockGroupDescChecksum ( =20 @return TRUE if all features are supported, else FALSE. **/ -#define EXT4_HAS_INCOMPAT(Partition, IncompatFeatureSet) \ +#define EXT4_HAS_INCOMPAT(Partition, IncompatFeatureSet) = \ ((Partition->FeaturesIncompat & IncompatFeatureSet) =3D=3D IncompatFeatu= reSet) =20 -// Note: Might be a good idea to provide generic Ext4Has$feature() through= macros. +// Note: Might be a good idea to provide generic Ext4Has$feature() through +// macros. =20 /** Checks if metadata_csum is enabled on the partition. @@ -1056,8 +1085,8 @@ Ext4CalculateBlockGroupDescChecksum ( =20 @return TRUE if the metadata_csum is supported, else FALSE. **/ -#define EXT4_HAS_METADATA_CSUM(Partition) \ - EXT4_HAS_RO_COMPAT (Partition, EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) +#define EXT4_HAS_METADATA_CSUM(Partition) = \ + EXT4_HAS_RO_COMPAT(Partition, EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) =20 /** Checks if gdt_csum is enabled on the partition. @@ -1065,8 +1094,8 @@ Ext4CalculateBlockGroupDescChecksum ( =20 @return TRUE if the gdt_csum is supported, else FALSE. **/ -#define EXT4_HAS_GDT_CSUM(Partition) \ - EXT4_HAS_RO_COMPAT (Partition, EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) +#define EXT4_HAS_GDT_CSUM(Partition) = \ + EXT4_HAS_RO_COMPAT(Partition, EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) =20 /** Retrieves the volume name. @@ -1106,10 +1135,12 @@ Ext4SuperblockCheckMagic ( =20 @returns True if uninitialized, else false. **/ -#define EXT4_EXTENT_IS_UNINITIALIZED(Extent) ((Extent)->ee_len > EXT4_EXTE= NT_MAX_INITIALIZED) +#define EXT4_EXTENT_IS_UNINITIALIZED(Extent) = \ + ((Extent)->ee_len > EXT4_EXTENT_MAX_INITIALIZED) =20 /** - Retrieves the extent's length, dealing with uninitialized extents in th= e process. + Retrieves the extent's length, dealing with uninitialized extents in the +process. =20 @param[in] Extent Pointer to the EXT4_EXTENT =20 diff --git a/Features/Ext4Pkg/Ext4Dxe/Extents.c b/Features/Ext4Pkg/Ext4Dxe/= Extents.c index 1ae175f417c9..e920eed090fd 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Extents.c +++ b/Features/Ext4Pkg/Ext4Dxe/Extents.c @@ -249,7 +249,7 @@ Ext4GetExtent ( } =20 // ext4 does not have support for logical block numbers bigger than UINT= 32_MAX - if (LogicalBlock > (UINT32)- 1) { + if (LogicalBlock > (UINT32)-1) { return EFI_NO_MAPPING; } =20 @@ -332,7 +332,7 @@ Ext4GetExtent ( return EFI_NO_MAPPING; } =20 - if (!(LogicalBlock >=3D Ext->ee_block && Ext->ee_block + Ext4GetExtentLe= ngth (Ext) > LogicalBlock)) { + if (!((LogicalBlock >=3D Ext->ee_block) && (Ext->ee_block + Ext4GetExten= tLength (Ext) > LogicalBlock))) { // This extent does not cover the block if (Buffer !=3D NULL) { FreePool (Buffer); @@ -378,7 +378,7 @@ Ext4ExtentsMapStructCompare ( Extent1 =3D UserStruct1; Extent2 =3D UserStruct2; =20 - return Extent1->ee_block < Extent2->ee_block ? - 1 : + return Extent1->ee_block < Extent2->ee_block ? -1 : Extent1->ee_block > Extent2->ee_block ? 1 : 0; } =20 @@ -413,11 +413,11 @@ Ext4ExtentsMapKeyCompare ( Extent =3D UserStruct; Block =3D (UINT32)(UINTN)StandaloneKey; =20 - if (Block >=3D Extent->ee_block && Block < Extent->ee_block + Ext4GetExt= entLength (Extent)) { + if ((Block >=3D Extent->ee_block) && (Block < Extent->ee_block + Ext4Get= ExtentLength (Extent))) { return 0; } =20 - return Block < Extent->ee_block ? - 1 : + return Block < Extent->ee_block ? -1 : Block > Extent->ee_block ? 1 : 0; } =20 diff --git a/Features/Ext4Pkg/Ext4Dxe/File.c b/Features/Ext4Pkg/Ext4Dxe/Fil= e.c index 4ad7cad8dcf5..ff1746d5640a 100644 --- a/Features/Ext4Pkg/Ext4Dxe/File.c +++ b/Features/Ext4Pkg/Ext4Dxe/File.c @@ -91,7 +91,8 @@ Ext4IsLastPathSegment ( STATIC BOOLEAN Ext4ApplyPermissions ( - IN OUT EXT4_FILE *File, IN UINT64 OpenMode + IN OUT EXT4_FILE *File, + IN UINT64 OpenMode ) { UINT16 NeededPerms; @@ -228,7 +229,7 @@ Ext4Open ( =20 Status =3D Ext4OpenFile (Current, PathSegment, Partition, EFI_FILE_MOD= E_READ, &File); =20 - if (EFI_ERROR (Status) && Status !=3D EFI_NOT_FOUND) { + if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { return Status; } else if (Status =3D=3D EFI_NOT_FOUND) { // We explicitly ignore the EFI_FILE_MODE_CREATE flag, since we don'= t have write support @@ -308,7 +309,7 @@ Ext4CloseInternal ( IN EXT4_FILE *File ) { - if (File =3D=3D File->Partition->Root && !File->Partition->Unmounting) { + if ((File =3D=3D File->Partition->Root) && !File->Partition->Unmounting)= { return EFI_SUCCESS; } =20 @@ -374,7 +375,7 @@ Ext4ReadFile ( EXT4_PARTITION *Partition; EFI_STATUS Status; =20 - File =3D (EXT4_FILE *)This; + File =3D (EXT4_FILE *)This; Partition =3D File->Partition; =20 ASSERT (Ext4FileIsOpenable (File)); @@ -491,12 +492,12 @@ Ext4SetPosition ( File =3D (EXT4_FILE *)This; =20 // Only seeks to 0 (so it resets the ReadDir operation) are allowed - if (Ext4FileIsDir (File) && Position !=3D 0) { + if (Ext4FileIsDir (File) && (Position !=3D 0)) { return EFI_UNSUPPORTED; } =20 // -1 (0xffffff.......) seeks to the end of the file - if (Position =3D=3D (UINT64)- 1) { + if (Position =3D=3D (UINT64)-1) { Position =3D EXT4_INODE_SIZE (File->Inode); } =20 @@ -549,7 +550,7 @@ Ext4GetFileInfo ( Ext4FileMTime (File, &Info->ModificationTime); Ext4FileCreateTime (File, &Info->LastAccessTime); Info->Attribute =3D 0; - Info->Size =3D NeededLength; + Info->Size =3D NeededLength; =20 if (Ext4FileIsDir (File)) { Info->Attribute |=3D EFI_FILE_DIRECTORY; @@ -659,7 +660,7 @@ Ext4GetFilesystemInfo ( Part->SuperBlock.s_free_blocks_count_hi ); =20 - Info->BlockSize =3D Part->BlockSize; + Info->BlockSize =3D Part->BlockSize; Info->Size =3D NeededLength; Info->ReadOnly =3D Part->ReadOnly; Info->VolumeSize =3D MultU64x32 (TotalBlocks, Part->BlockSize); @@ -790,7 +791,7 @@ Ext4DuplicateFile ( EFI_STATUS Status; =20 Partition =3D Original->Partition; - File =3D AllocateZeroPool (sizeof (EXT4_FILE)); + File =3D AllocateZeroPool (sizeof (EXT4_FILE)); =20 if (File =3D=3D NULL) { return NULL; diff --git a/Features/Ext4Pkg/Ext4Dxe/Inode.c b/Features/Ext4Pkg/Ext4Dxe/In= ode.c index 48bfe026a3c2..f692909edf78 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Inode.c +++ b/Features/Ext4Pkg/Ext4Dxe/Inode.c @@ -50,7 +50,7 @@ Ext4CalculateInodeChecksum ( =20 Crc =3D Ext4CalculateChecksum (Partition, &Dummy, sizeof (Dummy), Crc); =20 - RestOfInode =3D &Inode->i_osd2.data_linux.l_i_reserved; + RestOfInode =3D &Inode->i_osd2.data_linux.l_i_reserved; RestOfInodeLength =3D Partition->InodeSize - OFFSET_OF (EXT4_INODE, i_os= d2.data_linux.l_i_reserved); =20 if (HasSecondChecksumField) { @@ -61,7 +61,7 @@ Ext4CalculateInodeChecksum ( =20 // 4 is the size of the i_extra_size field + the size of i_checksum_hi RestOfInodeLength =3D Partition->InodeSize - EXT4_GOOD_OLD_INODE_SIZE = - 4; - RestOfInode =3D &Inode->i_ctime_extra; + RestOfInode =3D &Inode->i_ctime_extra; } =20 Crc =3D Ext4CalculateChecksum (Partition, RestOfInode, RestOfInodeLength= , Crc); @@ -138,14 +138,13 @@ Ext4Read ( &Extent ); =20 - if (Status !=3D EFI_SUCCESS && Status !=3D EFI_NO_MAPPING) { + if ((Status !=3D EFI_SUCCESS) && (Status !=3D EFI_NO_MAPPING)) { return Status; } =20 HasBackingExtent =3D Status !=3D EFI_NO_MAPPING; =20 if (!HasBackingExtent || EXT4_EXTENT_IS_UNINITIALIZED (&Extent)) { - HoleOff =3D BlockOff; =20 if (!HasBackingExtent) { @@ -167,8 +166,8 @@ Ext4Read ( ); ExtentLengthBytes =3D Extent.ee_len * Partition->BlockSize; ExtentLogicalBytes =3D (UINT64)Extent.ee_block * Partition->BlockSiz= e; - ExtentOffset =3D CurrentSeek - ExtentLogicalBytes; - ExtentMayRead =3D (UINTN)(ExtentLengthBytes - ExtentOffset); + ExtentOffset =3D CurrentSeek - ExtentLogicalBytes; + ExtentMayRead =3D (UINTN)(ExtentLengthBytes - ExtentOffset); =20 WasRead =3D ExtentMayRead > RemainingRead ? RemainingRead : ExtentMa= yRead; =20 @@ -187,9 +186,9 @@ Ext4Read ( } =20 RemainingRead -=3D WasRead; - Buffer =3D (VOID *)((CHAR8 *)Buffer + WasRead); - BeenRead +=3D WasRead; - CurrentSeek +=3D WasRead; + Buffer =3D (VOID *)((CHAR8 *)Buffer + WasRead); + BeenRead +=3D WasRead; + CurrentSeek +=3D WasRead; } =20 *Length =3D BeenRead; @@ -214,7 +213,7 @@ Ext4AllocateInode ( EXT4_INODE *Inode; =20 NeedsToZeroRest =3D FALSE; - InodeSize =3D Partition->InodeSize; + InodeSize =3D Partition->InodeSize; =20 // We allocate a structure of at least sizeof(EXT4_INODE), but in the fu= ture, when // write support is added and we need to flush inodes to disk, we could = have a bit better @@ -224,7 +223,7 @@ Ext4AllocateInode ( // is 160 bytes). =20 if (InodeSize < sizeof (EXT4_INODE)) { - InodeSize =3D sizeof (EXT4_INODE); + InodeSize =3D sizeof (EXT4_INODE); NeedsToZeroRest =3D TRUE; } =20 @@ -409,7 +408,8 @@ EXT4_FILE_GET_TIME_GENERIC (MTime, i_mtime); **/ STATIC EXT4_FILE_GET_TIME_GENERIC ( - CrTime, i_crtime + CrTime, + i_crtime ); =20 /** diff --git a/Features/Ext4Pkg/Ext4Dxe/Partition.c b/Features/Ext4Pkg/Ext4Dx= e/Partition.c index afa0392024ec..316807497dd4 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Partition.c +++ b/Features/Ext4Pkg/Ext4Dxe/Partition.c @@ -50,12 +50,12 @@ Ext4OpenPartition ( =20 Part->Interface.Revision =3D EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION; Part->Interface.OpenVolume =3D Ext4OpenVolume; - Status =3D gBS->InstallMultipleProtocolInterfaces ( - &DeviceHandle, - &gEfiSimpleFileSystemProtocolGuid, - &Part->Interface, - NULL - ); + Status =3D gBS->InstallMultipleProtocolInterfaces ( + &DeviceHandle, + &gEfiSimpleFileSystemProtocolGuid, + &Part->Interface, + NULL + ); =20 if (EFI_ERROR (Status)) { FreePool (Part); diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4D= xe/Superblock.c index 9c3f7a9e7bfb..a7dbe9bf0fec 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c +++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c @@ -85,7 +85,7 @@ Ext4SuperblockValidate ( return FALSE; } =20 - if (Sb->s_rev_level !=3D EXT4_DYNAMIC_REV && Sb->s_rev_level !=3D EXT4_G= OOD_OLD_REV) { + if ((Sb->s_rev_level !=3D EXT4_DYNAMIC_REV) && (Sb->s_rev_level !=3D EXT= 4_GOOD_OLD_REV)) { return FALSE; } =20 @@ -188,11 +188,11 @@ Ext4OpenSuperblock ( Partition->FeaturesCompat =3D Sb->s_feature_compat; Partition->FeaturesIncompat =3D Sb->s_feature_incompat; Partition->FeaturesRoCompat =3D Sb->s_feature_ro_compat; - Partition->InodeSize =3D Sb->s_inode_size; + Partition->InodeSize =3D Sb->s_inode_size; } else { // GOOD_OLD_REV Partition->FeaturesCompat =3D Partition->FeaturesIncompat =3D Partitio= n->FeaturesRoCompat =3D 0; - Partition->InodeSize =3D EXT4_GOOD_OLD_INODE_SIZE; + Partition->InodeSize =3D EXT4_GOOD_OLD_INODE_SIZE; } =20 // Now, check for the feature set of the filesystem @@ -220,7 +220,8 @@ Ext4OpenSuperblock ( =20 // At the time of writing, it's the only supported checksum. if (Partition->FeaturesCompat & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM && - Sb->s_checksum_type !=3D EXT4_CHECKSUM_CRC32C) { + (Sb->s_checksum_type !=3D EXT4_CHECKSUM_CRC32C)) + { return EFI_UNSUPPORTED; } =20 @@ -250,7 +251,7 @@ Ext4OpenSuperblock ( return EFI_UNSUPPORTED; } =20 - Partition->NumberBlocks =3D EXT4_BLOCK_NR_FROM_HALFS (Partition, Sb->s_b= locks_count, Sb->s_blocks_count_hi); + Partition->NumberBlocks =3D EXT4_BLOCK_NR_FROM_HALFS (Partition, Sb= ->s_blocks_count, Sb->s_blocks_count_hi); Partition->NumberBlockGroups =3D DivU64x32 (Partition->NumberBlocks, Sb-= >s_blocks_per_group); =20 DEBUG (( @@ -266,7 +267,7 @@ Ext4OpenSuperblock ( Partition->DescSize =3D EXT4_OLD_BLOCK_DESC_SIZE; } =20 - if (Partition->DescSize < EXT4_64BIT_BLOCK_DESC_SIZE && EXT4_IS_64_BIT (= Partition)) { + if ((Partition->DescSize < EXT4_64BIT_BLOCK_DESC_SIZE) && EXT4_IS_64_BIT= (Partition)) { // 64 bit filesystems need DescSize to be 64 bytes return EFI_VOLUME_CORRUPTED; } --=20 2.35.1 -=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 (#88558): https://edk2.groups.io/g/devel/message/88558 Mute This Topic: https://groups.io/mt/90324104/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- From nobody Fri May 17 05:54:40 2024 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+88557+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+88557+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1649368915; cv=none; d=zohomail.com; s=zohoarc; b=DrtojTNcSJF5qJBB2GNr76aFfWaUodfoj5H3xKJPJez4P09Wd8yDrsrx7Vza2vZVdAQeXaUMwCl9BBH+QhISQ5mQFVmG9Fp+P3jU15jMY0izVKlRja3nJ2KomphtlsG2lFXv8LP/8j6IO7XZPT+O59XJBPG2Dfy0KwqS4uKKZDA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1649368915; h=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=frAOgzGoXXQjffBl7dmE4yoZZoPWaOH99HNJJKEFnGc=; b=a0qNbPyvLFM9/umdT9JWeKhdE6In5XJ+gTlP8N3QXA6hF04eK4oV/gMVxkSnTLjjaF8SNrtdCnPmHFgU0CNo8bo/qNqSOHZBLQBQ+tJfa70bosWgdm/vNEOAXZce8lA2UbBT4uzP5oVIUn+O9oxHXlXQfW3wuJiH83xJsUfHlDI= 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+88557+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 1649368915083231.62853724997626; Thu, 7 Apr 2022 15:01:55 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id OqwUYY1788612xAeOxvvRPjG; Thu, 07 Apr 2022 15:01:54 -0700 X-Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mx.groups.io with SMTP id smtpd.web08.430.1649368913400520530 for ; Thu, 07 Apr 2022 15:01:53 -0700 X-Received: by mail-wr1-f45.google.com with SMTP id d29so9942085wra.10 for ; Thu, 07 Apr 2022 15:01:53 -0700 (PDT) X-Gm-Message-State: UVD3V13DYLOn2Lde2RLKQre7x1787277AA= X-Google-Smtp-Source: ABdhPJw70bb5YB8LpIcW+bdS6Q9Mt1GyJsLoQEgzZzkXrWGi6NHgKCRAGbtcpho0lZH9tbQxMtH+bw== X-Received: by 2002:a1c:ed18:0:b0:37e:7a1d:a507 with SMTP id l24-20020a1ced18000000b0037e7a1da507mr14175691wmh.187.1649368911417; Thu, 07 Apr 2022 15:01:51 -0700 (PDT) X-Received: from PC-PEDRO-ARCH.lan ([2001:8a0:7280:5801:9441:3dce:686c:bfc7]) by smtp.gmail.com with ESMTPSA id m18-20020a05600c4f5200b0038e8f9d7b57sm2813379wmq.42.2022.04.07.15.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 15:01:51 -0700 (PDT) From: "Pedro Falcato" To: devel@edk2.groups.io Cc: Leif Lindholm , Michael D Kinney Subject: [edk2-devel] [PATCH edk2-platforms 3/3] Ext4Pkg: Add ext2/3 support Date: Thu, 7 Apr 2022 23:01:46 +0100 Message-Id: <20220407220146.149580-4-pedro.falcato@gmail.com> In-Reply-To: <20220407220146.149580-1-pedro.falcato@gmail.com> References: <20220407220146.149580-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-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1649368914; bh=bljrqz0I7MF132aJUQ2+h+raB23mOFnzhSV1XbfNnDk=; h=Cc:Date:From:Reply-To:Subject:To; b=M0YhPECx3wfAHoYPa50Xzxk1jNziG9dta9Tmo7TvdKeRfXiWDYBZ6LuhtWDoXYdsGp2 4xShV/MMm8kAcX7Hz0+Gd7IVFMSG8/HJ8thS9GNSzC8VqF+sUhSK8sg6B2FLamF2Kqdbq DhN+3N+VcmUe1jING8FmYwvZdd4mbFfXvWo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1649368916281100009 Content-Type: text/plain; charset="utf-8" BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3745 Adds ext2/3 support by supporting (legacy) block maps. Also fixes a bug regarding uninitialised extents. Cc: Leif Lindholm Cc: Michael D Kinney Signed-off-by: Pedro Falcato --- Features/Ext4Pkg/Ext4Dxe/BlockMap.c | 279 ++++++++++++++++++++++++++ Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h | 2 + Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h | 18 ++ Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf | 1 + Features/Ext4Pkg/Ext4Dxe/Extents.c | 17 +- Features/Ext4Pkg/Ext4Dxe/Inode.c | 9 +- Features/Ext4Pkg/Ext4Dxe/Superblock.c | 7 +- 7 files changed, 318 insertions(+), 15 deletions(-) create mode 100644 Features/Ext4Pkg/Ext4Dxe/BlockMap.c diff --git a/Features/Ext4Pkg/Ext4Dxe/BlockMap.c b/Features/Ext4Pkg/Ext4Dxe= /BlockMap.c new file mode 100644 index 000000000000..6e8ccaa82437 --- /dev/null +++ b/Features/Ext4Pkg/Ext4Dxe/BlockMap.c @@ -0,0 +1,279 @@ +/** @file + Implementation of routines that deal with ext2/3 block maps. + + Copyright (c) 2022 Pedro Falcato All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include + +// Note: The largest path we can take uses up 4 indices +#define EXT4_MAX_BLOCK_PATH 4 + +typedef enum ext4_logical_block_type { + EXT4_TYPE_DIRECT_BLOCK =3D 0, + EXT4_TYPE_SINGLY_BLOCK, + EXT4_TYPE_DOUBLY_BLOCK, + EXT4_TYPE_TREBLY_BLOCK, + EXT4_TYPE_BAD_BLOCK +} EXT4_LOGICAL_BLOCK_TYPE; + +/** + @brief Detect the type of path the logical block will follow + + @param[in] LogicalBlock The logical block + @param[in] Partition Pointer to an EXT4_PARTITION + @return The type of path the logical block will need to follow + */ +STATIC +EXT4_LOGICAL_BLOCK_TYPE +Ext4DetectBlockType ( + IN UINT32 LogicalBlock, + IN CONST EXT4_PARTITION *Partition + ) +{ + UINT32 Entries; + UINT32 MinSinglyBlock; + UINT32 MinDoublyBlock; + UINT32 MinTreblyBlock; + UINT32 MinQuadBlock; + + Entries =3D (Partition->BlockSize / sizeof (UINT32)); + MinSinglyBlock =3D EXT4_DBLOCKS; + MinDoublyBlock =3D Entries + MinSinglyBlock; + MinTreblyBlock =3D Entries * Entries + MinDoublyBlock; + MinQuadBlock =3D Entries * Entries * Entries + MinTreblyBlock; // Does= n't actually exist + + if (LogicalBlock < MinSinglyBlock) { + return EXT4_TYPE_DIRECT_BLOCK; + } else if ((LogicalBlock >=3D MinSinglyBlock) && (LogicalBlock < MinDoub= lyBlock)) { + return EXT4_TYPE_SINGLY_BLOCK; + } else if ((LogicalBlock >=3D MinDoublyBlock) && (LogicalBlock < MinTreb= lyBlock)) { + return EXT4_TYPE_DOUBLY_BLOCK; + } else if (((LogicalBlock >=3D MinTreblyBlock) && (LogicalBlock < MinQua= dBlock))) { + return EXT4_TYPE_TREBLY_BLOCK; + } else { + return EXT4_TYPE_BAD_BLOCK; + } +} + +/** + @brief Get a block's path in indices + + @param[in] Partition Pointer to an EXT4_PARTITION + @param[in] LogicalBlock Logical block + @param[out] BlockPath Pointer to an array of EXT4_MAX_BLOCK_PATH = elements, where the + indices we'll need to read are inserted. + @return The number of path elements that are required (and were inserte= d in BlockPath) + */ +UINTN +Ext4GetBlockPath ( + IN CONST EXT4_PARTITION *Partition, + IN UINT32 LogicalBlock, + OUT EXT4_BLOCK_NR BlockPath[EXT4_MAX_BLOCK_PATH] + ) +{ + // The logic behind the block map is very much like a page table + // Let's think of blocks with 512 entries (exactly like a page table on = x64). + // On doubly indirect block paths, we subtract the min doubly blocks fro= m the logical block. + // The top 9 bits of the result are the index inside the dind block, the= bottom 9 bits are the + // index inside the ind block. Since Entries is always a power of 2, ent= ries - 1 will give us + // a mask of the BlockMapBits. + // Note that all this math could be done with ands and shifts (similar i= mplementations exist + // in a bunch of other places), but I'm doing it a simplified way with d= ivs and modulus, + // since it's not going to be a bottleneck anyway. + + UINT32 Entries; + UINT32 EntriesEntries; + UINT32 MinSinglyBlock; + UINT32 MinDoublyBlock; + UINT32 MinTreblyBlock; + + EXT4_LOGICAL_BLOCK_TYPE Type; + + Entries =3D (Partition->BlockSize / sizeof (UINT32)); + EntriesEntries =3D Entries * Entries; + + MinSinglyBlock =3D EXT4_DBLOCKS; + MinDoublyBlock =3D Entries + MinSinglyBlock; + MinTreblyBlock =3D EntriesEntries + MinDoublyBlock; + + Type =3D Ext4DetectBlockType (LogicalBlock, Partition); + + switch (Type) { + case EXT4_TYPE_DIRECT_BLOCK: + BlockPath[0] =3D LogicalBlock; + break; + case EXT4_TYPE_SINGLY_BLOCK: + BlockPath[0] =3D EXT4_IND_BLOCK; + BlockPath[1] =3D LogicalBlock - EXT4_DBLOCKS; + break; + case EXT4_TYPE_DOUBLY_BLOCK: + BlockPath[0] =3D EXT4_DIND_BLOCK; + LogicalBlock -=3D MinDoublyBlock; + BlockPath[1] =3D LogicalBlock / Entries; + BlockPath[2] =3D LogicalBlock % Entries; + break; + case EXT4_TYPE_TREBLY_BLOCK: + BlockPath[0] =3D EXT4_DIND_BLOCK; + LogicalBlock -=3D MinTreblyBlock; + BlockPath[1] =3D LogicalBlock / EntriesEntries; + BlockPath[2] =3D (LogicalBlock % EntriesEntries) / Entries; + BlockPath[3] =3D (LogicalBlock % EntriesEntries) % Entries; + break; + default: + // EXT4_TYPE_BAD_BLOCK + return -1; + } + + return Type + 1; +} + +/** + @brief Get an extent from a block map + Note: Also parses file holes and creates uninitialised extents from the= m. + + @param[in] Buffer Buffer of block pointers + @param[in] IndEntries Number of entries in this block pointer tab= le + @param[in] StartIndex The start index from which we want to find = a contiguous extent + @param[out] Extent Pointer to the resulting EXT4_EXTENT + */ +VOID +Ext4GetExtentInBlockMap ( + IN CONST UINT32 *Buffer, + IN CONST UINT32 IndEntries, + IN UINT32 StartIndex, + OUT EXT4_EXTENT *Extent + ) +{ + UINT32 Index; + UINT32 FirstBlock; + UINT32 LastBlock; + UINT16 Count; + + Count =3D 1; + LastBlock =3D Buffer[StartIndex]; + FirstBlock =3D LastBlock; + + if (FirstBlock =3D=3D EXT4_BLOCK_FILE_HOLE) { + // File hole, let's see how many blocks this hole spans + Extent->ee_start_hi =3D 0; + Extent->ee_start_lo =3D 0; + + for (Index =3D StartIndex + 1; Index < IndEntries; Index++) { + if (Count =3D=3D EXT4_EXTENT_MAX_INITIALIZED - 1) { + // We've reached the max size of an uninit extent, break + break; + } + + if (Buffer[Index] =3D=3D EXT4_BLOCK_FILE_HOLE) { + Count++; + } else { + break; + } + } + + // We mark the extent as uninitialised, although there's a difference = between uninit + // extents and file holes. + Extent->ee_len =3D EXT4_EXTENT_MAX_INITIALIZED + Count; + return; + } + + for (Index =3D StartIndex + 1; Index < IndEntries; Index++) { + if (Count =3D=3D EXT4_EXTENT_MAX_INITIALIZED) { + // We've reached the max size of an extent, break + break; + } + + if ((Buffer[Index] =3D=3D LastBlock + 1) && (Buffer[Index] !=3D EXT4_B= LOCK_FILE_HOLE)) { + Count++; + } else { + break; + } + + LastBlock =3D Buffer[Index]; + } + + Extent->ee_start_lo =3D FirstBlock; + Extent->ee_start_hi =3D 0; + Extent->ee_len =3D Count; +} + +/** + Retrieves an extent from an EXT2/3 inode (with a blockmap). + @param[in] Partition Pointer to the opened EXT4 partition. + @param[in] File Pointer to the opened file. + @param[in] LogicalBlock Block number which the returned extent mu= st cover. + @param[out] Extent Pointer to the output buffer, where the e= xtent will be copied to. + + @retval EFI_SUCCESS Retrieval was succesful. + @retval EFI_NO_MAPPING Block has no mapping. +**/ +EFI_STATUS +Ext4GetBlocks ( + IN EXT4_PARTITION *Partition, + IN EXT4_FILE *File, + IN EXT4_BLOCK_NR LogicalBlock, + OUT EXT4_EXTENT *Extent + ) +{ + EXT4_INODE *Inode; + EXT4_BLOCK_NR BlockPath[EXT4_MAX_BLOCK_PATH]; + UINTN BlockPathLength; + UINTN Index; + UINT32 *Buffer; + EFI_STATUS Status; + UINT32 Block; + UINT32 BlockIndex; + + Inode =3D File->Inode; + + BlockPathLength =3D Ext4GetBlockPath (Partition, LogicalBlock, BlockPath= ); + + if (BlockPathLength =3D=3D (UINTN)-1) { + // Bad logical block (out of range) + return EFI_NO_MAPPING; + } + + Extent->ee_block =3D LogicalBlock; + + if (BlockPathLength =3D=3D 1) { + // Fast path for blocks 0 - 12 that skips allocations + Ext4GetExtentInBlockMap (Inode->i_data, EXT4_DBLOCKS, BlockPath[0], Ex= tent); + + return EFI_SUCCESS; + } + + Buffer =3D AllocatePool (Partition->BlockSize); + if (Buffer =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // Note the BlockPathLength - 1 so we don't end up reading the final blo= ck + for (Index =3D 0; Index < BlockPathLength - 1; Index++) { + BlockIndex =3D BlockPath[Index]; + + if (Index =3D=3D 0) { + Block =3D Inode->i_data[BlockIndex]; + } else { + Block =3D Buffer[BlockIndex]; + } + + if (Block =3D=3D EXT4_BLOCK_FILE_HOLE) { + FreePool (Buffer); + return EFI_NO_MAPPING; + } + + Status =3D Ext4ReadBlocks (Partition, Buffer, 1, Block); + + if (EFI_ERROR (Status)) { + FreePool (Buffer); + return Status; + } + } + + Ext4GetExtentInBlockMap (Buffer, Partition->BlockSize / sizeof (UINT32),= BlockPath[BlockPathLength - 1], Extent); + FreePool (Buffer); + + return EFI_SUCCESS; +} diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h b/Features/Ext4Pkg/Ext4Dxe= /Ext4Disk.h index 5f812215fbb8..a55cd2fa68ad 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Disk.h @@ -468,4 +468,6 @@ typedef UINT32 EXT4_INO_NR; // 2 is always the root inode number in ext4 #define EXT4_ROOT_INODE_NR 2 =20 +#define EXT4_BLOCK_FILE_HOLE 0 + #endif diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h b/Features/Ext4Pkg/Ext4Dxe/= Ext4Dxe.h index 03e0586cbb05..b1508482b0a7 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.h @@ -1151,4 +1151,22 @@ Ext4GetExtentLength ( IN CONST EXT4_EXTENT *Extent ); =20 +/** + Retrieves an extent from an EXT2/3 inode (with a blockmap). + @param[in] Partition Pointer to the opened EXT4 partition. + @param[in] File Pointer to the opened file. + @param[in] LogicalBlock Block number which the returned extent mu= st cover. + @param[out] Extent Pointer to the output buffer, where the e= xtent will be copied to. + + @retval EFI_SUCCESS Retrieval was succesful. + @retval EFI_NO_MAPPING Block has no mapping. +**/ +EFI_STATUS +Ext4GetBlocks ( + IN EXT4_PARTITION *Partition, + IN EXT4_FILE *File, + IN EXT4_BLOCK_NR LogicalBlock, + OUT EXT4_EXTENT *Extent + ); + #endif diff --git a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf b/Features/Ext4Pkg/Ext4Dx= e/Ext4Dxe.inf index 12e89bf1fdfc..deaf89fb3743 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf +++ b/Features/Ext4Pkg/Ext4Dxe/Ext4Dxe.inf @@ -111,6 +111,7 @@ Collation.c Ext4Disk.h Ext4Dxe.h + BlockMap.c =20 [Packages] MdePkg/MdePkg.dec diff --git a/Features/Ext4Pkg/Ext4Dxe/Extents.c b/Features/Ext4Pkg/Ext4Dxe/= Extents.c index e920eed090fd..c3874df71751 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Extents.c +++ b/Features/Ext4Pkg/Ext4Dxe/Extents.c @@ -1,7 +1,7 @@ /** @file Extent related routines =20 - Copyright (c) 2021 Pedro Falcato All rights reserved. + Copyright (c) 2021 - 2022 Pedro Falcato All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 @@ -244,10 +244,6 @@ Ext4GetExtent ( =20 DEBUG ((DEBUG_FS, "[ext4] Looking up extent for block %lu\n", LogicalBlo= ck)); =20 - if (!(Inode->i_flags & EXT4_EXTENTS_FL)) { - return EFI_UNSUPPORTED; - } - // ext4 does not have support for logical block numbers bigger than UINT= 32_MAX if (LogicalBlock > (UINT32)-1) { return EFI_NO_MAPPING; @@ -261,6 +257,17 @@ Ext4GetExtent ( return EFI_SUCCESS; } =20 + if (!(Inode->i_flags & EXT4_EXTENTS_FL)) { + // If this is an older ext2/ext3 filesystem, emulate Ext4GetExtent usi= ng the block map + Status =3D Ext4GetBlocks (Partition, File, LogicalBlock, Extent); + + if (!EFI_ERROR (Status)) { + Ext4CacheExtents (File, Extent, 1); + } + + return Status; + } + // Slow path, we'll need to read from disk and (try to) cache those exte= nts. =20 ExtHeader =3D Ext4GetInoExtentHeader (Inode); diff --git a/Features/Ext4Pkg/Ext4Dxe/Inode.c b/Features/Ext4Pkg/Ext4Dxe/In= ode.c index f692909edf78..831f5946e870 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Inode.c +++ b/Features/Ext4Pkg/Ext4Dxe/Inode.c @@ -1,7 +1,7 @@ /** @file Inode related routines =20 - Copyright (c) 2021 Pedro Falcato All rights reserved. + Copyright (c) 2021 - 2022 Pedro Falcato All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent =20 EpochToEfiTime copied from EmbeddedPkg/Library/TimeBaseLib.c @@ -150,8 +150,9 @@ Ext4Read ( if (!HasBackingExtent) { HoleLen =3D Partition->BlockSize - HoleOff; } else { - // Uninitialized extents behave exactly the same as file holes. - HoleLen =3D Ext4GetExtentLength (&Extent) - HoleOff; + // Uninitialized extents behave exactly the same as file holes, ex= cept they have + // blocks already allocated to them. + HoleLen =3D (Ext4GetExtentLength (&Extent) * Partition->BlockSize)= - HoleOff; } =20 WasRead =3D HoleLen > RemainingRead ? RemainingRead : HoleLen; @@ -176,7 +177,7 @@ Ext4Read ( if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, - "[ext4] Error %x reading [%lu, %lu]\n", + "[ext4] Error %r reading [%lu, %lu]\n", Status, ExtentStartBytes + ExtentOffset, ExtentStartBytes + ExtentOffset + WasRead - 1 diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4D= xe/Superblock.c index a7dbe9bf0fec..47fc3a65507a 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Superblock.c +++ b/Features/Ext4Pkg/Ext4Dxe/Superblock.c @@ -1,7 +1,7 @@ /** @file Superblock managing routines =20 - Copyright (c) 2021 Pedro Falcato All rights reserved. + Copyright (c) 2021 - 2022 Pedro Falcato All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 @@ -208,11 +208,6 @@ Ext4OpenSuperblock ( return EFI_UNSUPPORTED; } =20 - // This should be removed once we add ext2/3 support in the future. - if ((Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_EXTENTS) =3D=3D= 0) { - return EFI_UNSUPPORTED; - } - if (EXT4_HAS_INCOMPAT (Partition, EXT4_FEATURE_INCOMPAT_RECOVER)) { DEBUG ((DEBUG_WARN, "[ext4] Needs journal recovery, mounting read-only= \n")); Partition->ReadOnly =3D TRUE; --=20 2.35.1 -=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 (#88557): https://edk2.groups.io/g/devel/message/88557 Mute This Topic: https://groups.io/mt/90324102/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-