FatPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the FatPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
a550d468a6
commit
bcdcc4160d
@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "Fat.h"
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Get the FAT entry of the volume, which is identified with the Index.
|
||||
@@ -24,46 +23,48 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
STATIC
|
||||
VOID *
|
||||
FatLoadFatEntry (
|
||||
IN FAT_VOLUME *Volume,
|
||||
IN UINTN Index
|
||||
IN FAT_VOLUME *Volume,
|
||||
IN UINTN Index
|
||||
)
|
||||
{
|
||||
UINTN Pos;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (Index > (Volume->MaxCluster + 1)) {
|
||||
Volume->FatEntryBuffer = (UINT32) -1;
|
||||
Volume->FatEntryBuffer = (UINT32)-1;
|
||||
return &Volume->FatEntryBuffer;
|
||||
}
|
||||
|
||||
//
|
||||
// Compute buffer position needed
|
||||
//
|
||||
switch (Volume->FatType) {
|
||||
case Fat12:
|
||||
Pos = FAT_POS_FAT12 (Index);
|
||||
break;
|
||||
case Fat12:
|
||||
Pos = FAT_POS_FAT12 (Index);
|
||||
break;
|
||||
|
||||
case Fat16:
|
||||
Pos = FAT_POS_FAT16 (Index);
|
||||
break;
|
||||
case Fat16:
|
||||
Pos = FAT_POS_FAT16 (Index);
|
||||
break;
|
||||
|
||||
default:
|
||||
Pos = FAT_POS_FAT32 (Index);
|
||||
default:
|
||||
Pos = FAT_POS_FAT32 (Index);
|
||||
}
|
||||
|
||||
//
|
||||
// Set the position and read the buffer
|
||||
//
|
||||
Volume->FatEntryPos = Volume->FatPos + Pos;
|
||||
Status = FatDiskIo (
|
||||
Volume,
|
||||
ReadFat,
|
||||
Volume->FatEntryPos,
|
||||
Volume->FatEntrySize,
|
||||
&Volume->FatEntryBuffer,
|
||||
NULL
|
||||
);
|
||||
Status = FatDiskIo (
|
||||
Volume,
|
||||
ReadFat,
|
||||
Volume->FatEntryPos,
|
||||
Volume->FatEntrySize,
|
||||
&Volume->FatEntryBuffer,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Volume->FatEntryBuffer = (UINT32) -1;
|
||||
Volume->FatEntryBuffer = (UINT32)-1;
|
||||
}
|
||||
|
||||
return &Volume->FatEntryBuffer;
|
||||
@@ -82,8 +83,8 @@ FatLoadFatEntry (
|
||||
STATIC
|
||||
UINTN
|
||||
FatGetFatEntry (
|
||||
IN FAT_VOLUME *Volume,
|
||||
IN UINTN Index
|
||||
IN FAT_VOLUME *Volume,
|
||||
IN UINTN Index
|
||||
)
|
||||
{
|
||||
VOID *Pos;
|
||||
@@ -95,27 +96,27 @@ FatGetFatEntry (
|
||||
Pos = FatLoadFatEntry (Volume, Index);
|
||||
|
||||
if (Index > (Volume->MaxCluster + 1)) {
|
||||
return (UINTN) -1;
|
||||
return (UINTN)-1;
|
||||
}
|
||||
|
||||
switch (Volume->FatType) {
|
||||
case Fat12:
|
||||
En12 = Pos;
|
||||
Accum = En12[0] | (En12[1] << 8);
|
||||
Accum = FAT_ODD_CLUSTER_FAT12 (Index) ? (Accum >> 4) : (Accum & FAT_CLUSTER_MASK_FAT12);
|
||||
Accum = Accum | ((Accum >= FAT_CLUSTER_SPECIAL_FAT12) ? FAT_CLUSTER_SPECIAL_EXT : 0);
|
||||
break;
|
||||
case Fat12:
|
||||
En12 = Pos;
|
||||
Accum = En12[0] | (En12[1] << 8);
|
||||
Accum = FAT_ODD_CLUSTER_FAT12 (Index) ? (Accum >> 4) : (Accum & FAT_CLUSTER_MASK_FAT12);
|
||||
Accum = Accum | ((Accum >= FAT_CLUSTER_SPECIAL_FAT12) ? FAT_CLUSTER_SPECIAL_EXT : 0);
|
||||
break;
|
||||
|
||||
case Fat16:
|
||||
En16 = Pos;
|
||||
Accum = *En16;
|
||||
Accum = Accum | ((Accum >= FAT_CLUSTER_SPECIAL_FAT16) ? FAT_CLUSTER_SPECIAL_EXT : 0);
|
||||
break;
|
||||
case Fat16:
|
||||
En16 = Pos;
|
||||
Accum = *En16;
|
||||
Accum = Accum | ((Accum >= FAT_CLUSTER_SPECIAL_FAT16) ? FAT_CLUSTER_SPECIAL_EXT : 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
En32 = Pos;
|
||||
Accum = *En32 & FAT_CLUSTER_MASK_FAT32;
|
||||
Accum = Accum | ((Accum >= FAT_CLUSTER_SPECIAL_FAT32) ? FAT_CLUSTER_SPECIAL_EXT : 0);
|
||||
default:
|
||||
En32 = Pos;
|
||||
Accum = *En32 & FAT_CLUSTER_MASK_FAT32;
|
||||
Accum = Accum | ((Accum >= FAT_CLUSTER_SPECIAL_FAT32) ? FAT_CLUSTER_SPECIAL_EXT : 0);
|
||||
}
|
||||
|
||||
return Accum;
|
||||
@@ -137,9 +138,9 @@ FatGetFatEntry (
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
FatSetFatEntry (
|
||||
IN FAT_VOLUME *Volume,
|
||||
IN UINTN Index,
|
||||
IN UINTN Value
|
||||
IN FAT_VOLUME *Volume,
|
||||
IN UINTN Index,
|
||||
IN UINTN Value
|
||||
)
|
||||
{
|
||||
VOID *Pos;
|
||||
@@ -155,16 +156,17 @@ FatSetFatEntry (
|
||||
}
|
||||
|
||||
OriginalVal = FatGetFatEntry (Volume, Index);
|
||||
if (Value == FAT_CLUSTER_FREE && OriginalVal != FAT_CLUSTER_FREE) {
|
||||
if ((Value == FAT_CLUSTER_FREE) && (OriginalVal != FAT_CLUSTER_FREE)) {
|
||||
Volume->FatInfoSector.FreeInfo.ClusterCount += 1;
|
||||
if (Index < Volume->FatInfoSector.FreeInfo.NextCluster) {
|
||||
Volume->FatInfoSector.FreeInfo.NextCluster = (UINT32) Index;
|
||||
Volume->FatInfoSector.FreeInfo.NextCluster = (UINT32)Index;
|
||||
}
|
||||
} else if (Value != FAT_CLUSTER_FREE && OriginalVal == FAT_CLUSTER_FREE) {
|
||||
} else if ((Value != FAT_CLUSTER_FREE) && (OriginalVal == FAT_CLUSTER_FREE)) {
|
||||
if (Volume->FatInfoSector.FreeInfo.ClusterCount != 0) {
|
||||
Volume->FatInfoSector.FreeInfo.ClusterCount -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Make sure the entry is in memory
|
||||
//
|
||||
@@ -174,37 +176,39 @@ FatSetFatEntry (
|
||||
// Update the value
|
||||
//
|
||||
switch (Volume->FatType) {
|
||||
case Fat12:
|
||||
En12 = Pos;
|
||||
Accum = En12[0] | (En12[1] << 8);
|
||||
Value = Value & FAT_CLUSTER_MASK_FAT12;
|
||||
case Fat12:
|
||||
En12 = Pos;
|
||||
Accum = En12[0] | (En12[1] << 8);
|
||||
Value = Value & FAT_CLUSTER_MASK_FAT12;
|
||||
|
||||
if (FAT_ODD_CLUSTER_FAT12 (Index)) {
|
||||
Accum = (Value << 4) | (Accum & 0xF);
|
||||
} else {
|
||||
Accum = Value | (Accum & FAT_CLUSTER_UNMASK_FAT12);
|
||||
}
|
||||
if (FAT_ODD_CLUSTER_FAT12 (Index)) {
|
||||
Accum = (Value << 4) | (Accum & 0xF);
|
||||
} else {
|
||||
Accum = Value | (Accum & FAT_CLUSTER_UNMASK_FAT12);
|
||||
}
|
||||
|
||||
En12[0] = (UINT8) (Accum & 0xFF);
|
||||
En12[1] = (UINT8) (Accum >> 8);
|
||||
break;
|
||||
En12[0] = (UINT8)(Accum & 0xFF);
|
||||
En12[1] = (UINT8)(Accum >> 8);
|
||||
break;
|
||||
|
||||
case Fat16:
|
||||
En16 = Pos;
|
||||
*En16 = (UINT16) Value;
|
||||
break;
|
||||
case Fat16:
|
||||
En16 = Pos;
|
||||
*En16 = (UINT16)Value;
|
||||
break;
|
||||
|
||||
default:
|
||||
En32 = Pos;
|
||||
*En32 = (*En32 & FAT_CLUSTER_UNMASK_FAT32) | (UINT32) (Value & FAT_CLUSTER_MASK_FAT32);
|
||||
default:
|
||||
En32 = Pos;
|
||||
*En32 = (*En32 & FAT_CLUSTER_UNMASK_FAT32) | (UINT32)(Value & FAT_CLUSTER_MASK_FAT32);
|
||||
}
|
||||
|
||||
//
|
||||
// If the volume's dirty bit is not set, set it now
|
||||
//
|
||||
if (!Volume->FatDirty && Volume->FatType != Fat12) {
|
||||
if (!Volume->FatDirty && (Volume->FatType != Fat12)) {
|
||||
Volume->FatDirty = TRUE;
|
||||
FatAccessVolumeDirty (Volume, WriteFat, &Volume->DirtyValue);
|
||||
}
|
||||
|
||||
//
|
||||
// Write the updated fat entry value to the volume
|
||||
// The fat is the first fat, and other fat will be in sync
|
||||
@@ -235,15 +239,14 @@ FatSetFatEntry (
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
FatFreeClusters (
|
||||
IN FAT_VOLUME *Volume,
|
||||
IN UINTN Cluster
|
||||
IN FAT_VOLUME *Volume,
|
||||
IN UINTN Cluster
|
||||
)
|
||||
{
|
||||
UINTN LastCluster;
|
||||
UINTN LastCluster;
|
||||
|
||||
while (!FAT_END_OF_FAT_CHAIN (Cluster)) {
|
||||
if (Cluster == FAT_CLUSTER_FREE || Cluster >= FAT_CLUSTER_SPECIAL) {
|
||||
|
||||
if ((Cluster == FAT_CLUSTER_FREE) || (Cluster >= FAT_CLUSTER_SPECIAL)) {
|
||||
DEBUG ((DEBUG_INIT | DEBUG_ERROR, "FatShrinkEof: cluster chain corrupt\n"));
|
||||
return EFI_VOLUME_CORRUPTED;
|
||||
}
|
||||
@@ -268,30 +271,30 @@ FatFreeClusters (
|
||||
STATIC
|
||||
UINTN
|
||||
FatAllocateCluster (
|
||||
IN FAT_VOLUME *Volume
|
||||
IN FAT_VOLUME *Volume
|
||||
)
|
||||
{
|
||||
UINTN Cluster;
|
||||
UINTN Cluster;
|
||||
|
||||
//
|
||||
// Start looking at FatFreePos for the next unallocated cluster
|
||||
//
|
||||
if (Volume->DiskError) {
|
||||
return (UINTN) FAT_CLUSTER_LAST;
|
||||
return (UINTN)FAT_CLUSTER_LAST;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
for ( ; ;) {
|
||||
//
|
||||
// If the end of the list, return no available cluster
|
||||
//
|
||||
if (Volume->FatInfoSector.FreeInfo.NextCluster > (Volume->MaxCluster + 1)) {
|
||||
if (Volume->FreeInfoValid && 0 < (INT32) (Volume->FatInfoSector.FreeInfo.ClusterCount)) {
|
||||
if (Volume->FreeInfoValid && (0 < (INT32)(Volume->FatInfoSector.FreeInfo.ClusterCount))) {
|
||||
Volume->FreeInfoValid = FALSE;
|
||||
}
|
||||
|
||||
FatComputeFreeInfo (Volume);
|
||||
if (Volume->FatInfoSector.FreeInfo.NextCluster > (Volume->MaxCluster + 1)) {
|
||||
return (UINTN) FAT_CLUSTER_LAST;
|
||||
return (UINTN)FAT_CLUSTER_LAST;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,13 +302,14 @@ FatAllocateCluster (
|
||||
if (Cluster == FAT_CLUSTER_FREE) {
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Try the next cluster
|
||||
//
|
||||
Volume->FatInfoSector.FreeInfo.NextCluster += 1;
|
||||
}
|
||||
|
||||
Cluster = Volume->FatInfoSector.FreeInfo.NextCluster;
|
||||
Cluster = Volume->FatInfoSector.FreeInfo.NextCluster;
|
||||
Volume->FatInfoSector.FreeInfo.NextCluster += 1;
|
||||
return Cluster;
|
||||
}
|
||||
@@ -323,11 +327,11 @@ FatAllocateCluster (
|
||||
STATIC
|
||||
UINTN
|
||||
FatSizeToClusters (
|
||||
IN FAT_VOLUME *Volume,
|
||||
IN UINTN Size
|
||||
IN FAT_VOLUME *Volume,
|
||||
IN UINTN Size
|
||||
)
|
||||
{
|
||||
UINTN Clusters;
|
||||
UINTN Clusters;
|
||||
|
||||
Clusters = Size >> Volume->ClusterAlignment;
|
||||
if ((Size & (Volume->ClusterSize - 1)) > 0) {
|
||||
@@ -349,7 +353,7 @@ FatSizeToClusters (
|
||||
**/
|
||||
EFI_STATUS
|
||||
FatShrinkEof (
|
||||
IN FAT_OFILE *OFile
|
||||
IN FAT_OFILE *OFile
|
||||
)
|
||||
{
|
||||
FAT_VOLUME *Volume;
|
||||
@@ -358,7 +362,7 @@ FatShrinkEof (
|
||||
UINTN Cluster;
|
||||
UINTN LastCluster;
|
||||
|
||||
Volume = OFile->Volume;
|
||||
Volume = OFile->Volume;
|
||||
ASSERT_VOLUME_LOCKED (Volume);
|
||||
|
||||
NewSize = FatSizeToClusters (Volume, OFile->FileSize);
|
||||
@@ -370,10 +374,8 @@ FatShrinkEof (
|
||||
LastCluster = FAT_CLUSTER_FREE;
|
||||
|
||||
if (NewSize != 0) {
|
||||
|
||||
for (CurSize = 0; CurSize < NewSize; CurSize++) {
|
||||
if (Cluster == FAT_CLUSTER_FREE || Cluster >= FAT_CLUSTER_SPECIAL) {
|
||||
|
||||
if ((Cluster == FAT_CLUSTER_FREE) || (Cluster >= FAT_CLUSTER_SPECIAL)) {
|
||||
DEBUG ((DEBUG_INIT | DEBUG_ERROR, "FatShrinkEof: cluster chain corrupt\n"));
|
||||
return EFI_VOLUME_CORRUPTED;
|
||||
}
|
||||
@@ -382,8 +384,7 @@ FatShrinkEof (
|
||||
Cluster = FatGetFatEntry (Volume, Cluster);
|
||||
}
|
||||
|
||||
FatSetFatEntry (Volume, LastCluster, (UINTN) FAT_CLUSTER_LAST);
|
||||
|
||||
FatSetFatEntry (Volume, LastCluster, (UINTN)FAT_CLUSTER_LAST);
|
||||
} else {
|
||||
//
|
||||
// Check to see if the file is already completely truncated
|
||||
@@ -391,11 +392,13 @@ FatShrinkEof (
|
||||
if (Cluster == FAT_CLUSTER_FREE) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// The file is being completely truncated.
|
||||
//
|
||||
OFile->FileCluster = FAT_CLUSTER_FREE;
|
||||
OFile->FileCluster = FAT_CLUSTER_FREE;
|
||||
}
|
||||
|
||||
//
|
||||
// Set CurrentCluster == FileCluster
|
||||
// to force a recalculation of Position related stuffs
|
||||
@@ -424,8 +427,8 @@ FatShrinkEof (
|
||||
**/
|
||||
EFI_STATUS
|
||||
FatGrowEof (
|
||||
IN FAT_OFILE *OFile,
|
||||
IN UINT64 NewSizeInBytes
|
||||
IN FAT_OFILE *OFile,
|
||||
IN UINT64 NewSizeInBytes
|
||||
)
|
||||
{
|
||||
FAT_VOLUME *Volume;
|
||||
@@ -450,42 +453,41 @@ FatGrowEof (
|
||||
// If the file is already large enough, do nothing
|
||||
//
|
||||
CurSize = FatSizeToClusters (Volume, OFile->FileSize);
|
||||
NewSize = FatSizeToClusters (Volume, (UINTN) NewSizeInBytes);
|
||||
NewSize = FatSizeToClusters (Volume, (UINTN)NewSizeInBytes);
|
||||
|
||||
if (CurSize < NewSize) {
|
||||
//
|
||||
// If we haven't found the files last cluster do it now
|
||||
//
|
||||
if ((OFile->FileCluster != 0) && (OFile->FileLastCluster == 0)) {
|
||||
Cluster = OFile->FileCluster;
|
||||
ClusterCount = 0;
|
||||
Cluster = OFile->FileCluster;
|
||||
ClusterCount = 0;
|
||||
|
||||
while (!FAT_END_OF_FAT_CHAIN (Cluster)) {
|
||||
if (Cluster < FAT_MIN_CLUSTER || Cluster > Volume->MaxCluster + 1) {
|
||||
|
||||
if ((Cluster < FAT_MIN_CLUSTER) || (Cluster > Volume->MaxCluster + 1)) {
|
||||
DEBUG (
|
||||
(DEBUG_INIT | DEBUG_ERROR,
|
||||
"FatGrowEof: cluster chain corrupt\n")
|
||||
"FatGrowEof: cluster chain corrupt\n")
|
||||
);
|
||||
Status = EFI_VOLUME_CORRUPTED;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
ClusterCount++;
|
||||
OFile->FileLastCluster = Cluster;
|
||||
Cluster = FatGetFatEntry (Volume, Cluster);
|
||||
OFile->FileLastCluster = Cluster;
|
||||
Cluster = FatGetFatEntry (Volume, Cluster);
|
||||
}
|
||||
|
||||
if (ClusterCount != CurSize) {
|
||||
DEBUG (
|
||||
(DEBUG_INIT | DEBUG_ERROR,
|
||||
"FatGrowEof: cluster chain size does not match file size\n")
|
||||
"FatGrowEof: cluster chain size does not match file size\n")
|
||||
);
|
||||
Status = EFI_VOLUME_CORRUPTED;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Loop until we've allocated enough space
|
||||
//
|
||||
@@ -495,7 +497,7 @@ FatGrowEof (
|
||||
NewCluster = FatAllocateCluster (Volume);
|
||||
if (FAT_END_OF_FAT_CHAIN (NewCluster)) {
|
||||
if (LastCluster != FAT_CLUSTER_FREE) {
|
||||
FatSetFatEntry (Volume, LastCluster, (UINTN) FAT_CLUSTER_LAST);
|
||||
FatSetFatEntry (Volume, LastCluster, (UINTN)FAT_CLUSTER_LAST);
|
||||
OFile->FileLastCluster = LastCluster;
|
||||
}
|
||||
|
||||
@@ -503,7 +505,7 @@ FatGrowEof (
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (NewCluster < FAT_MIN_CLUSTER || NewCluster > Volume->MaxCluster + 1) {
|
||||
if ((NewCluster < FAT_MIN_CLUSTER) || (NewCluster > Volume->MaxCluster + 1)) {
|
||||
Status = EFI_VOLUME_CORRUPTED;
|
||||
goto Done;
|
||||
}
|
||||
@@ -516,7 +518,7 @@ FatGrowEof (
|
||||
}
|
||||
|
||||
LastCluster = NewCluster;
|
||||
CurSize += 1;
|
||||
CurSize += 1;
|
||||
|
||||
//
|
||||
// Terminate the cluster list
|
||||
@@ -529,12 +531,12 @@ FatGrowEof (
|
||||
// a second time. There are other, less predictable scenarios
|
||||
// where this could happen, as well.
|
||||
//
|
||||
FatSetFatEntry (Volume, LastCluster, (UINTN) FAT_CLUSTER_LAST);
|
||||
FatSetFatEntry (Volume, LastCluster, (UINTN)FAT_CLUSTER_LAST);
|
||||
OFile->FileLastCluster = LastCluster;
|
||||
}
|
||||
}
|
||||
|
||||
OFile->FileSize = (UINTN) NewSizeInBytes;
|
||||
OFile->FileSize = (UINTN)NewSizeInBytes;
|
||||
OFile->Dirty = TRUE;
|
||||
return EFI_SUCCESS;
|
||||
|
||||
@@ -558,9 +560,9 @@ Done:
|
||||
**/
|
||||
EFI_STATUS
|
||||
FatOFilePosition (
|
||||
IN FAT_OFILE *OFile,
|
||||
IN UINTN Position,
|
||||
IN UINTN PosLimit
|
||||
IN FAT_OFILE *OFile,
|
||||
IN UINTN Position,
|
||||
IN UINTN PosLimit
|
||||
)
|
||||
{
|
||||
FAT_VOLUME *Volume;
|
||||
@@ -579,8 +581,8 @@ FatOFilePosition (
|
||||
// from its fixed info in the fat bpb
|
||||
//
|
||||
if (OFile->IsFixedRootDir) {
|
||||
OFile->PosDisk = Volume->RootPos + Position;
|
||||
Run = OFile->FileSize - Position;
|
||||
OFile->PosDisk = Volume->RootPos + Position;
|
||||
Run = OFile->FileSize - Position;
|
||||
} else {
|
||||
//
|
||||
// Run the file's cluster chain to find the current position
|
||||
@@ -594,30 +596,30 @@ FatOFilePosition (
|
||||
// when OFile->FileCluster is updated, so make a check of this
|
||||
// and invalidate the original OFile->Position in this case
|
||||
//
|
||||
Cluster = OFile->FileCurrentCluster;
|
||||
StartPos = OFile->Position;
|
||||
if (Position < StartPos || OFile->FileCluster == Cluster) {
|
||||
StartPos = 0;
|
||||
Cluster = OFile->FileCluster;
|
||||
Cluster = OFile->FileCurrentCluster;
|
||||
StartPos = OFile->Position;
|
||||
if ((Position < StartPos) || (OFile->FileCluster == Cluster)) {
|
||||
StartPos = 0;
|
||||
Cluster = OFile->FileCluster;
|
||||
}
|
||||
|
||||
while (StartPos + ClusterSize <= Position) {
|
||||
StartPos += ClusterSize;
|
||||
if (Cluster == FAT_CLUSTER_FREE || (Cluster >= FAT_CLUSTER_SPECIAL)) {
|
||||
DEBUG ((DEBUG_INIT | DEBUG_ERROR, "FatOFilePosition:"" cluster chain corrupt\n"));
|
||||
if ((Cluster == FAT_CLUSTER_FREE) || (Cluster >= FAT_CLUSTER_SPECIAL)) {
|
||||
DEBUG ((DEBUG_INIT | DEBUG_ERROR, "FatOFilePosition:" " cluster chain corrupt\n"));
|
||||
return EFI_VOLUME_CORRUPTED;
|
||||
}
|
||||
|
||||
Cluster = FatGetFatEntry (Volume, Cluster);
|
||||
}
|
||||
|
||||
if (Cluster < FAT_MIN_CLUSTER || Cluster > Volume->MaxCluster + 1) {
|
||||
if ((Cluster < FAT_MIN_CLUSTER) || (Cluster > Volume->MaxCluster + 1)) {
|
||||
return EFI_VOLUME_CORRUPTED;
|
||||
}
|
||||
|
||||
OFile->PosDisk = Volume->FirstClusterPos +
|
||||
LShiftU64 (Cluster - FAT_MIN_CLUSTER, Volume->ClusterAlignment) +
|
||||
Position - StartPos;
|
||||
OFile->PosDisk = Volume->FirstClusterPos +
|
||||
LShiftU64 (Cluster - FAT_MIN_CLUSTER, Volume->ClusterAlignment) +
|
||||
Position - StartPos;
|
||||
OFile->FileCurrentCluster = Cluster;
|
||||
OFile->Position = StartPos;
|
||||
|
||||
@@ -650,11 +652,12 @@ FatOFilePosition (
|
||||
**/
|
||||
UINTN
|
||||
FatPhysicalDirSize (
|
||||
IN FAT_VOLUME *Volume,
|
||||
IN UINTN Cluster
|
||||
IN FAT_VOLUME *Volume,
|
||||
IN UINTN Cluster
|
||||
)
|
||||
{
|
||||
UINTN Size;
|
||||
UINTN Size;
|
||||
|
||||
ASSERT_VOLUME_LOCKED (Volume);
|
||||
//
|
||||
// Run the cluster chain for the OFile
|
||||
@@ -666,15 +669,15 @@ FatPhysicalDirSize (
|
||||
//
|
||||
if (Cluster != 0) {
|
||||
while (!FAT_END_OF_FAT_CHAIN (Cluster)) {
|
||||
if (Cluster == FAT_CLUSTER_FREE || Cluster >= FAT_CLUSTER_SPECIAL) {
|
||||
if ((Cluster == FAT_CLUSTER_FREE) || (Cluster >= FAT_CLUSTER_SPECIAL)) {
|
||||
DEBUG (
|
||||
(DEBUG_INIT | DEBUG_ERROR,
|
||||
"FATDirSize: cluster chain corrupt\n")
|
||||
"FATDirSize: cluster chain corrupt\n")
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Size += Volume->ClusterSize;
|
||||
Size += Volume->ClusterSize;
|
||||
Cluster = FatGetFatEntry (Volume, Cluster);
|
||||
}
|
||||
}
|
||||
@@ -694,14 +697,15 @@ FatPhysicalDirSize (
|
||||
**/
|
||||
UINT64
|
||||
FatPhysicalFileSize (
|
||||
IN FAT_VOLUME *Volume,
|
||||
IN UINTN RealSize
|
||||
IN FAT_VOLUME *Volume,
|
||||
IN UINTN RealSize
|
||||
)
|
||||
{
|
||||
UINTN ClusterSizeMask;
|
||||
UINT64 PhysicalSize;
|
||||
|
||||
ClusterSizeMask = Volume->ClusterSize - 1;
|
||||
PhysicalSize = (RealSize + ClusterSizeMask) & (~((UINT64) ClusterSizeMask));
|
||||
PhysicalSize = (RealSize + ClusterSizeMask) & (~((UINT64)ClusterSizeMask));
|
||||
return PhysicalSize;
|
||||
}
|
||||
|
||||
@@ -714,18 +718,17 @@ FatPhysicalFileSize (
|
||||
**/
|
||||
VOID
|
||||
FatComputeFreeInfo (
|
||||
IN FAT_VOLUME *Volume
|
||||
IN FAT_VOLUME *Volume
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// If we don't have valid info, compute it now
|
||||
//
|
||||
if (!Volume->FreeInfoValid) {
|
||||
|
||||
Volume->FreeInfoValid = TRUE;
|
||||
Volume->FatInfoSector.FreeInfo.ClusterCount = 0;
|
||||
Volume->FreeInfoValid = TRUE;
|
||||
Volume->FatInfoSector.FreeInfo.ClusterCount = 0;
|
||||
for (Index = Volume->MaxCluster + 1; Index >= FAT_MIN_CLUSTER; Index--) {
|
||||
if (Volume->DiskError) {
|
||||
break;
|
||||
@@ -733,7 +736,7 @@ FatComputeFreeInfo (
|
||||
|
||||
if (FatGetFatEntry (Volume, Index) == FAT_CLUSTER_FREE) {
|
||||
Volume->FatInfoSector.FreeInfo.ClusterCount += 1;
|
||||
Volume->FatInfoSector.FreeInfo.NextCluster = (UINT32) Index;
|
||||
Volume->FatInfoSector.FreeInfo.NextCluster = (UINT32)Index;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user