- 時間撮記:
- 2009-8-16 下午09:12:50 (15 年 以前)
- 檔案:
-
- 修改 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. 5 4 */ 6 5 … … 25 24 * Header Files * 26 25 *******************************************************************************/ 27 #define LOG_GROUP LOG_GROUP_D RV_NAMEDPIPE26 #define LOG_GROUP LOG_GROUP_DEFAULT 28 27 #include <VBox/pdmdrv.h> 29 28 #include <iprt/assert.h> … … 60 59 PPDMDRVINS pDrvIns; 61 60 /** Pointer to the file name. (Freed by MM) */ 62 char 61 char *pszLocation; 63 62 /** Flag whether VirtualBox represents the server or client side. */ 64 63 RTFILE OutputFile; … … 121 120 * Construct a raw output stream driver instance. 122 121 * 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 */ 124 static DECLCALLBACK(int) drvRawFileConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags) 125 { 134 126 PDRVRAWFILE pThis = PDMINS_2_DATA(pDrvIns, PDRVRAWFILE); 135 127 … … 149 141 */ 150 142 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); 157 153 if (RT_FAILURE(rc)) 158 154 { 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)); 181 161 return VINF_SUCCESS; 182 162 } … … 198 178 if (pThis->pszLocation) 199 179 MMR3HeapFree(pThis->pszLocation); 180 181 if (pThis->OutputFile != NIL_RTFILE) 182 { 183 RTFileClose(pThis->OutputFile); 184 pThis->OutputFile = NIL_RTFILE; 185 } 200 186 } 201 187 … … 214 200 215 201 if (pThis->OutputFile != NIL_RTFILE) 202 { 216 203 RTFileClose(pThis->OutputFile); 204 pThis->OutputFile = NIL_RTFILE; 205 } 217 206 } 218 207 … … 251 240 /* pfnResume */ 252 241 NULL, 242 /* pfnAttach */ 243 NULL, 253 244 /* pfnDetach */ 254 245 NULL, 255 246 /* pfnPowerOff */ 256 247 drvRawFilePowerOff, 248 /* pfnSoftReset */ 249 NULL, 250 /* u32EndVersion */ 251 PDM_DRVREG_VERSION 257 252 }; 253
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器