]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FatPkg/EnhancedFatDxe/ReadWrite.c
MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version
[mirror_edk2.git] / FatPkg / EnhancedFatDxe / ReadWrite.c
index 7ccf517bf15950b9711520bf77c4757cd15b726e..ad3c2604127434f866f85af317c95f0a4bb55fca 100644 (file)
@@ -1,7 +1,8 @@
-/*++\r
+/** @file\r
+  Functions that perform file read/write.\r
 \r
-Copyright (c) 2005, Intel Corporation\r
-All rights reserved. This program and the accompanying materials are licensed and made available\r
+Copyright (c) 2005 - 2017, 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
@@ -10,44 +11,29 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 \r
-Module Name:\r
+**/\r
 \r
-  ReadWrite.c\r
+#include "Fat.h"\r
 \r
-Abstract:\r
+/**\r
 \r
-  Functions that perform file read/write\r
+  Get the file's position of the file.\r
 \r
-Revision History\r
 \r
---*/\r
+  @param  FHand                 - The handle of file.\r
+  @param  Position              - The file's position of the file.\r
 \r
-#include "Fat.h"\r
+  @retval EFI_SUCCESS           - Get the info successfully.\r
+  @retval EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
+  @retval EFI_UNSUPPORTED       - The open file is not a file.\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 FatGetPosition (\r
-  IN  EFI_FILE          *FHand,\r
+  IN  EFI_FILE_PROTOCOL *FHand,\r
   OUT UINT64            *Position\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get the file's position of the file.\r
-\r
-Arguments:\r
-\r
-  FHand                 - The handle of file.\r
-  Position              - The file's position of the file.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Get the info successfully.\r
-  EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
-  EFI_UNSUPPORTED       - The open file is not a file.\r
-\r
---*/\r
 {\r
   FAT_IFILE *IFile;\r
   FAT_OFILE *OFile;\r
@@ -67,30 +53,24 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-EFI_STATUS\r
-EFIAPI\r
-FatSetPosition (\r
-  IN EFI_FILE  *FHand,\r
-  IN UINT64    Position\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Set the file's position of the file.\r
 \r
-Arguments:\r
-\r
-  FHand                 - The handle of file.\r
-  Position              - The file's position of the file.\r
-\r
-Returns:\r
+  @param  FHand                 - The handle of file.\r
+  @param  Position              - The file's position of the file.\r
 \r
-  EFI_SUCCESS           - Set the info successfully.\r
-  EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
-  EFI_UNSUPPORTED       - Set a directory with a not-zero position.\r
+  @retval EFI_SUCCESS           - Set the info successfully.\r
+  @retval EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
+  @retval EFI_UNSUPPORTED       - Set a directory with a not-zero position.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FatSetPosition (\r
+  IN EFI_FILE_PROTOCOL  *FHand,\r
+  IN UINT64             Position\r
+  )\r
 {\r
   FAT_IFILE *IFile;\r
   FAT_OFILE *OFile;\r
@@ -101,6 +81,9 @@ Returns:
   if (OFile->Error == EFI_NOT_FOUND) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
+\r
+  FatWaitNonblockingTask (IFile);\r
+\r
   //\r
   // If this is a directory, we can only set back to position 0\r
   //\r
@@ -117,7 +100,7 @@ Returns:
   //\r
   // Set the position\r
   //\r
-  if (Position == -1) {\r
+  if (Position == (UINT64)-1) {\r
     Position = OFile->FileSize;\r
   }\r
   //\r
@@ -127,30 +110,24 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+\r
+  Get the file info from the open file of the IFile into Buffer.\r
+\r
+  @param  IFile                 - The instance of the open file.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param  Buffer                - Buffer containing read data.\r
+\r
+  @retval EFI_SUCCESS           - Get the file info successfully.\r
+  @retval other                 - An error occurred when operation the disk.\r
+\r
+**/\r
 EFI_STATUS\r
 FatIFileReadDir (\r
   IN     FAT_IFILE              *IFile,\r
   IN OUT UINTN                  *BufferSize,\r
      OUT VOID                   *Buffer\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get the file info from the open file of the IFile into Buffer.\r
-\r
-Arguments:\r
-\r
-  IFile                 - The instance of the open file.\r
-  BufferSize            - Size of Buffer.\r
-  Buffer                - Buffer containing read data.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Get the file info successfully.\r
-  other                 - An error occurred when operation the disk.\r
-\r
---*/\r
 {\r
   EFI_STATUS  Status;\r
   FAT_OFILE   *OFile;\r
@@ -196,58 +173,63 @@ Done:
     // Update IFile->Position, if everything is all right\r
     //\r
     CurrentPos      = ODir->CurrentPos;\r
-    IFile->Position = (UINT64) (CurrentPos * sizeof (FAT_DIRECTORY_ENTRY));\r
+    IFile->Position = CurrentPos * sizeof (FAT_DIRECTORY_ENTRY);\r
   }\r
 \r
   return Status;\r
 }\r
 \r
-EFI_STATUS\r
-FatIFileAccess (\r
-  IN     EFI_FILE              *FHand,\r
-  IN     IO_MODE               IoMode,\r
-  IN OUT UINTN                 *BufferSize,\r
-  IN OUT VOID                  *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Get the file info from the open file of the IFile into Buffer.\r
 \r
-Arguments:\r
-\r
-  FHand                 - The file handle to access.\r
-  IoMode                - Indicate whether the access mode is reading or writing.\r
-  BufferSize            - Size of Buffer.\r
-  Buffer                - Buffer containing read data.\r
-\r
-Returns:\r
+  @param FHand                 - The file handle to access.\r
+  @param  IoMode                - Indicate whether the access mode is reading or writing.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param  Buffer                - Buffer containing read data.\r
+  @param  Token                 - A pointer to the token associated with the transaction.\r
 \r
-  EFI_SUCCESS           - Get the file info successfully.\r
-  EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
-  EFI_VOLUME_CORRUPTED  - The file type of open file is error.\r
-  EFI_WRITE_PROTECTED   - The disk is write protect.\r
-  EFI_ACCESS_DENIED     - The file is read-only.\r
-  other                 - An error occurred when operating on the disk.\r
+  @retval EFI_SUCCESS           - Get the file info successfully.\r
+  @retval EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
+  @retval EFI_VOLUME_CORRUPTED  - The file type of open file is error.\r
+  @retval EFI_WRITE_PROTECTED   - The disk is write protect.\r
+  @retval EFI_ACCESS_DENIED     - The file is read-only.\r
+  @return other                 - An error occurred when operating on the disk.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+FatIFileAccess (\r
+  IN     EFI_FILE_PROTOCOL     *FHand,\r
+  IN     IO_MODE               IoMode,\r
+  IN OUT UINTN                 *BufferSize,\r
+  IN OUT VOID                  *Buffer,\r
+  IN     EFI_FILE_IO_TOKEN     *Token\r
+  )\r
 {\r
   EFI_STATUS  Status;\r
   FAT_IFILE   *IFile;\r
   FAT_OFILE   *OFile;\r
   FAT_VOLUME  *Volume;\r
   UINT64      EndPosition;\r
+  FAT_TASK    *Task;\r
 \r
   IFile  = IFILE_FROM_FHAND (FHand);\r
   OFile  = IFile->OFile;\r
   Volume = OFile->Volume;\r
+  Task   = NULL;\r
+\r
+  //\r
+  // Write to a directory is unsupported\r
+  //\r
+  if ((OFile->ODir != NULL) && (IoMode == WriteData)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
 \r
   if (OFile->Error == EFI_NOT_FOUND) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
-  if (IoMode == READ_DATA) {\r
+  if (IoMode == ReadData) {\r
     //\r
     // If position is at EOF, then return device error\r
     //\r
@@ -267,22 +249,32 @@ Returns:
     }\r
   }\r
 \r
+  if (Token == NULL) {\r
+    FatWaitNonblockingTask (IFile);\r
+  } else {\r
+    //\r
+    // Caller shouldn't call the non-blocking interfaces if the low layer doesn't support DiskIo2.\r
+    // But if it calls, the below check can avoid crash.\r
+    //\r
+    if (FHand->Revision < EFI_FILE_PROTOCOL_REVISION2) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+    Task = FatCreateTask (IFile, Token);\r
+    if (Task == NULL) {\r
+      return EFI_OUT_OF_RESOURCES;\r
+    }\r
+  }\r
+\r
   FatAcquireLock ();\r
 \r
   Status = OFile->Error;\r
   if (!EFI_ERROR (Status)) {\r
     if (OFile->ODir != NULL) {\r
       //\r
-      // Access a directory\r
+      // Read a directory is supported\r
       //\r
-      Status = EFI_UNSUPPORTED;\r
-      if (IoMode == READ_DATA) {\r
-        //\r
-        // Read a directory is supported\r
-        //\r
-        Status = FatIFileReadDir (IFile, BufferSize, Buffer);\r
-      }\r
-\r
+      ASSERT (IoMode == ReadData);\r
+      Status = FatIFileReadDir (IFile, BufferSize, Buffer);\r
       OFile = NULL;\r
     } else {\r
       //\r
@@ -293,7 +285,7 @@ Returns:
         //\r
         // The position goes beyond the end of file\r
         //\r
-        if (IoMode == READ_DATA) {\r
+        if (IoMode == ReadData) {\r
           //\r
           // Adjust the actual size read\r
           //\r
@@ -318,15 +310,20 @@ Returns:
         }\r
       }\r
 \r
-      Status = FatAccessOFile (OFile, IoMode, (UINTN) IFile->Position, BufferSize, Buffer);\r
+      Status = FatAccessOFile (OFile, IoMode, (UINTN) IFile->Position, BufferSize, Buffer, Task);\r
       IFile->Position += *BufferSize;\r
     }\r
   }\r
 \r
-Done:\r
-  if (EFI_ERROR (Status)) {\r
-    Status = FatCleanupVolume (Volume, OFile, Status);\r
+  if (Token != NULL) {\r
+    if (!EFI_ERROR (Status)) {\r
+      Status = FatQueueTask (IFile, Task);\r
+    } else {\r
+      FatDestroyTask (Task);\r
+    }\r
   }\r
+\r
+Done:\r
   //\r
   // On EFI_SUCCESS case, not calling FatCleanupVolume():\r
   // 1) The Cache flush operation is avoided to enhance\r
@@ -336,104 +333,139 @@ Done:
   // 3) Write operation doesn't affect OFile/IFile structure, so\r
   // Reference checking is not necessary.\r
   //\r
+  if (EFI_ERROR (Status)) {\r
+    Status = FatCleanupVolume (Volume, OFile, Status, NULL);\r
+  }\r
+\r
   FatReleaseLock ();\r
   return Status;\r
 }\r
 \r
+/**\r
+\r
+  Get the file info.\r
+\r
+  @param  FHand                 - The handle of the file.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param  Buffer                - Buffer containing read data.\r
+\r
+\r
+  @retval EFI_SUCCESS           - Get the file info successfully.\r
+  @retval EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
+  @retval EFI_VOLUME_CORRUPTED  - The file type of open file is error.\r
+  @return other                 - An error occurred when operation the disk.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 FatRead (\r
-  IN     EFI_FILE       *FHand,\r
-  IN OUT UINTN          *BufferSize,\r
-     OUT VOID           *Buffer\r
+  IN     EFI_FILE_PROTOCOL  *FHand,\r
+  IN OUT UINTN              *BufferSize,\r
+     OUT VOID               *Buffer\r
   )\r
-/*++\r
+{\r
+  return FatIFileAccess (FHand, ReadData, BufferSize, Buffer, NULL);\r
+}\r
 \r
-Routine Description:\r
+/**\r
 \r
   Get the file info.\r
 \r
-Arguments:\r
-\r
-  FHand                 - The handle of the file.\r
-  BufferSize            - Size of Buffer.\r
-  Buffer                - Buffer containing read data.\r
+  @param  FHand                 - The handle of the file.\r
+  @param  Token                 - A pointer to the token associated with the transaction.\r
 \r
-Returns:\r
-\r
-  EFI_SUCCESS           - Get the file info successfully.\r
-  EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
-  EFI_VOLUME_CORRUPTED  - The file type of open file is error.\r
-  other                 - An error occurred when operation the disk.\r
-\r
---*/\r
-{\r
-  return FatIFileAccess (FHand, READ_DATA, BufferSize, Buffer);\r
-}\r
+  @retval EFI_SUCCESS           - Get the file info successfully.\r
+  @retval EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
+  @retval EFI_VOLUME_CORRUPTED  - The file type of open file is error.\r
+  @return other                 - An error occurred when operation the disk.\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
-FatWrite (\r
-  IN     EFI_FILE       *FHand,\r
-  IN OUT UINTN          *BufferSize,\r
-  IN     VOID           *Buffer\r
+FatReadEx (\r
+  IN     EFI_FILE_PROTOCOL  *FHand,\r
+  IN OUT EFI_FILE_IO_TOKEN  *Token\r
   )\r
-/*++\r
+{\r
+  return FatIFileAccess (FHand, ReadData, &Token->BufferSize, Token->Buffer, Token);\r
+}\r
 \r
-Routine Description:\r
+/**\r
 \r
   Write the content of buffer into files.\r
 \r
-Arguments:\r
-\r
-  FHand                 - The handle of the file.\r
-  BufferSize            - Size of Buffer.\r
-  Buffer                - Buffer containing write data.\r
+  @param  FHand                 - The handle of the file.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param  Buffer                - Buffer containing write data.\r
 \r
-Returns:\r
-\r
-  EFI_SUCCESS           - Set the file info successfully.\r
-  EFI_WRITE_PROTECTED   - The disk is write protect.\r
-  EFI_ACCESS_DENIED     - The file is read-only.\r
-  EFI_DEVICE_ERROR      - The OFile is not valid.\r
-  EFI_UNSUPPORTED       - The open file is not a file.\r
+  @retval EFI_SUCCESS           - Set the file info successfully.\r
+  @retval EFI_WRITE_PROTECTED   - The disk is write protect.\r
+  @retval EFI_ACCESS_DENIED     - The file is read-only.\r
+  @retval EFI_DEVICE_ERROR      - The OFile is not valid.\r
+  @retval EFI_UNSUPPORTED       - The open file is not a file.\r
                         - The writing file size is larger than 4GB.\r
-  other                 - An error occurred when operation the disk.\r
+  @return other                 - An error occurred when operation the disk.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FatWrite (\r
+  IN     EFI_FILE_PROTOCOL  *FHand,\r
+  IN OUT UINTN              *BufferSize,\r
+  IN     VOID               *Buffer\r
+  )\r
 {\r
-  return FatIFileAccess (FHand, WRITE_DATA, BufferSize, Buffer);\r
+  return FatIFileAccess (FHand, WriteData, BufferSize, Buffer, NULL);\r
 }\r
 \r
+/**\r
+\r
+  Get the file info.\r
+\r
+  @param  FHand                 - The handle of the file.\r
+  @param  Token                 - A pointer to the token associated with the transaction.\r
+\r
+  @retval EFI_SUCCESS           - Get the file info successfully.\r
+  @retval EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
+  @retval EFI_VOLUME_CORRUPTED  - The file type of open file is error.\r
+  @return other                 - An error occurred when operation the disk.\r
+\r
+**/\r
 EFI_STATUS\r
-FatAccessOFile (\r
-  IN     FAT_OFILE      *OFile,\r
-  IN     IO_MODE        IoMode,\r
-  IN     UINTN          Position,\r
-  IN OUT UINTN          *DataBufferSize,\r
-  IN OUT UINT8          *UserBuffer\r
+EFIAPI\r
+FatWriteEx (\r
+  IN     EFI_FILE_PROTOCOL  *FHand,\r
+  IN OUT EFI_FILE_IO_TOKEN  *Token\r
   )\r
-/*++\r
+{\r
+  return FatIFileAccess (FHand, WriteData, &Token->BufferSize, Token->Buffer, Token);\r
+}\r
 \r
-Routine Description:\r
+/**\r
 \r
   This function reads data from a file or writes data to a file.\r
   It uses OFile->PosRem to determine how much data can be accessed in one time.\r
 \r
-Arguments:\r
-\r
-  OFile                 - The open file.\r
-  IoMode                - Indicate whether the access mode is reading or writing.\r
-  Position              - The position where data will be accessed.\r
-  DataBufferSize        - Size of Buffer.\r
-  UserBuffer            - Buffer containing data.\r
-\r
-Returns:\r
+  @param  OFile                 - The open file.\r
+  @param  IoMode                - Indicate whether the access mode is reading or writing.\r
+  @param  Position              - The position where data will be accessed.\r
+  @param  DataBufferSize        - Size of Buffer.\r
+  @param  UserBuffer            - Buffer containing data.\r
+  @param  Task                    point to task instance.\r
 \r
-  EFI_SUCCESS           - Access the data successfully.\r
-  other                 - An error occurred when operating on the disk.\r
+  @retval EFI_SUCCESS           - Access the data successfully.\r
+  @return other                 - An error occurred when operating on the disk.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+FatAccessOFile (\r
+  IN     FAT_OFILE      *OFile,\r
+  IN     IO_MODE        IoMode,\r
+  IN     UINTN          Position,\r
+  IN OUT UINTN          *DataBufferSize,\r
+  IN OUT UINT8          *UserBuffer,\r
+  IN FAT_TASK           *Task\r
+  )\r
 {\r
   FAT_VOLUME  *Volume;\r
   UINTN       Len;\r
@@ -461,7 +493,7 @@ Returns:
     //\r
     // Write the data\r
     //\r
-    Status = FatDiskIo (Volume, IoMode, OFile->PosDisk, Len, UserBuffer);\r
+    Status = FatDiskIo (Volume, IoMode, OFile->PosDisk, Len, UserBuffer, Task);\r
     if (EFI_ERROR (Status)) {\r
       break;\r
     }\r
@@ -471,7 +503,7 @@ Returns:
     Position   += Len;\r
     UserBuffer += Len;\r
     BufferSize -= Len;\r
-    if (IoMode == WRITE_DATA) {\r
+    if (IoMode == WriteData) {\r
       OFile->Dirty    = TRUE;\r
       OFile->Archive  = TRUE;\r
     }\r
@@ -487,28 +519,22 @@ Returns:
   return Status;\r
 }\r
 \r
-EFI_STATUS\r
-FatExpandOFile (\r
-  IN FAT_OFILE          *OFile,\r
-  IN UINT64             ExpandedSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Expand OFile by appending zero bytes at the end of OFile.\r
 \r
-Arguments:\r
-\r
-  OFile                 - The open file.\r
-  ExpandedSize          - The number of zero bytes appended at the end of the file.\r
-\r
-Returns:\r
+  @param  OFile                 - The open file.\r
+  @param  ExpandedSize          - The number of zero bytes appended at the end of the file.\r
 \r
-  EFI_SUCCESS           - The file is expanded successfully.\r
-  other                 - An error occurred when expanding file.\r
+  @retval EFI_SUCCESS           - The file is expanded successfully.\r
+  @return other                 - An error occurred when expanding file.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+FatExpandOFile (\r
+  IN FAT_OFILE          *OFile,\r
+  IN UINT64             ExpandedSize\r
+  )\r
 {\r
   EFI_STATUS  Status;\r
   UINTN       WritePos;\r
@@ -522,29 +548,23 @@ Returns:
   return Status;\r
 }\r
 \r
-EFI_STATUS\r
-FatWriteZeroPool (\r
-  IN FAT_OFILE  *OFile,\r
-  IN UINTN      WritePos\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Write zero pool from the WritePos to the end of OFile.\r
 \r
-Arguments:\r
-\r
-  OFile                 - The open file to write zero pool.\r
-  WritePos              - The number of zero bytes written.\r
+  @param  OFile                 - The open file to write zero pool.\r
+  @param  WritePos              - The number of zero bytes written.\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS           - Write the zero pool successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  - Not enough memory to perform the operation.\r
+  @return other                 - An error occurred when writing disk.\r
 \r
-  EFI_SUCCESS           - Write the zero pool successfully.\r
-  EFI_OUT_OF_RESOURCES  - Not enough memory to perform the operation.\r
-  other                 - An error occurred when writing disk.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+FatWriteZeroPool (\r
+  IN FAT_OFILE  *OFile,\r
+  IN UINTN      WritePos\r
+  )\r
 {\r
   EFI_STATUS  Status;\r
   VOID        *ZeroBuffer;\r
@@ -572,7 +592,7 @@ Returns:
   do {\r
     WriteSize     = AppendedSize > BufferSize ? BufferSize : (UINTN) AppendedSize;\r
     AppendedSize -= WriteSize;\r
-    Status = FatAccessOFile (OFile, WRITE_DATA, WritePos, &WriteSize, ZeroBuffer);\r
+    Status = FatAccessOFile (OFile, WriteData, WritePos, &WriteSize, ZeroBuffer, NULL);\r
     if (EFI_ERROR (Status)) {\r
       break;\r
     }\r
@@ -584,28 +604,22 @@ Returns:
   return Status;\r
 }\r
 \r
-EFI_STATUS\r
-FatTruncateOFile (\r
-  IN FAT_OFILE          *OFile,\r
-  IN UINTN              TruncatedSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Truncate the OFile to smaller file size.\r
 \r
-Arguments:\r
-\r
-  OFile                 - The open file.\r
-  TruncatedSize         - The new file size.\r
+  @param  OFile                 - The open file.\r
+  @param  TruncatedSize         - The new file size.\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS           - The file is truncated successfully.\r
+  @return other                 - An error occurred when truncating file.\r
 \r
-  EFI_SUCCESS           - The file is truncated successfully.\r
-  other                 - An error occurred when truncating file.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+FatTruncateOFile (\r
+  IN FAT_OFILE          *OFile,\r
+  IN UINTN              TruncatedSize\r
+  )\r
 {\r
   OFile->FileSize = TruncatedSize;\r
   return FatShrinkEof (OFile);\r