Changeset 31052 in vbox
- Timestamp:
- Jul 23, 2010 12:10:41 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
include/VBox/VBoxGuestLib.h (modified) (1 diff)
-
include/VBox/shflsvc.h (modified) (1 diff)
-
src/VBox/Additions/WINNT/VBoxTray/VBoxSharedFolders.cpp (modified) (2 diffs)
-
src/VBox/Additions/common/VBoxControl/VBoxControl.cpp (modified) (2 diffs)
-
src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibSharedFolders.cpp (modified) (3 diffs)
-
src/VBox/HostServices/SharedFolders/mappings.cpp (modified) (12 diffs)
-
src/VBox/HostServices/SharedFolders/mappings.h (modified) (2 diffs)
-
src/VBox/HostServices/SharedFolders/service.cpp (modified) (2 diffs)
-
src/VBox/HostServices/SharedFolders/shfl.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxGuestLib.h
r31025 r31052 527 527 VBGLR3DECL(int) VbglR3SharedFolderDisconnect(uint32_t u32ClientId); 528 528 VBGLR3DECL(int) VbglR3SharedFolderGetMappings(uint32_t u32ClientId, bool fAutoMountOnly, 529 PVBGLR3SHAREDFOLDERMAPPING paMappings, uint32_t cbMappings,530 uint32_t *pcMappings);529 PVBGLR3SHAREDFOLDERMAPPING *ppaMappings, uint32_t *pcMappings); 530 VBGLR3DECL(void) VbglR3SharedFolderFreeMappings(PVBGLR3SHAREDFOLDERMAPPING paMappings); 531 531 VBGLR3DECL(int) VbglR3SharedFolderGetName(uint32_t u32ClientId,uint32_t u32Root, char **ppszName); 532 532 /** @} */ -
trunk/include/VBox/shflsvc.h
r31002 r31052 379 379 SHFLROOT root; 380 380 } SHFLMAPPING; 381 381 /** Pointer to a SHFLMAPPING structure. */ 382 382 typedef SHFLMAPPING *PSHFLMAPPING; 383 383 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxSharedFolders.cpp
r31027 r31052 25 25 int VBoxSharedFoldersAutoMount(void) 26 26 { 27 #if 0 27 28 uint32_t u32ClientId; 28 29 int rc = VbglR3SharedFolderConnect(&u32ClientId); … … 97 98 } 98 99 return rc; 100 #endif 101 return 0; 99 102 } 100 103 -
trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp
r31041 r31052 1274 1274 bool usageOK = true; 1275 1275 bool fOnlyShowAutoMount = false; 1276 if ( argc == 1 1277 && ( RTStrICmp(argv[0], "-automount") == 0 1276 if (argc == 1) 1277 { 1278 if ( RTStrICmp(argv[0], "-automount") == 0 1278 1279 || RTStrICmp(argv[0], "/automount") == 0) 1279 ) 1280 { 1281 fOnlyShowAutoMount = true; 1280 { 1281 fOnlyShowAutoMount = true; 1282 } 1283 else 1284 usageOK = false; 1282 1285 } 1283 1286 else if (argc > 1) … … 1296 1299 else 1297 1300 { 1298 uint32_t cMappings = 64; /* See shflsvc.h for define; should be used later. */ 1299 uint32_t cbMappings = cMappings * sizeof(VBGLR3SHAREDFOLDERMAPPING); 1300 VBGLR3SHAREDFOLDERMAPPING *paMappings = (PVBGLR3SHAREDFOLDERMAPPING)RTMemAlloc(cbMappings); 1301 1302 if (paMappings) 1303 { 1304 rc = VbglR3SharedFolderGetMappings(u32ClientId, fOnlyShowAutoMount, 1305 paMappings, cbMappings, 1306 &cMappings); 1307 if (RT_SUCCESS(rc)) 1301 PVBGLR3SHAREDFOLDERMAPPING paMappings; 1302 uint32_t cMappings; 1303 rc = VbglR3SharedFolderGetMappings(u32ClientId, fOnlyShowAutoMount, 1304 &paMappings, &cMappings); 1305 if (RT_SUCCESS(rc)) 1306 { 1307 if (fOnlyShowAutoMount) 1308 RTPrintf("Auto-mounted Shared Folder mappings (%u):\n\n", cMappings); 1309 else 1310 RTPrintf("Shared Folder mappings (%u):\n\n", cMappings); 1311 1312 for (uint32_t i = 0; i < cMappings; i++) 1308 1313 { 1309 /* Maximum mappings, see shflsvc.h */ 1310 if (cMappings > 64) 1311 cMappings = 64; 1312 RTPrintf("Shared Folder Mappings (%u):\n\n", cMappings); 1313 for (uint32_t i = 0; i < cMappings; i++) 1314 char *pszName; 1315 rc = VbglR3SharedFolderGetName(u32ClientId, paMappings[i].u32Root, &pszName); 1316 if (RT_SUCCESS(rc)) 1314 1317 { 1315 char *pszName; 1316 rc = VbglR3SharedFolderGetName(u32ClientId, paMappings[i].u32Root, &pszName); 1317 if (RT_SUCCESS(rc)) 1318 { 1319 RTPrintf("%02u - %s\n", i + 1, pszName); 1320 RTStrFree(pszName); 1321 } 1322 else 1323 VBoxControlError("Error while getting the shared folder name for root node = %u, rc = %Rrc\n", 1324 paMappings[i].u32Root, rc); 1318 RTPrintf("%02u - %s\n", i + 1, pszName); 1319 RTStrFree(pszName); 1325 1320 } 1326 if (cMappings == 0) 1327 RTPrintf("No Shared Folders available.\n"); 1321 else 1322 VBoxControlError("Error while getting the shared folder name for root node = %u, rc = %Rrc\n", 1323 paMappings[i].u32Root, rc); 1328 1324 } 1329 else1330 VBoxControlError("Error while getting the shared folder mappings, rc = %Rrc\n", rc);1331 RTMemFree(paMappings);1325 if (cMappings == 0) 1326 RTPrintf("No Shared Folders available.\n"); 1327 VbglR3SharedFolderFreeMappings(paMappings); 1332 1328 } 1333 1329 else 1334 rc = VERR_NO_MEMORY;1330 VBoxControlError("Error while getting the shared folder mappings, rc = %Rrc\n", rc); 1335 1331 VbglR3SharedFolderDisconnect(u32ClientId); 1336 1332 } -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibSharedFolders.cpp
r31025 r31052 90 90 * 91 91 * @returns VBox status code. 92 * @param u32ClientId The client id returned by VbglR3 InvsSvcConnect().92 * @param u32ClientId The client id returned by VbglR3SharedFolderConnect(). 93 93 * @param fAutoMountOnly Flag whether only auto-mounted shared folders 94 94 * should be reported. 95 * @param paMappings Pointer to a preallocated array which will retrieve the mapping info. 96 * @param cbMappings Size (in bytes) of the provided array. 97 * @param pcMappings On input, the size of @a paMappings gives as an 98 * item count. On output, the number of mappings 99 * returned in @a paMappings. 100 * 101 * @todo r=bird: cbMappings and @a *pcMappings overlap. The better API 102 * would be to change cbMappings to cMappings (the entries are fixed 103 * sized) and move the move the input aspect of @a *pcMappings to it. 104 * 105 * However, it would be better if this function would do the array 106 * allocation. This way you could deal with too-much-data conditions 107 * here (or hide the max-number-of-shared-folders-per-vm-define). 108 * Then paMappings would become ppaMappings and cbMappings could be 109 * removed altogether. *pcMappings would only be output. A 110 * corresponding VbglR3SharedFolderFreeMappings would be required for 111 * a 100% clean API (this is an (/going to be) offical API for C/C++ 112 * programs). 95 * @param ppaMappings Allocated array which will retrieve the mapping info. Needs 96 * to be freed with VbglR3SharedFolderFreeMappings() later. 97 * @param pcMappings The number of mappings returned in @a ppaMappings. 113 98 */ 114 99 VBGLR3DECL(int) VbglR3SharedFolderGetMappings(uint32_t u32ClientId, bool fAutoMountOnly, 115 PVBGLR3SHAREDFOLDERMAPPING paMappings, uint32_t cbMappings, 116 uint32_t *pcMappings) 100 PVBGLR3SHAREDFOLDERMAPPING *ppaMappings, uint32_t *pcMappings) 117 101 { 118 102 AssertPtr(pcMappings); … … 131 115 VbglHGCMParmUInt32Set(&Msg.flags, u32Flags); 132 116 133 /* Init the rest of the message. */ 134 VbglHGCMParmUInt32Set(&Msg.numberOfMappings, *pcMappings); 135 VbglHGCMParmPtrSet(&Msg.mappings, &paMappings[0], cbMappings); 136 137 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 138 if (RT_SUCCESS(rc)) 117 /* 118 * Prepare and get the actual mappings from the host service. 119 */ 120 int rc = VINF_SUCCESS; 121 uint32_t cMappings = 8; /* Should be a good default value. */ 122 uint32_t cbSize = cMappings * sizeof(VBGLR3SHAREDFOLDERMAPPING); 123 VBGLR3SHAREDFOLDERMAPPING *ppaMappingsTemp = (PVBGLR3SHAREDFOLDERMAPPING)RTMemAllocZ(cbSize); 124 if (ppaMappingsTemp == NULL) 125 rc = VERR_NO_MEMORY; 126 127 *pcMappings = 0; 128 do 139 129 { 140 VbglHGCMParmUInt32Get(&Msg.numberOfMappings, pcMappings); 141 rc = Msg.callInfo.result; 142 } 143 return rc; 130 VbglHGCMParmUInt32Set(&Msg.numberOfMappings, cMappings); 131 VbglHGCMParmPtrSet(&Msg.mappings, ppaMappingsTemp, cbSize); 132 133 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 134 if (RT_SUCCESS(rc)) 135 { 136 rc = Msg.callInfo.result; 137 if (RT_SUCCESS(rc)) 138 { 139 VbglHGCMParmUInt32Get(&Msg.numberOfMappings, pcMappings); 140 141 /* Do we have more mappings than we have allocated space for? */ 142 if (rc == VINF_BUFFER_OVERFLOW) 143 { 144 cMappings = *pcMappings; 145 cbSize = cMappings * sizeof(VBGLR3SHAREDFOLDERMAPPING); 146 void *pvNew = RTMemRealloc(ppaMappingsTemp, cbSize); 147 AssertPtrBreakStmt(pvNew, rc = VERR_NO_MEMORY); 148 ppaMappingsTemp = (PVBGLR3SHAREDFOLDERMAPPING)pvNew; 149 } 150 else 151 *ppaMappings = ppaMappingsTemp; 152 } 153 } 154 } while (rc == VINF_BUFFER_OVERFLOW); 155 156 if (RT_FAILURE(rc) && ppaMappingsTemp) 157 RTMemFree(ppaMappingsTemp); 158 159 return rc; 160 } 161 162 163 /** 164 * Frees the shared folder mappings allocated by 165 * VbglR3SharedFolderGetMappings() before. 166 * 167 * @param paMappings What 168 */ 169 VBGLR3DECL(void) VbglR3SharedFolderFreeMappings(PVBGLR3SHAREDFOLDERMAPPING paMappings) 170 { 171 RTMemFree(paMappings); 144 172 } 145 173 … … 179 207 if (RT_SUCCESS(rc)) 180 208 { 181 *ppszName = NULL; 182 rc = RTUtf16ToUtf8(&pString->String.ucs2[0], ppszName); 209 rc = Msg.callInfo.result; 183 210 if (RT_SUCCESS(rc)) 184 rc = Msg.callInfo.result; /** @todo r=bird: Shouldn't you check this *before* doing the conversion? */ 211 { 212 *ppszName = NULL; 213 rc = RTUtf16ToUtf8(&pString->String.ucs2[0], ppszName); 214 } 185 215 } 186 216 RTMemFree(pString); -
trunk/src/VBox/HostServices/SharedFolders/mappings.cpp
r31002 r31052 37 37 } 38 38 39 int vbsfMappingLoaded (const MAPPING *pLoadedMapping, SHFLROOT root)39 int vbsfMappingLoaded(const PMAPPING pLoadedMapping, SHFLROOT root) 40 40 { 41 41 /* Mapping loaded from the saved state with the index. Which means … … 173 173 * We are always executed from one specific HGCM thread. So thread safe. 174 174 */ 175 int vbsfMappingsAdd (PSHFLSTRING pFolderName, PSHFLSTRING pMapName,176 uint32_t fWritable, uint32_tfAutoMount)175 int vbsfMappingsAdd(PSHFLSTRING pFolderName, PSHFLSTRING pMapName, 176 uint32_t fWritable, uint32_t fAutoMount) 177 177 { 178 178 unsigned i; … … 255 255 } 256 256 257 int vbsfMappingsRemove (PSHFLSTRING pMapName)257 int vbsfMappingsRemove(PSHFLSTRING pMapName) 258 258 { 259 259 unsigned i; … … 294 294 } 295 295 296 PCRTUTF16 vbsfMappingsQueryHostRoot (SHFLROOT root, uint32_t *pcbRoot)296 PCRTUTF16 vbsfMappingsQueryHostRoot(SHFLROOT root, uint32_t *pcbRoot) 297 297 { 298 298 MAPPING *pFolderMapping = vbsfMappingGetByRoot(root); … … 307 307 } 308 308 309 bool vbsfIsGuestMappingCaseSensitive (SHFLROOT root)309 bool vbsfIsGuestMappingCaseSensitive(SHFLROOT root) 310 310 { 311 311 MAPPING *pFolderMapping = vbsfMappingGetByRoot(root); … … 319 319 } 320 320 321 bool vbsfIsHostMappingCaseSensitive (SHFLROOT root)321 bool vbsfIsHostMappingCaseSensitive(SHFLROOT root) 322 322 { 323 323 MAPPING *pFolderMapping = vbsfMappingGetByRoot(root); … … 331 331 } 332 332 333 int vbsfMappingsQuery (SHFLCLIENTDATA *pClient, SHFLMAPPING *pMappings, uint32_t *pcMappings) 333 /** 334 * Note: If pMappings/*pcMappings is smaller than the actual amount of mappings 335 * that *could* have been returned *pcMappings contains the required buffer size 336 * so that the caller can retry the operation if wanted. 337 */ 338 int vbsfMappingsQuery(PSHFLCLIENTDATA pClient, PSHFLMAPPING pMappings, uint32_t *pcMappings) 334 339 { 335 340 int rc = VINF_SUCCESS; 336 uint32_t cMaxMappings = RT_MIN(*pcMappings, SHFL_MAX_MAPPINGS); 341 342 uint32_t cMappings = 0; /* Will contain actual valid mappings. */ 343 uint32_t idx = 0; /* Current index in mappings buffer. */ 337 344 338 345 LogFlow(("vbsfMappingsQuery: pClient = %p, pMappings = %p, pcMappings = %p, *pcMappings = %d\n", 339 346 pClient, pMappings, pcMappings, *pcMappings)); 340 347 341 *pcMappings = 0; 342 for (uint32_t i=0;i<cMaxMappings;i++) 348 for (uint32_t i = 0; i < SHFL_MAX_MAPPINGS; i++) 343 349 { 344 350 MAPPING *pFolderMapping = vbsfMappingGetByRoot(i); … … 346 352 && pFolderMapping->fValid == true) 347 353 { 348 /* Skip mappings which are not marked for auto-mounting if 349 * the SHFL_MF_AUTOMOUNT flag ist set. */ 350 if ( (pClient->fu32Flags & SHFL_MF_AUTOMOUNT) 351 && !pFolderMapping->fAutoMount) 352 continue; 353 354 pMappings[*pcMappings].u32Status = SHFL_MS_NEW; 355 pMappings[*pcMappings].root = i; 356 *pcMappings = *pcMappings + 1; 357 } 358 } 354 if (idx < *pcMappings) 355 { 356 /* Skip mappings which are not marked for auto-mounting if 357 * the SHFL_MF_AUTOMOUNT flag ist set. */ 358 if ( (pClient->fu32Flags & SHFL_MF_AUTOMOUNT) 359 && !pFolderMapping->fAutoMount) 360 continue; 361 362 pMappings[idx].u32Status = SHFL_MS_NEW; 363 pMappings[idx].root = i; 364 idx++; 365 } 366 cMappings++; 367 } 368 } 369 370 /* Return actual number of mappings, regardless whether the handed in 371 * mapping buffer was big enough. */ 372 *pcMappings = cMappings; 373 359 374 LogFlow(("vbsfMappingsQuery: return rc = %Rrc\n", rc)); 360 375 return rc; 361 376 } 362 377 363 int vbsfMappingsQueryName (SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pString)378 int vbsfMappingsQueryName(PSHFLCLIENTDATA pClient, SHFLROOT root, SHFLSTRING *pString) 364 379 { 365 380 int rc = VINF_SUCCESS; … … 394 409 } 395 410 396 int vbsfMappingsQueryWritable (SHFLCLIENTDATA *pClient, SHFLROOT root, bool *fWritable)411 int vbsfMappingsQueryWritable(PSHFLCLIENTDATA pClient, SHFLROOT root, bool *fWritable) 397 412 { 398 413 int rc = VINF_SUCCESS; … … 417 432 } 418 433 419 int vbsfMappingsQueryAutoMount (SHFLCLIENTDATA *pClient, SHFLROOT root, bool *fAutoMount)434 int vbsfMappingsQueryAutoMount(PSHFLCLIENTDATA pClient, SHFLROOT root, bool *fAutoMount) 420 435 { 421 436 int rc = VINF_SUCCESS; … … 440 455 } 441 456 442 int vbsfMapFolder (SHFLCLIENTDATA *pClient, PSHFLSTRING pszMapName, RTUTF16 delimiter, bool fCaseSensitive, SHFLROOT *pRoot) 457 int vbsfMapFolder(PSHFLCLIENTDATA pClient, PSHFLSTRING pszMapName, 458 RTUTF16 delimiter, bool fCaseSensitive, SHFLROOT *pRoot) 443 459 { 444 460 MAPPING *pFolderMapping = NULL; … … 490 506 } 491 507 492 int vbsfUnmapFolder (SHFLCLIENTDATA *pClient, SHFLROOT root)508 int vbsfUnmapFolder(PSHFLCLIENTDATA pClient, SHFLROOT root) 493 509 { 494 510 int rc = VINF_SUCCESS; -
trunk/src/VBox/HostServices/SharedFolders/mappings.h
r31002 r31052 31 31 bool fWritable; 32 32 bool fAutoMount; 33 } MAPPING, *PMAPPING; 33 } MAPPING; 34 /** Pointer to a MAPPING structure. */ 35 typedef MAPPING *PMAPPING; 34 36 35 37 void vbsfMappingInit(void); … … 40 42 int vbsfMappingsRemove(PSHFLSTRING pMapName); 41 43 42 int vbsfMappingsQuery( SHFLCLIENTDATA *pClient, SHFLMAPPING *pMappings, uint32_t *pcMappings);43 int vbsfMappingsQueryName( SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pString);44 int vbsfMappingsQueryWritable( SHFLCLIENTDATA *pClient, SHFLROOT root, bool *fWritable);44 int vbsfMappingsQuery(PSHFLCLIENTDATA pClient, PSHFLMAPPING pMappings, uint32_t *pcMappings); 45 int vbsfMappingsQueryName(PSHFLCLIENTDATA pClient, SHFLROOT root, SHFLSTRING *pString); 46 int vbsfMappingsQueryWritable(PSHFLCLIENTDATA pClient, SHFLROOT root, bool *fWritable); 45 47 46 int vbsfMapFolder( SHFLCLIENTDATA *pClient, PSHFLSTRING pszMapName, RTUTF16 delimiter, bool fCaseSensitive, SHFLROOT *pRoot);47 int vbsfUnmapFolder( SHFLCLIENTDATA *pClient, SHFLROOT root);48 int vbsfMapFolder(PSHFLCLIENTDATA pClient, PSHFLSTRING pszMapName, RTUTF16 delimiter, bool fCaseSensitive, SHFLROOT *pRoot); 49 int vbsfUnmapFolder(PSHFLCLIENTDATA pClient, SHFLROOT root); 48 50 49 PCRTUTF16 vbsfMappingsQueryHostRoot (SHFLROOT root, uint32_t *pcbRoot);50 bool vbsfIsGuestMappingCaseSensitive (SHFLROOT root);51 bool vbsfIsHostMappingCaseSensitive (SHFLROOT root);51 PCRTUTF16 vbsfMappingsQueryHostRoot(SHFLROOT root, uint32_t *pcbRoot); 52 bool vbsfIsGuestMappingCaseSensitive(SHFLROOT root); 53 bool vbsfIsHostMappingCaseSensitive(SHFLROOT root); 52 54 53 int vbsfMappingLoaded (const MAPPING *pLoadedMapping, SHFLROOT root);54 MAPPING *vbsfMappingGetByRoot(SHFLROOT root);55 int vbsfMappingLoaded(const PMAPPING pLoadedMapping, SHFLROOT root); 56 PMAPPING vbsfMappingGetByRoot(SHFLROOT root); 55 57 56 58 #endif /* !___MAPPINGS_H */ -
trunk/src/VBox/HostServices/SharedFolders/service.cpp
r31002 r31052 4 4 5 5 /* 6 * Copyright (C) 2006-20 07Oracle Corporation6 * Copyright (C) 2006-2010 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 327 327 if (RT_SUCCESS(rc)) 328 328 { 329 /* Report that there are more mappings to get if 330 * handed in buffer is too small. */ 331 if (paParms[1].u.uint32 < cMappings) 332 rc = VINF_BUFFER_OVERFLOW; 333 329 334 /* Update parameters. */ 330 335 paParms[1].u.uint32 = cMappings; -
trunk/src/VBox/HostServices/SharedFolders/shfl.h
r28800 r31052 4 4 5 5 /* 6 * Copyright (C) 2006-20 07Oracle Corporation6 * Copyright (C) 2006-2010 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 46 46 /** Client flags */ 47 47 uint32_t fu32Flags; 48 48 /** Path delimiter. */ 49 49 RTUTF16 PathDelimiter; 50 50 } SHFLCLIENTDATA; 51 51 /** Pointer to a SHFLCLIENTDATA structure. */ 52 typedef SHFLCLIENTDATA *PSHFLCLIENTDATA; 52 53 53 54 #endif /* !___SHFL_H */
Note:
See TracChangeset
for help on using the changeset viewer.

