X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Nt32Pkg%2FWinNtSimpleFileSystemDxe%2FWinNtSimpleFileSystem.c;h=ef9fa8673c5ceac7a30278e4537d7a6235d66b94;hb=b80022da3b54bda5de3da298a56a7ec0e5873384;hp=eb8971febeca87c57825ed280a75e23d3c5b058c;hpb=c0cf06d6dacbed7b64e4f0fd2383e5b552ed1aba;p=mirror_edk2.git diff --git a/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c b/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c index eb8971febe..ef9fa8673c 100644 --- a/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c +++ b/Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c @@ -1,7 +1,7 @@ /**@file -Copyright (c) 2006 - 2009, Intel Corporation -All rights reserved. This program and the accompanying materials +Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -544,6 +544,7 @@ Returns: WIN_NT_EFI_FILE_PRIVATE *PrivateFile; EFI_TPL OldTpl; CHAR16 *TempFileName; + UINTN Size; if (This == NULL || Root == NULL) { return EFI_INVALID_PARAMETER; @@ -613,10 +614,12 @@ Returns: // // Find the first file under it // + Size = StrSize (PrivateFile->FilePath); + Size += StrSize (L"\\*"); Status = gBS->AllocatePool ( EfiBootServicesData, - StrSize (PrivateFile->FilePath) + StrSize (L"\\*"), - &TempFileName + Size, + (VOID **)&TempFileName ); if (EFI_ERROR (Status)) { goto Done; @@ -1972,11 +1975,6 @@ 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); @@ -1997,6 +1995,7 @@ Returns: Info->FileSize = FileInfo.nFileSizeLow; Info->PhysicalSize = Info->FileSize; + PrivateFile->WinNtThunk->FileTimeToLocalFileTime(&FileInfo.ftCreationTime, &FileInfo.ftCreationTime); PrivateFile->WinNtThunk->FileTimeToSystemTime (&FileInfo.ftCreationTime, &SystemTime); Info->CreateTime.Year = SystemTime.wYear; Info->CreateTime.Month = (UINT8) SystemTime.wMonth; @@ -2005,6 +2004,7 @@ Returns: Info->CreateTime.Minute = (UINT8) SystemTime.wMinute; Info->CreateTime.Second = (UINT8) SystemTime.wSecond; + PrivateFile->WinNtThunk->FileTimeToLocalFileTime(&FileInfo.ftLastAccessTime, &FileInfo.ftLastAccessTime); PrivateFile->WinNtThunk->FileTimeToSystemTime (&FileInfo.ftLastAccessTime, &SystemTime); Info->LastAccessTime.Year = SystemTime.wYear; Info->LastAccessTime.Month = (UINT8) SystemTime.wMonth; @@ -2013,6 +2013,7 @@ Returns: Info->LastAccessTime.Minute = (UINT8) SystemTime.wMinute; Info->LastAccessTime.Second = (UINT8) SystemTime.wSecond; + PrivateFile->WinNtThunk->FileTimeToLocalFileTime(&FileInfo.ftLastWriteTime, &FileInfo.ftLastWriteTime); PrivateFile->WinNtThunk->FileTimeToSystemTime (&FileInfo.ftLastWriteTime, &SystemTime); Info->ModificationTime.Year = SystemTime.wYear; Info->ModificationTime.Month = (UINT8) SystemTime.wMonth; @@ -2061,45 +2062,6 @@ 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; @@ -2388,12 +2350,12 @@ Returns: // Set file system information. // if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) { - if (BufferSize < SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (PrivateRoot->VolumeLabel)) { + NewFileSystemInfo = (EFI_FILE_SYSTEM_INFO *) Buffer; + if (BufferSize < SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (NewFileSystemInfo->VolumeLabel)) { Status = EFI_BAD_BUFFER_SIZE; goto Done; } - NewFileSystemInfo = (EFI_FILE_SYSTEM_INFO *) Buffer; FreePool (PrivateRoot->VolumeLabel); PrivateRoot->VolumeLabel = AllocatePool (StrSize (NewFileSystemInfo->VolumeLabel)); @@ -2669,8 +2631,8 @@ Returns: FreePool (TempFileName); } } else { + Status = EFI_ACCESS_DENIED; Reopen: ; - Status = EFI_DEVICE_ERROR; NtStatus = PrivateFile->WinNtThunk->SetFileAttributes (OldFileName, OldAttr); @@ -2771,6 +2733,13 @@ Reopen: ; goto Done; } + if (!PrivateFile->WinNtThunk->LocalFileTimeToFileTime ( + &NewCreationFileTime, + &NewCreationFileTime + )) { + goto Done; + } + NewLastAccessSystemTime.wYear = NewFileInfo->LastAccessTime.Year; NewLastAccessSystemTime.wMonth = NewFileInfo->LastAccessTime.Month; NewLastAccessSystemTime.wDay = NewFileInfo->LastAccessTime.Day; @@ -2786,6 +2755,13 @@ Reopen: ; goto Done; } + if (!PrivateFile->WinNtThunk->LocalFileTimeToFileTime ( + &NewLastAccessFileTime, + &NewLastAccessFileTime + )) { + goto Done; + } + NewLastWriteSystemTime.wYear = NewFileInfo->ModificationTime.Year; NewLastWriteSystemTime.wMonth = NewFileInfo->ModificationTime.Month; NewLastWriteSystemTime.wDay = NewFileInfo->ModificationTime.Day; @@ -2801,6 +2777,13 @@ Reopen: ; goto Done; } + if (!PrivateFile->WinNtThunk->LocalFileTimeToFileTime ( + &NewLastWriteFileTime, + &NewLastWriteFileTime + )) { + goto Done; + } + if (!PrivateFile->WinNtThunk->SetFileTime ( PrivateFile->IsDirectoryPath ? PrivateFile->DirHandle : PrivateFile->LHandle, &NewCreationFileTime, @@ -2846,6 +2829,7 @@ Reopen: ; NtStatus = PrivateFile->WinNtThunk->SetFileAttributes (NewFileName, NewAttr); if (!NtStatus) { + Status = EFI_DEVICE_ERROR; goto Reopen; }