- 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
Support a Semi Host file system over a debuggers JTAG\r
\r
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
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
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
if (CompareGuid (InformationType, &gEfiFileSystemInfoGuid) != 0) {\r
//Status = SetFilesystemInfo (Fcb, BufferSize, Buffer);\r
} else if (CompareGuid (InformationType, &gEfiFileInfoGuid) != 0) {\r
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
} else if (CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid) != 0) {\r
if (StrSize (Buffer) > 0) {\r
FreePool (mSemihostFsLabel);\r
/** @file\r
\r
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
/** @file\r
\r
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\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
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
\r
Result = Semihost_SYS_SEEK(&SeekBlock);\r
\r
\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
+ } else {\r
+ return RETURN_SUCCESS;\r
\r
Result = Semihost_SYS_READ(&ReadBlock);\r
\r
\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
return RETURN_ABORTED;\r
} else {\r
*Length -= Result;\r
WriteBlock.Length = *Length;\r
\r
*Length = Semihost_SYS_WRITE(&WriteBlock);\r
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
SEMIHOST_FILE_REMOVE_BLOCK RemoveBlock;\r
UINT32 Result;\r
\r
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
RemoveBlock.FileName = FileName;\r
RemoveBlock.NameLength = AsciiStrLen(FileName);\r
\r