]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UnixPkg/UnixBlockIoDxe/UnixBlockIo.c
Roll back one unnecessary change in Dispatcher.c, which is added by previous patch.
[mirror_edk2.git] / UnixPkg / UnixBlockIoDxe / UnixBlockIo.c
index a483a876dcdda9ea5250da332d7b7dfcf42a0b6c..2de6cc628267b894723f0849de86f5ee3216965a 100644 (file)
@@ -1,7 +1,7 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -410,7 +410,7 @@ Returns:
   BOOLEAN                     WriteProtected;\r
   UINTN                       NumberOfBlocks;\r
   UINTN                       BlockSize;\r
-  INTN                       i;\r
+  INTN                        i;\r
 \r
   //\r
   // Grab the protocols we need\r
@@ -774,12 +774,9 @@ Returns:
   //\r
   // Open the device\r
   //\r
-  Private->fd = Private->UnixThunk->Open\r
-    (Private->Filename, Private->Mode, 0644);\r
-\r
+  Private->fd = Private->UnixThunk->Open (Private->Filename, Private->Mode, 0644);\r
   if (Private->fd < 0) {\r
-    DEBUG ((EFI_D_INFO, "PlOpenBlock: Could not open %s\n",\r
-           Private->Filename));\r
+    DEBUG ((EFI_D_INFO, "PlOpenBlock: Could not open %a\n", Private->Filename));\r
     BlockIo->Media->MediaPresent  = FALSE;\r
     Status                        = EFI_NO_MEDIA;\r
     goto Done;\r
@@ -798,16 +795,17 @@ Returns:
   // get the size of the file\r
   //\r
   Status = SetFilePointer64 (Private, 0, &FileSize, SEEK_END);\r
-\r
   if (EFI_ERROR (Status)) {\r
     FileSize = MultU64x32 (Private->NumberOfBlocks, Private->BlockSize);\r
-    DEBUG ((EFI_D_ERROR, "PlOpenBlock: Could not get filesize of %s\n", Private->Filename));\r
+    DEBUG ((EFI_D_ERROR, "PlOpenBlock: Could not get filesize of %a\n", Private->Filename));\r
     Status = EFI_UNSUPPORTED;\r
     goto Done;\r
   }\r
 \r
   if (Private->NumberOfBlocks == 0) {\r
     Private->NumberOfBlocks = DivU64x32 (FileSize, Private->BlockSize);\r
+    Private->LastBlock = Private->NumberOfBlocks - 1;\r
+    Private->Media.LastBlock = Private->LastBlock;\r
   }\r
 \r
   EndOfFile = MultU64x32 (Private->NumberOfBlocks, Private->BlockSize);\r
@@ -829,7 +827,7 @@ Returns:
     Private->UnixThunk->FTruncate (Private->fd, EndOfFile);\r
   }\r
 \r
-  DEBUG ((EFI_D_INIT, "%HPlOpenBlock: opened %s%N\n", Private->Filename));\r
+  DEBUG ((EFI_D_INIT, "%HPlOpenBlock: opened %a%N\n", Private->Filename));\r
   Status = EFI_SUCCESS;\r
 \r
 Done:\r
@@ -975,7 +973,7 @@ Returns:
     return EFI_MEDIA_CHANGED;\r
   }\r
 \r
-  if ((UINT32) Buffer % Private->Media.IoAlign != 0) {\r
+  if ((UINTN) Buffer % Private->Media.IoAlign != 0) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
   \r
@@ -1258,7 +1256,7 @@ SetFilePointer64 (
   IN  UNIX_BLOCK_IO_PRIVATE    *Private,\r
   IN  INT64                      DistanceToMove,\r
   OUT UINT64                     *NewFilePointer,\r
-  IN  INTN                      MoveMethod\r
+  IN  INT32                      MoveMethod\r
   )\r
 /*++\r
 \r
@@ -1276,6 +1274,7 @@ This function extends the capability of SetFilePointer to accept 64 bit paramete
   EFI_STATUS    Status;\r
   off_t         res;\r
 \r
+  Status = EFI_SUCCESS;\r
   res = Private->UnixThunk->Lseek(Private->fd, DistanceToMove, MoveMethod);\r
   if (res == -1) {\r
     Status = EFI_INVALID_PARAMETER;\r