Changeset 31355 in vbox for trunk/src/VBox
- Timestamp:
- Aug 4, 2010 12:37:50 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 64403
- Location:
- trunk/src/VBox/Additions/common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibSharedFolders.cpp
r31130 r31355 259 259 } 260 260 261 /** 262 * Retrieves the prefix for a shared folder mount point. If no prefix 263 * is set in the guest properties "sf_" is returned. 264 * 265 * @returns VBox status code. 266 * @param ppszPrefix Where to return the prefix string. This shall be 267 * freed by calling RTStrFree. 268 */ 269 VBGLR3DECL(int) VbglR3SharedFolderGetMountPrefix(char **ppszPrefix) 270 { 271 AssertPtrReturn(ppszPrefix, VERR_INVALID_POINTER); 272 273 uint32_t u32ClientIdGuestProp; 274 int rc = VbglR3GuestPropConnect(&u32ClientIdGuestProp); 275 if (RT_SUCCESS(rc)) 276 { 277 rc = VbglR3GuestPropReadValueAlloc(u32ClientIdGuestProp, "/VirtualBox/GuestAdd/SharedFolders/MountPrefix", ppszPrefix); 278 if (rc == VERR_NOT_FOUND) /* No prefix set? Then set the default. */ 279 { 280 if (RTStrAPrintf(ppszPrefix, "sf_")) 281 rc = VINF_SUCCESS; 282 } 283 VbglR3GuestPropDisconnect(u32ClientIdGuestProp); 284 } 285 return rc; 286 } -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp
r31317 r31355 258 258 if (RT_SUCCESS(rc)) 259 259 { 260 char *pszSharePrefix; 261 rc = VbglR3SharedFolderGetMountPrefix(&pszSharePrefix); 262 if (RT_SUCCESS(rc)) 263 { 264 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Shared folder mount prefix set to \"%s\"\n", pszSharePrefix); 260 265 #if 0 261 /* Check for a fixed/virtual auto-mount share. */262 if (VbglR3SharedFolderExists(u32ClientId, "vbsfAutoMount"))263 {264 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Host supports auto-mount root\n");265 }266 else267 {266 /* Check for a fixed/virtual auto-mount share. */ 267 if (VbglR3SharedFolderExists(u32ClientId, "vbsfAutoMount")) 268 { 269 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Host supports auto-mount root\n"); 270 } 271 else 272 { 268 273 #endif 269 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Got %u shared folder mappings\n", cMappings); 270 for (uint32_t i = 0; i < cMappings && RT_SUCCESS(rc); i++) 271 { 272 char *pszShareName = NULL; 273 rc = VbglR3SharedFolderGetName(u32ClientId, paMappings[i].u32Root, &pszShareName); 274 if ( RT_SUCCESS(rc) 275 && *pszShareName) 274 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Got %u shared folder mappings\n", cMappings); 275 for (uint32_t i = 0; i < cMappings && RT_SUCCESS(rc); i++) 276 276 { 277 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Connecting share %u (%s) ...\n", i+1, pszShareName); 278 279 char *pszMountPoint = NULL; 280 #ifdef RT_OS_SOLARIS 281 if ( RTStrAPrintf(&pszMountPoint, "/mnt/sf_%s", pszShareName) > 0 282 #else 283 if ( RTStrAPrintf(&pszMountPoint, "/media/sf_%s", pszShareName) > 0 284 #endif 285 && pszMountPoint) 277 char *pszShareName = NULL; 278 rc = VbglR3SharedFolderGetName(u32ClientId, paMappings[i].u32Root, &pszShareName); 279 if ( RT_SUCCESS(rc) 280 && *pszShareName) 286 281 { 287 struct group *grp_vboxsf = getgrnam("vboxsf"); 288 if (grp_vboxsf) 282 VBoxServiceVerbose(3, "VBoxServiceAutoMountWorker: Connecting share %u (%s) ...\n", i+1, pszShareName); 283 284 char *pszMountPoint = NULL; 285 #ifdef RT_OS_SOLARIS 286 if ( RTStrAPrintf(&pszMountPoint, "/mnt/%s%s", pszSharePrefix, pszShareName) > 0 287 #else 288 if ( RTStrAPrintf(&pszMountPoint, "/media/%s%s", pszSharePrefix, pszShareName) > 0 289 #endif 290 && pszMountPoint) 289 291 { 290 struct vbsf_mount_opts mount_opts = 292 struct group *grp_vboxsf = getgrnam("vboxsf"); 293 if (grp_vboxsf) 291 294 { 292 0, /* uid */ 293 grp_vboxsf->gr_gid, /* gid */ 294 0, /* ttl */ 295 0770, /* dmode, owner and group "vboxsf" have full access */ 296 0770, /* fmode, owner and group "vboxsf" have full access */ 297 0, /* dmask */ 298 0, /* fmask */ 299 0, /* ronly */ 300 0, /* noexec */ 301 0, /* nodev */ 302 0, /* nosuid */ 303 0, /* remount */ 304 "\0", /* nls_name */ 305 NULL, /* convertcp */ 306 }; 307 308 /* We always use "/media" as our root mounting directory. */ 309 /** @todo Detect the correct "media/mnt" directory, based on the current guest (?). */ 310 rc = VBoxServiceAutoMountSharedFolder(pszShareName, pszMountPoint, &mount_opts); 295 struct vbsf_mount_opts mount_opts = 296 { 297 0, /* uid */ 298 grp_vboxsf->gr_gid, /* gid */ 299 0, /* ttl */ 300 0770, /* dmode, owner and group "vboxsf" have full access */ 301 0770, /* fmode, owner and group "vboxsf" have full access */ 302 0, /* dmask */ 303 0, /* fmask */ 304 0, /* ronly */ 305 0, /* noexec */ 306 0, /* nodev */ 307 0, /* nosuid */ 308 0, /* remount */ 309 "\0", /* nls_name */ 310 NULL, /* convertcp */ 311 }; 312 313 /* We always use "/media" as our root mounting directory. */ 314 /** @todo Detect the correct "media/mnt" directory, based on the current guest (?). */ 315 rc = VBoxServiceAutoMountSharedFolder(pszShareName, pszMountPoint, &mount_opts); 316 } 317 else 318 VBoxServiceError("VBoxServiceAutoMountWorker: Group \"vboxsf\" does not exist\n"); 319 RTStrFree(pszMountPoint); 311 320 } 312 321 else 313 VBoxServiceError("VBoxServiceAutoMountWorker: Group \"vboxsf\" does not exist\n");314 RTStrFree(psz MountPoint);322 rc = VERR_NO_MEMORY; 323 RTStrFree(pszShareName); 315 324 } 316 325 else 317 rc = VERR_NO_MEMORY; 318 RTStrFree(pszShareName); 319 } 320 else 321 VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder name for root node = %u, rc = %Rrc\n", 322 paMappings[i].u32Root, rc); 326 VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder name for root node = %u, rc = %Rrc\n", 327 paMappings[i].u32Root, rc); 328 } /* for cMappings. */ 329 #if 0 323 330 } 324 #if 0 325 } 326 #endif 331 #endif 332 RTStrFree(pszSharePrefix); 333 } /* Mount prefix. */ 334 else 335 VBoxServiceError("VBoxServiceAutoMountWorker: Error while getting the shared folder mount prefix, rc = %Rrc\n", rc); 327 336 RTMemFree(paMappings); 328 337 }
Note:
See TracChangeset
for help on using the changeset viewer.