Changeset 39576 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Dec 10, 2011 8:34:39 PM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r39477 r39576 218 218 "\n" 219 219 : "", 220 (u64Cmd & USAGE_REPAIRHD) 221 ? " repairhd [-dry-run]\n" 222 " [-format VDI|VMDK|VHD|...]\n" 223 " <filename>\n" 224 " Tries to repair corrupted disk images\n" 225 "\n" 226 : "", 220 227 #ifdef RT_OS_WINDOWS 221 228 (u64Cmd & USAGE_MODINSTALL) … … 595 602 { 596 603 NOREF(pvUser); 597 return RTPrintfV(pszFormat, va); 604 RTPrintfV(pszFormat, va); 605 return RTPrintf("\n"); 598 606 } 599 607 … … 1921 1929 1922 1930 /** 1931 * Tries to repair a corrupted hard disk image. 1932 * 1933 * @returns VBox status code 1934 */ 1935 static int CmdRepairHardDisk(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession) 1936 { 1937 Utf8Str image; 1938 Utf8Str format; 1939 int vrc; 1940 bool fDryRun = false; 1941 PVBOXHDD pDisk = NULL; 1942 1943 /* Parse the arguments. */ 1944 for (int i = 0; i < argc; i++) 1945 { 1946 if (strcmp(argv[i], "-dry-run") == 0) 1947 { 1948 fDryRun = true; 1949 } 1950 else if (strcmp(argv[i], "-format") == 0) 1951 { 1952 if (argc <= i + 1) 1953 { 1954 return errorArgument("Missing argument to '%s'", argv[i]); 1955 } 1956 i++; 1957 format = argv[i]; 1958 } 1959 else if (image.isEmpty()) 1960 { 1961 image = argv[i]; 1962 } 1963 else 1964 { 1965 return errorSyntax(USAGE_REPAIRHD, "Invalid parameter '%s'", argv[i]); 1966 } 1967 } 1968 1969 if (image.isEmpty()) 1970 return errorSyntax(USAGE_REPAIRHD, "Mandatory input image parameter missing"); 1971 1972 PVDINTERFACE pVDIfs = NULL; 1973 VDINTERFACEERROR vdInterfaceError; 1974 vdInterfaceError.pfnError = handleVDError; 1975 vdInterfaceError.pfnMessage = handleVDMessage; 1976 1977 vrc = VDInterfaceAdd(&vdInterfaceError.Core, "VBoxManage_IError", VDINTERFACETYPE_ERROR, 1978 NULL, sizeof(VDINTERFACEERROR), &pVDIfs); 1979 AssertRC(vrc); 1980 1981 do 1982 { 1983 /* Try to determine input image format */ 1984 if (format.isEmpty()) 1985 { 1986 char *pszFormat = NULL; 1987 VDTYPE enmSrcType = VDTYPE_INVALID; 1988 1989 vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */, 1990 image.c_str(), &pszFormat, &enmSrcType); 1991 if (RT_FAILURE(vrc) && (vrc != VERR_VD_IMAGE_CORRUPTED)) 1992 { 1993 RTMsgError("No file format specified and autodetect failed - please specify format: %Rrc", vrc); 1994 break; 1995 } 1996 format = pszFormat; 1997 RTStrFree(pszFormat); 1998 } 1999 2000 uint32_t fFlags = 0; 2001 if (fDryRun) 2002 fFlags |= VD_REPAIR_DRY_RUN; 2003 2004 vrc = VDRepair(pVDIfs, NULL, image.c_str(), format.c_str(), fFlags); 2005 } 2006 while (0); 2007 2008 return RT_SUCCESS(vrc) ? 0 : 1; 2009 } 2010 2011 /** 1923 2012 * Unloads the necessary driver. 1924 2013 * … … 2213 2302 if (!strcmp(pszCmd, "gueststats")) 2214 2303 return CmdGuestStats(a->argc - 1, &a->argv[1], a->virtualBox, a->session); 2304 if (!strcmp(pszCmd, "repairhd")) 2305 return CmdRepairHardDisk(a->argc - 1, &a->argv[1], a->virtualBox, a->session); 2215 2306 2216 2307 /* default: */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r39477 r39576 100 100 #define USAGE_BANDWIDTHCONTROL RT_BIT_64(56) 101 101 #define USAGE_GUESTSTATS RT_BIT_64(57) 102 #define USAGE_REPAIRHD RT_BIT_64(58) 102 103 #define USAGE_ALL (~(uint64_t)0) 103 104 /** @} */
Note:
See TracChangeset
for help on using the changeset viewer.