Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Sync with Edk I Fat driver
git-svn-id: https://fat-driver2.tianocore.org/svn/fat-driver2/trunk@21 65ba2f78-6c18-0410-a7b4-885970cf29fa
  • Loading branch information
qhuang8 committed May 31, 2007
1 parent 39b24fe commit 95db08f
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 10 deletions.
10 changes: 8 additions & 2 deletions EnhancedFat/Dxe/DirectoryManage.c
Expand Up @@ -1430,7 +1430,7 @@ Routine Description:
{
EFI_STATUS Status;
FAT_VOLUME *Volume;
CHAR16 ComponentName[EFI_FILE_STRING_LENGTH + 1];
CHAR16 ComponentName[EFI_PATH_STRING_LENGTH];
UINTN FileNameLen;
BOOLEAN DirIntended;
CHAR16 *Next;
Expand Down Expand Up @@ -1458,7 +1458,13 @@ Routine Description:
FileName++;
FileNameLen--;
}
if (OFile->FullPathLen + FileNameLen > EFI_FILE_STRING_LENGTH) {
//
// Per FAT Spec the file name should meet the following criteria:
// C1. Length (FileLongName) <= 255
// C2. Length (X:FileFullPath<NUL>) <= 260
// Here we check C2 first.
//
if (2 + OFile->FullPathLen + 1 + FileNameLen + 1 > EFI_PATH_STRING_LENGTH) {
//
// Full path length can not surpass 256
//
Expand Down
6 changes: 3 additions & 3 deletions EnhancedFat/Dxe/DiskCache.c
Expand Up @@ -70,7 +70,7 @@ Routine Description:
BaseAddress = DiskCache->CacheBase;
GroupMask = DiskCache->GroupMask;
PageAlignment = DiskCache->PageAlignment;
PageSize = 1 << PageAlignment;
PageSize = (UINTN)1 << PageAlignment;

for (PageNo = StartPageNo; PageNo < EndPageNo; PageNo++) {
GroupNo = PageNo & GroupMask;
Expand Down Expand Up @@ -146,7 +146,7 @@ Routine Description:
EntryPos = DiskCache->BaseAddress + LShiftU64 (PageNo, PageAlignment);
RealSize = CacheTag->RealSize;
if (IoMode == READ_DISK) {
RealSize = 1 << PageAlignment;
RealSize = (UINTN)1 << PageAlignment;
MaxSize = DiskCache->LimitAddress - EntryPos;
if (MaxSize < RealSize) {
DEBUG ((EFI_D_INFO, "FatDiskIo: Cache Page OutBound occurred! \n"));
Expand Down Expand Up @@ -356,7 +356,7 @@ Routine Description:
DiskCache = &Volume->DiskCache[CacheDataType];
EntryPos = Offset - DiskCache->BaseAddress;
PageAlignment = DiskCache->PageAlignment;
PageSize = 1 << PageAlignment;
PageSize = (UINTN)1 << PageAlignment;
PageNo = (UINTN) RShiftU64 (EntryPos, PageAlignment);
UnderRun = ((UINTN) EntryPos) & (PageSize - 1);

Expand Down
5 changes: 5 additions & 0 deletions EnhancedFat/Dxe/Fat.c
Expand Up @@ -375,6 +375,11 @@ Routine Description:
//
Status = FatAllocateVolume (ControllerHandle, DiskIo, BlockIo);

//
// When the media changes on a device it will Reinstall the BlockIo interaface.
// This will cause a call to our Stop(), and a subsequent reentrant call to our
// Start() successfully. We should leave the device open when this happen.
//
if (EFI_ERROR (Status)) {
Status = gBS->OpenProtocol (
ControllerHandle,
Expand Down
3 changes: 2 additions & 1 deletion EnhancedFat/Dxe/Fat.h
Expand Up @@ -109,7 +109,8 @@ Revision History
#define PATH_NAME_SEPARATOR L'\\'


#define EFI_FILE_STRING_LENGTH 256
#define EFI_PATH_STRING_LENGTH 260
#define EFI_FILE_STRING_LENGTH 255
#define FAT_MAX_ALLOCATE_SIZE 0xA00000
#define LC_ISO_639_2_ENTRY_SIZE 3
#define MAX_LANG_CODE_SIZE 100
Expand Down
10 changes: 10 additions & 0 deletions EnhancedFat/Dxe/FileName.c
Expand Up @@ -545,6 +545,16 @@ Routine Description:
}

*TempNamePointer = 0;

//
// Per FAT Spec the file name should meet the following criteria:
// C1. Length (FileLongName) <= 255
// C2. Length (X:FileFullPath<NUL>) <= 260
// Here we check C1.
//
if (TempNamePointer - OutputFileName > EFI_FILE_STRING_LENGTH) {
return FALSE;
}
//
// See if there is any illegal characters within the name
//
Expand Down
2 changes: 1 addition & 1 deletion EnhancedFat/Dxe/Hash.c
Expand Up @@ -42,7 +42,7 @@ Routine Description:
--*/
{
UINT32 HashValue;
CHAR16 UpCasedLongFileName[EFI_FILE_STRING_LENGTH + 1];
CHAR16 UpCasedLongFileName[EFI_PATH_STRING_LENGTH];
EfiStrCpy (UpCasedLongFileName, LongNameString);
FatStrUpr (UpCasedLongFileName);
gBS->CalculateCrc32 (UpCasedLongFileName, EfiStrSize (UpCasedLongFileName), &HashValue);
Expand Down
2 changes: 1 addition & 1 deletion EnhancedFat/Dxe/Info.c
Expand Up @@ -302,7 +302,7 @@ Routine Description:
EFI_FILE_INFO *NewInfo;
FAT_OFILE *DotOFile;
FAT_OFILE *Parent;
CHAR16 NewFileName[EFI_FILE_STRING_LENGTH + 1];
CHAR16 NewFileName[EFI_PATH_STRING_LENGTH];
EFI_TIME ZeroTime;
FAT_DIRENT *DirEnt;
FAT_DIRENT *TempDirEnt;
Expand Down
2 changes: 1 addition & 1 deletion EnhancedFat/Dxe/Init.c
Expand Up @@ -462,7 +462,7 @@ Routine Description:
Volume->FirstClusterPos = LShiftU64 (FirstClusterLba, BlockAlignment);
Volume->MaxCluster = (Sectors - FirstClusterLba) >> SectorsPerClusterAlignment;
Volume->ClusterAlignment = BlockAlignment + SectorsPerClusterAlignment;
Volume->ClusterSize = 1 << (Volume->ClusterAlignment);
Volume->ClusterSize = (UINTN)1 << (Volume->ClusterAlignment);

//
// If this is not a fat32, determine if it's a fat16 or fat12
Expand Down
2 changes: 1 addition & 1 deletion EnhancedFat/Dxe/Open.c
Expand Up @@ -105,7 +105,7 @@ Routine Description:
{
FAT_VOLUME *Volume;
EFI_STATUS Status;
CHAR16 NewFileName[EFI_FILE_STRING_LENGTH + 1];
CHAR16 NewFileName[EFI_PATH_STRING_LENGTH];
FAT_DIRENT *DirEnt;
UINT8 FileAttributes;
BOOLEAN WriteMode;
Expand Down

0 comments on commit 95db08f

Please sign in to comment.