]>
Commit | Line | Data |
---|---|---|
5d73d92f | 1 | /** @file\r |
2 | Main file for SetSize shell Debug1 function.\r | |
3 | \r | |
4 | Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include "UefiShellDebug1CommandsLib.h"\r | |
16 | \r | |
17 | SHELL_STATUS\r | |
18 | EFIAPI\r | |
19 | ShellCommandRunSetSize (\r | |
20 | IN EFI_HANDLE ImageHandle,\r | |
21 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
22 | )\r | |
23 | {\r | |
24 | EFI_STATUS Status;\r | |
25 | LIST_ENTRY *Package;\r | |
26 | CHAR16 *ProblemParam;\r | |
27 | SHELL_STATUS ShellStatus;\r | |
28 | CONST CHAR16 *Temp1;\r | |
29 | UINTN NewSize;\r | |
30 | UINTN LoopVar;\r | |
31 | SHELL_FILE_HANDLE FileHandle;\r | |
32 | \r | |
33 | ShellStatus = SHELL_SUCCESS;\r | |
34 | Status = EFI_SUCCESS;\r | |
35 | \r | |
36 | //\r | |
37 | // initialize the shell lib (we must be in non-auto-init...)\r | |
38 | //\r | |
39 | Status = ShellInitialize();\r | |
40 | ASSERT_EFI_ERROR(Status);\r | |
41 | \r | |
42 | Status = CommandInit();\r | |
43 | ASSERT_EFI_ERROR(Status);\r | |
44 | \r | |
45 | //\r | |
46 | // parse the command line\r | |
47 | //\r | |
48 | Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);\r | |
49 | if (EFI_ERROR(Status)) {\r | |
50 | if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r | |
51 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam);\r | |
52 | FreePool(ProblemParam);\r | |
53 | ShellStatus = SHELL_INVALID_PARAMETER;\r | |
54 | } else {\r | |
55 | ASSERT(FALSE);\r | |
56 | }\r | |
57 | } else {\r | |
58 | Temp1 = ShellCommandLineGetRawValue(Package, 1);\r | |
59 | if (Temp1 == NULL) {\r | |
60 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SIZE_NOT_SPEC), gShellDebug1HiiHandle);\r | |
61 | ShellStatus = SHELL_INVALID_PARAMETER;\r | |
62 | NewSize = 0;\r | |
63 | } else {\r | |
64 | NewSize = ShellStrToUintn(Temp1);\r | |
65 | }\r | |
66 | for (LoopVar = 2 ; LoopVar < ShellCommandLineGetCount(Package) && ShellStatus == SHELL_SUCCESS ; LoopVar++) {\r | |
67 | Status = ShellOpenFileByName(ShellCommandLineGetRawValue(Package, LoopVar), &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);\r | |
68 | if (EFI_ERROR(Status) && LoopVar == 2) {\r | |
69 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_SPEC), gShellDebug1HiiHandle);\r | |
70 | ShellStatus = SHELL_INVALID_PARAMETER;\r | |
71 | } else if (EFI_ERROR(Status)) {\r | |
72 | break;\r | |
73 | } else {\r | |
74 | Status = FileHandleSetSize(FileHandle, NewSize);\r | |
75 | if (Status == EFI_VOLUME_FULL) {\r | |
76 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_VOLUME_FULL), gShellDebug1HiiHandle);\r | |
77 | ShellStatus = SHELL_VOLUME_FULL;\r | |
78 | } else if (EFI_ERROR(Status)) {\r | |
79 | ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SET_SIZE_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, LoopVar), Status);\r | |
80 | ShellStatus = SHELL_INVALID_PARAMETER;\r | |
81 | }\r | |
82 | ShellCloseFile(&FileHandle);\r | |
83 | }\r | |
84 | }\r | |
85 | \r | |
86 | ShellCommandLineFreeVarList (Package);\r | |
87 | }\r | |
88 | \r | |
89 | return (ShellStatus);\r | |
90 | }\r |