]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/FileSystem/BootMonFs/BootMonFsReadWrite.c
ArmPlatformPkg/BootMonFs: Fix error codes returned by Open() and Read()
[mirror_edk2.git] / ArmPlatformPkg / FileSystem / BootMonFs / BootMonFsReadWrite.c
index 653b2c507c7e5d1f02a81f6926188d3d167e72bd..358332d6582f2bbe3f9fbdf8abda95ed68c024c3 100644 (file)
 \r
 #include "BootMonFsInternal.h"\r
 \r
+/**\r
+  Read data from an open file.\r
+\r
+  @param[in]      This        A pointer to the EFI_FILE_PROTOCOL instance that\r
+                              is the file handle to read data from.\r
+  @param[in out]  BufferSize  On input, the size of the Buffer. On output, the\r
+                              amount of data returned in Buffer. In both cases,\r
+                              the size is measured in bytes.\r
+  @param[out]     Buffer      The buffer into which the data is read.\r
+\r
+  @retval  EFI_SUCCESS            The data was read.\r
+  @retval  EFI_DEVICE_ERROR       On entry, the current file position is\r
+                                  beyond the end of the file, or the device\r
+                                  reported an error while performing the read\r
+                                  operation.\r
+  @retval  EFI_INVALID_PARAMETER  At least one of the parameters is invalid.\r
+**/\r
 EFIAPI\r
 EFI_STATUS\r
 BootMonFsReadFile (\r
@@ -51,9 +68,14 @@ BootMonFsReadFile (
   FileStart = (Media->LowestAlignedLba + File->HwDescription.BlockStart) * Media->BlockSize;\r
 \r
   if (File->Position >= File->HwDescription.Region[0].Size) {\r
-    // The entire file has been read\r
+    // The entire file has been read or the position has been\r
+    // set past the end of the file.\r
     *BufferSize = 0;\r
-    return EFI_DEVICE_ERROR;\r
+    if (File->Position > File->HwDescription.Region[0].Size) {\r
+      return EFI_DEVICE_ERROR;\r
+    } else {\r
+      return EFI_SUCCESS;\r
+    }\r
   }\r
 \r
   // This driver assumes that the entire file is in region 0.\r