]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/SemihostFs: Various fixes for the file system
authorHarry Liebel <Harry.Liebel@arm.com>
Tue, 25 Mar 2014 11:04:41 +0000 (11:04 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 25 Mar 2014 11:04:41 +0000 (11:04 +0000)
- Fix file deletion from the shell.
- Fix file creation using the shell editor.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Harry Liebel <Harry.Liebel@arm.com>
Reviewed-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15390 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
ArmPkg/Library/SemihostLib/SemihostLib.c

index 447ab5631a3e311576f6312cf9b6d1e96460a9e7..aae9582a6aa5a71221f3e1b2e5e73b258d0ee614 100644 (file)
@@ -2,7 +2,7 @@
   Support a Semi Host file system over a debuggers JTAG\r
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-  Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>\r
+  Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -544,7 +544,9 @@ FileSetInfo (
   if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid) != 0) {\r
     //Status = SetFilesystemInfo (Fcb, BufferSize, Buffer);\r
   } else if (CompareGuid (InformationType, &gEfiFileInfoGuid) != 0) {\r
-    //Status = SetFileInfo (Fcb, BufferSize, Buffer);\r
+    // Semihosting does not give us access to setting file info, but\r
+    // if we fail here we cannot create new files.\r
+    Status = EFI_SUCCESS;\r
   } else if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid) != 0) {\r
     if (StrSize (Buffer) > 0) {\r
       FreePool (mSemihostFsLabel);\r
index 87c0379d6b3a34eddd9cfea8a48bd86451d97bdf..53405edd7a330ad0d08409ff8b434bb6c121e605 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-  \r
+  Copyright (c) 2013 - 2014, ARM Ltd. All rights reserved.<BR>\r
+\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
@@ -73,10 +74,12 @@ SemihostFileSeek (
 \r
   Result = Semihost_SYS_SEEK(&SeekBlock);\r
 \r
-  if (Result == 0) {\r
-    return RETURN_SUCCESS;\r
-  } else {\r
+  // Semihosting does not behave as documented. It returns the offset on\r
+  // success.\r
+  if (Result < 0) {\r
     return RETURN_ABORTED;\r
+  } else {\r
+    return RETURN_SUCCESS;\r
   }\r
 }\r
 \r
@@ -100,7 +103,7 @@ SemihostFileRead (
 \r
   Result = Semihost_SYS_READ(&ReadBlock);\r
 \r
-  if (Result == *Length) {\r
+  if ((*Length != 0) && (Result == *Length)) {\r
     return RETURN_ABORTED;\r
   } else {\r
     *Length -= Result;\r
@@ -126,8 +129,11 @@ SemihostFileWrite (
   WriteBlock.Length = *Length;\r
 \r
   *Length = Semihost_SYS_WRITE(&WriteBlock);\r
-  \r
-  return RETURN_SUCCESS;\r
+\r
+  if (*Length != 0)\r
+    return RETURN_ABORTED;\r
+  else\r
+    return RETURN_SUCCESS;\r
 }\r
 \r
 RETURN_STATUS\r
@@ -174,6 +180,11 @@ SemihostFileRemove (
   SEMIHOST_FILE_REMOVE_BLOCK  RemoveBlock;\r
   UINT32                      Result;\r
 \r
+  // Remove any leading separator (e.g.: '\'). EFI Shell adds one.\r
+  if (*FileName == '\\') {\r
+    FileName++;\r
+  }\r
+\r
   RemoveBlock.FileName    = FileName;\r
   RemoveBlock.NameLength  = AsciiStrLen(FileName);\r
 \r