X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ArmPkg%2FLibrary%2FSemihostLib%2FSemihostLib.c;fp=ArmPkg%2FLibrary%2FSemihostLib%2FSemihostLib.c;h=53405edd7a330ad0d08409ff8b434bb6c121e605;hp=87c0379d6b3a34eddd9cfea8a48bd86451d97bdf;hb=d276ac10f184aea06b5b484c8eeef88c5d6df881;hpb=228fdff4bece78e53f44c79f5478dde7d51a8250 diff --git a/ArmPkg/Library/SemihostLib/SemihostLib.c b/ArmPkg/Library/SemihostLib/SemihostLib.c index 87c0379d6b..53405edd7a 100644 --- a/ArmPkg/Library/SemihostLib/SemihostLib.c +++ b/ArmPkg/Library/SemihostLib/SemihostLib.c @@ -1,7 +1,8 @@ /** @file Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- + Copyright (c) 2013 - 2014, ARM Ltd. All rights reserved.
+ 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 @@ SemihostFileSeek ( Result = Semihost_SYS_SEEK(&SeekBlock); - if (Result == 0) { - return RETURN_SUCCESS; - } else { + // Semihosting does not behave as documented. It returns the offset on + // success. + if (Result < 0) { return RETURN_ABORTED; + } else { + return RETURN_SUCCESS; } } @@ -100,7 +103,7 @@ SemihostFileRead ( Result = Semihost_SYS_READ(&ReadBlock); - if (Result == *Length) { + if ((*Length != 0) && (Result == *Length)) { return RETURN_ABORTED; } else { *Length -= Result; @@ -126,8 +129,11 @@ SemihostFileWrite ( 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 @@ SemihostFileRemove ( 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);