Revision: 15390
          http://sourceforge.net/p/edk2/code/15390
Author:   oliviermartin
Date:     2014-03-25 11:04:41 +0000 (Tue, 25 Mar 2014)
Log Message:
-----------
ArmPkg/SemihostFs: Various fixes for the file system

- 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 <[email protected]>
Reviewed-by: Olivier Martin <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
    trunk/edk2/ArmPkg/Library/SemihostLib/SemihostLib.c

Modified: trunk/edk2/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
===================================================================
--- trunk/edk2/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c    2014-03-25 
11:03:54 UTC (rev 15389)
+++ trunk/edk2/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c    2014-03-25 
11:04:41 UTC (rev 15390)
@@ -2,7 +2,7 @@
   Support a Semi Host file system over a debuggers JTAG
 
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-  Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
+  Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
@@ -544,7 +544,9 @@
   if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid) != 0) {
     //Status = SetFilesystemInfo (Fcb, BufferSize, Buffer);
   } else if (CompareGuid (InformationType, &gEfiFileInfoGuid) != 0) {
-    //Status = SetFileInfo (Fcb, BufferSize, Buffer);
+    // Semihosting does not give us access to setting file info, but
+    // if we fail here we cannot create new files.
+    Status = EFI_SUCCESS;
   } else if (CompareGuid (InformationType, 
&gEfiFileSystemVolumeLabelInfoIdGuid) != 0) {
     if (StrSize (Buffer) > 0) {
       FreePool (mSemihostFsLabel);

Modified: trunk/edk2/ArmPkg/Library/SemihostLib/SemihostLib.c
===================================================================
--- trunk/edk2/ArmPkg/Library/SemihostLib/SemihostLib.c 2014-03-25 11:03:54 UTC 
(rev 15389)
+++ trunk/edk2/ArmPkg/Library/SemihostLib/SemihostLib.c 2014-03-25 11:04:41 UTC 
(rev 15390)
@@ -1,7 +1,8 @@
 /** @file
 
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-  
+  Copyright (c) 2013 - 2014, ARM Ltd. All rights reserved.<BR>
+
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD 
License
   which accompanies this distribution.  The full text of the license may be 
found at
@@ -73,10 +74,12 @@
 
   Result = Semihost_SYS_SEEK(&SeekBlock);
 
-  if (Result == 0) {
+  // Semihosting does not behave as documented. It returns the offset on
+  // success.
+  if (Result < 0) {
+    return RETURN_ABORTED;
+  } else {
     return RETURN_SUCCESS;
-  } else {
-    return RETURN_ABORTED;
   }
 }
 
@@ -100,7 +103,7 @@
 
   Result = Semihost_SYS_READ(&ReadBlock);
 
-  if (Result == *Length) {
+  if ((*Length != 0) && (Result == *Length)) {
     return RETURN_ABORTED;
   } else {
     *Length -= Result;
@@ -126,8 +129,11 @@
   WriteBlock.Length = *Length;
 
   *Length = Semihost_SYS_WRITE(&WriteBlock);
-  
-  return RETURN_SUCCESS;
+
+  if (*Length != 0)
+    return RETURN_ABORTED;
+  else
+    return RETURN_SUCCESS;
 }
 
 RETURN_STATUS
@@ -174,6 +180,11 @@
   SEMIHOST_FILE_REMOVE_BLOCK  RemoveBlock;
   UINT32                      Result;
 
+  // Remove any leading separator (e.g.: '\'). EFI Shell adds one.
+  if (*FileName == '\\') {
+    FileName++;
+  }
+
   RemoveBlock.FileName    = FileName;
   RemoveBlock.NameLength  = AsciiStrLen(FileName);
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to