]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c
ShellPkg/DP: Add more check for input parameters
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel3CommandsLib / Touch.c
index f5e27ef1a914866f86a5a353a32221f132a00e6a..1e8f4bdb358f4b91950e941601c80cb6e6bf561c 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   Main file for Touch shell level 3 function.\r
 \r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>\r
+  (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. <BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -25,7 +26,6 @@
   @retval EFI_SUCCESS       The operation was successful.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 TouchFileByHandle (\r
   IN EFI_HANDLE Handle\r
   )\r
@@ -64,7 +64,6 @@ TouchFileByHandle (
   @retval EFI_SUCCESS           The operation was successful.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 DoTouchByHandle (\r
   IN CONST CHAR16       *Name,\r
   IN       CHAR16       *FS,\r
@@ -99,7 +98,7 @@ DoTouchByHandle (
   //\r
   Status = TouchFileByHandle(Handle);\r
   if (EFI_ERROR(Status)) {\r
-    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NO_OPEN), gShellLevel3HiiHandle, Name, Status);\r
+    ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Name);\r
     return (Status);\r
   }\r
 \r
@@ -129,7 +128,7 @@ DoTouchByHandle (
         //\r
         Status = gEfiShellProtocol->OpenFileByName (Walker->FullName, &Walker->Handle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE);\r
         if (EFI_ERROR(Status)) {\r
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NO_OPEN), gShellLevel3HiiHandle, Walker->FullName, Status);\r
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Walker->FullName);\r
           Status = EFI_ACCESS_DENIED;\r
         } else {\r
           Status = DoTouchByHandle(Walker->FullName, FS, Walker->Handle, TRUE);\r
@@ -197,7 +196,7 @@ ShellCommandRunTouch (
   Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
   if (EFI_ERROR(Status)) {\r
     if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"touch", ProblemParam);\r
       FreePool(ProblemParam);\r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
     } else {\r
@@ -214,7 +213,7 @@ ShellCommandRunTouch (
       //\r
       // we insufficient parameters\r
       //\r
-      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle);\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle, L"touch");\r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
     } else {\r
       //\r
@@ -227,7 +226,7 @@ ShellCommandRunTouch (
          ){\r
         Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, &FileList);\r
         if (EFI_ERROR(Status)) {\r
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, (CHAR16*)Param);\r
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"touch", (CHAR16*)Param);\r
           ShellStatus = SHELL_NOT_FOUND;\r
           break;\r
         }\r
@@ -240,7 +239,7 @@ ShellCommandRunTouch (
           // check that we have at least 1 file\r
           //\r
           if (FileList == NULL || IsListEmpty(&FileList->Link)) {\r
-            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel3HiiHandle, Param);\r
+            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel3HiiHandle, L"touch", Param);\r
             continue;\r
           } else {\r
             //\r
@@ -254,14 +253,14 @@ ShellCommandRunTouch (
               // make sure the file opened ok\r
               //\r
               if (EFI_ERROR(Node->Status)){\r
-                ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NO_OPEN), gShellLevel3HiiHandle, Node->FileName, Node->Status);\r
+                ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Node->FileName);\r
                 ShellStatus = SHELL_NOT_FOUND;\r
                 continue;\r
               }\r
 \r
               Status = DoTouchByHandle(Node->FullName, NULL, Node->Handle, ShellCommandLineGetFlag(Package, L"-r"));\r
               if (EFI_ERROR(Status) && Status != EFI_ACCESS_DENIED) {\r
-                ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NO_OPEN), gShellLevel3HiiHandle, Node->FileName, Status);\r
+                ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Node->FileName);\r
                 ShellStatus = SHELL_NOT_FOUND;\r
               }\r
             }\r