public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ShellPkg: Expand special output file to include "NULL" and case insensitive
@ 2016-09-22 16:13 Tapan Shah
  2016-09-22 16:20 ` Carsey, Jaben
  0 siblings, 1 reply; 4+ messages in thread
From: Tapan Shah @ 2016-09-22 16:13 UTC (permalink / raw)
  To: edk2-devel; +Cc: jaben.carsey, Tapan Shah

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 <tapandshah@hpe.com>
---
 ShellPkg/Application/Shell/ShellParametersProtocol.c | 3 ++-
 ShellPkg/Application/Shell/ShellProtocol.c           | 6 ++++--
 ShellPkg/Library/UefiShellLib/UefiShellLib.c         | 5 ++++-
 ShellPkg/Library/UefiShellLib/UefiShellLib.h         | 2 ++
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c
index 3684f9c..58156a2 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.c
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c
@@ -2,6 +2,7 @@
   Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation,
   manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.
 
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
   Copyright (C) 2014, Red Hat, Inc.
   (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>
   Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
@@ -1174,7 +1175,7 @@ UpdateStdInStdOutStdErr(
         if (TempHandle == NULL) {
           Status = EFI_INVALID_PARAMETER;
         } else {
-          if (StrStr(StdOutFileName, L"NUL")==StdOutFileName) {
+          if (gUnicodeCollation->MetaiMatch (gUnicodeCollation, StdOutFileName, L"NUL")) {
             //no-op
           } else if (!OutAppend && OutUnicode && !EFI_ERROR(Status)) {
             Status = WriteFileTag (TempHandle);
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index 6f29250..fb7dd84 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -3,6 +3,7 @@
   manipulation, and initialization of EFI_SHELL_PROTOCOL.
 
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
   Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
@@ -1287,9 +1288,10 @@ EfiShellOpenFileByName(
   }
 
   //
-  // Is this for NUL file
+  // Is this for NUL / NULL file
   //
-  if (StrCmp(FileName, L"NUL") == 0) {
+  if ((gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16*)FileName, L"NUL") == 0) ||
+      (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16*)FileName, L"NULL") == 0)) {
     *FileHandle = &FileInterfaceNulFile;
     return (EFI_SUCCESS);
   }
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 3dcdba6..27523e2 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<BR>
   Copyright 2016 Dell Inc.
   Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
@@ -720,7 +721,9 @@ ShellOpenFileByName(
     Status = gEfiShellProtocol->OpenFileByName(FileName,
                                                FileHandle,
                                                OpenMode);
-    if (StrCmp(FileName, L"NUL") != 0 && !EFI_ERROR(Status) && ((OpenMode & EFI_FILE_MODE_CREATE) != 0)){
+    if ((gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16*)FileName, L"NUL") != 0) &&
+        (gUnicodeCollation->StriColl (gUnicodeCollation, (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 3596f7b..6903227 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<BR>
   Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
@@ -38,6 +39,7 @@
 #include <Library/UefiLib.h>
 #include <Library/HiiLib.h>
 #include <Library/ShellLib.h>
+#include <Library/ShellCommandLib.h>
 
 typedef struct  {
   EFI_SHELL_GET_FILE_INFO                   GetFileInfo;
-- 
1.9.5.msysgit.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ShellPkg: Expand special output file to include "NULL" and case insensitive
  2016-09-22 16:13 [PATCH] ShellPkg: Expand special output file to include "NULL" and case insensitive Tapan Shah
@ 2016-09-22 16:20 ` Carsey, Jaben
  0 siblings, 0 replies; 4+ messages in thread
From: Carsey, Jaben @ 2016-09-22 16:20 UTC (permalink / raw)
  To: Tapan Shah, edk2-devel@lists.01.org; +Cc: Carsey, Jaben

Tapan,

I do not think we should tie UefiShellLib into UefiShellCommandLib.  The problem is that UefiShellLib is for internal commands, the shell itself, and shell applications.  The UefiShellCommandLib is only for internal commands.  What amount of work would it take to keep these libraries separate?

-Jaben

