From 583448b441650f9a7cb29a320d52db96df81e043 Mon Sep 17 00:00:00 2001 From: Tapan Shah Date: Thu, 22 Sep 2016 12:12:47 -0700 Subject: ShellPkg: Expand special output file to include "NULL" and case insensitive As per ECR 1349 change in UEFI Shell Specification 2.2, expanding a special output file name to include "NULL". Previously it only supported "NUL" as a special output file and it was case sensitive. With this change both "NUL" and "NULL" are special output file and checked as case insensitive. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Tapan Shah Reviewed-by: Jaben Carsey --- ShellPkg/Library/UefiShellLib/UefiShellLib.c | 14 +++++++++++++- ShellPkg/Library/UefiShellLib/UefiShellLib.h | 2 ++ ShellPkg/Library/UefiShellLib/UefiShellLib.inf | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) (limited to 'ShellPkg/Library/UefiShellLib') diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index 3dcdba6ba0..e47d5350e0 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -1,6 +1,7 @@ /** @file Provides interface to shell functionality for shell commands and applications. + (C) Copyright 2016 Hewlett Packard Enterprise Development LP
Copyright 2016 Dell Inc. Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials @@ -36,6 +37,7 @@ EFI_SHELL_PROTOCOL *gEfiShellProtocol; EFI_SHELL_PARAMETERS_PROTOCOL *gEfiShellParametersProtocol; EFI_HANDLE mEfiShellEnvironment2Handle; FILE_HANDLE_FUNCTION_MAP FileFunctionMap; +EFI_UNICODE_COLLATION_PROTOCOL *mUnicodeCollationProtocol; /** Check if a Unicode character is a hexadecimal character. @@ -290,12 +292,19 @@ ShellLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable ) { + EFI_STATUS Status; + mEfiShellEnvironment2 = NULL; gEfiShellProtocol = NULL; gEfiShellParametersProtocol = NULL; mEfiShellInterface = NULL; mEfiShellEnvironment2Handle = NULL; + if (mUnicodeCollationProtocol == NULL) { + Status = gBS->LocateProtocol (&gEfiUnicodeCollation2ProtocolGuid, NULL, (VOID**)&mUnicodeCollationProtocol); + ASSERT_EFI_ERROR (Status); + } + // // verify that auto initialize is not set false // @@ -720,7 +729,10 @@ ShellOpenFileByName( Status = gEfiShellProtocol->OpenFileByName(FileName, FileHandle, OpenMode); - if (StrCmp(FileName, L"NUL") != 0 && !EFI_ERROR(Status) && ((OpenMode & EFI_FILE_MODE_CREATE) != 0)){ + + if ((mUnicodeCollationProtocol->StriColl (mUnicodeCollationProtocol, (CHAR16*)FileName, L"NUL") != 0) && + (mUnicodeCollationProtocol->StriColl (mUnicodeCollationProtocol, (CHAR16*)FileName, L"NULL") != 0) && + !EFI_ERROR(Status) && ((OpenMode & EFI_FILE_MODE_CREATE) != 0)){ FileInfo = FileFunctionMap.GetFileInfo(*FileHandle); ASSERT(FileInfo != NULL); FileInfo->Attribute = Attributes; diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.h b/ShellPkg/Library/UefiShellLib/UefiShellLib.h index 3596f7b011..b323bcf7d7 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.h +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.h @@ -1,6 +1,7 @@ /** @file Provides interface to shell functionality for shell commands and applications. + (C) Copyright 2016 Hewlett Packard Enterprise Development LP
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -25,6 +26,7 @@ #include #include #include +#include #include #include diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.inf b/ShellPkg/Library/UefiShellLib/UefiShellLib.inf index 782649a7a0..0be682865e 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.inf +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.inf @@ -1,6 +1,7 @@ ## @file # Provides interface to shell functionality for shell commands and applications. # +# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
# # This program and the accompanying materials @@ -51,6 +52,7 @@ [Protocols] gEfiSimpleFileSystemProtocolGuid ## SOMETIMES_CONSUMES + gEfiUnicodeCollation2ProtocolGuid ## CONSUMES # shell 2.0 gEfiShellProtocolGuid ## SOMETIMES_CONSUMES -- cgit v1.2.3