VirtualBox

忽略:
時間撮記:
2009-8-16 下午09:12:50 (15 年 以前)
作者:
vboxsync
訊息:

PDMDRVREG change (big changeset).

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Devices/Serial/DrvRawFile.cpp

    r19626 r22277  
    1 /** @file
    2  *
    3  * VBox stream devices:
    4  * Raw file output
     1/* $Id$ */
     2/** @file
     3 * VBox stream drivers - Raw file output.
    54 */
    65
     
    2524*   Header Files                                                               *
    2625*******************************************************************************/
    27 #define LOG_GROUP LOG_GROUP_DRV_NAMEDPIPE
     26#define LOG_GROUP LOG_GROUP_DEFAULT
    2827#include <VBox/pdmdrv.h>
    2928#include <iprt/assert.h>
     
    6059    PPDMDRVINS          pDrvIns;
    6160    /** Pointer to the file name. (Freed by MM) */
    62     char                *pszLocation;
     61    char               *pszLocation;
    6362    /** Flag whether VirtualBox represents the server or client side. */
    6463    RTFILE              OutputFile;
     
    121120 * Construct a raw output stream driver instance.
    122121 *
    123  * @returns VBox status.
    124  * @param   pDrvIns     The driver instance data.
    125  *                      If the registration structure is needed, pDrvIns->pDrvReg points to it.
    126  * @param   pCfgHandle  Configuration node handle for the driver. Use this to obtain the configuration
    127  *                      of the driver instance. It's also found in pDrvIns->pCfgHandle, but like
    128  *                      iInstance it's expected to be used a bit in this function.
    129  */
    130 static DECLCALLBACK(int) drvRawFileConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle)
    131 {
    132     int rc;
    133     char *pszLocation = NULL;
     122 * @copydoc FNPDMDRVCONSTRUCT
     123 */
     124static DECLCALLBACK(int) drvRawFileConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags)
     125{
    134126    PDRVRAWFILE pThis = PDMINS_2_DATA(pDrvIns, PDRVRAWFILE);
    135127
     
    149141     */
    150142    if (!CFGMR3AreValuesValid(pCfgHandle, "Location\0"))
    151     {
    152         rc = VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
    153         goto out;
    154     }
    155 
    156     rc = CFGMR3QueryStringAlloc(pCfgHandle, "Location", &pszLocation);
     143        AssertFailedReturn(VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES);
     144
     145    int rc = CFGMR3QueryStringAlloc(pCfgHandle, "Location", &pThis->pszLocation);
     146    if (RT_FAILURE(rc))
     147        AssertMsgFailedReturn(("Configuration error: query \"Location\" resulted in %Rrc.\n", rc), rc);
     148
     149    /*
     150     * Open the raw file.
     151     */
     152    rc = RTFileOpen(&pThis->OutputFile, pThis->pszLocation, RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
    157153    if (RT_FAILURE(rc))
    158154    {
    159         AssertMsgFailed(("Configuration error: query \"Location\" resulted in %Rrc.\n", rc));
    160         goto out;
    161     }
    162     pThis->pszLocation = pszLocation;
    163 
    164     rc = RTFileOpen(&pThis->OutputFile, pThis->pszLocation, RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE);
    165     if (RT_FAILURE(rc))
    166     {
    167         LogRel(("RawFile%d: CreateFile failed rc=%Rrc\n", pThis->pDrvIns->iInstance));
    168         return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("RawFile#%d failed to create the raw output file %s"), pDrvIns->iInstance, pszLocation);
    169     }
    170 
    171 out:
    172     if (RT_FAILURE(rc))
    173     {
    174         if (pszLocation)
    175             MMR3HeapFree(pszLocation);
    176         return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("RawFile#%d failed to initialize"), pDrvIns->iInstance);
    177     }
    178 
    179     LogFlow(("drvRawFileConstruct: location %s\n", pszLocation));
    180     LogRel(("RawFile: location %s\n", pszLocation));
     155        LogRel(("RawFile%d: CreateFile failed rc=%Rrc\n", pDrvIns->iInstance));
     156        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("RawFile#%d failed to create the raw output file %s"), pDrvIns->iInstance, pThis->pszLocation);
     157    }
     158
     159    LogFlow(("drvRawFileConstruct: location %s\n", pThis->pszLocation));
     160    LogRel(("RawFile#%u: location %s\n", pDrvIns->iInstance, pThis->pszLocation));
    181161    return VINF_SUCCESS;
    182162}
     
    198178    if (pThis->pszLocation)
    199179        MMR3HeapFree(pThis->pszLocation);
     180
     181    if (pThis->OutputFile != NIL_RTFILE)
     182    {   
     183        RTFileClose(pThis->OutputFile);
     184        pThis->OutputFile = NIL_RTFILE;
     185    }
    200186}
    201187
     
    214200
    215201    if (pThis->OutputFile != NIL_RTFILE)
     202    {   
    216203        RTFileClose(pThis->OutputFile);
     204        pThis->OutputFile = NIL_RTFILE;
     205    }
    217206}
    218207
     
    251240    /* pfnResume */
    252241    NULL,
     242    /* pfnAttach */
     243    NULL,
    253244    /* pfnDetach */
    254245    NULL,
    255246    /* pfnPowerOff */
    256247    drvRawFilePowerOff,
     248    /* pfnSoftReset */
     249    NULL,
     250    /* u32EndVersion */
     251    PDM_DRVREG_VERSION
    257252};
     253
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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