summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-22 22:52:16 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-22 22:52:16 +0000
commit5439ccda50acf4f6e2c1cbd256a30ba555da3eda (patch)
tree5d986aad10a800681be1ea8afa8601ced744b308 /EmbeddedPkg
parentc93ab96c015f878b9e20e7b524a566f49bab907b (diff)
downloadedk2-5439ccda50acf4f6e2c1cbd256a30ba555da3eda.tar.gz
edk2-5439ccda50acf4f6e2c1cbd256a30ba555da3eda.tar.bz2
edk2-5439ccda50acf4f6e2c1cbd256a30ba555da3eda.zip
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
Diffstat (limited to 'EmbeddedPkg')
-rw-r--r--EmbeddedPkg/Ebl/EfiDevice.c56
1 files changed, 53 insertions, 3 deletions
diff --git a/EmbeddedPkg/Ebl/EfiDevice.c b/EmbeddedPkg/Ebl/EfiDevice.c
index dfdbc3fe78..c623bd8b7e 100644
--- a/EmbeddedPkg/Ebl/EfiDevice.c
+++ b/EmbeddedPkg/Ebl/EfiDevice.c
@@ -732,19 +732,64 @@ EblFileCopyCmd (
VOID *Buffer = NULL;
UINTN Size;
UINTN Offset;
- UINTN Chunk = FILE_COPY_CHUNK;
+ UINTN Chunk = FILE_COPY_CHUNK;
+ UINTN FileNameLen;
+ CHAR8* DestFileName;
+ CHAR8* SrcFileName;
+ CHAR8* SrcPtr;
if (Argc < 3) {
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);
if (Source == NULL) {
AsciiPrint("Source file open error.\n");
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) {
AsciiPrint("Destination file open error.\n");
return EFI_NOT_FOUND;
@@ -803,6 +848,11 @@ Exit:
if (EFI_ERROR(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) {
@@ -972,7 +1022,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdDeviceTemplate[] =
},
{
"cp",
- " file1 file2; copy file",
+ " file1 file2; copy file only.",
NULL,
EblFileCopyCmd
},