VirtualBox

Changeset 39519 in vbox


Ignore:
Timestamp:
Dec 2, 2011 9:12:21 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
75197
Message:

VD: API to repair corrupted images

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/err.h

    r39405 r39519  
    15221522/** The discard operation is not supported for this image. */
    15231523#define VERR_VD_DISCARD_NOT_SUPPORTED               (-3278)
     1524/** The image is the correct format but is corrupted. */
     1525#define VERR_VD_IMAGE_CORRUPTED                     (-3279)
     1526/** Repairing the image is not supported. */
     1527#define VERR_VD_IMAGE_REPAIR_NOT_SUPPORTED          (-3280)
     1528/** Repairing the image is not possible because the corruption is to severe. */
     1529#define VERR_VD_IMAGE_REPAIR_IMPOSSIBLE             (-3281)
    15241530/** @} */
    15251531
  • trunk/include/VBox/vd-plugin.h

    r38876 r39519  
    634634                                                unsigned fDiscard));
    635635
     636    /**
     637     * Try to repair the given image.
     638     *
     639     * @returns VBox status code.
     640     * @param   pszFilename     Name of the image file.
     641     * @param   pVDIfsDisk      Pointer to the per-disk VD interface list.
     642     * @param   pVDIfsImage     Pointer to the per-image VD interface list.
     643     * @param   fFlags          Combination of the VD_REPAIR_* flags.
     644     */
     645    DECLR3CALLBACKMEMBER(int, pfnRepair, (const char *pszFilename, PVDINTERFACE pVDIfsDisk,
     646                                          PVDINTERFACE pVDIfsImage, uint32_t fFlags));
     647
    636648} VBOXHDDBACKEND;
    637649
  • trunk/include/VBox/vd.h

    r38876 r39519  
    105105/** @} */
    106106
     107/** @name VD image repair flags
     108 * @{
     109 */
     110/** Don't repair the image but check what needs to be done. */
     111#define VD_REPAIR_DRY_RUN                       RT_BIT_32(0)
     112
     113/** Mask of all valid repair flags. */
     114#define VD_REPAIR_FLAGS_MASK                    (VD_REPAIR_DRY_RUN)
     115/** @} */
    107116
    108117/**
     
    11701179                                       void *pvUser1, void *pvUser);
    11711180
     1181/**
     1182 * Tries to repair a corrupted image.
     1183 *
     1184 * @return  VBox status code.
     1185 * @retval  VERR_VD_IMAGE_REPAIR_NOT_SUPPORTED if the backend does not support repairing the image.
     1186 * @retval  VERR_VD_IMAGE_REPAIR_IMPOSSIBLE if the corruption is to severe to repair the image.
     1187 * @param   pVDIfsDisk      Pointer to the per-disk VD interface list.
     1188 * @param   pVDIfsImage     Pointer to the per-image VD interface list.
     1189 * @param   pszFilename     Name of the image file to repair.
     1190 * @param   pszFormat       The backend to use.
     1191 * @param   fFlags          Combination of the VD_REPAIR_* flags.
     1192 */
     1193VBOXDDU_DECL(int) VDRepair(PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
     1194                           const char *pszFilename, const char *pszBackend,
     1195                           uint32_t fFlags);
     1196
    11721197RT_C_DECLS_END
    11731198
  • trunk/src/VBox/Storage/DMG.cpp

    r38876 r39519  
    23362336    NULL,
    23372337    /* pfnAsyncDiscard */
     2338    NULL,
     2339    /* pfnRepair */
    23382340    NULL
    23392341};
  • trunk/src/VBox/Storage/ISCSI.cpp

    r38876 r39519  
    55745574    NULL,
    55755575    /* pfnAsyncDiscard */
     5576    NULL,
     5577    /* pfnRepair */
    55765578    NULL
    55775579};
  • trunk/src/VBox/Storage/QCOW.cpp

    r38876 r39519  
    28562856    NULL,
    28572857    /* pfnAsyncDiscard */
     2858    NULL,
     2859    /* pfnRepair */
    28582860    NULL
    28592861};
  • trunk/src/VBox/Storage/QED.cpp

    r38876 r39519  
    29232923    NULL,
    29242924    /* pfnAsyncDiscard */
     2925    NULL,
     2926    /* pfnRepair */
    29252927    NULL
    29262928};
  • trunk/src/VBox/Storage/RAW.cpp

    r38876 r39519  
    12941294    NULL,
    12951295    /* pfnAsyncDiscard */
     1296    NULL,
     1297    /* pfnRepair */
    12961298    NULL
    12971299};
  • trunk/src/VBox/Storage/VD.cpp

    r39413 r39519  
    49814981                    ("ppszFormat=%#p\n", ppszFormat),
    49824982                    VERR_INVALID_PARAMETER);
    4983     AssertMsgReturn(VALID_PTR(ppszFormat),
     4983    AssertMsgReturn(VALID_PTR(penmType),
    49844984                    ("penmType=%#p\n", penmType),
    49854985                    VERR_INVALID_PARAMETER);
     
    93229322}
    93239323
     9324VBOXDDU_DECL(int) VDRepair(PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
     9325                           const char *pszFilename, const char *pszBackend,
     9326                           uint32_t fFlags)
     9327{
     9328    int rc = VERR_NOT_SUPPORTED;
     9329    PCVBOXHDDBACKEND pBackend = NULL;
     9330    VDINTERFACEIOINT VDIfIoInt;
     9331    VDINTERFACEIO    VDIfIoFallback;
     9332    PVDINTERFACEIO   pInterfaceIo;
     9333
     9334    LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename));
     9335    /* Check arguments. */
     9336    AssertMsgReturn(VALID_PTR(pszFilename) && *pszFilename,
     9337                    ("pszFilename=%#p \"%s\"\n", pszFilename, pszFilename),
     9338                    VERR_INVALID_PARAMETER);
     9339    AssertMsgReturn(VALID_PTR(pszBackend),
     9340                    ("pszBackend=%#p\n", pszBackend),
     9341                    VERR_INVALID_PARAMETER);
     9342    AssertMsgReturn((fFlags & ~VD_REPAIR_FLAGS_MASK) == 0,
     9343                    ("fFlags=%#x\n", fFlags),
     9344                    VERR_INVALID_PARAMETER);
     9345
     9346    pInterfaceIo = VDIfIoGet(pVDIfsImage);
     9347    if (!pInterfaceIo)
     9348    {
     9349        /*
     9350         * Caller doesn't provide an I/O interface, create our own using the
     9351         * native file API.
     9352         */
     9353        vdIfIoFallbackCallbacksSetup(&VDIfIoFallback);
     9354        pInterfaceIo = &VDIfIoFallback;
     9355    }
     9356
     9357    /* Set up the internal I/O interface. */
     9358    AssertReturn(!VDIfIoIntGet(pVDIfsImage), VERR_INVALID_PARAMETER);
     9359    VDIfIoInt.pfnOpen                   = vdIOIntOpenLimited;
     9360    VDIfIoInt.pfnClose                  = vdIOIntCloseLimited;
     9361    VDIfIoInt.pfnDelete                 = vdIOIntDeleteLimited;
     9362    VDIfIoInt.pfnMove                   = vdIOIntMoveLimited;
     9363    VDIfIoInt.pfnGetFreeSpace           = vdIOIntGetFreeSpaceLimited;
     9364    VDIfIoInt.pfnGetModificationTime    = vdIOIntGetModificationTimeLimited;
     9365    VDIfIoInt.pfnGetSize                = vdIOIntGetSizeLimited;
     9366    VDIfIoInt.pfnSetSize                = vdIOIntSetSizeLimited;
     9367    VDIfIoInt.pfnReadSync               = vdIOIntReadSyncLimited;
     9368    VDIfIoInt.pfnWriteSync              = vdIOIntWriteSyncLimited;
     9369    VDIfIoInt.pfnFlushSync              = vdIOIntFlushSyncLimited;
     9370    VDIfIoInt.pfnReadUserAsync          = NULL;
     9371    VDIfIoInt.pfnWriteUserAsync         = NULL;
     9372    VDIfIoInt.pfnReadMetaAsync          = NULL;
     9373    VDIfIoInt.pfnWriteMetaAsync         = NULL;
     9374    VDIfIoInt.pfnFlushAsync             = NULL;
     9375    rc = VDInterfaceAdd(&VDIfIoInt.Core, "VD_IOINT", VDINTERFACETYPE_IOINT,
     9376                        pInterfaceIo, sizeof(VDINTERFACEIOINT), &pVDIfsImage);
     9377    AssertRC(rc);
     9378
     9379    rc = vdFindBackend(pszBackend, &pBackend);
     9380    if (RT_SUCCESS(rc))
     9381    {
     9382        if (pBackend->pfnRepair)
     9383            rc = pBackend->pfnRepair(pszFilename, pVDIfsDisk, pVDIfsImage, fFlags);
     9384        else
     9385            rc = VERR_VD_IMAGE_REPAIR_NOT_SUPPORTED;
     9386    }
     9387
     9388    LogFlowFunc(("returns %Rrc\n", rc));
     9389    return rc;
     9390}
     9391
  • trunk/src/VBox/Storage/VDI.cpp

    r38876 r39519  
    31803180    vdiDiscard,
    31813181    /* pfnAsyncDiscard */
    3182     vdiAsyncDiscard
     3182    vdiAsyncDiscard,
     3183    /* pfnRepair */
     3184    NULL
    31833185};
  • trunk/src/VBox/Storage/VHD.cpp

    r38876 r39519  
    31433143    NULL,
    31443144    /* pfnAsyncDiscard */
     3145    NULL,
     3146    /* pfnRepair */
    31453147    NULL
    31463148};
  • trunk/src/VBox/Storage/VMDK.cpp

    r39052 r39519  
    3232#include <iprt/zip.h>
    3333#include <iprt/asm.h>
    34 
    3534
    3635/*******************************************************************************
     
    52995298{
    53005299    int rc;
     5300
     5301    LogFlowFunc(("pImage=%#p pExtent=%#p uSector=%llu pvBuf=%#p cbRead=%llu\n",
     5302                 pImage, pExtent, uSector, pvBuf, cbRead));
    53015303
    53025304    /* Do not allow to go back. */
     
    54295431        /* The next data block we have is not for this area, so just return
    54305432         * that there is no data. */
     5433        LogFlowFunc(("returns VERR_VD_BLOCK_FREE\n"));
    54315434        return VERR_VD_BLOCK_FREE;
    54325435    }
     
    54365439           (uint8_t *)pExtent->pvGrain + VMDK_SECTOR2BYTE(uSectorInGrain),
    54375440           cbRead);
     5441    LogFlowFunc(("returns VINF_SUCCESS\n"));
    54385442    return VINF_SUCCESS;
    54395443}
     
    71987202    NULL,
    71997203    /* pfnAsyncDiscard */
     7204    NULL,
     7205    /* pfnRepair */
    72007206    NULL
    72017207};
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette