Changeset 35058 in vbox for trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp
- Timestamp:
- Dec 14, 2010 10:07:31 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 68889
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp
r35055 r35058 66 66 /** The semaphore we're blocking on. */ 67 67 static RTSEMEVENTMULTI g_AutoMountEvent = NIL_RTSEMEVENTMULTI; 68 68 /** The guest property service client ID. */ 69 static uint32_t g_SharedFoldersSvcClientID = 0; 69 70 70 71 /** @copydoc VBOXSERVICE::pfnPreInit */ … … 93 94 int rc = RTSemEventMultiCreate(&g_AutoMountEvent); 94 95 AssertRCReturn(rc, rc); 96 97 rc = VbglR3SharedFolderConnect(&g_SharedFoldersSvcClientID); 98 if (RT_SUCCESS(rc)) 99 { 100 VBoxServiceVerbose(3, "VBoxServiceAutoMountInit: Service Client ID: %#x\n", g_SharedFoldersSvcClientID); 101 } 102 else 103 { 104 /* If the service was not found, we disable this service without 105 causing VBoxService to fail. */ 106 if (rc == VERR_HGCM_SERVICE_NOT_FOUND) /* Host service is not available. */ 107 { 108 VBoxServiceVerbose(0, "VBoxServiceAutoMountInit: Shared Folders service is not available\n"); 109 rc = VERR_SERVICE_DISABLED; 110 } 111 else 112 VBoxServiceError("Control: Failed to connect to the Shared Folders service! Error: %Rrc\n", rc); 113 RTSemEventMultiDestroy(g_AutoMountEvent); 114 g_AutoMountEvent = NIL_RTSEMEVENTMULTI; 115 } 95 116 96 117 return rc; … … 196 217 if (rc == VERR_WRITE_PROTECT) 197 218 { 198 VBoxService Error("VBoxServiceAutoMountPrepareMountPoint: Mount directory \"%s\" already is used/mounted\n", pszMountPoint);219 VBoxServiceVerbose(3, "VBoxServiceAutoMountPrepareMountPoint: Mount directory \"%s\" already is used/mounted\n", pszMountPoint); 199 220 rc = VINF_SUCCESS; 200 221 } … … 459 480 RTThreadUserSignal(RTThreadSelf()); 460 481 461 uint32_t u32ClientId; 462 int rc = VbglR3SharedFolderConnect(&u32ClientId); 463 if (!RT_SUCCESS(rc)) 464 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Failed to connect to the shared folder service, error %Rrc\n", rc); 482 uint32_t cMappings; 483 PVBGLR3SHAREDFOLDERMAPPING paMappings; 484 int rc = VbglR3SharedFolderGetMappings(g_SharedFoldersSvcClientID, true /* Only process auto-mounted folders */, 485 &paMappings, &cMappings); 486 if ( RT_SUCCESS(rc) 487 && cMappings) 488 { 489 char *pszMountDir; 490 rc = VbglR3SharedFolderGetMountDir(&pszMountDir); 491 if (rc == VERR_NOT_FOUND) 492 rc = RTStrDupEx(&pszMountDir, VBOXSERVICE_AUTOMOUNT_DEFAULT_DIR); 493 if (RT_SUCCESS(rc)) 494 { 495 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Shared folder mount dir set to \"%s\"\n", pszMountDir); 496 497 char *pszSharePrefix; 498 rc = VbglR3SharedFolderGetMountPrefix(&pszSharePrefix); 499 if (RT_SUCCESS(rc)) 500 { 501 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Shared folder mount prefix set to \"%s\"\n", pszSharePrefix); 502 #ifdef USE_VIRTUAL_SHARES 503 /* Check for a fixed/virtual auto-mount share. */ 504 if (VbglR3SharedFolderExists(g_SharedFoldersSvcClientID, "vbsfAutoMount")) 505 { 506 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Host supports auto-mount root\n"); 507 } 508 else 509 { 510 #endif 511 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Got %u shared folder mappings\n", cMappings); 512 rc = VBoxServiceAutoMountProcessMappings(paMappings, cMappings, pszMountDir, pszSharePrefix, g_SharedFoldersSvcClientID); 513 #ifdef USE_VIRTUAL_SHARES 514 } 515 #endif 516 RTStrFree(pszSharePrefix); 517 } /* Mount share prefix. */ 518 else 519 VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder mount prefix, rc = %Rrc\n", rc); 520 RTStrFree(pszMountDir); 521 } 522 else 523 VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder directory, rc = %Rrc\n", rc); 524 VbglR3SharedFolderFreeMappings(paMappings); 525 } 465 526 else 466 527 { 467 uint32_t cMappings; 468 PVBGLR3SHAREDFOLDERMAPPING paMappings; 469 470 rc = VbglR3SharedFolderGetMappings(u32ClientId, true /* Only process auto-mounted folders */, 471 &paMappings, &cMappings); 472 if ( RT_SUCCESS(rc) 473 && cMappings) 474 { 475 char *pszMountDir; 476 rc = VbglR3SharedFolderGetMountDir(&pszMountDir); 477 if (rc == VERR_NOT_FOUND) 478 rc = RTStrDupEx(&pszMountDir, VBOXSERVICE_AUTOMOUNT_DEFAULT_DIR); 479 if (RT_SUCCESS(rc)) 480 { 481 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Shared folder mount dir set to \"%s\"\n", pszMountDir); 482 483 char *pszSharePrefix; 484 rc = VbglR3SharedFolderGetMountPrefix(&pszSharePrefix); 485 if (RT_SUCCESS(rc)) 486 { 487 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Shared folder mount prefix set to \"%s\"\n", pszSharePrefix); 488 #if 0 489 /* Check for a fixed/virtual auto-mount share. */ 490 if (VbglR3SharedFolderExists(u32ClientId, "vbsfAutoMount")) 491 { 492 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Host supports auto-mount root\n"); 493 } 494 else 495 { 496 #endif 497 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Got %u shared folder mappings\n", cMappings); 498 rc = VBoxServiceAutoMountProcessMappings(paMappings, cMappings, pszMountDir, pszSharePrefix, u32ClientId); 499 #if 0 500 } 501 #endif 502 RTStrFree(pszSharePrefix); 503 } /* Mount share prefix. */ 504 else 505 VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder mount prefix, rc = %Rrc\n", rc); 506 RTStrFree(pszMountDir); 507 } 508 else 509 VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder directory, rc = %Rrc\n", rc); 510 RTMemFree(paMappings); 511 } 512 else 513 { 514 if (RT_FAILURE(rc)) 515 VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder mappings, rc = %Rrc\n", rc); 516 else if (!cMappings) 517 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: No shared folder mappings fouund\n"); 518 } 519 VbglR3SharedFolderDisconnect(u32ClientId); 528 if (RT_FAILURE(rc)) 529 VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder mappings, rc = %Rrc\n", rc); 530 else if (!cMappings) 531 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: No shared folder mappings fouund\n"); 520 532 } 521 533 … … 531 543 { 532 544 VBoxServiceVerbose(3, "VBoxServiceAutoMountTerm\n"); 545 546 VbglR3SharedFolderDisconnect(g_SharedFoldersSvcClientID); 547 g_SharedFoldersSvcClientID = 0; 548 549 if (g_AutoMountEvent != NIL_RTSEMEVENTMULTI) 550 { 551 RTSemEventMultiDestroy(g_AutoMountEvent); 552 g_AutoMountEvent = NIL_RTSEMEVENTMULTI; 553 } 533 554 return; 534 555 } … … 538 559 static DECLCALLBACK(void) VBoxServiceAutoMountStop(void) 539 560 { 540 RTSemEventMultiSignal(g_AutoMountEvent); 561 /* 562 * We need this check because at the moment our auto-mount 563 * thread really is a one-timer which destroys the event itself 564 * after running. 565 */ 566 if (g_AutoMountEvent != NIL_RTSEMEVENTMULTI) 567 RTSemEventMultiSignal(g_AutoMountEvent); 541 568 } 542 569
Note:
See TracChangeset
for help on using the changeset viewer.