diff options
author | ajfish <ajfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-05-05 02:05:48 +0000 |
---|---|---|
committer | ajfish <ajfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-05-05 02:05:48 +0000 |
commit | f4c3fab9b839a86c7f8ad8981d030666272d7539 (patch) | |
tree | 688944aee5ed1c8cd46f278f44359fcc84d40408 | |
parent | 34e0daf37dcf7279a42a9f12c601707e53998aaa (diff) | |
download | edk2-f4c3fab9b839a86c7f8ad8981d030666272d7539.zip edk2-f4c3fab9b839a86c7f8ad8981d030666272d7539.tar.gz edk2-f4c3fab9b839a86c7f8ad8981d030666272d7539.tar.bz2 |
Fixed bug in NT32 file system driver. The FileInfo->FileSize returned for a directory was not a valid value. I fixed the driver to return the correct value.
It looks like the BDS and Shell use a bad algorithm of guessing how big a file name can be. This is bad as it's not defined by the protocol.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2583 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c index 28fd819..eb7b434 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c @@ -1273,7 +1273,7 @@ Returns: UINTN FileInfoSize;
EFI_TPL OldTpl;
- if (This == NULL || BufferSize == NULL || Buffer == NULL) {
+ if (This == NULL || BufferSize == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -1717,6 +1717,11 @@ Returns: SYSTEMTIME SystemTime;
CHAR16 *RealFileName;
CHAR16 *TempPointer;
+ EFI_FILE_INFO *DirInfo;
+ UINTN ReadSize;
+ UINT64 Location;
+ EFI_STATUS DirStatus;
+
Size = SIZE_OF_EFI_FILE_INFO;
NameSize = StrSize (PrivateFile->FileName);
@@ -1801,6 +1806,45 @@ Returns: } else {
CopyMem ((CHAR8 *) Buffer + Size, RealFileName, NameSize);
}
+
+ if (Info->Attribute & EFI_FILE_DIRECTORY) {
+ //
+ // The GetFileInformationByHandle.nFileSizeLow is bogus for dir so we
+ // need to do the same thing the caller would do to get the right value
+ //
+ ASSERT (PrivateFile->EfiFile.Read != NULL);
+ DirStatus = PrivateFile->EfiFile.GetPosition (&PrivateFile->EfiFile, &Location);
+ if (EFI_ERROR (DirStatus)) {
+ Location = 0;
+ }
+
+ PrivateFile->EfiFile.SetPosition (&PrivateFile->EfiFile, 0);
+ Info->FileSize = 0;
+ do {
+ ReadSize = 0;
+ DirInfo = NULL;
+ DirStatus = PrivateFile->EfiFile.Read (&PrivateFile->EfiFile, &ReadSize, DirInfo);
+ if (DirStatus == EFI_BUFFER_TOO_SMALL) {
+ DirInfo = AllocatePool (ReadSize);
+ if (DirInfo != NULL) {
+ //
+ // Read each dir entry to figure out how big the directory is
+ //
+ DirStatus = PrivateFile->EfiFile.Read (&PrivateFile->EfiFile, &ReadSize, DirInfo);
+ if (!EFI_ERROR (DirStatus) && (ReadSize != 0)) {
+ Info->FileSize += ReadSize;
+ }
+ FreePool (DirInfo);
+ }
+ }
+
+ } while (!EFI_ERROR (DirStatus) && (ReadSize != 0));
+
+ //
+ // reset the file possition back to the previous location
+ //
+ PrivateFile->EfiFile.SetPosition (&PrivateFile->EfiFile, Location);
+ }
}
*BufferSize = ResultSize;
|