]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FatPkg/EnhancedFatDxe/DirectoryManage.c
MdeModulePkg/PiSmmIpl: Check order of EndOfDxe and DxeSmmReadyToLock
[mirror_edk2.git] / FatPkg / EnhancedFatDxe / DirectoryManage.c
index 9fdb7affe4547b4a9c4beeec805d17f33762e5d6..91e7599e272258e465f485c35416af0f33c16208 100644 (file)
@@ -1,7 +1,7 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials are licensed and made available\r
+Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available\r
 under the terms and conditions of the BSD License which accompanies this\r
 distribution. The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -67,7 +67,7 @@ Returns:
   }\r
 \r
   BufferSize = sizeof (FAT_DIRECTORY_ENTRY);\r
-  return FatAccessOFile (Parent, IoMode, Position, &BufferSize, Entry);\r
+  return FatAccessOFile (Parent, IoMode, Position, &BufferSize, Entry, NULL);\r
 }\r
 \r
 EFI_STATUS\r
@@ -116,7 +116,15 @@ Returns:
     // Write LFN directory entry\r
     //\r
     SetMem (LfnBuffer, sizeof (CHAR16) * LFN_CHAR_TOTAL * EntryCount, 0xff);\r
-    StrCpy (LfnBuffer, DirEnt->FileString);\r
+    Status = StrCpyS (\r
+               LfnBuffer,\r
+               sizeof (LfnBuffer) / sizeof (LfnBuffer[0]),\r
+               DirEnt->FileString\r
+               );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
     LfnBufferPointer    = LfnBuffer;\r
     LfnEntry.Attributes = FAT_ATTRIBUTE_LFN;\r
     LfnEntry.Type       = 0;\r
@@ -349,7 +357,11 @@ Returns:
     // Fail to get the long file name from long file name entry,\r
     // get the file name from short name\r
     //\r
-    FatGetFileNameViaCaseFlag (DirEnt, LfnBuffer);\r
+    FatGetFileNameViaCaseFlag (\r
+      DirEnt,\r
+      LfnBuffer,\r
+      sizeof (LfnBuffer) / sizeof (LfnBuffer[0])\r
+      );\r
   }\r
 \r
   DirEnt->FileString = AllocateCopyPool (StrSize (LfnBuffer), LfnBuffer);\r
@@ -989,7 +1001,8 @@ Returns:
   // We will append this entry to the end of directory\r
   //\r
   FatGetCurrentFatTime (&DirEnt->Entry.FileCreateTime);\r
-  FatGetCurrentFatTime (&DirEnt->Entry.FileModificationTime);\r
+  CopyMem (&DirEnt->Entry.FileModificationTime, &DirEnt->Entry.FileCreateTime, sizeof (FAT_DATE_TIME));\r
+  CopyMem (&DirEnt->Entry.FileLastAccess, &DirEnt->Entry.FileCreateTime.Date, sizeof (FAT_DATE));\r
   NewEndPos = ODir->CurrentEndPos + DirEnt->EntryCount;\r
   if (NewEndPos * sizeof (FAT_DIRECTORY_ENTRY) > OFile->FileSize) {\r
     if (NewEndPos >= (OFile->IsFixedRootDir ? OFile->Volume->RootEntries : FAT_MAX_DIRENTRY_COUNT)) {\r
@@ -1184,6 +1197,7 @@ Returns:
   FAT_ODIR    *ODir;\r
   EFI_STATUS  Status;\r
 \r
+  ASSERT (OFile != NULL);\r
   ODir = OFile->ODir;\r
   ASSERT (ODir != NULL);\r
   DirEnt = AllocateZeroPool (sizeof (FAT_DIRENT));\r
@@ -1375,8 +1389,8 @@ Returns:
   FAT_VOLUME  *Volume;\r
 \r
   OFile   = DirEnt->OFile;\r
-  Volume  = OFile->Volume;\r
   ASSERT (OFile != NULL);\r
+  Volume  = OFile->Volume;\r
 \r
   if (OFile->ODir != NULL) {\r
     FatDiscardODir (OFile);\r
@@ -1440,6 +1454,8 @@ Returns:
   FAT_OFILE   *OFile;\r
   FAT_DIRENT  *DirEnt;\r
 \r
+  DirEnt = NULL;\r
+\r
   FileNameLen = StrLen (FileName);\r
   if (FileNameLen == 0) {\r
     return EFI_INVALID_PARAMETER;\r