Changeset 35016 in vbox
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxGuestLib.h
r33247 r35016 538 538 VBGLR3DECL(int) VbglR3SharedFolderGetName(uint32_t u32ClientId,uint32_t u32Root, char **ppszName); 539 539 VBGLR3DECL(int) VbglR3SharedFolderGetMountPrefix(char **ppszPrefix); 540 VBGLR3DECL(int) VbglR3SharedFolderGetMountDir(char **ppszDir); 540 541 /** @} */ 541 542 # endif /* VBOX_WITH_SHARED_FOLDERS defined */ -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibSharedFolders.cpp
r33540 r35016 288 288 return rc; 289 289 } 290 291 /** 292 * Retrieves the mount root directory for auto-mounted shared 293 * folders. mount point. If no string is set (VERR_NOT_FOUND) 294 * it's up on the caller (guest) to decide where to mount. 295 * 296 * @returns VBox status code. 297 * @param ppszDir Where to return the directory 298 * string. This shall be freed by 299 * calling RTStrFree. 300 */ 301 VBGLR3DECL(int) VbglR3SharedFolderGetMountDir(char **ppszDir) 302 { 303 AssertPtrReturn(ppszDir, VERR_INVALID_POINTER); 304 int rc; 305 #ifdef VBOX_WITH_GUEST_PROPS 306 uint32_t u32ClientIdGuestProp; 307 rc = VbglR3GuestPropConnect(&u32ClientIdGuestProp); 308 if (RT_SUCCESS(rc)) 309 { 310 rc = VbglR3GuestPropReadValueAlloc(u32ClientIdGuestProp, "/VirtualBox/GuestAdd/SharedFolders/MountDir", ppszDir); 311 VbglR3GuestPropDisconnect(u32ClientIdGuestProp); 312 } 313 #endif 314 return rc; 315 } 316 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp
r35010 r35016 48 48 49 49 #ifdef RT_OS_SOLARIS 50 # define AUTO_MOUNT_POINT "/mnt/%s%s"50 # define VBOXSERVICE_AUTOMOUNT_DEFAULT_DIR "/mnt" 51 51 #else 52 # define AUTO_MOUNT_POINT "/media/%s%s"52 # define VBOXSERVICE_AUTOMOUNT_DEFAULT_DIR "/media" 53 53 #endif 54 54 55 55 #ifndef _PATH_MOUNTED 56 56 #ifdef RT_OS_SOLARIS 57 #define _PATH_MOUNTED "/etc/mnttab"57 #define _PATH_MOUNTED "/etc/mnttab" 58 58 #else 59 #define _PATH_MOUNTED "/etc/mtab"59 #define _PATH_MOUNTED "/etc/mtab" 60 60 #endif 61 61 #endif … … 190 190 rc = RTPathSetMode(pszMountPoint, fMode); 191 191 if (RT_FAILURE(rc)) 192 VBoxServiceError(" : Could not set mode %RTfmode for mount directory \"%s\", rc = %Rrc\n",192 VBoxServiceError("VBoxServiceAutoMountPrepareMountPoint: Could not set mode %RTfmode for mount directory \"%s\", rc = %Rrc\n", 193 193 fMode, pszMountPoint, rc); 194 194 } … … 368 368 } 369 369 370 static int VBoxServiceAutoMountProcessMappings(PVBGLR3SHAREDFOLDERMAPPING paMappings, uint32_t cMappings, 371 const char *pszMountDir, const char *pszSharePrefix, uint32_t uClientID) 372 { 373 if (cMappings == 0) 374 return VINF_SUCCESS; 375 AssertPtrReturn(paMappings, VERR_INVALID_PARAMETER); 376 AssertPtrReturn(pszMountDir, VERR_INVALID_PARAMETER); 377 AssertPtrReturn(pszSharePrefix, VERR_INVALID_PARAMETER); 378 AssertPtrReturn(*pszSharePrefix, VERR_INVALID_PARAMETER); 379 AssertReturn(uClientID > 0, VERR_INVALID_PARAMETER); 380 381 int rc = VINF_SUCCESS; 382 for (uint32_t i = 0; i < cMappings && RT_SUCCESS(rc); i++) 383 { 384 char *pszShareName = NULL; 385 rc = VbglR3SharedFolderGetName(uClientID, paMappings[i].u32Root, &pszShareName); 386 if ( RT_SUCCESS(rc) 387 && *pszShareName) 388 { 389 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Connecting share %u (%s) ...\n", i+1, pszShareName); 390 391 char *pszShareNameFull = NULL; 392 if (RTStrAPrintf(&pszShareNameFull, "%s%s", pszSharePrefix, pszShareName) > 0) 393 { 394 char szMountPoint[RTPATH_MAX]; 395 rc = RTPathJoin(szMountPoint, sizeof(szMountPoint), pszMountDir, pszShareNameFull); 396 if (RT_SUCCESS(rc)) 397 { 398 VBoxServiceVerbose(4, "VBoxServiceAutoMountWorker: Processing mount point \"%s\"\n", szMountPoint); 399 400 struct group *grp_vboxsf = getgrnam("vboxsf"); 401 if (grp_vboxsf) 402 { 403 struct vbsf_mount_opts mount_opts = 404 { 405 0, /* uid */ 406 grp_vboxsf->gr_gid, /* gid */ 407 0, /* ttl */ 408 0770, /* dmode, owner and group "vboxsf" have full access */ 409 0770, /* fmode, owner and group "vboxsf" have full access */ 410 0, /* dmask */ 411 0, /* fmask */ 412 0, /* ronly */ 413 0, /* noexec */ 414 0, /* nodev */ 415 0, /* nosuid */ 416 0, /* remount */ 417 "\0", /* nls_name */ 418 NULL, /* convertcp */ 419 }; 420 421 /* We always use "/media" as our root mounting directory. */ 422 /** @todo Detect the correct "media/mnt" directory, based on the current guest (?). */ 423 rc = VBoxServiceAutoMountSharedFolder(pszShareName, szMountPoint, &mount_opts); 424 } 425 else 426 VBoxServiceError("VBoxServiceAutoMountWorker: Group \"vboxsf\" does not exist\n"); 427 } 428 else 429 VBoxServiceError("VBoxServiceAutoMountWorker: Unable to join mount point/prefix/shrae, rc = %Rrc\n", rc); 430 RTStrFree(pszShareNameFull); 431 } 432 else 433 VBoxServiceError("VBoxServiceAutoMountWorker: Unable to allocate full share name\n"); 434 RTStrFree(pszShareName); 435 } 436 else 437 VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder name for root node = %u, rc = %Rrc\n", 438 paMappings[i].u32Root, rc); 439 } /* for cMappings. */ 440 return rc; 441 } 442 370 443 371 444 /** @copydoc VBOXSERVICE::pfnWorker */ … … 385 458 { 386 459 uint32_t cMappings; 387 VBGLR3SHAREDFOLDERMAPPING *paMappings;460 PVBGLR3SHAREDFOLDERMAPPING paMappings; 388 461 389 462 rc = VbglR3SharedFolderGetMappings(u32ClientId, true /* Only process auto-mounted folders */, … … 391 464 if (RT_SUCCESS(rc)) 392 465 { 393 char *pszSharePrefix; 394 rc = VbglR3SharedFolderGetMountPrefix(&pszSharePrefix); 466 char *pszMountDir; 467 rc = VbglR3SharedFolderGetMountDir(&pszMountDir); 468 if (rc == VERR_NOT_FOUND) 469 rc = RTStrDupEx(&pszMountDir, VBOXSERVICE_AUTOMOUNT_DEFAULT_DIR); 395 470 if (RT_SUCCESS(rc)) 396 471 { 397 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Shared folder mount prefix set to \"%s\"\n", pszSharePrefix); 398 #if 0 399 /* Check for a fixed/virtual auto-mount share. */ 400 if (VbglR3SharedFolderExists(u32ClientId, "vbsfAutoMount")) 472 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Shared folder mount dir set to \"%s\"\n", pszMountDir); 473 474 char *pszSharePrefix; 475 rc = VbglR3SharedFolderGetMountPrefix(&pszSharePrefix); 476 401 477 { 402 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Host supports auto-mount root\n");403 478 } 479 if (RT_SUCCESS(rc)) 480 { 481 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Shared folder mount prefix set to \"%s\"\n", pszSharePrefix); 482 #if 0 483 /* Check for a fixed/virtual auto-mount share. */ 484 if (VbglR3SharedFolderExists(u32ClientId, "vbsfAutoMount")) 485 { 486 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Host supports auto-mount root\n"); 487 } 488 else 489 { 490 #endif 491 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Got %u shared folder mappings\n", cMappings); 492 rc = VBoxServiceAutoMountProcessMappings(paMappings, cMappings, pszMountDir, pszSharePrefix, u32ClientId); 493 #if 0 494 } 495 #endif 496 RTStrFree(pszSharePrefix); 497 } /* Mount share prefix. */ 404 498 else 405 { 406 #endif 407 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Got %u shared folder mappings\n", cMappings); 408 for (uint32_t i = 0; i < cMappings && RT_SUCCESS(rc); i++) 409 { 410 char *pszShareName = NULL; 411 rc = VbglR3SharedFolderGetName(u32ClientId, paMappings[i].u32Root, &pszShareName); 412 if ( RT_SUCCESS(rc) 413 && *pszShareName) 414 { 415 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Connecting share %u (%s) ...\n", i+1, pszShareName); 416 417 char *pszMountPoint = NULL; 418 if ( RTStrAPrintf(&pszMountPoint, AUTO_MOUNT_POINT, pszSharePrefix, pszShareName) > 0 419 && pszMountPoint) 420 { 421 struct group *grp_vboxsf = getgrnam("vboxsf"); 422 if (grp_vboxsf) 423 { 424 struct vbsf_mount_opts mount_opts = 425 { 426 0, /* uid */ 427 grp_vboxsf->gr_gid, /* gid */ 428 0, /* ttl */ 429 0770, /* dmode, owner and group "vboxsf" have full access */ 430 0770, /* fmode, owner and group "vboxsf" have full access */ 431 0, /* dmask */ 432 0, /* fmask */ 433 0, /* ronly */ 434 0, /* noexec */ 435 0, /* nodev */ 436 0, /* nosuid */ 437 0, /* remount */ 438 "\0", /* nls_name */ 439 NULL, /* convertcp */ 440 }; 441 442 /* We always use "/media" as our root mounting directory. */ 443 /** @todo Detect the correct "media/mnt" directory, based on the current guest (?). */ 444 rc = VBoxServiceAutoMountSharedFolder(pszShareName, pszMountPoint, &mount_opts); 445 } 446 else 447 VBoxServiceError("VBoxServiceAutoMountWorker: Group \"vboxsf\" does not exist\n"); 448 RTStrFree(pszMountPoint); 449 } 450 else 451 rc = VERR_NO_MEMORY; 452 RTStrFree(pszShareName); 453 } 454 else 455 VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder name for root node = %u, rc = %Rrc\n", 456 paMappings[i].u32Root, rc); 457 } /* for cMappings. */ 458 #if 0 459 } 460 #endif 461 RTStrFree(pszSharePrefix); 462 } /* Mount prefix. */ 499 VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder mount prefix, rc = %Rrc\n", rc); 500 RTStrFree(pszMountDir); 501 } 463 502 else 464 VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder mount prefix, rc = %Rrc\n", rc);503 VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder directory, rc = %Rrc\n", rc); 465 504 RTMemFree(paMappings); 466 505 }
Note:
See TracChangeset
for help on using the changeset viewer.