From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=E0WEvcFx; spf=temperror, err=temporary DNS error (domain: gmail.com, ip: 209.85.221.45, mailfrom: pedro.falcato@gmail.com) Received: by mail-wr1-f45.google.com with SMTP id w4so9925907wrg.12 for ; Thu, 07 Apr 2022 15:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NinpyOMGuqjnVgRn/v96liBQ5XXJ1/nEDjx1weZK3fE=; b=E0WEvcFx7YRiuCqRWoGoy6NJUfNTJcvary46QgeKW8NseeN58xS8hV3HD4TagMKsz6 AsduK6LctSDWEv5O5157aQy6KTDMtohIzliS6jMVT1IQntkB1a/l+iX8wPPc9p9sAnfc a+mzUAmaTeVhiIkYy+Eo0bW/vsgi1LiPq8xTZI44UjPqRzVcXKz9ZW9nu6tiD32kS+7g lkAeEJHmUzzzlgj/1HBEhbKINOLArzs8MmLgba6DNQ+5YpPB1nZ0MvayAIdvllVtwIf+ iJkeNh43j8TvefRDmgS52N8liEn3m4Nb75zLBkXFwwSQDvmEfVO50wIhSpY9452k21g+ hlYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NinpyOMGuqjnVgRn/v96liBQ5XXJ1/nEDjx1weZK3fE=; b=jY0QnisMcKDPLQBTveYqIu38FC2cKVgaS92xQUwhQ16+0oXppXq7g5kTbKYoQNZboK nJYpvGzcLkuepbqZ4NtDwYAmgQPG2lTS3Xji1g/oQmwXqlti9bpXpKnvBqiCadT2oyh7 mPl8jiEJ5QBiHOYXKrtfysS7lu+novfY1CZF52JkGuEhXwtJIhnwgIYOtzRkxvyiSAhn 04FULz4U+zu1r6KANkHuQuyKWmcusDJGbL4MIpVzAusciNDL25YAy7Rn2GIutI06wi11 dRAx8VYy/mSODP+3Otha29rf5YSHLSudOH5krSb7XHMCiK0iVekzzC/iO6TKQYOXUbjl kIWA== X-Gm-Message-State: AOAM530HfzmEqOY6M3JD7TzxMKkfBwLSVbsyrrHeHUtEHz4zn57f+qqU Q4c2VJdsjsmXgUAUZDe7WuCwfiMURkFTqQ== 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) Return-Path: 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: [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> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407220146.149580-1-pedro.falcato@gmail.com> References: <20220407220146.149580-1-pedro.falcato@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Previously, Ext4Pkg was formatted using uncrustify with an older config file. 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/Ext4Dxe/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; Iso639Language = (BOOLEAN)(ProtocolGuid == &gEfiUnicodeCollationProtocolGuid); - RetStatus = EFI_UNSUPPORTED; + RetStatus = EFI_UNSUPPORTED; GetEfiGlobalVariable2 (VariableName, (VOID **)&Language, NULL); Status = gBS->LocateHandleBuffer ( @@ -96,7 +96,7 @@ Ext4InitialiseUnicodeCollationInternal ( if (BestLanguage != NULL) { FreePool (BestLanguage); gUnicodeCollationInterface = Uci; - RetStatus = EFI_SUCCESS; + RetStatus = EFI_SUCCESS; break; } } diff --git a/Features/Ext4Pkg/Ext4Dxe/Directory.c b/Features/Ext4Pkg/Ext4Dxe/Directory.c index 9e003ea43719..682f66ad5525 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Directory.c +++ b/Features/Ext4Pkg/Ext4Dxe/Directory.c @@ -121,7 +121,7 @@ Ext4RetrieveDirent ( Off = 0; - Inode = Directory->Inode; + Inode = Directory->Inode; DirInoSize = EXT4_INODE_SIZE (Inode); DivU64x32Remainder (DirInoSize, Partition->BlockSize, &BlockRemainder); @@ -141,7 +141,7 @@ Ext4RetrieveDirent ( } for (BlockOffset = 0; BlockOffset < Partition->BlockSize; ) { - Entry = (EXT4_DIR_ENTRY *)(Buf + BlockOffset); + Entry = (EXT4_DIR_ENTRY *)(Buf + BlockOffset); RemainingBlock = Partition->BlockSize - BlockOffset; // Check if the minimum directory entry fits inside [BlockOffset, EndOfBlock] if (RemainingBlock < EXT4_MIN_DIR_ENTRY_LEN) { @@ -154,7 +154,7 @@ Ext4RetrieveDirent ( return EFI_VOLUME_CORRUPTED; } - if (Entry->name_len > RemainingBlock || Entry->rec_len > RemainingBlock) { + if ((Entry->name_len > RemainingBlock) || (Entry->rec_len > RemainingBlock)) { // Corrupted filesystem FreePool (Buf); return EFI_VOLUME_CORRUPTED; @@ -191,8 +191,9 @@ Ext4RetrieveDirent ( continue; } - if (Entry->name_len == StrLen (Name) && - !Ext4StrCmpInsensitive (DirentUcs2Name, (CHAR16 *)Name)) { + if ((Entry->name_len == StrLen (Name)) && + !Ext4StrCmpInsensitive (DirentUcs2Name, (CHAR16 *)Name)) + { ToCopy = MIN (Entry->rec_len, sizeof (EXT4_DIR_ENTRY)); 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. - if (Offset > DivU64x32 ((UINT64)- 1, Partition->BlockSize)) { + if (Offset > DivU64x32 ((UINT64)-1, Partition->BlockSize)) { return EFI_INVALID_PARAMETER; } - if (Length > (UINTN)- 1/Partition->BlockSize) { + if (Length > (UINTN)-1/Partition->BlockSize) { return EFI_INVALID_PARAMETER; } @@ -94,7 +94,7 @@ Ext4AllocAndReadBlocks ( Length = NumberBlocks * Partition->BlockSize; - if (Length > (UINTN)- 1/Partition->BlockSize) { + if (Length > (UINTN)-1/Partition->BlockSize) { return NULL; } 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 @@ #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 implemented 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 // 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) -**/ + **/ #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; @@ -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; -STATIC_ASSERT (sizeof (EXT4_SUPERBLOCK) == 1024, "ext4 superblock struct has incorrect size"); +STATIC_ASSERT ( + sizeof (EXT4_SUPERBLOCK) == 1024, + "ext4 superblock struct has incorrect size" + ); typedef struct { UINT32 bg_block_bitmap_lo; @@ -355,7 +358,8 @@ typedef struct _Ext4_I_OSD2_Hurd { } EXT4_OSD2_HURD; typedef union { - // Note: Toolchain-specific defines (such as "linux") stops us from using 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; @@ -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 uninitialized. - * Long story short, it's an extent that behaves as a file hole but has blocks 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) 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 ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName ); extern EFI_COMPONENT_NAME_PROTOCOL gExt4ComponentName; @@ -175,9 +175,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL 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 ); /** @@ -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 ); /** @@ -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 ); EFI_DRIVER_BINDING_PROTOCOL gExt4BindingProtocol = @@ -309,11 +309,11 @@ EFI_DRIVER_BINDING_PROTOCOL gExt4BindingProtocol = EFI_STATUS EFIAPI Ext4ComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName + 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; - DiskIo = NULL; + DiskIo = NULL; BlockIo = NULL; // @@ -655,7 +655,7 @@ Ext4IsBindingSupported ( Status = 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 = gBS->OpenProtocol ( ControllerHandle, &gEfiBlockIoProtocolGuid, - (VOID **) &BlockIo, + (VOID **)&BlockIo, BindingProtocol->DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL @@ -687,20 +688,22 @@ Ext4IsBindingSupported ( // if (DiskIo != NULL) { gBS->CloseProtocol ( - ControllerHandle, - &gEfiDiskIoProtocolGuid, - BindingProtocol->DriverBindingHandle, - ControllerHandle - ); + ControllerHandle, + &gEfiDiskIoProtocolGuid, + BindingProtocol->DriverBindingHandle, + ControllerHandle + ); } + if (BlockIo != NULL) { gBS->CloseProtocol ( - ControllerHandle, - &gEfiBlockIoProtocolGuid, - BindingProtocol->DriverBindingHandle, - ControllerHandle - ); + ControllerHandle, + &gEfiBlockIoProtocolGuid, + BindingProtocol->DriverBindingHandle, + ControllerHandle + ); } + return Status; } @@ -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 -#include -#include -#include #include #include +#include #include -#include +#include +#include #include +#include +#include #include -#include #include "Ext4Disk.h" @@ -40,7 +40,8 @@ @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. @retval EFI_SUCCESS The opening was successful. @@ -54,8 +55,8 @@ Ext4OpenPartition ( IN EFI_BLOCK_IO_PROTOCOL *BlockIo ); -typedef struct _Ext4File EXT4_FILE; -typedef struct _Ext4_Dentry EXT4_DENTRY; +typedef struct _Ext4File EXT4_FILE; +typedef struct _Ext4_Dentry EXT4_DENTRY; typedef struct _Ext4_PARTITION { EFI_SIMPLE_FILE_SYSTEM_PROTOCOL Interface; @@ -88,12 +89,12 @@ typedef struct _Ext4_PARTITION { /** 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 opening 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 list of - children. Therefore, the dentry tree does not accurately reflect the filesystem - 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; }; -#define EXT4_DENTRY_FROM_DENTRY_LIST(Node) BASE_CR (Node, EXT4_DENTRY, ListNode) +#define EXT4_DENTRY_FROM_DENTRY_LIST(Node) BASE_CR(Node, EXT4_DENTRY, ListNode) /** 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 ); /** @@ -147,7 +148,8 @@ Ext4UnrefDentry ( /** Opens and parses the superblock. - @param[out] Partition Partition structure to fill with filesystem details. + @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 ); /** - 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 future. @param[in] Partition Pointer to the opened ext4 partition. @param[in] NumberBlocks Length of the read, in filesystem blocks. @@ -244,13 +246,15 @@ Ext4AllocAndReadBlocks ( ); /** - 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). @param[in] Partition Pointer to the opened ext4 partition. @return TRUE if EXT4_FEATURE_INCOMPAT_64BIT is enabled, else FALSE. **/ -#define EXT4_IS_64_BIT(Partition) ((Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_64BIT) != 0) +#define EXT4_IS_64_BIT(Partition) \ + ((Partition->FeaturesIncompat & EXT4_FEATURE_INCOMPAT_64BIT) != 0) /** Composes an EXT4_BLOCK_NR safely, from two halfs. @@ -261,8 +265,8 @@ Ext4AllocAndReadBlocks ( @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 /** Retrieves a block group descriptor of the ext4 filesystem. @@ -283,15 +287,16 @@ Ext4GetBlockGroupDesc ( @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 to the read inode. + @param[out] OutIno Pointer to where it will be stored a pointer to the +read inode. @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 ); /** @@ -302,7 +307,8 @@ Ext4ReadInode ( @return The number of bytes. **/ -#define EXT4_BLOCK_TO_BYTES(Partition, Block) MultU64x32 (Block, Partition->BlockSize) +#define EXT4_BLOCK_TO_BYTES(Partition, Block) \ + MultU64x32(Block, Partition->BlockSize) /** 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 bytes. - After a succesful read, it's updated to the number of read bytes. + After a succesful read, it's updated to the +number of read bytes. @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 ); /** @@ -331,24 +338,27 @@ Ext4Read ( @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) /** 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 must cover. - @param[out] Extent Pointer to the output buffer, where the extent will be copied to. + @param[in] LogicalBlock Block number which the returned extent must +cover. + @param[out] Extent Pointer to the output buffer, where the extent +will be copied to. @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 ); struct _Ext4File { @@ -369,7 +379,8 @@ struct _Ext4File { EXT4_DENTRY *Dentry; }; -#define EXT4_FILE_FROM_OPEN_FILES_NODE(Node) BASE_CR (Node, EXT4_FILE, OpenFilesListNode) +#define EXT4_FILE_FROM_OPEN_FILES_NODE(Node) \ + BASE_CR(Node, EXT4_FILE, OpenFilesListNode) /** 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 ); @@ -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 ); /** @@ -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 ); /** @@ -447,20 +458,22 @@ Ext4AllocateInode ( Open the root directory on a volume. @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 handle for the - root directory. + @param[out] Root A pointer to the location to return the opened file handle +for the root directory. @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 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 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 are no +longer valid. To access the files on the new medium, the volume must be reopened +with OpenVolume(). **/ EFI_STATUS @@ -501,30 +514,32 @@ Ext4CloseInternal ( /** Opens a new file relative to the source file's location. - @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 handle for the new - file. - @param[in] FileName The Null-terminated string of the name of the file 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 combinations 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 case 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 handle +for the new file. + @param[in] FileName The Null-terminated string of the name of the file 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 combinations +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 case +these are the attribute bits for the newly created file. @retval EFI_SUCCESS The file was opened. - @retval EFI_NOT_FOUND The specified file could not be found on the 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 open a file for write - when the media is write-protected. + @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open 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. **/ @@ -541,8 +556,8 @@ Ext4Open ( /** Closes a specified file handle. - @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file - handle to close. + @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is +the file handle to close. @retval EFI_SUCCESS The file was closed. @@ -556,11 +571,13 @@ Ext4Close ( /** Close and delete the file handle. - @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. - @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. + @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. **/ EFI_STATUS @@ -572,21 +589,23 @@ Ext4Delete ( /** Reads data from a file. - @param[in] This A pointer to the EFI_FILE_PROTOCOL instance that is the file - handle to read data from. - @param[in out] BufferSize On input, the size of the Buffer. On output, 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 instance +that is the file handle to read data from. + @param[in out] BufferSize On input, the size of the Buffer. On output, +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. @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 beyond the end of the file. + @retval EFI_DEVICE_ERROR On entry, the current file position is beyond 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 current 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 current +directory entry. BufferSize has been updated with the size needed to complete +the request. **/ EFI_STATUS @@ -600,10 +619,10 @@ Ext4ReadFile ( /** Writes data to a file. - @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 bytes. @param[in] Buffer The buffer of data to write. @retval EFI_SUCCESS Data was written. @@ -628,13 +647,15 @@ Ext4WriteFile ( /** Returns a file's current position. - @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 position 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 position +value. @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. **/ EFI_STATUS @@ -647,14 +668,16 @@ Ext4GetPosition ( /** Sets a file's current position. - @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. @retval EFI_SUCCESS The position was set. @retval EFI_UNSUPPORTED The seek request for nonzero is not valid on open directories. - @retval EFI_DEVICE_ERROR An attempt was made to set the position of a deleted file. + @retval EFI_DEVICE_ERROR An attempt was made to set the position of a deleted +file. **/ EFI_STATUS @@ -667,21 +690,22 @@ Ext4SetPosition ( /** Returns information about a file. - @param[in] This A pointer to the EFI_FILE_PROTOCOL instance 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. + @param[in] This A pointer to the EFI_FILE_PROTOCOL instance +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. @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 current directory entry. - BufferSize has been updated with the size needed to complete + @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the current +directory entry. BufferSize has been updated with the size needed to complete the request. **/ EFI_STATUS @@ -696,35 +720,36 @@ Ext4GetInfo ( /** Sets information about a file. - @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 being set. @param[in] BufferSize The size, in bytes, of Buffer. - @param[in] Buffer A pointer to the data buffer to write. The buffer'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. @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_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_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. **/ EFI_STATUS @@ -760,8 +785,8 @@ Ext4FileIsReg ( IN CONST EXT4_FILE *File ); -// 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. /** 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(File)) -#define EXT4_INODE_HAS_FIELD(Inode, \ - Field) (Inode->i_extra_isize + EXT4_GOOD_OLD_INODE_SIZE >= 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 >= \ + OFFSET_OF(EXT4_INODE, Field) + sizeof(((EXT4_INODE *)NULL)->Field)) /** 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 recorded, - Time is zeroed. + In the case where the the creation time isn't +recorded, Time is zeroed. **/ VOID Ext4FileCreateTime ( @@ -825,8 +850,9 @@ Ext4FileCreateTime ( ); /** - Initialises Unicode collation, which is needed for case-insensitive string comparisons - within the driver (a good example of an application of this is filename comparison). + Initialises Unicode collation, which is needed for case-insensitive string +comparisons within the driver (a good example of an application of this is +filename comparison). @param[in] DriverHandle Handle to the driver image. @@ -839,8 +865,8 @@ Ext4InitialiseUnicodeCollation ( ); /** - Does a case-insensitive string comparison. Refer to EFI_UNICODE_COLLATION_PROTOCOL's StriColl - for more details. + Does a case-insensitive string comparison. Refer to +EFI_UNICODE_COLLATION_PROTOCOL's StriColl for more details. @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 @param[in] Entry Pointer to a EXT4_DIR_ENTRY. - @param[out] Ucs2FileName Pointer to an array of CHAR16's, of size EXT4_NAME_MAX + 1. + @param[out] Ucs2FileName Pointer to an array of CHAR16's, of size +EXT4_NAME_MAX + 1. @retval EFI_SUCCESS Unicode collation was successfully initialised. @retval !EFI_SUCCESS Failure. @@ -871,7 +898,8 @@ Ext4GetUcs2DirentName ( ); /** - 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. @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 ); /** @@ -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. @return Result of the operation. **/ @@ -1025,7 +1053,7 @@ Ext4CalculateBlockGroupDescChecksum ( @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) == RoCompatFeatureSet) /** @@ -1035,7 +1063,7 @@ Ext4CalculateBlockGroupDescChecksum ( @return TRUE if all features are supported, else FALSE. **/ -#define EXT4_HAS_COMPAT(Partition, CompatFeatureSet) \ +#define EXT4_HAS_COMPAT(Partition, CompatFeatureSet) \ ((Partition->FeaturesCompat & CompatFeatureSet) == CompatFeatureSet) /** @@ -1045,10 +1073,11 @@ Ext4CalculateBlockGroupDescChecksum ( @return TRUE if all features are supported, else FALSE. **/ -#define EXT4_HAS_INCOMPAT(Partition, IncompatFeatureSet) \ +#define EXT4_HAS_INCOMPAT(Partition, IncompatFeatureSet) \ ((Partition->FeaturesIncompat & IncompatFeatureSet) == IncompatFeatureSet) -// 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. /** Checks if metadata_csum is enabled on the partition. @@ -1056,8 +1085,8 @@ Ext4CalculateBlockGroupDescChecksum ( @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) /** Checks if gdt_csum is enabled on the partition. @@ -1065,8 +1094,8 @@ Ext4CalculateBlockGroupDescChecksum ( @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) /** Retrieves the volume name. @@ -1106,10 +1135,12 @@ Ext4SuperblockCheckMagic ( @returns True if uninitialized, else false. **/ -#define EXT4_EXTENT_IS_UNINITIALIZED(Extent) ((Extent)->ee_len > EXT4_EXTENT_MAX_INITIALIZED) +#define EXT4_EXTENT_IS_UNINITIALIZED(Extent) \ + ((Extent)->ee_len > EXT4_EXTENT_MAX_INITIALIZED) /** - Retrieves the extent's length, dealing with uninitialized extents in the process. + Retrieves the extent's length, dealing with uninitialized extents in the +process. @param[in] Extent Pointer to the EXT4_EXTENT 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 ( } // ext4 does not have support for logical block numbers bigger than UINT32_MAX - if (LogicalBlock > (UINT32)- 1) { + if (LogicalBlock > (UINT32)-1) { return EFI_NO_MAPPING; } @@ -332,7 +332,7 @@ Ext4GetExtent ( return EFI_NO_MAPPING; } - if (!(LogicalBlock >= Ext->ee_block && Ext->ee_block + Ext4GetExtentLength (Ext) > LogicalBlock)) { + if (!((LogicalBlock >= Ext->ee_block) && (Ext->ee_block + Ext4GetExtentLength (Ext) > LogicalBlock))) { // This extent does not cover the block if (Buffer != NULL) { FreePool (Buffer); @@ -378,7 +378,7 @@ Ext4ExtentsMapStructCompare ( Extent1 = UserStruct1; Extent2 = UserStruct2; - return Extent1->ee_block < Extent2->ee_block ? - 1 : + return Extent1->ee_block < Extent2->ee_block ? -1 : Extent1->ee_block > Extent2->ee_block ? 1 : 0; } @@ -413,11 +413,11 @@ Ext4ExtentsMapKeyCompare ( Extent = UserStruct; Block = (UINT32)(UINTN)StandaloneKey; - if (Block >= Extent->ee_block && Block < Extent->ee_block + Ext4GetExtentLength (Extent)) { + if ((Block >= Extent->ee_block) && (Block < Extent->ee_block + Ext4GetExtentLength (Extent))) { return 0; } - return Block < Extent->ee_block ? - 1 : + return Block < Extent->ee_block ? -1 : Block > Extent->ee_block ? 1 : 0; } diff --git a/Features/Ext4Pkg/Ext4Dxe/File.c b/Features/Ext4Pkg/Ext4Dxe/File.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 ( Status = Ext4OpenFile (Current, PathSegment, Partition, EFI_FILE_MODE_READ, &File); - if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) { + if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { return Status; } else if (Status == 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 == File->Partition->Root && !File->Partition->Unmounting) { + if ((File == File->Partition->Root) && !File->Partition->Unmounting) { return EFI_SUCCESS; } @@ -374,7 +375,7 @@ Ext4ReadFile ( EXT4_PARTITION *Partition; EFI_STATUS Status; - File = (EXT4_FILE *)This; + File = (EXT4_FILE *)This; Partition = File->Partition; ASSERT (Ext4FileIsOpenable (File)); @@ -491,12 +492,12 @@ Ext4SetPosition ( File = (EXT4_FILE *)This; // Only seeks to 0 (so it resets the ReadDir operation) are allowed - if (Ext4FileIsDir (File) && Position != 0) { + if (Ext4FileIsDir (File) && (Position != 0)) { return EFI_UNSUPPORTED; } // -1 (0xffffff.......) seeks to the end of the file - if (Position == (UINT64)- 1) { + if (Position == (UINT64)-1) { Position = EXT4_INODE_SIZE (File->Inode); } @@ -549,7 +550,7 @@ Ext4GetFileInfo ( Ext4FileMTime (File, &Info->ModificationTime); Ext4FileCreateTime (File, &Info->LastAccessTime); Info->Attribute = 0; - Info->Size = NeededLength; + Info->Size = NeededLength; if (Ext4FileIsDir (File)) { Info->Attribute |= EFI_FILE_DIRECTORY; @@ -659,7 +660,7 @@ Ext4GetFilesystemInfo ( Part->SuperBlock.s_free_blocks_count_hi ); - Info->BlockSize = Part->BlockSize; + Info->BlockSize = Part->BlockSize; Info->Size = NeededLength; Info->ReadOnly = Part->ReadOnly; Info->VolumeSize = MultU64x32 (TotalBlocks, Part->BlockSize); @@ -790,7 +791,7 @@ Ext4DuplicateFile ( EFI_STATUS Status; Partition = Original->Partition; - File = AllocateZeroPool (sizeof (EXT4_FILE)); + File = AllocateZeroPool (sizeof (EXT4_FILE)); if (File == NULL) { return NULL; diff --git a/Features/Ext4Pkg/Ext4Dxe/Inode.c b/Features/Ext4Pkg/Ext4Dxe/Inode.c index 48bfe026a3c2..f692909edf78 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Inode.c +++ b/Features/Ext4Pkg/Ext4Dxe/Inode.c @@ -50,7 +50,7 @@ Ext4CalculateInodeChecksum ( Crc = Ext4CalculateChecksum (Partition, &Dummy, sizeof (Dummy), Crc); - RestOfInode = &Inode->i_osd2.data_linux.l_i_reserved; + RestOfInode = &Inode->i_osd2.data_linux.l_i_reserved; RestOfInodeLength = Partition->InodeSize - OFFSET_OF (EXT4_INODE, i_osd2.data_linux.l_i_reserved); if (HasSecondChecksumField) { @@ -61,7 +61,7 @@ Ext4CalculateInodeChecksum ( // 4 is the size of the i_extra_size field + the size of i_checksum_hi RestOfInodeLength = Partition->InodeSize - EXT4_GOOD_OLD_INODE_SIZE - 4; - RestOfInode = &Inode->i_ctime_extra; + RestOfInode = &Inode->i_ctime_extra; } Crc = Ext4CalculateChecksum (Partition, RestOfInode, RestOfInodeLength, Crc); @@ -138,14 +138,13 @@ Ext4Read ( &Extent ); - if (Status != EFI_SUCCESS && Status != EFI_NO_MAPPING) { + if ((Status != EFI_SUCCESS) && (Status != EFI_NO_MAPPING)) { return Status; } HasBackingExtent = Status != EFI_NO_MAPPING; if (!HasBackingExtent || EXT4_EXTENT_IS_UNINITIALIZED (&Extent)) { - HoleOff = BlockOff; if (!HasBackingExtent) { @@ -167,8 +166,8 @@ Ext4Read ( ); ExtentLengthBytes = Extent.ee_len * Partition->BlockSize; ExtentLogicalBytes = (UINT64)Extent.ee_block * Partition->BlockSize; - ExtentOffset = CurrentSeek - ExtentLogicalBytes; - ExtentMayRead = (UINTN)(ExtentLengthBytes - ExtentOffset); + ExtentOffset = CurrentSeek - ExtentLogicalBytes; + ExtentMayRead = (UINTN)(ExtentLengthBytes - ExtentOffset); WasRead = ExtentMayRead > RemainingRead ? RemainingRead : ExtentMayRead; @@ -187,9 +186,9 @@ Ext4Read ( } RemainingRead -= WasRead; - Buffer = (VOID *)((CHAR8 *)Buffer + WasRead); - BeenRead += WasRead; - CurrentSeek += WasRead; + Buffer = (VOID *)((CHAR8 *)Buffer + WasRead); + BeenRead += WasRead; + CurrentSeek += WasRead; } *Length = BeenRead; @@ -214,7 +213,7 @@ Ext4AllocateInode ( EXT4_INODE *Inode; NeedsToZeroRest = FALSE; - InodeSize = Partition->InodeSize; + InodeSize = Partition->InodeSize; // We allocate a structure of at least sizeof(EXT4_INODE), but in the future, 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). if (InodeSize < sizeof (EXT4_INODE)) { - InodeSize = sizeof (EXT4_INODE); + InodeSize = sizeof (EXT4_INODE); NeedsToZeroRest = TRUE; } @@ -409,7 +408,8 @@ EXT4_FILE_GET_TIME_GENERIC (MTime, i_mtime); **/ STATIC EXT4_FILE_GET_TIME_GENERIC ( - CrTime, i_crtime + CrTime, + i_crtime ); /** diff --git a/Features/Ext4Pkg/Ext4Dxe/Partition.c b/Features/Ext4Pkg/Ext4Dxe/Partition.c index afa0392024ec..316807497dd4 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Partition.c +++ b/Features/Ext4Pkg/Ext4Dxe/Partition.c @@ -50,12 +50,12 @@ Ext4OpenPartition ( Part->Interface.Revision = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION; Part->Interface.OpenVolume = Ext4OpenVolume; - Status = gBS->InstallMultipleProtocolInterfaces ( - &DeviceHandle, - &gEfiSimpleFileSystemProtocolGuid, - &Part->Interface, - NULL - ); + Status = gBS->InstallMultipleProtocolInterfaces ( + &DeviceHandle, + &gEfiSimpleFileSystemProtocolGuid, + &Part->Interface, + NULL + ); if (EFI_ERROR (Status)) { FreePool (Part); diff --git a/Features/Ext4Pkg/Ext4Dxe/Superblock.c b/Features/Ext4Pkg/Ext4Dxe/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; } - if (Sb->s_rev_level != EXT4_DYNAMIC_REV && Sb->s_rev_level != EXT4_GOOD_OLD_REV) { + if ((Sb->s_rev_level != EXT4_DYNAMIC_REV) && (Sb->s_rev_level != EXT4_GOOD_OLD_REV)) { return FALSE; } @@ -188,11 +188,11 @@ Ext4OpenSuperblock ( Partition->FeaturesCompat = Sb->s_feature_compat; Partition->FeaturesIncompat = Sb->s_feature_incompat; Partition->FeaturesRoCompat = Sb->s_feature_ro_compat; - Partition->InodeSize = Sb->s_inode_size; + Partition->InodeSize = Sb->s_inode_size; } else { // GOOD_OLD_REV Partition->FeaturesCompat = Partition->FeaturesIncompat = Partition->FeaturesRoCompat = 0; - Partition->InodeSize = EXT4_GOOD_OLD_INODE_SIZE; + Partition->InodeSize = EXT4_GOOD_OLD_INODE_SIZE; } // Now, check for the feature set of the filesystem @@ -220,7 +220,8 @@ Ext4OpenSuperblock ( // At the time of writing, it's the only supported checksum. if (Partition->FeaturesCompat & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM && - Sb->s_checksum_type != EXT4_CHECKSUM_CRC32C) { + (Sb->s_checksum_type != EXT4_CHECKSUM_CRC32C)) + { return EFI_UNSUPPORTED; } @@ -250,7 +251,7 @@ Ext4OpenSuperblock ( return EFI_UNSUPPORTED; } - Partition->NumberBlocks = EXT4_BLOCK_NR_FROM_HALFS (Partition, Sb->s_blocks_count, Sb->s_blocks_count_hi); + Partition->NumberBlocks = EXT4_BLOCK_NR_FROM_HALFS (Partition, Sb->s_blocks_count, Sb->s_blocks_count_hi); Partition->NumberBlockGroups = DivU64x32 (Partition->NumberBlocks, Sb->s_blocks_per_group); DEBUG (( @@ -266,7 +267,7 @@ Ext4OpenSuperblock ( Partition->DescSize = EXT4_OLD_BLOCK_DESC_SIZE; } - 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; } -- 2.35.1