Changeset 71781 in vbox
- Timestamp:
- Apr 9, 2018 3:43:14 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 121884
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp ¶
r71432 r71781 183 183 if (RT_SUCCESS(rc)) 184 184 { 185 /** @todo r=bird: Plase, use RTStrCopy for stuff like this! */ 186 RTStrPrintf(pFile->szName, sizeof(pFile->szName), "%s", szFile); 185 RTStrCopy(pFile->szName, sizeof(pFile->szName), szFile); 187 186 188 187 uint64_t fFlags; 189 188 rc = RTFileModeToFlagsEx(szAccess, szDisposition, NULL /* pszSharing, not used yet */, &fFlags); 190 VGSvcVerbose(4, "[File %s] :Opening with fFlags=0x%x, rc=%Rrc\n", pFile->szName, fFlags, rc);189 VGSvcVerbose(4, "[File %s] Opening with fFlags=0x%x, rc=%Rrc\n", pFile->szName, fFlags, rc); 191 190 192 191 if (RT_SUCCESS(rc)) … … 199 198 rc = RTFileSeek(pFile->hFile, (int64_t)offOpen, RTFILE_SEEK_BEGIN, NULL /* Current offset */); 200 199 if (RT_FAILURE(rc)) 201 VGSvcError("[File %s] :Seeking to offset %RU64 failed; rc=%Rrc\n", pFile->szName, offOpen, rc);200 VGSvcError("[File %s] Seeking to offset %RU64 failed; rc=%Rrc\n", pFile->szName, offOpen, rc); 202 201 } 203 202 else if (RT_FAILURE(rc)) 204 VGSvcError("[File %s] :Opening failed with rc=%Rrc\n", pFile->szName, rc);203 VGSvcError("[File %s] Opening failed with rc=%Rrc\n", pFile->szName, rc); 205 204 } 206 205 … … 212 211 RTListAppend(&pSession->lstFiles, &pFile->Node); 213 212 214 VGSvcVerbose( 3, "[File %s]:Opened (ID=%RU32)\n", pFile->szName, pFile->uHandle);213 VGSvcVerbose(2, "[File %s] Opened (ID=%RU32)\n", pFile->szName, pFile->uHandle); 215 214 } 216 215 … … 233 232 } 234 233 235 #ifdef DEBUG 236 VGSvcVerbose(4, "Opening file '%s' (open mode='%s', disposition='%s', creation mode=0x%x returned rc=%Rrc\n", 234 VGSvcVerbose(4, "[File %s] Opening (open mode='%s', disposition='%s', creation mode=0x%x) returned rc=%Rrc\n", 237 235 szFile, szAccess, szDisposition, uCreationMode, rc); 238 #endif239 236 return rc; 240 237 } … … 246 243 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 247 244 248 PVBOXSERVICECTRLFILE pFile = NULL;249 250 245 uint32_t uHandle = 0; 251 246 int rc = VbglR3GuestCtrlFileGetClose(pHostCtx, &uHandle /* File handle to close */); 252 247 if (RT_SUCCESS(rc)) 253 248 { 254 pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);249 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle); 255 250 if (pFile) 251 { 252 VGSvcVerbose(2, "[File %s] Closing (handle=%RU32)\n", pFile ? pFile->szName : "<Not found>", uHandle); 253 256 254 rc = vgsvcGstCtrlSessionFileDestroy(pFile); 255 } 257 256 else 258 257 rc = VERR_NOT_FOUND; … … 266 265 } 267 266 268 #ifdef DEBUG269 VGSvcVerbose(4, "Closing file '%s' (handle=%RU32) returned rc=%Rrc\n", pFile ? pFile->szName : "<Not found>", uHandle, rc);270 #endif271 267 return rc; 272 268 } … … 278 274 AssertPtrReturn(pSession, VERR_INVALID_POINTER); 279 275 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 280 281 PVBOXSERVICECTRLFILE pFile = NULL;282 276 283 277 uint32_t uHandle = 0; … … 289 283 size_t cbRead = 0; 290 284 291 pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);285 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle); 292 286 if (pFile) 293 287 { … … 310 304 rc = VERR_NOT_FOUND; 311 305 306 VGSvcVerbose(4, "[File %s] Read %zu/%RU32 bytes, rc=%Rrc\n", pFile ? pFile->szName : "<Not found>", cbRead, cbToRead, rc); 307 312 308 /* Report back in any case. */ 313 309 int rc2 = VbglR3GuestCtrlFileCbRead(pHostCtx, rc, pvDataRead, (uint32_t)cbRead); … … 322 318 } 323 319 324 #ifdef DEBUG325 VGSvcVerbose(4, "Reading file '%s' (handle=%RU32) returned rc=%Rrc\n", pFile ? pFile->szName : "<Not found>", uHandle, rc);326 #endif327 320 return rc; 328 321 } … … 334 327 AssertPtrReturn(pSession, VERR_INVALID_POINTER); 335 328 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 336 337 PVBOXSERVICECTRLFILE pFile = NULL;338 329 339 330 uint32_t uHandle = 0; … … 346 337 size_t cbRead = 0; 347 338 348 pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);339 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle); 349 340 if (pFile) 350 341 { … … 360 351 if (RT_SUCCESS(rc)) 361 352 rc = RTFileReadAt(pFile->hFile, (RTFOFF)offReadAt, pvDataRead, cbToRead, &cbRead); 353 354 VGSvcVerbose(4, "[File %s] Read %zu bytes @ %RU64, rc=%Rrc\n", 355 pFile ? pFile->szName : "<Not found>", cbRead, offReadAt, rc); 362 356 } 363 357 else … … 379 373 } 380 374 381 #ifdef DEBUG382 VGSvcVerbose(4, "Reading file '%s' at offset (handle=%RU32) returned rc=%Rrc\n",383 pFile ? pFile->szName : "<Not found>", uHandle, rc);384 #endif385 375 return rc; 386 376 } … … 395 385 AssertPtrReturn(cbScratchBuf, VERR_INVALID_PARAMETER); 396 386 397 PVBOXSERVICECTRLFILE pFile = NULL;398 399 387 uint32_t uHandle = 0; 400 388 uint32_t cbToWrite; … … 403 391 { 404 392 size_t cbWritten = 0; 405 pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);393 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle); 406 394 if (pFile) 407 395 { 408 396 rc = RTFileWrite(pFile->hFile, pvScratchBuf, cbToWrite, &cbWritten); 409 397 #ifdef DEBUG 410 VGSvcVerbose(4, "[File %s] :Writing pvScratchBuf=%p, cbToWrite=%RU32, cbWritten=%zu, rc=%Rrc\n",398 VGSvcVerbose(4, "[File %s] Writing pvScratchBuf=%p, cbToWrite=%RU32, cbWritten=%zu, rc=%Rrc\n", 411 399 pFile->szName, pvScratchBuf, cbToWrite, cbWritten, rc); 412 400 #endif … … 423 411 } 424 412 425 #ifdef DEBUG426 VGSvcVerbose(4, "Writing file '%s' (handle=%RU32) returned rc=%Rrc\n", pFile ? pFile->szName : "<Not found>", uHandle, rc);427 #endif428 413 return rc; 429 414 } … … 438 423 AssertPtrReturn(cbScratchBuf, VERR_INVALID_PARAMETER); 439 424 440 PVBOXSERVICECTRLFILE pFile = NULL;441 442 425 uint32_t uHandle = 0; 443 426 uint32_t cbToWrite; … … 448 431 { 449 432 size_t cbWritten = 0; 450 pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);433 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle); 451 434 if (pFile) 452 435 { 453 436 rc = RTFileWriteAt(pFile->hFile, (RTFOFF)offWriteAt, pvScratchBuf, cbToWrite, &cbWritten); 454 437 #ifdef DEBUG 455 VGSvcVerbose(4, "[File %s] :Writing offWriteAt=%RI64, pvScratchBuf=%p, cbToWrite=%RU32, cbWritten=%zu, rc=%Rrc\n",438 VGSvcVerbose(4, "[File %s] Writing offWriteAt=%RI64, pvScratchBuf=%p, cbToWrite=%RU32, cbWritten=%zu, rc=%Rrc\n", 456 439 pFile->szName, offWriteAt, pvScratchBuf, cbToWrite, cbWritten, rc); 457 440 #endif … … 468 451 } 469 452 470 #ifdef DEBUG471 VGSvcVerbose(4, "Writing file '%s' at offset (handle=%RU32) returned rc=%Rrc\n",472 pFile ? pFile->szName : "<Not found>", uHandle, rc);473 #endif474 453 return rc; 475 454 } … … 480 459 AssertPtrReturn(pSession, VERR_INVALID_POINTER); 481 460 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 482 483 PVBOXSERVICECTRLFILE pFile = NULL;484 461 485 462 uint32_t uHandle = 0; … … 490 467 { 491 468 uint64_t offActual = 0; 492 pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);469 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle); 493 470 if (pFile) 494 471 { … … 534 511 } 535 512 536 #ifdef DEBUG537 VGSvcVerbose(4, "Seeking file '%s' (handle=%RU32) returned rc=%Rrc\n", pFile ? pFile->szName : "<Not found>", uHandle, rc);538 #endif539 513 return rc; 540 514 } … … 546 520 AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER); 547 521 548 PVBOXSERVICECTRLFILE pFile = NULL;549 550 522 uint32_t uHandle = 0; 551 523 int rc = VbglR3GuestCtrlFileGetTell(pHostCtx, &uHandle); 552 524 if (RT_SUCCESS(rc)) 553 525 { 554 uint64_t off= 0;555 pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);526 uint64_t uOffCurrent = 0; 527 PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle); 556 528 if (pFile) 557 529 { 558 off= RTFileTell(pFile->hFile);530 uOffCurrent = RTFileTell(pFile->hFile); 559 531 #ifdef DEBUG 560 VGSvcVerbose(4, "[File %s]: Telling off=%RU64\n", pFile->szName, off);532 VGSvcVerbose(4, "[File %s]: Telling uOffCurrent=%RU64\n", pFile->szName, uOffCurrent); 561 533 #endif 562 534 } … … 565 537 566 538 /* Report back in any case. */ 567 int rc2 = VbglR3GuestCtrlFileCbTell(pHostCtx, rc, off);539 int rc2 = VbglR3GuestCtrlFileCbTell(pHostCtx, rc, uOffCurrent); 568 540 if (RT_FAILURE(rc2)) 569 541 VGSvcError("Failed to report file tell status, rc=%Rrc\n", rc2); … … 572 544 } 573 545 574 #ifdef DEBUG575 VGSvcVerbose(4, "Telling file '%s' (handle=%RU32) returned rc=%Rrc\n", pFile ? pFile->szName : "<Not found>", uHandle, rc);576 #endif577 546 return rc; 578 547 }
Note:
See TracChangeset
for help on using the changeset viewer.