mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
[DISKPART] Improve the command table to support subcommands and start work on the create command
- Extend the command table to support subcommands. - Get rid of the existing subcommand code. - Use the new subcommand suport for the help system. - Start work on the create command. @Translators: Please do not translate any changes yet, because I will improve help system in one of the next steps.
This commit is contained in:
parent
1d690f0411
commit
566e8989c3
11 changed files with 518 additions and 247 deletions
|
@ -8,7 +8,114 @@
|
|||
|
||||
#include "diskpart.h"
|
||||
|
||||
BOOL create_main(INT argc, LPWSTR *argv)
|
||||
BOOL
|
||||
CreateExtendedPartition(
|
||||
INT argc,
|
||||
PWSTR *argv)
|
||||
{
|
||||
if (CurrentDisk == NULL)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ConPrintf(StdOut, L"Not implemented yet!\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
CreateLogicalPartition(
|
||||
INT argc,
|
||||
PWSTR *argv)
|
||||
{
|
||||
if (CurrentDisk == NULL)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ConPrintf(StdOut, L"Not implemented yet!\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
CreatePrimaryPartition(
|
||||
INT argc,
|
||||
PWSTR *argv)
|
||||
{
|
||||
LARGE_INTEGER liSize, liOffset;
|
||||
INT i;
|
||||
// BOOL bNoErr = FALSE;
|
||||
PWSTR pszSuffix = NULL;
|
||||
|
||||
liSize.QuadPart = -1;
|
||||
liOffset.QuadPart = -1;
|
||||
|
||||
/*
|
||||
if (CurrentDisk == NULL)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
|
||||
return TRUE;
|
||||
}
|
||||
*/
|
||||
|
||||
for (i = 3; i < argc; i++)
|
||||
{
|
||||
if (HasPrefix(argv[i], L"size=", &pszSuffix))
|
||||
{
|
||||
/* size=<N> (MB) */
|
||||
ConPrintf(StdOut, L"Size : %s\n", pszSuffix);
|
||||
|
||||
liSize.QuadPart = _wcstoui64(pszSuffix, NULL, 10);
|
||||
if (((liSize.QuadPart == 0) && (errno == ERANGE)) ||
|
||||
(liSize.QuadPart < 0))
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (HasPrefix(argv[i], L"offset=", &pszSuffix))
|
||||
{
|
||||
/* offset=<N> (KB) */
|
||||
ConPrintf(StdOut, L"Offset : %s\n", pszSuffix);
|
||||
|
||||
liOffset.QuadPart = _wcstoui64(pszSuffix, NULL, 10);
|
||||
if (((liOffset.QuadPart == 0) && (errno == ERANGE)) ||
|
||||
(liOffset.QuadPart < 0))
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (HasPrefix(argv[i], L"id=", &pszSuffix))
|
||||
{
|
||||
/* id=<Byte>|<GUID> */
|
||||
ConPrintf(StdOut, L"Id : %s\n", pszSuffix);
|
||||
}
|
||||
else if (HasPrefix(argv[i], L"align=", &pszSuffix))
|
||||
{
|
||||
/* align=<N> */
|
||||
ConPrintf(StdOut, L"Align : %s\n", pszSuffix);
|
||||
}
|
||||
else if (_wcsicmp(argv[i], L"noerr") == 0)
|
||||
{
|
||||
/* noerr */
|
||||
ConPrintf(StdOut, L"NoErr\n", pszSuffix);
|
||||
// bNoErr = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
ConPrintf(StdOut, L"Size: %I64d\n", liSize.QuadPart);
|
||||
ConPrintf(StdOut, L"Offset: %I64d\n", liOffset.QuadPart);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -13,24 +13,23 @@
|
|||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
static
|
||||
VOID
|
||||
BOOL
|
||||
DetailDisk(
|
||||
INT argc,
|
||||
LPWSTR *argv)
|
||||
PWSTR *argv)
|
||||
{
|
||||
DPRINT("DetailDisk()\n");
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (CurrentDisk == NULL)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* TODO: Print more disk details */
|
||||
|
@ -40,14 +39,15 @@ DetailDisk(
|
|||
ConResPrintf(StdOut, IDS_DETAIL_INFO_TARGET, CurrentDisk->TargetId);
|
||||
ConResPrintf(StdOut, IDS_DETAIL_INFO_LUN_ID, CurrentDisk->Lun);
|
||||
ConPuts(StdOut, L"\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
VOID
|
||||
BOOL
|
||||
DetailPartition(
|
||||
INT argc,
|
||||
LPWSTR *argv)
|
||||
PWSTR *argv)
|
||||
{
|
||||
PPARTENTRY PartEntry;
|
||||
ULONGLONG PartOffset;
|
||||
|
@ -57,19 +57,19 @@ DetailPartition(
|
|||
if (argc > 2)
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (CurrentDisk == NULL)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_SELECT_PARTITION_NO_DISK);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (CurrentPartition == NULL)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_SELECT_NO_PARTITION);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PartEntry = CurrentPartition;
|
||||
|
@ -83,55 +83,31 @@ DetailPartition(
|
|||
ConResPrintf(StdOut, IDS_DETAIL_PARTITION_ACTIVE, PartEntry->BootIndicator ? L"Yes" : L"No");
|
||||
ConResPrintf(StdOut, IDS_DETAIL_PARTITION_OFFSET, PartOffset);
|
||||
ConPuts(StdOut, L"\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
VOID
|
||||
BOOL
|
||||
DetailVolume(
|
||||
INT argc,
|
||||
LPWSTR *argv)
|
||||
PWSTR *argv)
|
||||
{
|
||||
DPRINT("DetailVolume()\n");
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (CurrentVolume == NULL)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_SELECT_NO_VOLUME);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* TODO: Print volume details */
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
detail_main(
|
||||
INT argc,
|
||||
LPWSTR *argv)
|
||||
{
|
||||
/* gets the first word from the string */
|
||||
if (argc == 1)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_HELP_CMD_DETAIL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* determines which details to print (disk, partition, etc.) */
|
||||
if (!wcsicmp(argv[1], L"disk"))
|
||||
DetailDisk(argc, argv);
|
||||
else if (!wcsicmp(argv[1], L"partition"))
|
||||
DetailPartition(argc, argv);
|
||||
else if (!wcsicmp(argv[1], L"volume"))
|
||||
DetailVolume(argc, argv);
|
||||
else
|
||||
ConResPuts(StdOut, IDS_HELP_CMD_DETAIL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,9 @@
|
|||
|
||||
typedef struct _COMMAND
|
||||
{
|
||||
LPWSTR name;
|
||||
PWSTR cmd1;
|
||||
PWSTR cmd2;
|
||||
PWSTR cmd3;
|
||||
BOOL (*func)(INT, WCHAR**);
|
||||
INT help;
|
||||
INT help_desc;
|
||||
|
@ -233,7 +235,20 @@ BOOL compact_main(INT argc, LPWSTR *argv);
|
|||
BOOL convert_main(INT argc, LPWSTR *argv);
|
||||
|
||||
/* create.c */
|
||||
BOOL create_main(INT argc, LPWSTR *argv);
|
||||
BOOL
|
||||
CreateExtendedPartition(
|
||||
INT argc,
|
||||
PWSTR *argv);
|
||||
|
||||
BOOL
|
||||
CreateLogicalPartition(
|
||||
INT argc,
|
||||
PWSTR *argv);
|
||||
|
||||
BOOL
|
||||
CreatePrimaryPartition(
|
||||
INT argc,
|
||||
PWSTR *argv);
|
||||
|
||||
/* delete.c */
|
||||
BOOL delete_main(INT argc, LPWSTR *argv);
|
||||
|
@ -242,7 +257,20 @@ BOOL delete_main(INT argc, LPWSTR *argv);
|
|||
BOOL detach_main(INT argc, LPWSTR *argv);
|
||||
|
||||
/* detail.c */
|
||||
BOOL detail_main(INT argc, LPWSTR *argv);
|
||||
BOOL
|
||||
DetailDisk(
|
||||
INT argc,
|
||||
PWSTR *argv);
|
||||
|
||||
BOOL
|
||||
DetailPartition(
|
||||
INT argc,
|
||||
PWSTR *argv);
|
||||
|
||||
BOOL
|
||||
DetailVolume(
|
||||
INT argc,
|
||||
PWSTR *argv);
|
||||
|
||||
/* diskpart.c */
|
||||
|
||||
|
@ -266,7 +294,8 @@ BOOL gpt_main(INT argc, LPWSTR *argv);
|
|||
|
||||
/* help.c */
|
||||
BOOL help_main(INT argc, LPWSTR *argv);
|
||||
VOID help_cmdlist(VOID);
|
||||
VOID HelpCommandList(VOID);
|
||||
BOOL HelpCommand(PCOMMAND pCommand);
|
||||
|
||||
/* import. c */
|
||||
BOOL import_main(INT argc, LPWSTR *argv);
|
||||
|
@ -280,7 +309,25 @@ BOOL InterpretCmd(INT argc, LPWSTR *argv);
|
|||
VOID InterpretMain(VOID);
|
||||
|
||||
/* list.c */
|
||||
BOOL list_main(INT argc, LPWSTR *argv);
|
||||
BOOL
|
||||
ListDisk(
|
||||
INT argc,
|
||||
PWSTR *argv);
|
||||
|
||||
BOOL
|
||||
ListPartition(
|
||||
INT argc,
|
||||
PWSTR *argv);
|
||||
|
||||
BOOL
|
||||
ListVolume(
|
||||
INT argc,
|
||||
PWSTR *argv);
|
||||
|
||||
BOOL
|
||||
ListVirtualDisk(
|
||||
INT argc,
|
||||
PWSTR *argv);
|
||||
|
||||
/* merge.c */
|
||||
BOOL merge_main(INT argc, LPWSTR *argv);
|
||||
|
@ -297,7 +344,8 @@ IsHexString(
|
|||
BOOL
|
||||
HasPrefix(
|
||||
_In_ PWSTR pszString,
|
||||
_In_ PWSTR pszPrefix);
|
||||
_In_ PWSTR pszPrefix,
|
||||
_Out_opt_ PWSTR *pszSuffix);
|
||||
|
||||
ULONGLONG
|
||||
RoundingDivide(
|
||||
|
@ -343,8 +391,26 @@ BOOL retain_main(INT argc, LPWSTR *argv);
|
|||
BOOL san_main(INT argc, LPWSTR *argv);
|
||||
|
||||
/* select.c */
|
||||
BOOL select_main(INT argc, LPWSTR *argv);
|
||||
BOOL
|
||||
SelectDisk(
|
||||
INT argc,
|
||||
PWSTR *argv);
|
||||
|
||||
BOOL
|
||||
SelectPartition(
|
||||
INT argc,
|
||||
PWSTR *argv);
|
||||
|
||||
BOOL
|
||||
SelectVolume(
|
||||
INT argc,
|
||||
PWSTR *argv);
|
||||
/*
|
||||
BOOL
|
||||
SelectVirtualDisk(
|
||||
INT argc,
|
||||
PWSTR *argv);
|
||||
*/
|
||||
/* setid.c */
|
||||
BOOL setid_main(INT argc, LPWSTR *argv);
|
||||
|
||||
|
@ -352,6 +418,9 @@ BOOL setid_main(INT argc, LPWSTR *argv);
|
|||
BOOL shrink_main(INT argc, LPWSTR *argv);
|
||||
|
||||
/* uniqueid.c */
|
||||
BOOL uniqueid_main(INT argc, LPWSTR *argv);
|
||||
BOOL
|
||||
UniqueIdDisk(
|
||||
_In_ INT argc,
|
||||
_In_ PWSTR *argv);
|
||||
|
||||
#endif /* DISKPART_H */
|
||||
|
|
|
@ -9,10 +9,11 @@
|
|||
#include "diskpart.h"
|
||||
|
||||
/*
|
||||
* help_cmdlist():
|
||||
* HelpCommandList():
|
||||
* shows all the available commands and basic descriptions for diskpart
|
||||
*/
|
||||
VOID help_cmdlist(VOID)
|
||||
VOID
|
||||
HelpCommandList(VOID)
|
||||
{
|
||||
PCOMMAND cmdptr;
|
||||
|
||||
|
@ -21,36 +22,79 @@ VOID help_cmdlist(VOID)
|
|||
ConPuts(StdOut, L"\n");
|
||||
|
||||
/* List all the commands and the basic descriptions */
|
||||
for (cmdptr = cmds; cmdptr->name; cmdptr++)
|
||||
ConResPuts(StdOut, cmdptr->help_desc);
|
||||
for (cmdptr = cmds; cmdptr->cmd1; cmdptr++)
|
||||
if (cmdptr->help_desc != IDS_NONE)
|
||||
ConResPuts(StdOut, cmdptr->help_desc);
|
||||
|
||||
ConPuts(StdOut, L"\n");
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
HelpCommand(
|
||||
PCOMMAND pCommand)
|
||||
{
|
||||
if (pCommand->help != IDS_NONE)
|
||||
{
|
||||
ConResPuts(StdOut, pCommand->help);
|
||||
// ConPuts(StdOut, L"\n");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* help_main(char *arg):
|
||||
* main entry point for the help command. Gives help to users who needs it.
|
||||
*/
|
||||
BOOL help_main(INT argc, LPWSTR *argv)
|
||||
{
|
||||
PCOMMAND cmdptr;
|
||||
PCOMMAND cmdptr1 = NULL;
|
||||
PCOMMAND cmdptr2 = NULL;
|
||||
PCOMMAND cmdptr3 = NULL;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
help_cmdlist();
|
||||
HelpCommandList();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Scan internal command table */
|
||||
for (cmdptr = cmds; cmdptr->name; cmdptr++)
|
||||
for (cmdptr = cmds; cmdptr->cmd1; cmdptr++)
|
||||
{
|
||||
if (_wcsicmp(argv[1], cmdptr->name) == 0)
|
||||
{
|
||||
ConResPuts(StdOut, cmdptr->help);
|
||||
return TRUE;
|
||||
}
|
||||
if ((cmdptr1 == NULL) &&
|
||||
(wcsicmp(argv[1], cmdptr->cmd1) == 0))
|
||||
cmdptr1 = cmdptr;
|
||||
|
||||
if ((cmdptr2 == NULL) &&
|
||||
(argc >= 3) &&
|
||||
(wcsicmp(argv[1], cmdptr->cmd1) == 0) &&
|
||||
(wcsicmp(argv[2], cmdptr->cmd2) == 0))
|
||||
cmdptr2 = cmdptr;
|
||||
|
||||
if ((cmdptr3 == NULL) &&
|
||||
(argc >= 4) &&
|
||||
(wcsicmp(argv[1], cmdptr->cmd1) == 0) &&
|
||||
(wcsicmp(argv[2], cmdptr->cmd2) == 0) &&
|
||||
(wcsicmp(argv[3], cmdptr->cmd3) == 0))
|
||||
cmdptr3 = cmdptr;
|
||||
}
|
||||
|
||||
help_cmdlist();
|
||||
if (cmdptr3 != NULL)
|
||||
{
|
||||
return HelpCommand(cmdptr3);
|
||||
}
|
||||
else if (cmdptr2 != NULL)
|
||||
{
|
||||
return HelpCommand(cmdptr2);
|
||||
}
|
||||
else if (cmdptr1 != NULL)
|
||||
{
|
||||
return HelpCommand(cmdptr1);
|
||||
}
|
||||
|
||||
HelpCommandList();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -15,46 +15,72 @@ BOOL rem_main(INT argc, LPWSTR *argv);
|
|||
|
||||
COMMAND cmds[] =
|
||||
{
|
||||
{L"active", active_main, IDS_HELP_CMD_ACTIVE, IDS_HELP_CMD_DESC_ACTIVE},
|
||||
{L"add", add_main, IDS_HELP_CMD_ADD, IDS_HELP_CMD_DESC_ADD},
|
||||
{L"assign", assign_main, IDS_HELP_CMD_ASSIGN, IDS_HELP_CMD_DESC_ASSIGN},
|
||||
{L"attach", attach_main, IDS_HELP_CMD_ATTACH, IDS_HELP_CMD_DESC_ATTACH},
|
||||
{L"attributes", attributes_main, IDS_HELP_CMD_ATTRIBUTES, IDS_HELP_CMD_DESC_ATTRIBUTES},
|
||||
{L"automount", automount_main, IDS_HELP_CMD_AUTOMOUNT, IDS_HELP_CMD_DESC_AUTOMOUNT},
|
||||
{L"break", break_main, IDS_HELP_CMD_BREAK, IDS_HELP_CMD_DESC_BREAK},
|
||||
{L"clean", clean_main, IDS_HELP_CMD_CLEAN, IDS_HELP_CMD_DESC_CLEAN},
|
||||
{L"compact", compact_main, IDS_HELP_CMD_COMPACT, IDS_HELP_CMD_DESC_COMPACT},
|
||||
{L"convert", convert_main, IDS_HELP_CMD_CONVERT, IDS_HELP_CMD_DESC_CONVERT},
|
||||
{L"create", create_main, IDS_HELP_CMD_CREATE, IDS_HELP_CMD_DESC_CREATE},
|
||||
{L"delete", delete_main, IDS_HELP_CMD_DELETE, IDS_HELP_CMD_DESC_DELETE},
|
||||
{L"detail", detail_main, IDS_HELP_CMD_DETAIL, IDS_HELP_CMD_DESC_DETAIL},
|
||||
{L"detach", detach_main, IDS_HELP_CMD_DETACH, IDS_HELP_CMD_DESC_DETACH},
|
||||
{L"dump", dump_main, IDS_NONE, IDS_NONE},
|
||||
{L"exit", NULL, IDS_NONE, IDS_HELP_CMD_DESC_EXIT},
|
||||
{L"expand", expand_main, IDS_HELP_CMD_EXPAND, IDS_HELP_CMD_DESC_EXPAND},
|
||||
{L"extend", extend_main, IDS_HELP_CMD_EXTEND, IDS_HELP_CMD_DESC_EXTEND},
|
||||
{L"filesystems", filesystems_main, IDS_HELP_CMD_FILESYSTEMS, IDS_HELP_CMD_DESC_FS},
|
||||
{L"format", format_main, IDS_HELP_CMD_FORMAT, IDS_HELP_CMD_DESC_FORMAT},
|
||||
{L"gpt", gpt_main, IDS_HELP_CMD_GPT, IDS_HELP_CMD_DESC_GPT},
|
||||
{L"help", help_main, IDS_HELP_CMD_HELP, IDS_HELP_CMD_DESC_HELP},
|
||||
{L"import", import_main, IDS_HELP_CMD_IMPORT, IDS_HELP_CMD_DESC_IMPORT},
|
||||
{L"inactive", inactive_main, IDS_HELP_CMD_INACTIVE, IDS_HELP_CMD_DESC_INACTIVE},
|
||||
{L"list", list_main, IDS_HELP_CMD_LIST, IDS_HELP_CMD_DESC_LIST},
|
||||
{L"merge", merge_main, IDS_HELP_CMD_MERGE, IDS_HELP_CMD_DESC_MERGE},
|
||||
{L"offline", offline_main, IDS_HELP_CMD_OFFLINE, IDS_HELP_CMD_DESC_OFFLINE},
|
||||
{L"online", online_main, IDS_HELP_CMD_ONLINE, IDS_HELP_CMD_DESC_ONLINE},
|
||||
{L"recover", recover_main, IDS_HELP_CMD_RECOVER, IDS_HELP_CMD_DESC_RECOVER},
|
||||
{L"rem", NULL, IDS_NONE, IDS_HELP_CMD_DESC_REM},
|
||||
{L"remove", remove_main, IDS_HELP_CMD_REMOVE, IDS_HELP_CMD_DESC_REMOVE},
|
||||
{L"repair", repair_main, IDS_HELP_CMD_REPAIR, IDS_HELP_CMD_DESC_REPAIR},
|
||||
{L"rescan", rescan_main, IDS_HELP_CMD_RESCAN, IDS_HELP_CMD_DESC_RESCAN},
|
||||
{L"retain", retain_main, IDS_HELP_CMD_RETAIN, IDS_HELP_CMD_DESC_RETAIN},
|
||||
{L"san", san_main, IDS_HELP_CMD_SAN, IDS_HELP_CMD_DESC_SAN},
|
||||
{L"select", select_main, IDS_HELP_CMD_SELECT, IDS_HELP_CMD_DESC_SELECT},
|
||||
{L"setid", setid_main, IDS_HELP_CMD_SETID, IDS_HELP_CMD_DESC_SETID},
|
||||
{L"shrink", shrink_main, IDS_HELP_CMD_SHRINK, IDS_HELP_CMD_DESC_SHRINK},
|
||||
{L"uniqueid", uniqueid_main, IDS_HELP_CMD_UNIQUEID, IDS_HELP_CMD_DESC_UNIQUEID},
|
||||
{NULL, NULL, IDS_NONE, IDS_NONE}
|
||||
{L"active", NULL, NULL, active_main, IDS_HELP_CMD_ACTIVE, IDS_HELP_CMD_DESC_ACTIVE},
|
||||
{L"add", NULL, NULL, add_main, IDS_HELP_CMD_ADD, IDS_HELP_CMD_DESC_ADD},
|
||||
{L"assign", NULL, NULL, assign_main, IDS_HELP_CMD_ASSIGN, IDS_HELP_CMD_DESC_ASSIGN},
|
||||
{L"attach", NULL, NULL, attach_main, IDS_HELP_CMD_ATTACH, IDS_HELP_CMD_DESC_ATTACH},
|
||||
{L"attributes", NULL, NULL, attributes_main, IDS_HELP_CMD_ATTRIBUTES, IDS_HELP_CMD_DESC_ATTRIBUTES},
|
||||
{L"automount", NULL, NULL, automount_main, IDS_HELP_CMD_AUTOMOUNT, IDS_HELP_CMD_DESC_AUTOMOUNT},
|
||||
{L"break", NULL, NULL, break_main, IDS_HELP_CMD_BREAK, IDS_HELP_CMD_DESC_BREAK},
|
||||
{L"clean", NULL, NULL, clean_main, IDS_HELP_CMD_CLEAN, IDS_HELP_CMD_DESC_CLEAN},
|
||||
{L"compact", NULL, NULL, compact_main, IDS_HELP_CMD_COMPACT, IDS_HELP_CMD_DESC_COMPACT},
|
||||
{L"convert", NULL, NULL, convert_main, IDS_HELP_CMD_CONVERT, IDS_HELP_CMD_DESC_CONVERT},
|
||||
|
||||
{L"create", NULL, NULL, NULL, IDS_HELP_CMD_CREATE, IDS_HELP_CMD_DESC_CREATE},
|
||||
{L"create", L"partition", NULL, NULL, IDS_HELP_CMD_CREATE_PARTITION, IDS_NONE},
|
||||
{L"create", L"partition", L"extended", CreateExtendedPartition, IDS_HELP_CMD_CREATE_PARTITION_EXTENDED, IDS_NONE},
|
||||
{L"create", L"partition", L"logical", CreateLogicalPartition, IDS_HELP_CMD_CREATE_PARTITION_LOGICAL, IDS_NONE},
|
||||
{L"create", L"partition", L"primary", CreatePrimaryPartition, IDS_HELP_CMD_CREATE_PARTITION_PRIMARY, IDS_NONE},
|
||||
|
||||
{L"delete", NULL, NULL, delete_main, IDS_HELP_CMD_DELETE, IDS_HELP_CMD_DESC_DELETE},
|
||||
|
||||
{L"detail", NULL, NULL, NULL, IDS_HELP_CMD_DETAIL, IDS_HELP_CMD_DESC_DETAIL},
|
||||
{L"detail", L"disk", NULL, DetailDisk, IDS_HELP_CMD_DETAIL_DISK, IDS_NONE},
|
||||
{L"detail", L"partition", NULL, DetailPartition, IDS_HELP_CMD_DETAIL_PARTITION, IDS_NONE},
|
||||
{L"detail", L"volume", NULL, DetailVolume, IDS_HELP_CMD_DETAIL_VOLUME, IDS_NONE},
|
||||
|
||||
{L"detach", NULL, NULL, detach_main, IDS_HELP_CMD_DETACH, IDS_HELP_CMD_DESC_DETACH},
|
||||
{L"dump", NULL, NULL, dump_main, IDS_NONE, IDS_NONE},
|
||||
{L"exit", NULL, NULL, NULL, IDS_NONE, IDS_HELP_CMD_DESC_EXIT},
|
||||
{L"expand", NULL, NULL, expand_main, IDS_HELP_CMD_EXPAND, IDS_HELP_CMD_DESC_EXPAND},
|
||||
{L"extend", NULL, NULL, extend_main, IDS_HELP_CMD_EXTEND, IDS_HELP_CMD_DESC_EXTEND},
|
||||
{L"filesystems", NULL, NULL, filesystems_main, IDS_HELP_CMD_FILESYSTEMS, IDS_HELP_CMD_DESC_FS},
|
||||
{L"format", NULL, NULL, format_main, IDS_HELP_CMD_FORMAT, IDS_HELP_CMD_DESC_FORMAT},
|
||||
{L"gpt", NULL, NULL, gpt_main, IDS_HELP_CMD_GPT, IDS_HELP_CMD_DESC_GPT},
|
||||
{L"help", NULL, NULL, help_main, IDS_HELP_CMD_HELP, IDS_HELP_CMD_DESC_HELP},
|
||||
{L"import", NULL, NULL, import_main, IDS_HELP_CMD_IMPORT, IDS_HELP_CMD_DESC_IMPORT},
|
||||
{L"inactive", NULL, NULL, inactive_main, IDS_HELP_CMD_INACTIVE, IDS_HELP_CMD_DESC_INACTIVE},
|
||||
|
||||
{L"list", NULL, NULL, NULL, IDS_HELP_CMD_LIST, IDS_HELP_CMD_DESC_LIST},
|
||||
{L"list", L"disk", NULL, ListDisk, IDS_HELP_CMD_LIST_DISK, IDS_NONE},
|
||||
{L"list", L"partition", NULL, ListPartition, IDS_HELP_CMD_LIST_PARTITION, IDS_NONE},
|
||||
{L"list", L"volume", NULL, ListVolume, IDS_HELP_CMD_LIST_VOLUME, IDS_NONE},
|
||||
{L"list", L"vdisk", NULL, ListVirtualDisk, IDS_HELP_CMD_LIST_VDISK, IDS_NONE},
|
||||
|
||||
{L"merge", NULL, NULL, merge_main, IDS_HELP_CMD_MERGE, IDS_HELP_CMD_DESC_MERGE},
|
||||
{L"offline", NULL, NULL, offline_main, IDS_HELP_CMD_OFFLINE, IDS_HELP_CMD_DESC_OFFLINE},
|
||||
{L"online", NULL, NULL, online_main, IDS_HELP_CMD_ONLINE, IDS_HELP_CMD_DESC_ONLINE},
|
||||
{L"recover", NULL, NULL, recover_main, IDS_HELP_CMD_RECOVER, IDS_HELP_CMD_DESC_RECOVER},
|
||||
{L"rem", NULL, NULL, NULL, IDS_NONE, IDS_HELP_CMD_DESC_REM},
|
||||
{L"remove", NULL, NULL, remove_main, IDS_HELP_CMD_REMOVE, IDS_HELP_CMD_DESC_REMOVE},
|
||||
{L"repair", NULL, NULL, repair_main, IDS_HELP_CMD_REPAIR, IDS_HELP_CMD_DESC_REPAIR},
|
||||
{L"rescan", NULL, NULL, rescan_main, IDS_HELP_CMD_RESCAN, IDS_HELP_CMD_DESC_RESCAN},
|
||||
{L"retain", NULL, NULL, retain_main, IDS_HELP_CMD_RETAIN, IDS_HELP_CMD_DESC_RETAIN},
|
||||
{L"san", NULL, NULL, san_main, IDS_HELP_CMD_SAN, IDS_HELP_CMD_DESC_SAN},
|
||||
|
||||
{L"select", NULL, NULL, NULL, IDS_HELP_CMD_SELECT, IDS_HELP_CMD_DESC_SELECT},
|
||||
{L"select", L"disk", NULL, SelectDisk, IDS_HELP_CMD_SELECT_DISK, IDS_NONE},
|
||||
{L"select", L"partition", NULL, SelectPartition, IDS_HELP_CMD_SELECT_PARTITION, IDS_NONE},
|
||||
{L"select", L"volume", NULL, SelectVolume, IDS_HELP_CMD_SELECT_VOLUME, IDS_NONE},
|
||||
// {L"select", L"vdisk", NULL, SelectVirtualDisk, IDS_HELP_CMD_SELECT_VDISK, IDS_NONE},
|
||||
|
||||
{L"setid", NULL, NULL, setid_main, IDS_HELP_CMD_SETID, IDS_HELP_CMD_DESC_SETID},
|
||||
{L"shrink", NULL, NULL, shrink_main, IDS_HELP_CMD_SHRINK, IDS_HELP_CMD_DESC_SHRINK},
|
||||
|
||||
{L"uniqueid", NULL, NULL, NULL, IDS_HELP_CMD_UNIQUEID, IDS_HELP_CMD_DESC_UNIQUEID},
|
||||
{L"uniqueid", L"disk", NULL, UniqueIdDisk, IDS_HELP_CMD_UNIQUEID_DISK, IDS_NONE},
|
||||
|
||||
{NULL, NULL, NULL, NULL, IDS_NONE, IDS_NONE}
|
||||
};
|
||||
|
||||
|
||||
|
@ -66,9 +92,14 @@ COMMAND cmds[] =
|
|||
* determines which function to invoke.
|
||||
*/
|
||||
BOOL
|
||||
InterpretCmd(int argc, LPWSTR *argv)
|
||||
InterpretCmd(
|
||||
int argc,
|
||||
LPWSTR *argv)
|
||||
{
|
||||
PCOMMAND cmdptr;
|
||||
PCOMMAND cmdptr1 = NULL;
|
||||
PCOMMAND cmdptr2 = NULL;
|
||||
PCOMMAND cmdptr3 = NULL;
|
||||
|
||||
/* If no args provided */
|
||||
if (argc < 1)
|
||||
|
@ -76,20 +107,56 @@ InterpretCmd(int argc, LPWSTR *argv)
|
|||
|
||||
/* First, determine if the user wants to exit
|
||||
or to use a comment */
|
||||
if(wcsicmp(argv[0], L"exit") == 0)
|
||||
if (wcsicmp(argv[0], L"exit") == 0)
|
||||
return FALSE;
|
||||
|
||||
if(wcsicmp(argv[0], L"rem") == 0)
|
||||
if (wcsicmp(argv[0], L"rem") == 0)
|
||||
return TRUE;
|
||||
|
||||
/* Scan internal command table */
|
||||
for (cmdptr = cmds; cmdptr->name; cmdptr++)
|
||||
for (cmdptr = cmds; cmdptr->cmd1; cmdptr++)
|
||||
{
|
||||
if (wcsicmp(argv[0], cmdptr->name) == 0)
|
||||
return cmdptr->func(argc, argv);
|
||||
if ((cmdptr1 == NULL) &&
|
||||
(wcsicmp(argv[0], cmdptr->cmd1) == 0))
|
||||
cmdptr1 = cmdptr;
|
||||
|
||||
if ((cmdptr2 == NULL) &&
|
||||
(argc >= 2) &&
|
||||
(wcsicmp(argv[0], cmdptr->cmd1) == 0) &&
|
||||
(wcsicmp(argv[1], cmdptr->cmd2) == 0))
|
||||
cmdptr2 = cmdptr;
|
||||
|
||||
if ((cmdptr3 == NULL) &&
|
||||
(argc >= 3) &&
|
||||
(wcsicmp(argv[0], cmdptr->cmd1) == 0) &&
|
||||
(wcsicmp(argv[1], cmdptr->cmd2) == 0) &&
|
||||
(wcsicmp(argv[2], cmdptr->cmd3) == 0))
|
||||
cmdptr3 = cmdptr;
|
||||
}
|
||||
|
||||
help_cmdlist();
|
||||
if (cmdptr3 != NULL)
|
||||
{
|
||||
if (cmdptr3->func == NULL)
|
||||
return HelpCommand(cmdptr3);
|
||||
else
|
||||
return cmdptr3->func(argc, argv);
|
||||
}
|
||||
else if (cmdptr2 != NULL)
|
||||
{
|
||||
if (cmdptr2->func == NULL)
|
||||
return HelpCommand(cmdptr2);
|
||||
else
|
||||
return cmdptr2->func(argc, argv);
|
||||
}
|
||||
else if (cmdptr1 != NULL)
|
||||
{
|
||||
if (cmdptr1->func == NULL)
|
||||
return HelpCommand(cmdptr1);
|
||||
else
|
||||
return cmdptr1->func(argc, argv);
|
||||
}
|
||||
|
||||
HelpCommandList();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -220,7 +220,25 @@ END
|
|||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_HELP_CMD_CREATE "\n\
|
||||
<Add create command help text here>\n\n"
|
||||
PARTITION - Create a partition.\n\
|
||||
VOLUME - Create a volume.\n\
|
||||
VDISK - Create a virtual disk file.\n\n"
|
||||
|
||||
IDS_HELP_CMD_CREATE_PARTITION "\n\
|
||||
EFI - Create an EFI system partition.\n\
|
||||
EXTENDED - Create an extended partition.\n\
|
||||
LOGICAL - Create a logical drive.\n\
|
||||
MSR - Create an MSR partition.\n\
|
||||
PRIMARY - Create a primary partition.\n\n"
|
||||
|
||||
IDS_HELP_CMD_CREATE_PARTITION_EXTENDED "\n\
|
||||
Create an exteded partition.\n\n"
|
||||
|
||||
IDS_HELP_CMD_CREATE_PARTITION_LOGICAL "\n\
|
||||
Create a logical drive.\n\n"
|
||||
|
||||
IDS_HELP_CMD_CREATE_PARTITION_PRIMARY "\n\
|
||||
Create a primary partition.\n\n"
|
||||
END
|
||||
|
||||
/* Delete help description */
|
||||
|
@ -235,6 +253,12 @@ STRINGTABLE
|
|||
BEGIN
|
||||
IDS_HELP_CMD_DETAIL "\n\
|
||||
<Add detail command help text here>\n\n"
|
||||
IDS_HELP_CMD_DETAIL_DISK "\n\
|
||||
<Add detail disk command help text here>\n\n"
|
||||
IDS_HELP_CMD_DETAIL_PARTITION "\n\
|
||||
<Add detail partition command help text here>\n\n"
|
||||
IDS_HELP_CMD_DETAIL_VOLUME "\n\
|
||||
<Add detail volume command help text here>\n\n"
|
||||
END
|
||||
|
||||
/* Detach help description */
|
||||
|
@ -304,7 +328,16 @@ END
|
|||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_HELP_CMD_LIST "\n\
|
||||
<Add list command help text here>\n\n"
|
||||
DISK - Show a list of disks.\n\
|
||||
PARTITION - Show a list of partitions on the selected disk.\n\
|
||||
VOLUME - Show a list of volumes.\n\
|
||||
VDISK - Show a list of virtual disk files.\n\n"
|
||||
IDS_HELP_CMD_LIST_DISK "\n\
|
||||
Display a list of disks.\n\n\
|
||||
Syntax: LIST DISK\n\n\
|
||||
Shows a list of disks and additional infomation about the disks.\n\n\
|
||||
Example:\n\n\
|
||||
LIST DISK\n\n"
|
||||
END
|
||||
|
||||
/* Merge help descriptions */
|
||||
|
@ -374,7 +407,18 @@ END
|
|||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_HELP_CMD_SELECT "\n\
|
||||
<Add SELECT command help text here>\n\n"
|
||||
DISK - Moves the focus to the disk.\n\
|
||||
PARTITION - Moves the focus to the partition.\n\
|
||||
VOLUME - Moves the focus to the volume.\n\
|
||||
VDISK - Moves the focus to the virtual disk.\n\n"
|
||||
IDS_HELP_CMD_SELECT_DISK "\n\
|
||||
<Add SELECT DISK command help text here>\n\n"
|
||||
IDS_HELP_CMD_SELECT_PARTITION "\n\
|
||||
<Add SELECT PARTITION command help text here>\n\n"
|
||||
IDS_HELP_CMD_SELECT_VOLUME "\n\
|
||||
<Add SELECT VOLUME command help text here>\n\n"
|
||||
IDS_HELP_CMD_SELECT_VDISK "\n\
|
||||
<Add SELECT VDISK command help text here>\n\n"
|
||||
END
|
||||
|
||||
/* Setid help descriptions */
|
||||
|
@ -395,5 +439,8 @@ END
|
|||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_HELP_CMD_UNIQUEID "\n\
|
||||
<Add UNIQUEID command help text here>\n\n"
|
||||
DISK - Used to display or set the ID of a GUID partition table\n\
|
||||
or the Signature of an MBR partition table.\n\n"
|
||||
IDS_HELP_CMD_UNIQUEID_DISK "\n\
|
||||
<Add UNIQUEID DISK command help text here>\n\n"
|
||||
END
|
||||
|
|
|
@ -13,9 +13,10 @@
|
|||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
static
|
||||
VOID
|
||||
ListDisk(VOID)
|
||||
BOOL
|
||||
ListDisk(
|
||||
INT argc,
|
||||
PWSTR *argv)
|
||||
{
|
||||
PLIST_ENTRY Entry;
|
||||
PDISKENTRY DiskEntry;
|
||||
|
@ -68,11 +69,15 @@ ListDisk(VOID)
|
|||
}
|
||||
|
||||
ConPuts(StdOut, L"\n\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
ListPartition(VOID)
|
||||
|
||||
BOOL
|
||||
ListPartition(
|
||||
INT argc,
|
||||
PWSTR *argv)
|
||||
{
|
||||
PLIST_ENTRY Entry;
|
||||
PPARTENTRY PartEntry;
|
||||
|
@ -85,7 +90,7 @@ ListPartition(VOID)
|
|||
if (CurrentDisk == NULL)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_LIST_PARTITION_NO_DISK);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Header labels */
|
||||
|
@ -205,11 +210,15 @@ ListPartition(VOID)
|
|||
}
|
||||
|
||||
ConPuts(StdOut, L"\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
ListVolume(VOID)
|
||||
|
||||
BOOL
|
||||
ListVolume(
|
||||
INT argc,
|
||||
PWSTR *argv)
|
||||
{
|
||||
PLIST_ENTRY Entry;
|
||||
PVOLENTRY VolumeEntry;
|
||||
|
@ -253,38 +262,16 @@ ListVolume(VOID)
|
|||
}
|
||||
|
||||
ConPuts(StdOut, L"\n\n");
|
||||
}
|
||||
|
||||
static
|
||||
VOID
|
||||
ListVdisk(VOID)
|
||||
{
|
||||
ConPuts(StdOut, L"List VDisk!!\n");
|
||||
}
|
||||
|
||||
BOOL
|
||||
list_main(
|
||||
INT argc,
|
||||
LPWSTR *argv)
|
||||
{
|
||||
/* gets the first word from the string */
|
||||
if (argc == 1)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_HELP_CMD_LIST);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* determines which to list (disk, partition, etc.) */
|
||||
if (!wcsicmp(argv[1], L"disk"))
|
||||
ListDisk();
|
||||
else if (!wcsicmp(argv[1], L"partition"))
|
||||
ListPartition();
|
||||
else if (!wcsicmp(argv[1], L"volume"))
|
||||
ListVolume();
|
||||
else if (!wcsicmp(argv[1], L"vdisk"))
|
||||
ListVdisk();
|
||||
else
|
||||
ConResPuts(StdOut, IDS_HELP_CMD_LIST);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
ListVirtualDisk(
|
||||
INT argc,
|
||||
PWSTR *argv)
|
||||
{
|
||||
ConPuts(StdOut, L"ListVirtualDisk()!\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -57,9 +57,17 @@ IsHexString(
|
|||
BOOL
|
||||
HasPrefix(
|
||||
_In_ PWSTR pszString,
|
||||
_In_ PWSTR pszPrefix)
|
||||
_In_ PWSTR pszPrefix,
|
||||
_Out_opt_ PWSTR *ppszSuffix)
|
||||
{
|
||||
return (_wcsnicmp(pszString, pszPrefix, wcslen(pszPrefix)) == 0);
|
||||
INT nPrefixLength, ret;
|
||||
|
||||
nPrefixLength = wcslen(pszPrefix);
|
||||
ret = _wcsnicmp(pszString, pszPrefix, nPrefixLength);
|
||||
if ((ret == 0) && (ppszSuffix != NULL))
|
||||
*ppszSuffix = &pszString[nPrefixLength];
|
||||
|
||||
return (ret == 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -127,10 +127,16 @@
|
|||
#define IDS_HELP_CMD_COMPACT 113
|
||||
#define IDS_HELP_CMD_CONVERT 114
|
||||
#define IDS_HELP_CMD_CREATE 115
|
||||
#define IDS_HELP_CMD_CREATE_PARTITION 180
|
||||
#define IDS_HELP_CMD_CREATE_PARTITION 180
|
||||
#define IDS_HELP_CMD_CREATE_PARTITION_EXTENDED 181
|
||||
#define IDS_HELP_CMD_CREATE_PARTITION_LOGICAL 182
|
||||
#define IDS_HELP_CMD_CREATE_PARTITION_PRIMARY 183
|
||||
#define IDS_HELP_CMD_DELETE 116
|
||||
#define IDS_HELP_CMD_DETACH 117
|
||||
#define IDS_HELP_CMD_DETAIL 118
|
||||
#define IDS_HELP_CMD_DETAIL_DISK 184
|
||||
#define IDS_HELP_CMD_DETAIL_PARTITION 185
|
||||
#define IDS_HELP_CMD_DETAIL_VOLUME 186
|
||||
#define IDS_HELP_CMD_EXPAND 119
|
||||
#define IDS_HELP_CMD_EXTEND 120
|
||||
#define IDS_HELP_CMD_FILESYSTEMS 121
|
||||
|
@ -140,6 +146,10 @@
|
|||
#define IDS_HELP_CMD_IMPORT 125
|
||||
#define IDS_HELP_CMD_INACTIVE 126
|
||||
#define IDS_HELP_CMD_LIST 127
|
||||
#define IDS_HELP_CMD_LIST_DISK 190
|
||||
#define IDS_HELP_CMD_LIST_PARTITION 191
|
||||
#define IDS_HELP_CMD_LIST_VOLUME 192
|
||||
#define IDS_HELP_CMD_LIST_VDISK 193
|
||||
#define IDS_HELP_CMD_MERGE 128
|
||||
#define IDS_HELP_CMD_OFFLINE 129
|
||||
#define IDS_HELP_CMD_ONLINE 130
|
||||
|
@ -150,8 +160,13 @@
|
|||
#define IDS_HELP_CMD_RETAIN 135
|
||||
#define IDS_HELP_CMD_SAN 136
|
||||
#define IDS_HELP_CMD_SELECT 137
|
||||
#define IDS_HELP_CMD_SELECT_DISK 190
|
||||
#define IDS_HELP_CMD_SELECT_PARTITION 191
|
||||
#define IDS_HELP_CMD_SELECT_VOLUME 192
|
||||
#define IDS_HELP_CMD_SELECT_VDISK 193
|
||||
#define IDS_HELP_CMD_SETID 138
|
||||
#define IDS_HELP_CMD_SHRINK 139
|
||||
#define IDS_HELP_CMD_UNIQUEID 140
|
||||
#define IDS_HELP_CMD_UNIQUEID_DISK 141
|
||||
|
||||
#define IDS_ERROR_INVALID_ARGS 211
|
||||
|
|
|
@ -13,11 +13,10 @@
|
|||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
static
|
||||
VOID
|
||||
BOOL
|
||||
SelectDisk(
|
||||
INT argc,
|
||||
LPWSTR *argv)
|
||||
PWSTR *argv)
|
||||
{
|
||||
PLIST_ENTRY Entry;
|
||||
PDISKENTRY DiskEntry;
|
||||
|
@ -28,7 +27,7 @@ SelectDisk(
|
|||
if (argc > 3)
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (argc == 2)
|
||||
|
@ -37,20 +36,20 @@ SelectDisk(
|
|||
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
|
||||
else
|
||||
ConResPrintf(StdOut, IDS_SELECT_DISK, CurrentDisk->DiskNumber);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!IsDecString(argv[2]))
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ulValue = wcstoul(argv[2], NULL, 10);
|
||||
if ((ulValue == 0) && (errno == ERANGE))
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CurrentDisk = NULL;
|
||||
|
@ -65,21 +64,21 @@ SelectDisk(
|
|||
CurrentDisk = DiskEntry;
|
||||
CurrentPartition = NULL;
|
||||
ConResPrintf(StdOut, IDS_SELECT_DISK, CurrentDisk->DiskNumber);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Entry = Entry->Flink;
|
||||
}
|
||||
|
||||
ConResPuts(StdErr, IDS_SELECT_DISK_INVALID);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
VOID
|
||||
BOOL
|
||||
SelectPartition(
|
||||
INT argc,
|
||||
LPWSTR *argv)
|
||||
PWSTR *argv)
|
||||
{
|
||||
PLIST_ENTRY Entry;
|
||||
PPARTENTRY PartEntry;
|
||||
|
@ -91,13 +90,13 @@ SelectPartition(
|
|||
if (argc > 3)
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (CurrentDisk == NULL)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_SELECT_PARTITION_NO_DISK);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (argc == 2)
|
||||
|
@ -106,20 +105,20 @@ SelectPartition(
|
|||
ConResPuts(StdOut, IDS_SELECT_NO_PARTITION);
|
||||
else
|
||||
ConResPrintf(StdOut, IDS_SELECT_PARTITION, CurrentPartition);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!IsDecString(argv[2]))
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ulValue = wcstoul(argv[2], NULL, 10);
|
||||
if ((ulValue == 0) && (errno == ERANGE))
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Entry = CurrentDisk->PrimaryPartListHead.Flink;
|
||||
|
@ -133,7 +132,7 @@ SelectPartition(
|
|||
{
|
||||
CurrentPartition = PartEntry;
|
||||
ConResPrintf(StdOut, IDS_SELECT_PARTITION, PartNumber);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PartNumber++;
|
||||
|
@ -153,7 +152,7 @@ SelectPartition(
|
|||
{
|
||||
CurrentPartition = PartEntry;
|
||||
ConResPrintf(StdOut, IDS_SELECT_PARTITION, PartNumber);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PartNumber++;
|
||||
|
@ -162,14 +161,14 @@ SelectPartition(
|
|||
}
|
||||
|
||||
ConResPuts(StdErr, IDS_SELECT_PARTITION_INVALID);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
VOID
|
||||
BOOL
|
||||
SelectVolume(
|
||||
INT argc,
|
||||
LPWSTR *argv)
|
||||
PWSTR *argv)
|
||||
{
|
||||
PLIST_ENTRY Entry;
|
||||
PVOLENTRY VolumeEntry;
|
||||
|
@ -180,7 +179,7 @@ SelectVolume(
|
|||
if (argc > 3)
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (argc == 2)
|
||||
|
@ -189,20 +188,20 @@ SelectVolume(
|
|||
ConResPuts(StdOut, IDS_SELECT_NO_VOLUME);
|
||||
else
|
||||
ConResPrintf(StdOut, IDS_SELECT_VOLUME, CurrentVolume->VolumeNumber);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!IsDecString(argv[2]))
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ulValue = wcstoul(argv[2], NULL, 10);
|
||||
if ((ulValue == 0) && (errno == ERANGE))
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CurrentVolume = NULL;
|
||||
|
@ -216,37 +215,12 @@ SelectVolume(
|
|||
{
|
||||
CurrentVolume = VolumeEntry;
|
||||
ConResPrintf(StdOut, IDS_SELECT_VOLUME, CurrentVolume->VolumeNumber);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Entry = Entry->Flink;
|
||||
}
|
||||
|
||||
ConResPuts(StdErr, IDS_SELECT_VOLUME_INVALID);
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
select_main(
|
||||
INT argc,
|
||||
LPWSTR *argv)
|
||||
{
|
||||
/* gets the first word from the string */
|
||||
if (argc == 1)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_HELP_CMD_SELECT);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* determines which to list (disk, partition, etc.) */
|
||||
if (!wcsicmp(argv[1], L"disk"))
|
||||
SelectDisk(argc, argv);
|
||||
else if (!wcsicmp(argv[1], L"partition"))
|
||||
SelectPartition(argc, argv);
|
||||
else if (!wcsicmp(argv[1], L"volume"))
|
||||
SelectVolume(argc, argv);
|
||||
else
|
||||
ConResPuts(StdOut, IDS_HELP_CMD_SELECT);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -13,18 +13,18 @@
|
|||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
static
|
||||
VOID
|
||||
BOOL
|
||||
UniqueIdDisk(
|
||||
_In_ INT argc,
|
||||
_In_ LPWSTR *argv)
|
||||
_In_ PWSTR *argv)
|
||||
{
|
||||
ULONG ulLength, ulValue;
|
||||
PWSTR pszSuffix = NULL;
|
||||
ULONG ulValue;
|
||||
|
||||
if (CurrentDisk == NULL)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (argc == 2)
|
||||
|
@ -32,39 +32,34 @@ UniqueIdDisk(
|
|||
ConPuts(StdOut, L"\n");
|
||||
ConPrintf(StdOut, L"Disk ID: %08lx\n", CurrentDisk->LayoutBuffer->Signature);
|
||||
ConPuts(StdOut, L"\n");
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ulLength = wcslen(argv[2]);
|
||||
if ((ulLength <= 3) || (ulLength > 11))
|
||||
if (!HasPrefix(argv[2], L"ID=", &pszSuffix))
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!HasPrefix(argv[2], L"ID="))
|
||||
if ((pszSuffix == NULL) ||
|
||||
(wcslen(pszSuffix) > 8) ||
|
||||
(IsHexString(pszSuffix) == FALSE))
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!IsHexString(&argv[2][3]))
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
}
|
||||
|
||||
ulValue = wcstoul(&argv[2][3], NULL, 16);
|
||||
ulValue = wcstoul(pszSuffix, NULL, 16);
|
||||
if ((ulValue == 0) && (errno == ERANGE))
|
||||
{
|
||||
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
ConPrintf(StdOut, L"Setting the disk signature is not implemented yet!\n");
|
||||
|
@ -74,23 +69,5 @@ UniqueIdDisk(
|
|||
// SetDiskLayout(CurrentDisk);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL uniqueid_main(INT argc, LPWSTR *argv)
|
||||
{
|
||||
/* gets the first word from the string */
|
||||
if (argc == 1)
|
||||
{
|
||||
ConResPuts(StdOut, IDS_HELP_CMD_UNIQUEID);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* determines which details to print (disk, partition, etc.) */
|
||||
if (!wcsicmp(argv[1], L"disk"))
|
||||
UniqueIdDisk(argc, argv);
|
||||
else
|
||||
ConResPuts(StdOut, IDS_HELP_CMD_UNIQUEID);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue