mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 07:34:06 +02:00
EmbeddedPkg/Ebl: Fix EBL copy file command
In the previous version, this command was not working: cp fs0:\zImage fs1:\ This change uses the source filename is the destination filename is not specified. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12406 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
c93ab96c01
commit
5439ccda50
@ -732,19 +732,64 @@ EblFileCopyCmd (
|
|||||||
VOID *Buffer = NULL;
|
VOID *Buffer = NULL;
|
||||||
UINTN Size;
|
UINTN Size;
|
||||||
UINTN Offset;
|
UINTN Offset;
|
||||||
UINTN Chunk = FILE_COPY_CHUNK;
|
UINTN Chunk = FILE_COPY_CHUNK;
|
||||||
|
UINTN FileNameLen;
|
||||||
|
CHAR8* DestFileName;
|
||||||
|
CHAR8* SrcFileName;
|
||||||
|
CHAR8* SrcPtr;
|
||||||
|
|
||||||
if (Argc < 3) {
|
if (Argc < 3) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DestFileName = Argv[2];
|
||||||
|
FileNameLen = AsciiStrLen (DestFileName);
|
||||||
|
|
||||||
|
// Check if the destination file name looks like a directory
|
||||||
|
if ((DestFileName[FileNameLen-1] == '\\') || (DestFileName[FileNameLen-1] == ':')) {
|
||||||
|
// Set the pointer after the source drive (eg: after fs1:)
|
||||||
|
SrcPtr = AsciiStrStr (Argv[1], ":");
|
||||||
|
if (SrcPtr == NULL) {
|
||||||
|
SrcPtr = Argv[1];
|
||||||
|
} else {
|
||||||
|
SrcPtr++;
|
||||||
|
if (*SrcPtr == '\\') {
|
||||||
|
SrcPtr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*SrcPtr == '\0') {
|
||||||
|
AsciiPrint("Source file incorrect.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip the Source Directories
|
||||||
|
while (1) {
|
||||||
|
SrcFileName = SrcPtr;
|
||||||
|
SrcPtr = AsciiStrStr (SrcPtr,"\\");
|
||||||
|
if (SrcPtr != NULL) {
|
||||||
|
SrcPtr++;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*SrcFileName == '\0') {
|
||||||
|
AsciiPrint("Source file incorrect (Error 2).\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct the destination filepath
|
||||||
|
DestFileName = (CHAR8*)AllocatePool (FileNameLen + AsciiStrLen (SrcFileName) + 1);
|
||||||
|
AsciiStrCpy (DestFileName, Argv[2]);
|
||||||
|
AsciiStrCat (DestFileName, SrcFileName);
|
||||||
|
}
|
||||||
|
|
||||||
Source = EfiOpen(Argv[1], EFI_FILE_MODE_READ, 0);
|
Source = EfiOpen(Argv[1], EFI_FILE_MODE_READ, 0);
|
||||||
if (Source == NULL) {
|
if (Source == NULL) {
|
||||||
AsciiPrint("Source file open error.\n");
|
AsciiPrint("Source file open error.\n");
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
Destination = EfiOpen(Argv[2], EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);
|
Destination = EfiOpen(DestFileName, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);
|
||||||
if (Destination == NULL) {
|
if (Destination == NULL) {
|
||||||
AsciiPrint("Destination file open error.\n");
|
AsciiPrint("Destination file open error.\n");
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
@ -803,6 +848,11 @@ Exit:
|
|||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
AsciiPrint("Destination close error %r\n", Status);
|
AsciiPrint("Destination close error %r\n", Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Case when we have concated the filename to the destination directory
|
||||||
|
if (DestFileName != Argv[2]) {
|
||||||
|
FreePool (DestFileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Buffer != NULL) {
|
if (Buffer != NULL) {
|
||||||
@ -972,7 +1022,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdDeviceTemplate[] =
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cp",
|
"cp",
|
||||||
" file1 file2; copy file",
|
" file1 file2; copy file only.",
|
||||||
NULL,
|
NULL,
|
||||||
EblFileCopyCmd
|
EblFileCopyCmd
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user