]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FatPkg/EnhancedFatDxe/DirectoryManage.c
FatPkg/EnhancedFatDxe: Make the variable name follow rule
[mirror_edk2.git] / FatPkg / EnhancedFatDxe / DirectoryManage.c
index 8d6d15467e6b5e9341fae27758e3df1d4e5d93fb..149119dc2dba194ba60d8263fc57371838dfb57b 100644 (file)
@@ -1,7 +1,7 @@
 /*++\r
 \r
 /*++\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
 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
@@ -60,14 +60,14 @@ Returns:
     //\r
     // End of directory\r
     //\r
     //\r
     // End of directory\r
     //\r
-    ASSERT (IoMode == READ_DATA);\r
+    ASSERT (IoMode == ReadData);\r
     ((FAT_DIRECTORY_ENTRY *) Entry)->FileName[0] = EMPTY_ENTRY_MARK;\r
     ((FAT_DIRECTORY_ENTRY *) Entry)->Attributes  = 0;\r
     return EFI_SUCCESS;\r
   }\r
 \r
   BufferSize = sizeof (FAT_DIRECTORY_ENTRY);\r
     ((FAT_DIRECTORY_ENTRY *) Entry)->FileName[0] = EMPTY_ENTRY_MARK;\r
     ((FAT_DIRECTORY_ENTRY *) Entry)->Attributes  = 0;\r
     return EFI_SUCCESS;\r
   }\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
 }\r
 \r
 EFI_STATUS\r
@@ -106,7 +106,7 @@ Returns:
   //\r
   // Write directory entry\r
   //\r
   //\r
   // Write directory entry\r
   //\r
-  Status = FatAccessEntry (OFile, WRITE_DATA, EntryPos, &DirEnt->Entry);\r
+  Status = FatAccessEntry (OFile, WriteData, EntryPos, &DirEnt->Entry);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -116,7 +116,15 @@ Returns:
     // Write LFN directory entry\r
     //\r
     SetMem (LfnBuffer, sizeof (CHAR16) * LFN_CHAR_TOTAL * EntryCount, 0xff);\r
     // 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
+               ARRAY_SIZE (LfnBuffer),\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
     LfnBufferPointer    = LfnBuffer;\r
     LfnEntry.Attributes = FAT_ATTRIBUTE_LFN;\r
     LfnEntry.Type       = 0;\r
@@ -139,7 +147,7 @@ Returns:
         LfnEntry.Ordinal = DELETE_ENTRY_MARK;\r
       }\r
 \r
         LfnEntry.Ordinal = DELETE_ENTRY_MARK;\r
       }\r
 \r
-      Status = FatAccessEntry (OFile, WRITE_DATA, EntryPos, &LfnEntry);\r
+      Status = FatAccessEntry (OFile, WriteData, EntryPos, &LfnEntry);\r
       if (EFI_ERROR (Status)) {\r
         return Status;\r
       }\r
       if (EFI_ERROR (Status)) {\r
         return Status;\r
       }\r
@@ -314,7 +322,7 @@ Returns:
     }\r
 \r
     EntryPos--;\r
     }\r
 \r
     EntryPos--;\r
-    Status = FatAccessEntry (Parent, READ_DATA, EntryPos, &LfnEntry);\r
+    Status = FatAccessEntry (Parent, ReadData, EntryPos, &LfnEntry);\r
     if (EFI_ERROR (Status) ||\r
         LfnEntry.Attributes != FAT_ATTRIBUTE_LFN ||\r
         LfnEntry.MustBeZero != 0 ||\r
     if (EFI_ERROR (Status) ||\r
         LfnEntry.Attributes != FAT_ATTRIBUTE_LFN ||\r
         LfnEntry.MustBeZero != 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
     // 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
+      ARRAY_SIZE (LfnBuffer)\r
+      );\r
   }\r
 \r
   DirEnt->FileString = AllocateCopyPool (StrSize (LfnBuffer), LfnBuffer);\r
   }\r
 \r
   DirEnt->FileString = AllocateCopyPool (StrSize (LfnBuffer), LfnBuffer);\r
@@ -430,7 +442,7 @@ Returns:
     //\r
     // Read the next directory entry until we find a valid directory entry (excluding lfn entry)\r
     //\r
     //\r
     // Read the next directory entry until we find a valid directory entry (excluding lfn entry)\r
     //\r
-    Status = FatAccessEntry (OFile, READ_DATA, ODir->CurrentEndPos, &Entry);\r
+    Status = FatAccessEntry (OFile, ReadData, ODir->CurrentEndPos, &Entry);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
@@ -450,7 +462,7 @@ Returns:
     // Although FAT spec states this field is always 0 for FAT12 & FAT16, some applications\r
     // might use it for some special usage, it is safer to zero it in memory for FAT12 & FAT16.\r
     //\r
     // Although FAT spec states this field is always 0 for FAT12 & FAT16, some applications\r
     // might use it for some special usage, it is safer to zero it in memory for FAT12 & FAT16.\r
     //\r
-    if (OFile->Volume->FatType != FAT32) {\r
+    if (OFile->Volume->FatType != Fat32) {\r
       Entry.FileClusterHigh = 0;\r
     }\r
 \r
       Entry.FileClusterHigh = 0;\r
     }\r
 \r
@@ -845,7 +857,7 @@ Returns:
   Entry           = &DirEnt->Entry;\r
   DirEnt->Invalid = TRUE;\r
   do {\r
   Entry           = &DirEnt->Entry;\r
   DirEnt->Invalid = TRUE;\r
   do {\r
-    Status = FatAccessEntry (Root, READ_DATA, EntryPos, Entry);\r
+    Status = FatAccessEntry (Root, ReadData, EntryPos, Entry);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
@@ -1185,6 +1197,7 @@ Returns:
   FAT_ODIR    *ODir;\r
   EFI_STATUS  Status;\r
 \r
   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
   ODir = OFile->ODir;\r
   ASSERT (ODir != NULL);\r
   DirEnt = AllocateZeroPool (sizeof (FAT_DIRENT));\r
@@ -1322,7 +1335,7 @@ Returns:
       Volume                = VOLUME_FROM_ROOT_DIRENT (DirEnt);\r
       Volume->Root          = OFile;\r
       OFile->FileCluster    = Volume->RootCluster;\r
       Volume                = VOLUME_FROM_ROOT_DIRENT (DirEnt);\r
       Volume->Root          = OFile;\r
       OFile->FileCluster    = Volume->RootCluster;\r
-      if (Volume->FatType  != FAT32) {\r
+      if (Volume->FatType  != Fat32) {\r
         OFile->IsFixedRootDir  = TRUE;\r
       }\r
     }\r
         OFile->IsFixedRootDir  = TRUE;\r
       }\r
     }\r
@@ -1376,8 +1389,8 @@ Returns:
   FAT_VOLUME  *Volume;\r
 \r
   OFile   = DirEnt->OFile;\r
   FAT_VOLUME  *Volume;\r
 \r
   OFile   = DirEnt->OFile;\r
-  Volume  = OFile->Volume;\r
   ASSERT (OFile != NULL);\r
   ASSERT (OFile != NULL);\r
+  Volume  = OFile->Volume;\r
 \r
   if (OFile->ODir != NULL) {\r
     FatDiscardODir (OFile);\r
 \r
   if (OFile->ODir != NULL) {\r
     FatDiscardODir (OFile);\r
@@ -1441,6 +1454,8 @@ Returns:
   FAT_OFILE   *OFile;\r
   FAT_DIRENT  *DirEnt;\r
 \r
   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
   FileNameLen = StrLen (FileName);\r
   if (FileNameLen == 0) {\r
     return EFI_INVALID_PARAMETER;\r