Changeset 33745 in vbox for trunk/src/VBox/Storage/testcase
- Timestamp:
- Nov 3, 2010 6:31:53 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/testcase/vbox-img.cpp
r33595 r33745 52 52 " info --filename <filename>\n" 53 53 "\n" 54 " compact --filename <filename>\n", 54 " compact --filename <filename>\n" 55 " createcache --filename <filename>\n" 56 " --size <cache size>\n", 55 57 g_pszProgName); 56 58 } … … 969 971 970 972 973 int handleCreateCache(HandlerArg *a) 974 { 975 int rc = VINF_SUCCESS; 976 PVBOXHDD pDisk = NULL; 977 const char *pszFilename = NULL; 978 uint64_t cbSize = 0; 979 980 /* Parse the command line. */ 981 static const RTGETOPTDEF s_aOptions[] = 982 { 983 { "--filename", 'f', RTGETOPT_REQ_STRING }, 984 { "--size", 's', RTGETOPT_REQ_UINT64 } 985 }; 986 int ch; 987 RTGETOPTUNION ValueUnion; 988 RTGETOPTSTATE GetState; 989 RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 0, 0 /* fFlags */); 990 while ((ch = RTGetOpt(&GetState, &ValueUnion))) 991 { 992 switch (ch) 993 { 994 case 'f': // --filename 995 pszFilename = ValueUnion.psz; 996 break; 997 998 case 's': // --size 999 cbSize = ValueUnion.u64; 1000 break; 1001 1002 default: 1003 ch = RTGetOptPrintError(ch, &ValueUnion); 1004 printUsage(g_pStdErr); 1005 return ch; 1006 } 1007 } 1008 1009 /* Check for mandatory parameters. */ 1010 if (!pszFilename) 1011 return errorSyntax("Mandatory --filename option missing\n"); 1012 1013 if (!cbSize) 1014 return errorSyntax("Mandatory --size option missing\n"); 1015 1016 /* just try it */ 1017 rc = VDCreate(pVDIfs, VDTYPE_HDD, &pDisk); 1018 if (RT_FAILURE(rc)) 1019 return errorRuntime("Error while creating the virtual disk container: %Rrc\n", rc); 1020 1021 rc = VDCreateCache(pDisk, "VCI", pszFilename, cbSize, VD_IMAGE_FLAGS_DEFAULT, 1022 NULL, NULL, VD_OPEN_FLAGS_NORMAL, NULL, NULL); 1023 if (RT_FAILURE(rc)) 1024 return errorRuntime("Error while creating the virtual disk cache: %Rrc\n", rc); 1025 1026 VDCloseAll(pDisk); 1027 1028 return rc; 1029 } 1030 1031 971 1032 int main(int argc, char *argv[]) 972 1033 { … … 1052 1113 } s_commandHandlers[] = 1053 1114 { 1054 { "setuuid", handleSetUUID }, 1055 { "convert", handleConvert }, 1056 { "info", handleInfo }, 1057 { "compact", handleCompact }, 1058 { NULL, NULL } 1115 { "setuuid", handleSetUUID }, 1116 { "convert", handleConvert }, 1117 { "info", handleInfo }, 1118 { "compact", handleCompact }, 1119 { "createcache", handleCreateCache }, 1120 { NULL, NULL } 1059 1121 }; 1060 1122
Note:
See TracChangeset
for help on using the changeset viewer.