2 Main file for SetSize shell Debug1 function.
4 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "UefiShellDebug1CommandsLib.h"
19 ShellCommandRunSetSize (
20 IN EFI_HANDLE ImageHandle
,
21 IN EFI_SYSTEM_TABLE
*SystemTable
27 SHELL_STATUS ShellStatus
;
31 SHELL_FILE_HANDLE FileHandle
;
33 ShellStatus
= SHELL_SUCCESS
;
37 // initialize the shell lib (we must be in non-auto-init...)
39 Status
= ShellInitialize();
40 ASSERT_EFI_ERROR(Status
);
42 Status
= CommandInit();
43 ASSERT_EFI_ERROR(Status
);
46 // parse the command line
48 Status
= ShellCommandLineParse (EmptyParamList
, &Package
, &ProblemParam
, TRUE
);
49 if (EFI_ERROR(Status
)) {
50 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
51 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellDebug1HiiHandle
, ProblemParam
);
52 FreePool(ProblemParam
);
53 ShellStatus
= SHELL_INVALID_PARAMETER
;
58 Temp1
= ShellCommandLineGetRawValue(Package
, 1);
60 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_SIZE_NOT_SPEC
), gShellDebug1HiiHandle
);
61 ShellStatus
= SHELL_INVALID_PARAMETER
;
64 NewSize
= ShellStrToUintn(Temp1
);
66 for (LoopVar
= 2 ; LoopVar
< ShellCommandLineGetCount(Package
) && ShellStatus
== SHELL_SUCCESS
; LoopVar
++) {
67 Status
= ShellOpenFileByName(ShellCommandLineGetRawValue(Package
, LoopVar
), &FileHandle
, EFI_FILE_MODE_READ
|EFI_FILE_MODE_WRITE
|EFI_FILE_MODE_CREATE
, 0);
68 if (EFI_ERROR(Status
) && LoopVar
== 2) {
69 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_FILE_NOT_SPEC
), gShellDebug1HiiHandle
);
70 ShellStatus
= SHELL_INVALID_PARAMETER
;
71 } else if (EFI_ERROR(Status
)) {
74 Status
= FileHandleSetSize(FileHandle
, NewSize
);
75 if (Status
== EFI_VOLUME_FULL
) {
76 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_VOLUME_FULL
), gShellDebug1HiiHandle
);
77 ShellStatus
= SHELL_VOLUME_FULL
;
78 } else if (EFI_ERROR(Status
)) {
79 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_SET_SIZE_FAIL
), gShellDebug1HiiHandle
, ShellCommandLineGetRawValue(Package
, LoopVar
), Status
);
80 ShellStatus
= SHELL_INVALID_PARAMETER
;
82 ShellCloseFile(&FileHandle
);
86 ShellCommandLineFreeVarList (Package
);