> -----Original Message-----
> From: Tapan Shah [mailto:tapandshah@hpe.com]
> Sent: Thursday, September 22, 2016 9:14 AM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Tapan Shah
> <tapandshah@hpe.com>
> Subject: [PATCH] ShellPkg: Expand special output file to include "NULL" and
> case insensitive
> Importance: High
> 
> 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 <tapandshah@hpe.com>
> ---
>  ShellPkg/Application/Shell/ShellParametersProtocol.c | 3 ++-
>  ShellPkg/Application/Shell/ShellProtocol.c           | 6 ++++--
>  ShellPkg/Library/UefiShellLib/UefiShellLib.c         | 5 ++++-
>  ShellPkg/Library/UefiShellLib/UefiShellLib.h         | 2 ++
>  4 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c
> b/ShellPkg/Application/Shell/ShellParametersProtocol.c
> index 3684f9c..58156a2 100644
> --- a/ShellPkg/Application/Shell/ShellParametersProtocol.c
> +++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c
> @@ -2,6 +2,7 @@
>    Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions
> for creation,
>    manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.
> 
> +  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
>    Copyright (C) 2014, Red Hat, Inc.
>    (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>
>    Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
> @@ -1174,7 +1175,7 @@ UpdateStdInStdOutStdErr(
>          if (TempHandle == NULL) {
>            Status = EFI_INVALID_PARAMETER;
>          } else {
> -          if (StrStr(StdOutFileName, L"NUL")==StdOutFileName) {
> +          if (gUnicodeCollation->MetaiMatch (gUnicodeCollation,
> StdOutFileName, L"NUL")) {
>              //no-op
>            } else if (!OutAppend && OutUnicode && !EFI_ERROR(Status)) {
>              Status = WriteFileTag (TempHandle);
> diff --git a/ShellPkg/Application/Shell/ShellProtocol.c
> b/ShellPkg/Application/Shell/ShellProtocol.c
> index 6f29250..fb7dd84 100644
> --- a/ShellPkg/Application/Shell/ShellProtocol.c
> +++ b/ShellPkg/Application/Shell/ShellProtocol.c
> @@ -3,6 +3,7 @@
>    manipulation, and initialization of EFI_SHELL_PROTOCOL.
> 
>    (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
> +  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
>    Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
>    This program and the accompanying materials
>    are licensed and made available under the terms and conditions of the BSD
> License
> @@ -1287,9 +1288,10 @@ EfiShellOpenFileByName(
>    }
> 
>    //
> -  // Is this for NUL file
> +  // Is this for NUL / NULL file
>    //
> -  if (StrCmp(FileName, L"NUL") == 0) {
> +  if ((gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16*)FileName,
> L"NUL") == 0) ||
> +      (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16*)FileName,
> L"NULL") == 0)) {
>      *FileHandle = &FileInterfaceNulFile;
>      return (EFI_SUCCESS);
>    }
> diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
> b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
> index 3dcdba6..27523e2 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<BR>
>    Copyright 2016 Dell Inc.
>    Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
>    This program and the accompanying materials
> @@ -720,7 +721,9 @@ ShellOpenFileByName(
>      Status = gEfiShellProtocol->OpenFileByName(FileName,
>                                                 FileHandle,
>                                                 OpenMode);
> -    if (StrCmp(FileName, L"NUL") != 0 && !EFI_ERROR(Status) &&
> ((OpenMode & EFI_FILE_MODE_CREATE) != 0)){
> +    if ((gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16*)FileName,
> L"NUL") != 0) &&
> +        (gUnicodeCollation->StriColl (gUnicodeCollation, (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 3596f7b..6903227 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<BR>
>    Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
>    This program and the accompanying materials
>    are licensed and made available under the terms and conditions of the BSD
> License
> @@ -38,6 +39,7 @@
>  #include <Library/UefiLib.h>
>  #include <Library/HiiLib.h>
>  #include <Library/ShellLib.h>
> +#include <Library/ShellCommandLib.h>
> 
>  typedef struct  {
>    EFI_SHELL_GET_FILE_INFO                   GetFileInfo;
> --
> 1.9.5.msysgit.0



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ShellPkg: Expand special output file to include "NULL" and case insensitive
@ 2016-09-22 19:12 Tapan Shah
  2016-09-22 21:21 ` Carsey, Jaben
  0 siblings, 1 reply; 4+ messages in thread
From: Tapan Shah @ 2016-09-22 19:12 UTC (permalink / raw)
  To: edk2-devel; +Cc: jaben.carsey, Tapan Shah

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 <tapandshah@hpe.com>
---
 ShellPkg/Application/Shell/ShellParametersProtocol.c |  3 ++-
 ShellPkg/Application/Shell/ShellProtocol.c           |  6 ++++--
 ShellPkg/Library/UefiShellLib/UefiShellLib.c         | 14 +++++++++++++-
 ShellPkg/Library/UefiShellLib/UefiShellLib.h         |  2 ++
 ShellPkg/Library/UefiShellLib/UefiShellLib.inf       |  2 ++
 5 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c
index 3684f9c..58156a2 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.c
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c
@@ -2,6 +2,7 @@
   Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation,
   manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.
 
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
   Copyright (C) 2014, Red Hat, Inc.
   (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>
   Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
@@ -1174,7 +1175,7 @@ UpdateStdInStdOutStdErr(
         if (TempHandle == NULL) {
           Status = EFI_INVALID_PARAMETER;
         } else {
-          if (StrStr(StdOutFileName, L"NUL")==StdOutFileName) {
+          if (gUnicodeCollation->MetaiMatch (gUnicodeCollation, StdOutFileName, L"NUL")) {
             //no-op
           } else if (!OutAppend && OutUnicode && !EFI_ERROR(Status)) {
             Status = WriteFileTag (TempHandle);
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index 6f29250..fb7dd84 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -3,6 +3,7 @@
   manipulation, and initialization of EFI_SHELL_PROTOCOL.
 
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
   Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
@@ -1287,9 +1288,10 @@ EfiShellOpenFileByName(
   }
 
   //
-  // Is this for NUL file
+  // Is this for NUL / NULL file
   //
-  if (StrCmp(FileName, L"NUL") == 0) {
+  if ((gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16*)FileName, L"NUL") == 0) ||
+      (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16*)FileName, L"NULL") == 0)) {
     *FileHandle = &FileInterfaceNulFile;
     return (EFI_SUCCESS);
   }
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 3dcdba6..e47d535 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<BR>
   Copyright 2016 Dell Inc.
   Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
   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 3596f7b..b323bcf 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<BR>
   Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
   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 <Protocol/EfiShellEnvironment2.h>
 #include <Protocol/EfiShell.h>
 #include <Protocol/EfiShellParameters.h>
+#include <Protocol/UnicodeCollation.h>
 
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/BaseLib.h>
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.inf b/ShellPkg/Library/UefiShellLib/UefiShellLib.inf
index 782649a..0be6828 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<BR>
 # Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. <BR>
 #
 #  This program and the accompanying materials
@@ -51,6 +52,7 @@
 
 [Protocols]
   gEfiSimpleFileSystemProtocolGuid              ## SOMETIMES_CONSUMES
+  gEfiUnicodeCollation2ProtocolGuid             ## CONSUMES
 
   # shell 2.0
   gEfiShellProtocolGuid                         ## SOMETIMES_CONSUMES
-- 
1.9.5.msysgit.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ShellPkg: Expand special output file to include "NULL" and case insensitive
  2016-09-22 19:12 Tapan Shah
@ 2016-09-22 21:21 ` Carsey, Jaben
  0 siblings, 0 replies; 4+ messages in thread
From: Carsey, Jaben @ 2016-09-22 21:21 UTC (permalink / raw)
  To: Tapan Shah, edk2-devel@lists.01.org; +Cc: Carsey, Jaben

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
And commited.

> -----Original Message-----
> From: Tapan Shah [mailto:tapandshah@hpe.com]
> Sent: Thursday, September 22, 2016 12:13 PM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Tapan Shah
> <tapandshah@hpe.com>
> Subject: [PATCH] ShellPkg: Expand special output file to include "NULL" and
> case insensitive
> Importance: High
> 
> 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 <tapandshah@hpe.com>
> ---
>  ShellPkg/Application/Shell/ShellParametersProtocol.c |  3 ++-
>  ShellPkg/Application/Shell/ShellProtocol.c           |  6 ++++--
>  ShellPkg/Library/UefiShellLib/UefiShellLib.c         | 14 +++++++++++++-
>  ShellPkg/Library/UefiShellLib/UefiShellLib.h         |  2 ++
>  ShellPkg/Library/UefiShellLib/UefiShellLib.inf       |  2 ++
>  5 files changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c
> b/ShellPkg/Application/Shell/ShellParametersProtocol.c
> index 3684f9c..58156a2 100644
> --- a/ShellPkg/Application/Shell/ShellParametersProtocol.c
> +++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c
> @@ -2,6 +2,7 @@
>    Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions
> for creation,
>    manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.
> 
> +  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
>    Copyright (C) 2014, Red Hat, Inc.
>    (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<BR>
>    Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
> @@ -1174,7 +1175,7 @@ UpdateStdInStdOutStdErr(
>          if (TempHandle == NULL) {
>            Status = EFI_INVALID_PARAMETER;
>          } else {
> -          if (StrStr(StdOutFileName, L"NUL")==StdOutFileName) {
> +          if (gUnicodeCollation->MetaiMatch (gUnicodeCollation,
> StdOutFileName, L"NUL")) {
>              //no-op
>            } else if (!OutAppend && OutUnicode && !EFI_ERROR(Status)) {
>              Status = WriteFileTag (TempHandle);
> diff --git a/ShellPkg/Application/Shell/ShellProtocol.c
> b/ShellPkg/Application/Shell/ShellProtocol.c
> index 6f29250..fb7dd84 100644
> --- a/ShellPkg/Application/Shell/ShellProtocol.c
> +++ b/ShellPkg/Application/Shell/ShellProtocol.c
> @@ -3,6 +3,7 @@
>    manipulation, and initialization of EFI_SHELL_PROTOCOL.
> 
>    (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
> +  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
>    Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
>    This program and the accompanying materials
>    are licensed and made available under the terms and conditions of the BSD
> License
> @@ -1287,9 +1288,10 @@ EfiShellOpenFileByName(
>    }
> 
>    //
> -  // Is this for NUL file
> +  // Is this for NUL / NULL file
>    //
> -  if (StrCmp(FileName, L"NUL") == 0) {
> +  if ((gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16*)FileName,
> L"NUL") == 0) ||
> +      (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16*)FileName,
> L"NULL") == 0)) {
>      *FileHandle = &FileInterfaceNulFile;
>      return (EFI_SUCCESS);
>    }
> diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
> b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
> index 3dcdba6..e47d535 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<BR>
>    Copyright 2016 Dell Inc.
>    Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
>    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 3596f7b..b323bcf 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<BR>
>    Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
>    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 <Protocol/EfiShellEnvironment2.h>
>  #include <Protocol/EfiShell.h>
>  #include <Protocol/EfiShellParameters.h>
> +#include <Protocol/UnicodeCollation.h>
> 
>  #include <Library/UefiBootServicesTableLib.h>
>  #include <Library/BaseLib.h>
> diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.inf
> b/ShellPkg/Library/UefiShellLib/UefiShellLib.inf
> index 782649a..0be6828 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<BR>
>  # Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. <BR>
>  #
>  #  This program and the accompanying materials
> @@ -51,6 +52,7 @@
> 
>  [Protocols]
>    gEfiSimpleFileSystemProtocolGuid              ## SOMETIMES_CONSUMES
> +  gEfiUnicodeCollation2ProtocolGuid             ## CONSUMES
> 
>    # shell 2.0
>    gEfiShellProtocolGuid                         ## SOMETIMES_CONSUMES
> --
> 1.9.5.msysgit.0



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-22 21:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-22 16:13 [PATCH] ShellPkg: Expand special output file to include "NULL" and case insensitive Tapan Shah
2016-09-22 16:20 ` Carsey, Jaben
  -- strict thread matches above, loose matches on Subject: below --
2016-09-22 19:12 Tapan Shah
2016-09-22 21:21 ` Carsey, Jaben

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox