- Timestamp:
- Sep 9, 2016 10:06:48 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/DMG.cpp
r63785 r63786 2047 2047 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2048 2048 2049 AssertPtr(pThis); 2050 2051 if (pThis) 2052 return 1; 2053 else 2054 return 0; 2049 AssertPtrReturn(pThis, 0); 2050 2051 return 1; 2055 2052 } 2056 2053 … … 2060 2057 LogFlowFunc(("pBackendData=%#p\n", pBackendData)); 2061 2058 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2059 2060 AssertPtrReturn(pThis, 0); 2061 2062 2062 uint32_t cb = 0; 2063 2064 AssertPtr(pThis); 2065 2066 if (pThis && (pThis->pStorage || pThis->hDmgFileInXar != NIL_RTVFSFILE)) 2063 if (pThis->pStorage || pThis->hDmgFileInXar != NIL_RTVFSFILE) 2067 2064 cb = 2048; 2068 2065 … … 2076 2073 LogFlowFunc(("pBackendData=%#p\n", pBackendData)); 2077 2074 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2075 2076 AssertPtrReturn(pThis, 0); 2077 2078 2078 uint64_t cb = 0; 2079 2080 AssertPtr(pThis); 2081 2082 if (pThis && (pThis->pStorage || pThis->hDmgFileInXar != NIL_RTVFSFILE)) 2079 if (pThis->pStorage || pThis->hDmgFileInXar != NIL_RTVFSFILE) 2083 2080 cb = pThis->cbSize; 2084 2081 … … 2092 2089 LogFlowFunc(("pBackendData=%#p\n", pBackendData)); 2093 2090 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2094 uint64_t cb = 0; 2095 2096 AssertPtr(pThis); 2097 2098 if (pThis && (pThis->pStorage || pThis->hDmgFileInXar != NIL_RTVFSFILE)) 2099 { 2100 uint64_t cbFile; 2091 2092 AssertPtrReturn(pThis, 0); 2093 2094 uint64_t cbFile = 0; 2095 if (pThis->pStorage || pThis->hDmgFileInXar != NIL_RTVFSFILE) 2096 { 2101 2097 int rc = dmgWrapFileGetSize(pThis, &cbFile); 2102 if (RT_ SUCCESS(rc))2103 cb = cbFile;2104 } 2105 2106 LogFlowFunc(("returns %lld\n", cb ));2107 return cb ;2098 if (RT_FAILURE(rc)) 2099 cbFile = 0; /* Make sure it is 0 */ 2100 } 2101 2102 LogFlowFunc(("returns %lld\n", cbFile)); 2103 return cbFile; 2108 2104 } 2109 2105 … … 2113 2109 LogFlowFunc(("pBackendData=%#p pPCHSGeometry=%#p\n", pBackendData, pPCHSGeometry)); 2114 2110 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2115 int rc; 2116 2117 AssertPtr(pThis); 2118 2119 if (pThis) 2120 { 2121 if (pThis->PCHSGeometry.cCylinders) 2122 { 2123 *pPCHSGeometry = pThis->PCHSGeometry; 2124 rc = VINF_SUCCESS; 2125 } 2126 else 2127 rc = VERR_VD_GEOMETRY_NOT_SET; 2128 } 2111 int rc = VINF_SUCCESS; 2112 2113 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 2114 2115 if (pThis->PCHSGeometry.cCylinders) 2116 *pPCHSGeometry = pThis->PCHSGeometry; 2129 2117 else 2130 rc = VERR_VD_ NOT_OPENED;2118 rc = VERR_VD_GEOMETRY_NOT_SET; 2131 2119 2132 2120 LogFlowFunc(("returns %Rrc (PCHS=%u/%u/%u)\n", rc, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors)); … … 2140 2128 pBackendData, pPCHSGeometry, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors)); 2141 2129 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2142 int rc; 2143 2144 AssertPtr(pThis); 2145 2146 if (pThis) 2147 { 2148 if (!(pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY)) 2149 { 2150 pThis->PCHSGeometry = *pPCHSGeometry; 2151 rc = VINF_SUCCESS; 2152 } 2153 else 2154 rc = VERR_VD_IMAGE_READ_ONLY; 2155 } 2130 int rc = VINF_SUCCESS; 2131 2132 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 2133 2134 if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2135 rc = VERR_VD_IMAGE_READ_ONLY; 2156 2136 else 2157 rc = VERR_VD_NOT_OPENED;2137 pThis->PCHSGeometry = *pPCHSGeometry; 2158 2138 2159 2139 LogFlowFunc(("returns %Rrc\n", rc)); … … 2164 2144 static DECLCALLBACK(int) dmgGetLCHSGeometry(void *pBackendData, PVDGEOMETRY pLCHSGeometry) 2165 2145 { 2166 2146 LogFlowFunc(("pBackendData=%#p pLCHSGeometry=%#p\n", pBackendData, pLCHSGeometry)); 2167 2147 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2168 int rc; 2169 2170 AssertPtr(pThis); 2171 2172 if (pThis) 2173 { 2174 if (pThis->LCHSGeometry.cCylinders) 2175 { 2176 *pLCHSGeometry = pThis->LCHSGeometry; 2177 rc = VINF_SUCCESS; 2178 } 2179 else 2180 rc = VERR_VD_GEOMETRY_NOT_SET; 2181 } 2148 int rc = VINF_SUCCESS; 2149 2150 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 2151 2152 if (pThis->LCHSGeometry.cCylinders) 2153 *pLCHSGeometry = pThis->LCHSGeometry; 2182 2154 else 2183 rc = VERR_VD_ NOT_OPENED;2155 rc = VERR_VD_GEOMETRY_NOT_SET; 2184 2156 2185 2157 LogFlowFunc(("returns %Rrc (LCHS=%u/%u/%u)\n", rc, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors)); … … 2193 2165 pBackendData, pLCHSGeometry, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors)); 2194 2166 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2195 int rc; 2196 2197 AssertPtr(pThis); 2198 2199 if (pThis) 2200 { 2201 if (!(pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY)) 2202 { 2203 pThis->LCHSGeometry = *pLCHSGeometry; 2204 rc = VINF_SUCCESS; 2205 } 2206 else 2207 rc = VERR_VD_IMAGE_READ_ONLY; 2208 } 2167 int rc = VINF_SUCCESS; 2168 2169 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 2170 2171 if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2172 rc = VERR_VD_IMAGE_READ_ONLY; 2209 2173 else 2210 rc = VERR_VD_NOT_OPENED;2174 pThis->LCHSGeometry = *pLCHSGeometry; 2211 2175 2212 2176 LogFlowFunc(("returns %Rrc\n", rc)); … … 2219 2183 LogFlowFunc(("pBackendData=%#p\n", pBackendData)); 2220 2184 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2221 unsigned uImageFlags; 2222 2223 AssertPtr(pThis); 2224 2225 if (pThis) 2226 uImageFlags = pThis->uImageFlags; 2227 else 2228 uImageFlags = 0; 2229 2230 LogFlowFunc(("returns %#x\n", uImageFlags)); 2231 return uImageFlags; 2185 AssertPtrReturn(pThis, 0); 2186 2187 LogFlowFunc(("returns %#x\n", pThis->uImageFlags)); 2188 return pThis->uImageFlags; 2232 2189 } 2233 2190 … … 2237 2194 LogFlowFunc(("pBackendData=%#p\n", pBackendData)); 2238 2195 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2239 unsigned uOpenFlags; 2240 2241 AssertPtr(pThis); 2242 2243 if (pThis) 2244 uOpenFlags = pThis->uOpenFlags; 2245 else 2246 uOpenFlags = 0; 2247 2248 LogFlowFunc(("returns %#x\n", uOpenFlags)); 2249 return uOpenFlags; 2196 2197 AssertPtrReturn(pThis, 0); 2198 2199 LogFlowFunc(("returns %#x\n", pThis->uOpenFlags)); 2200 return pThis->uOpenFlags; 2250 2201 } 2251 2202 … … 2255 2206 LogFlowFunc(("pBackendData=%#p\n uOpenFlags=%#x", pBackendData, uOpenFlags)); 2256 2207 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2257 int rc ;2208 int rc = VINF_SUCCESS; 2258 2209 2259 2210 /* Image must be opened and the new flags must be valid. */ … … 2261 2212 | VD_OPEN_FLAGS_SHAREABLE | VD_OPEN_FLAGS_SEQUENTIAL 2262 2213 | VD_OPEN_FLAGS_SKIP_CONSISTENCY_CHECKS))) 2263 {2264 2214 rc = VERR_INVALID_PARAMETER; 2265 goto out; 2266 } 2267 2268 /* Implement this operation via reopening the image. */ 2269 rc = dmgFreeImage(pThis, false); 2270 if (RT_FAILURE(rc)) 2271 goto out; 2272 rc = dmgOpenImage(pThis, uOpenFlags); 2273 2274 out: 2215 else 2216 { 2217 /* Implement this operation via reopening the image. */ 2218 rc = dmgFreeImage(pThis, false); 2219 if (RT_SUCCESS(rc)) 2220 rc = dmgOpenImage(pThis, uOpenFlags); 2221 } 2222 2275 2223 LogFlowFunc(("returns %Rrc\n", rc)); 2276 2224 return rc; … … 2283 2231 LogFlowFunc(("pBackendData=%#p pszComment=%#p cbComment=%zu\n", pBackendData, pszComment, cbComment)); 2284 2232 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2285 int rc; 2286 2287 AssertPtr(pThis); 2288 2289 if (pThis) 2290 rc = VERR_NOT_SUPPORTED; 2291 else 2292 rc = VERR_VD_NOT_OPENED; 2293 2294 LogFlowFunc(("returns %Rrc comment='%s'\n", rc, pszComment)); 2295 return rc; 2233 2234 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 2235 2236 LogFlowFunc(("returns %Rrc comment='%s'\n", VERR_NOT_SUPPORTED, pszComment)); 2237 return VERR_NOT_SUPPORTED; 2296 2238 } 2297 2239 … … 2301 2243 RT_NOREF1(pszComment); 2302 2244 LogFlowFunc(("pBackendData=%#p pszComment=\"%s\"\n", pBackendData, pszComment)); 2303 PDMGIMAGE pImage = (PDMGIMAGE)pBackendData; 2245 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2246 2247 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 2248 2304 2249 int rc; 2305 2306 AssertPtr(pImage); 2307 2308 if (pImage) 2309 { 2310 if (pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2311 rc = VERR_VD_IMAGE_READ_ONLY; 2312 else 2313 rc = VERR_NOT_SUPPORTED; 2314 } 2250 if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2251 rc = VERR_VD_IMAGE_READ_ONLY; 2315 2252 else 2316 rc = VERR_ VD_NOT_OPENED;2253 rc = VERR_NOT_SUPPORTED; 2317 2254 2318 2255 LogFlowFunc(("returns %Rrc\n", rc)); … … 2326 2263 LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid)); 2327 2264 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2328 int rc; 2329 2330 AssertPtr(pThis); 2331 2332 if (pThis) 2333 rc = VERR_NOT_SUPPORTED; 2334 else 2335 rc = VERR_VD_NOT_OPENED; 2336 2337 LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid)); 2338 return rc; 2265 2266 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 2267 2268 LogFlowFunc(("returns %Rrc (%RTuuid)\n", VERR_NOT_SUPPORTED, pUuid)); 2269 return VERR_NOT_SUPPORTED; 2339 2270 } 2340 2271 … … 2345 2276 LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid)); 2346 2277 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2278 2279 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 2280 2347 2281 int rc; 2348 2349 LogFlowFunc(("%RTuuid\n", pUuid)); 2350 AssertPtr(pThis); 2351 2352 if (pThis) 2353 { 2354 if (!(pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY)) 2355 rc = VERR_NOT_SUPPORTED; 2356 else 2357 rc = VERR_VD_IMAGE_READ_ONLY; 2358 } 2282 if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2283 rc = VERR_VD_IMAGE_READ_ONLY; 2359 2284 else 2360 rc = VERR_ VD_NOT_OPENED;2285 rc = VERR_NOT_SUPPORTED; 2361 2286 2362 2287 LogFlowFunc(("returns %Rrc\n", rc)); … … 2370 2295 LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid)); 2371 2296 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2372 int rc; 2373 2374 AssertPtr(pThis); 2375 2376 if (pThis) 2377 rc = VERR_NOT_SUPPORTED; 2378 else 2379 rc = VERR_VD_NOT_OPENED; 2380 2381 LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid)); 2382 return rc; 2297 2298 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 2299 2300 LogFlowFunc(("returns %Rrc (%RTuuid)\n", VERR_NOT_SUPPORTED, pUuid)); 2301 return VERR_NOT_SUPPORTED; 2383 2302 } 2384 2303 … … 2389 2308 LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid)); 2390 2309 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2310 2311 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 2312 2391 2313 int rc; 2392 2393 AssertPtr(pThis); 2394 2395 if (pThis) 2396 { 2397 if (!(pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY)) 2398 rc = VERR_NOT_SUPPORTED; 2399 else 2400 rc = VERR_VD_IMAGE_READ_ONLY; 2401 } 2314 if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2315 rc = VERR_VD_IMAGE_READ_ONLY; 2402 2316 else 2403 rc = VERR_ VD_NOT_OPENED;2317 rc = VERR_NOT_SUPPORTED; 2404 2318 2405 2319 LogFlowFunc(("returns %Rrc\n", rc)); … … 2413 2327 LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid)); 2414 2328 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2415 int rc; 2416 2417 AssertPtr(pThis); 2418 2419 if (pThis) 2420 rc = VERR_NOT_SUPPORTED; 2421 else 2422 rc = VERR_VD_NOT_OPENED; 2423 2424 LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid)); 2425 return rc; 2329 2330 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 2331 2332 LogFlowFunc(("returns %Rrc (%RTuuid)\n", VERR_NOT_SUPPORTED, pUuid)); 2333 return VERR_NOT_SUPPORTED; 2426 2334 } 2427 2335 … … 2432 2340 LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid)); 2433 2341 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2342 2343 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 2344 2434 2345 int rc; 2435 2436 AssertPtr(pThis); 2437 2438 if (pThis) 2439 { 2440 if (!(pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY)) 2441 rc = VERR_NOT_SUPPORTED; 2442 else 2443 rc = VERR_VD_IMAGE_READ_ONLY; 2444 } 2346 if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2347 rc = VERR_VD_IMAGE_READ_ONLY; 2445 2348 else 2446 rc = VERR_ VD_NOT_OPENED;2349 rc = VERR_NOT_SUPPORTED; 2447 2350 2448 2351 LogFlowFunc(("returns %Rrc\n", rc)); … … 2456 2359 LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid)); 2457 2360 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2361 2362 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 2363 2458 2364 int rc; 2459 2460 AssertPtr(pThis); 2461 2462 if (pThis) 2365 if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2366 rc = VERR_VD_IMAGE_READ_ONLY; 2367 else 2463 2368 rc = VERR_NOT_SUPPORTED; 2464 else2465 rc = VERR_VD_NOT_OPENED;2466 2369 2467 2370 LogFlowFunc(("returns %Rrc (%RTuuid)\n", rc, pUuid)); … … 2475 2378 LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid)); 2476 2379 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2380 2381 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 2382 2477 2383 int rc; 2478 2479 AssertPtr(pThis); 2480 2481 if (pThis) 2482 { 2483 if (!(pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY)) 2484 rc = VERR_NOT_SUPPORTED; 2485 else 2486 rc = VERR_VD_IMAGE_READ_ONLY; 2487 } 2384 if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY) 2385 rc = VERR_VD_IMAGE_READ_ONLY; 2488 2386 else 2489 rc = VERR_ VD_NOT_OPENED;2387 rc = VERR_NOT_SUPPORTED; 2490 2388 2491 2389 LogFlowFunc(("returns %Rrc\n", rc)); … … 2498 2396 PDMGIMAGE pThis = (PDMGIMAGE)pBackendData; 2499 2397 2500 AssertPtr(pThis); 2501 if (pThis) 2502 { 2503 vdIfErrorMessage(pThis->pIfError, "Header: Geometry PCHS=%u/%u/%u LCHS=%u/%u/%u cSectors=%llu\n", 2504 pThis->PCHSGeometry.cCylinders, pThis->PCHSGeometry.cHeads, pThis->PCHSGeometry.cSectors, 2505 pThis->LCHSGeometry.cCylinders, pThis->LCHSGeometry.cHeads, pThis->LCHSGeometry.cSectors, 2506 pThis->cbSize / DMG_SECTOR_SIZE); 2507 } 2398 AssertPtrReturnVoid(pThis); 2399 vdIfErrorMessage(pThis->pIfError, "Header: Geometry PCHS=%u/%u/%u LCHS=%u/%u/%u cSectors=%llu\n", 2400 pThis->PCHSGeometry.cCylinders, pThis->PCHSGeometry.cHeads, pThis->PCHSGeometry.cSectors, 2401 pThis->LCHSGeometry.cCylinders, pThis->LCHSGeometry.cHeads, pThis->LCHSGeometry.cSectors, 2402 pThis->cbSize / DMG_SECTOR_SIZE); 2508 2403 } 2509 2404
Note:
See TracChangeset
for help on using the changeset viewer.