Changeset 75380 in vbox
- Timestamp:
- Nov 9, 2018 10:25:30 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 126515
- Location:
- trunk
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/settings.h
r75361 r75380 751 751 bool fWritable; 752 752 bool fAutoMount; 753 com::Utf8Str strAutoMountPoint; 753 754 }; 754 755 -
trunk/include/VBox/shflsvc.h
r75333 r75380 40 40 #include <iprt/fs.h> 41 41 #include <iprt/assert.h> 42 #ifdef IN_RING3 43 # include <iprt/mem.h> 44 #endif 42 45 43 46 … … 231 234 232 235 /** 236 * Helper for copying one string into another. 237 * 238 * @returns pDst 239 * @param pDst The destination string. Assumed to be the same size as 240 * the source. 241 * @param pSrc The source string. 242 */ 243 DECLINLINE(PSHFLSTRING) ShflStringCopy(PSHFLSTRING pDst, PCSHFLSTRING pSrc) 244 { 245 pDst->u16Length = pSrc->u16Length; 246 pDst->u16Size = pSrc->u16Size; 247 memcpy(&pDst->String, &pSrc->String, pSrc->u16Size); 248 return pDst; 249 } 250 251 #ifdef IN_RING3 252 253 /** 254 * Duplicates a string using RTMemAlloc as allocator. 255 * 256 * @returns Copy, NULL if out of memory. 257 * @param pSrc The source string. 258 */ 259 DECLINLINE(PSHFLSTRING) ShflStringDup(PCSHFLSTRING pSrc) 260 { 261 PSHFLSTRING pDst = (PSHFLSTRING)RTMemAlloc(SHFLSTRING_HEADER_SIZE + pSrc->u16Size); 262 if (pDst) 263 return ShflStringCopy(pDst, pSrc); 264 return pDst; 265 } 266 267 /** 268 * Duplicates a UTF-16 string using RTMemAlloc as allocator. 269 * 270 * The returned string will be using UTF-16 encoding too. 271 * 272 * @returns Pointer to copy on success - pass to RTMemFree to free. 273 * NULL if out of memory. 274 * @param pwszSrc The source string. Encoding is not checked. 275 */ 276 DECLINLINE(PSHFLSTRING) ShflStringDupUtf16(PCRTUTF16 pwszSrc) 277 { 278 size_t cwcSrc = RTUtf16Len(pwszSrc); 279 if (cwcSrc < UINT16_MAX / sizeof(RTUTF16)) 280 { 281 PSHFLSTRING pDst = (PSHFLSTRING)RTMemAlloc(SHFLSTRING_HEADER_SIZE + (cwcSrc + 1) * sizeof(RTUTF16)); 282 if (pDst) 283 { 284 pDst->u16Length = (uint16_t)(cwcSrc * sizeof(RTUTF16)); 285 pDst->u16Size = (uint16_t)((cwcSrc + 1) * sizeof(RTUTF16)); 286 memcpy(&pDst->String, pwszSrc, (cwcSrc + 1) * sizeof(RTUTF16)); 287 return pDst; 288 } 289 } 290 AssertFailed(); 291 return NULL; 292 } 293 294 /** 295 * Duplicates a UTF-8 string using RTMemAlloc as allocator. 296 * 297 * The returned string will be using UTF-8 encoding too. 298 * 299 * @returns Pointer to copy on success - pass to RTMemFree to free. 300 * NULL if out of memory. 301 * @param pszSrc The source string. Encoding is not checked. 302 */ 303 DECLINLINE(PSHFLSTRING) ShflStringDupUtf8(const char *pszSrc) 304 { 305 size_t cchSrc = strlen(pszSrc); 306 if (cchSrc < UINT16_MAX) 307 { 308 PSHFLSTRING pDst = (PSHFLSTRING)RTMemAlloc(SHFLSTRING_HEADER_SIZE + cchSrc + 1); 309 if (pDst) 310 { 311 pDst->u16Length = (uint16_t)cchSrc; 312 pDst->u16Size = (uint16_t)(cchSrc + 1); 313 memcpy(&pDst->String, pszSrc, cchSrc + 1); 314 return pDst; 315 } 316 } 317 AssertFailed(); 318 return NULL; 319 } 320 321 /** 322 * Creates a UTF-16 duplicate of the UTF-8 string @a pszSrc using RTMemAlloc as 323 * allocator. 324 * 325 * @returns Pointer to copy on success - pass to RTMemFree to free. 326 * NULL if out of memory or invalid UTF-8 encoding. 327 * @param pszSrc The source string. 328 */ 329 DECLINLINE(PSHFLSTRING) ShflStringDupUtf8AsUtf16(const char *pszSrc) 330 { 331 size_t cwcConversion = 0; 332 int rc = RTStrCalcUtf16LenEx(pszSrc, RTSTR_MAX, &cwcConversion); 333 if ( RT_SUCCESS(rc) 334 && cwcConversion < UINT16_MAX / sizeof(RTUTF16)) 335 { 336 PSHFLSTRING pDst = (PSHFLSTRING)RTMemAlloc(SHFLSTRING_HEADER_SIZE + (cwcConversion + 1) * sizeof(RTUTF16)); 337 if (pDst) 338 { 339 PRTUTF16 pwszDst = pDst->String.ucs2; 340 pDst->u16Size = (uint16_t)((cwcConversion + 1) * sizeof(RTUTF16)); 341 rc = RTStrToUtf16Ex(pszSrc, RTSTR_MAX, &pwszDst, cwcConversion + 1, &cwcConversion); 342 AssertRC(rc); 343 if (RT_SUCCESS(rc)) 344 { 345 pDst->u16Length = (uint16_t)(cwcConversion * sizeof(RTUTF16)); 346 return pDst; 347 } 348 RTMemFree(pDst); 349 } 350 } 351 AssertMsgFailed(("rc=%Rrc cwcConversion=%#x\n", rc, cwcConversion)); 352 return NULL; 353 } 354 355 #endif /* IN_RING3 */ 356 357 /** 233 358 * Validates a HGCM string output parameter. 234 359 * … … 312 437 } 313 438 439 /** Macro for passing as string as a HGCM parmeter (pointer) */ 440 #define SHFLSTRING_TO_HGMC_PARAM(a_pParam, a_pString) \ 441 do { \ 442 (a_pParam)->type = VBOX_HGCM_SVC_PARM_PTR; \ 443 (a_pParam)->u.pointer.addr = (a_pString); \ 444 (a_pParam)->u.pointer.size = ShflStringSizeOfBuffer(a_pString); \ 445 } while (0) 446 314 447 /** @} */ 315 448 … … 1426 1559 #define SHFL_ADD_MAPPING_F_MISSING (RT_BIT_32(3)) 1427 1560 1428 #define SHFL_CPARMS_ADD_MAPPING ( 3)1561 #define SHFL_CPARMS_ADD_MAPPING (4) 1429 1562 1430 1563 /** -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp
r75361 r75380 49 49 // funcs 50 50 /////////////////////////////////////////////////////////////////////////////// 51 52 /** 53 * Helper for formatting an indexed name or some such thing. 54 */ 55 static const char *FmtNm(char psz[80], const char *pszFormat, ...) 56 { 57 va_list va; 58 va_start(va, pszFormat); 59 RTStrPrintfV(psz, 80, pszFormat, va); 60 va_end(va); 61 return psz; 62 } 51 63 52 64 HRESULT showSnapshots(ComPtr<ISnapshot> &rootSnapshot, … … 368 380 } 369 381 382 /** Shows a shared folder. */ 383 static HRESULT showSharedFolder(ComPtr<ISharedFolder> &sf, VMINFO_DETAILS details, const char *pszDesc, 384 const char *pszMrInfix, size_t idxMr, bool fFirst) 385 { 386 Bstr name, hostPath, bstrAutoMountPoint; 387 BOOL writable = FALSE, fAutoMount = FALSE; 388 CHECK_ERROR2I_RET(sf, COMGETTER(Name)(name.asOutParam()), hrcCheck); 389 CHECK_ERROR2I_RET(sf, COMGETTER(HostPath)(hostPath.asOutParam()), hrcCheck); 390 CHECK_ERROR2I_RET(sf, COMGETTER(Writable)(&writable), hrcCheck); 391 CHECK_ERROR2I_RET(sf, COMGETTER(AutoMount)(&fAutoMount), hrcCheck); 392 CHECK_ERROR2I_RET(sf, COMGETTER(AutoMountPoint)(bstrAutoMountPoint.asOutParam()), hrcCheck); 393 394 if (fFirst && details != VMINFO_MACHINEREADABLE) 395 RTPrintf("\n\n"); 396 if (details == VMINFO_MACHINEREADABLE) 397 { 398 char szNm[80]; 399 outputMachineReadableString(FmtNm(szNm, "SharedFolderName%s%zu", pszMrInfix, idxMr), &name); 400 outputMachineReadableString(FmtNm(szNm, "SharedFolderPath%s%zu", pszMrInfix, idxMr), &hostPath); 401 } 402 else 403 { 404 RTPrintf("Name: '%ls', Host path: '%ls' (%s), %s%s%", 405 name.raw(), hostPath.raw(), pszDesc, writable ? "writable" : "readonly", fAutoMount ? ", auto-mount" : ""); 406 if (bstrAutoMountPoint.isNotEmpty()) 407 RTPrintf(", mount-point: '%ls'\n", bstrAutoMountPoint.raw()); 408 else 409 RTPrintf("\n"); 410 } 411 return S_OK; 412 } 413 414 370 415 static const char *paravirtProviderToString(ParavirtProvider_T provider, VMINFO_DETAILS details) 371 416 { … … 407 452 return "Unknown"; 408 453 } 409 }410 411 /**412 * Helper for formatting an indexed name or some such thing.413 */414 static const char *FmtNm(char psz[80], const char *pszFormat, ...)415 {416 va_list va;417 va_start(va, pszFormat);418 RTStrPrintfV(psz, 80, pszFormat, va);419 va_end(va);420 return psz;421 454 } 422 455 … … 2218 2251 { 2219 2252 ComPtr<ISharedFolder> sf = sfColl[i]; 2220 Bstr name, hostPath; 2221 sf->COMGETTER(Name)(name.asOutParam()); 2222 sf->COMGETTER(HostPath)(hostPath.asOutParam()); 2223 RTPrintf("Name: '%ls', Host path: '%ls' (global mapping)\n", name.raw(), hostPath.raw()); 2253 showSharedFolder(sf, details, "global mapping", "GlobalMapping", i + 1, numSharedFolders == 0); 2224 2254 ++numSharedFolders; 2225 2255 } … … 2229 2259 { 2230 2260 com::SafeIfaceArray <ISharedFolder> folders; 2231 2232 2261 CHECK_ERROR_RET(machine, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders)), rc); 2233 2234 2262 for (size_t i = 0; i < folders.size(); ++i) 2235 2263 { 2236 2264 ComPtr<ISharedFolder> sf = folders[i]; 2237 2238 Bstr name, hostPath; 2239 BOOL writable; 2240 sf->COMGETTER(Name)(name.asOutParam()); 2241 sf->COMGETTER(HostPath)(hostPath.asOutParam()); 2242 sf->COMGETTER(Writable)(&writable); 2243 if (!numSharedFolders && details != VMINFO_MACHINEREADABLE) 2244 RTPrintf("\n\n"); 2245 if (details == VMINFO_MACHINEREADABLE) 2246 { 2247 outputMachineReadableString(FmtNm(szNm, "SharedFolderNameMachineMapping%zu", i + 1), &name); 2248 outputMachineReadableString(FmtNm(szNm, "SharedFolderPathMachineMapping%zu", i + 1), &hostPath); 2249 } 2250 else 2251 RTPrintf("Name: '%ls', Host path: '%ls' (machine mapping), %s\n", 2252 name.raw(), hostPath.raw(), writable ? "writable" : "readonly"); 2265 showSharedFolder(sf, details, "machine mapping", "MachineMapping", i + 1, numSharedFolders == 0); 2253 2266 ++numSharedFolders; 2254 2267 } … … 2258 2271 { 2259 2272 com::SafeIfaceArray <ISharedFolder> folders; 2260 2261 2273 CHECK_ERROR_RET(pConsole, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders)), rc); 2262 2263 2274 for (size_t i = 0; i < folders.size(); ++i) 2264 2275 { 2265 2276 ComPtr<ISharedFolder> sf = folders[i]; 2266 2267 Bstr name, hostPath; 2268 sf->COMGETTER(Name)(name.asOutParam()); 2269 sf->COMGETTER(HostPath)(hostPath.asOutParam()); 2270 if (!numSharedFolders && details != VMINFO_MACHINEREADABLE) 2271 RTPrintf("\n\n"); 2272 if (details == VMINFO_MACHINEREADABLE) 2273 { 2274 outputMachineReadableString(FmtNm(szNm, "SharedFolderNameTransientMapping%zu", i + 1), &name); 2275 outputMachineReadableString(FmtNm(szNm, "SharedFolderPathTransientMapping%zu", i + 1), &hostPath); 2276 } 2277 else 2278 RTPrintf("Name: '%ls', Host path: '%ls' (transient mapping)\n", name.raw(), hostPath.raw()); 2277 showSharedFolder(sf, details, "transient mapping", "TransientMapping", i + 1, numSharedFolders == 0); 2279 2278 ++numSharedFolders; 2280 2279 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r74431 r75380 1096 1096 bool fWritable = true; 1097 1097 bool fAutoMount = false; 1098 char *pszAutoMountPoint = ""; 1098 1099 1099 1100 for (int i = 2; i < a->argc; i++) … … 1130 1131 fAutoMount = true; 1131 1132 } 1133 else if (!strcmp(a->argv[i], "--auto-mount-point")) 1134 { 1135 if (a->argc <= i + 1 || !*a->argv[i+1]) 1136 return errorArgument("Missing argument to '%s'", a->argv[i]); 1137 i++; 1138 pszAutoMountPoint = a->argv[i]; 1139 } 1132 1140 else 1133 1141 return errorSyntax(USAGE_SHAREDFOLDER_ADD, "Invalid parameter '%s'", Utf8Str(a->argv[i]).c_str()); … … 1160 1168 "Machine '%s' is not currently running.\n", pszMachineName); 1161 1169 1162 CHECK_ERROR(console, CreateSharedFolder(Bstr(name).raw(), 1163 Bstr(hostpath).raw(), 1164 fWritable, fAutoMount)); 1170 CHECK_ERROR(console, CreateSharedFolder(Bstr(name).raw(), Bstr(hostpath).raw(), 1171 fWritable, fAutoMount, Bstr(pszAutoMountPoint).raw())); 1165 1172 a->session->UnlockMachine(); 1166 1173 } … … 1174 1181 a->session->COMGETTER(Machine)(sessionMachine.asOutParam()); 1175 1182 1176 CHECK_ERROR(sessionMachine, CreateSharedFolder(Bstr(name).raw(), 1177 Bstr(hostpath).raw(), 1178 fWritable, fAutoMount)); 1183 CHECK_ERROR(sessionMachine, CreateSharedFolder(Bstr(name).raw(), Bstr(hostpath).raw(), 1184 fWritable, fAutoMount, Bstr(pszAutoMountPoint).raw())); 1179 1185 if (SUCCEEDED(rc)) 1180 1186 CHECK_ERROR(sessionMachine, SaveSettings()); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.cpp
r71355 r75380 42 42 UIDataSettingsSharedFolder() 43 43 : m_enmType(MachineType) 44 , m_strName(QString()) 45 , m_strPath(QString()) 44 , m_strName() 45 , m_strPath() 46 , m_fWritable(false) 46 47 , m_fAutoMount(false) 47 , m_ fWritable(false)48 , m_strAutoMountPoint() 48 49 {} 49 50 … … 52 53 { 53 54 return true 54 && (m_enmType == other.m_enmType) 55 && (m_strName == other.m_strName) 56 && (m_strPath == other.m_strPath) 57 && (m_fAutoMount == other.m_fAutoMount) 58 && (m_fWritable == other.m_fWritable) 55 && m_enmType == other.m_enmType 56 && m_strName == other.m_strName 57 && m_strPath == other.m_strPath 58 && m_fWritable == other.m_fWritable 59 && m_fAutoMount == other.m_fAutoMount 60 && m_strAutoMountPoint == other.m_strAutoMountPoint 59 61 ; 60 62 } … … 71 73 /** Holds the shared folder path. */ 72 74 QString m_strPath; 75 /** Holds whether the shared folder should be writeable. */ 76 bool m_fWritable; 73 77 /** Holds whether the shared folder should be auto-mounted at startup. */ 74 78 bool m_fAutoMount; 75 /** Holds whether the shared folder should be writeable. */ 76 bool m_fWritable; 79 /** Where in the guest to try auto mount the shared folder (drive for 80 * Windows & OS/2, path for unixy guests). */ 81 QString m_strAutoMountPoint; 77 82 }; 78 83 … … 161 166 m_fields << m_strName 162 167 << m_strPath 168 << (m_fWritable ? UIMachineSettingsSF::tr("Full") : UIMachineSettingsSF::tr("Read-only")) 163 169 << (m_fAutoMount ? UIMachineSettingsSF::tr("Yes") : "") 164 << (m_fWritable ? UIMachineSettingsSF::tr("Full") : UIMachineSettingsSF::tr("Read-only"));170 << m_strAutoMountPoint; 165 171 166 172 /* Adjust item layout: */ … … 180 186 virtual QString defaultText() const /* override */ 181 187 { 182 return parentItem() ?183 tr("%1, %2: %3, %4: %5, %6: %7",184 "col.1 text, col.2 name: col.2 text, col.3 name: col.3 text, col.4 name: col.4 text ")188 return parentItem() 189 ? tr("%1, %2: %3, %4: %5, %6: %7, %8: %9", 190 "col.1 text, col.2 name: col.2 text, col.3 name: col.3 text, col.4 name: col.4 text, col.5 name: col.5 text") 185 191 .arg(text(0)) 186 192 .arg(parentTree()->headerItem()->text(1)).arg(text(1)) 187 193 .arg(parentTree()->headerItem()->text(2)).arg(text(2)) 188 .arg(parentTree()->headerItem()->text(3)).arg(text(3)) : 189 text(0); 194 .arg(parentTree()->headerItem()->text(3)).arg(text(3)) 195 .arg(parentTree()->headerItem()->text(4)).arg(text(4)) 196 : text(0); 190 197 } 191 198 … … 215 222 iTextWidth = fm.width(strOneString); 216 223 if ( iTextWidth 217 && (iTextWidth + iIndentSize > cWidth))224 && iTextWidth + iIndentSize > cWidth) 218 225 { 219 226 iStart = 0; … … 331 338 oldFolderData.m_strName = comFolder.GetName(); 332 339 oldFolderData.m_strPath = comFolder.GetHostPath(); 340 oldFolderData.m_fWritable = comFolder.GetWritable(); 333 341 oldFolderData.m_fAutoMount = comFolder.GetAutoMount(); 334 oldFolderData.m_ fWritable = comFolder.GetWritable();342 oldFolderData.m_strAutoMountPoint = comFolder.GetAutoMountPoint(); 335 343 /* Override folder cache key: */ 336 344 strFolderKey = oldFolderData.m_strName; … … 474 482 newFolderData.m_strName = strName; 475 483 newFolderData.m_strPath = strPath; 484 newFolderData.m_fWritable = dlgFolderDetails.isWriteable(); 476 485 newFolderData.m_fAutoMount = dlgFolderDetails.isAutoMounted(); 477 newFolderData.m_ fWritable = dlgFolderDetails.isWriteable();486 newFolderData.m_strAutoMountPoint = dlgFolderDetails.autoMountPoint(); 478 487 479 488 /* Add new folder item: */ … … 502 511 dlgFolderDetails.setName(pItem->m_strName); 503 512 dlgFolderDetails.setPermanent(pItem->m_enmType == MachineType); 513 dlgFolderDetails.setWriteable(pItem->m_fWritable); 504 514 dlgFolderDetails.setAutoMount(pItem->m_fAutoMount); 505 dlgFolderDetails.set Writeable(pItem->m_fWritable);515 dlgFolderDetails.setAutoMountPoint(pItem->m_strAutoMountPoint); 506 516 507 517 /* Run folder details dialog: */ … … 518 528 pItem->m_strName = strName; 519 529 pItem->m_strPath = strPath; 530 pItem->m_fWritable = dlgFolderDetails.isWriteable(); 520 531 pItem->m_fAutoMount = dlgFolderDetails.isAutoMounted(); 521 pItem->m_ fWritable = dlgFolderDetails.isWriteable();532 pItem->m_strAutoMountPoint = dlgFolderDetails.autoMountPoint(); 522 533 pItem->updateFields(); 523 534 … … 598 609 * 599 610 * Columns 600 * 0 = Tree view 601 * 1 = Shared Folder name 602 * 2 = Auto-mount flag 603 * 3 = Writable flag 611 * 0 = Tree view / name 612 * 1 = Path 613 * 2 = Writable flag 614 * 3 = Auto-mount flag 615 * 4 = Auto mount point 604 616 */ 605 617 QAbstractItemView *pItemView = mTwFolders; … … 610 622 const int mw2 = qMax(pItemView->sizeHintForColumn(2), pItemHeader->sectionSizeHint(2)); 611 623 const int mw3 = qMax(pItemView->sizeHintForColumn(3), pItemHeader->sectionSizeHint(3)); 612 613 const int w0 = mw0 < iTotal / 4 ? mw0 : iTotal / 4; 614 const int w2 = mw2 < iTotal / 4 ? mw2 : iTotal / 4; 615 const int w3 = mw3 < iTotal / 4 ? mw3 : iTotal / 4; 624 const int mw4 = qMax(pItemView->sizeHintForColumn(4), pItemHeader->sectionSizeHint(4)); 625 #if 0 /** @todo Neither approach is perfect. Short folder names, short paths, plenty of white space, but there is often '...' in column 0. */ 626 627 const int w0 = mw0 < iTotal / 5 ? mw0 : iTotal / 5; 628 const int w2 = mw2 < iTotal / 5 ? mw2 : iTotal / 5; 629 const int w3 = mw3 < iTotal / 5 ? mw3 : iTotal / 5; 630 const int w4 = mw4 < iTotal / 5 ? mw4 : iTotal / 5; 616 631 617 632 /* Giving 1st column all the available space. */ 633 const int w1 = iTotal - w0 - w2 - w3 - w4; 634 #else 635 const int mw1 = qMax(pItemView->sizeHintForColumn(1), pItemHeader->sectionSizeHint(1)); 636 const int iHintTotal = mw0 + mw1 + mw2 + mw3 + mw4; 637 int w0, w1, w2, w3, w4; 638 int cExcess = iTotal - iHintTotal; 639 if (cExcess >= 0) 640 { 641 /* give excess width to column 1 (path) */ 642 w0 = mw0; 643 w1 = mw1 + cExcess; 644 w2 = mw2; 645 w3 = mw3; 646 w4 = mw4; 647 } 648 else 649 { 650 w0 = mw0 < iTotal / 5 ? mw0 : iTotal / 5; 651 w2 = mw2 < iTotal / 5 ? mw2 : iTotal / 5; 652 w3 = mw3 < iTotal / 5 ? mw3 : iTotal / 5; 653 w4 = mw4 < iTotal / 5 ? mw4 : iTotal / 5; 654 w1 = iTotal - w0 - w2 - w3 - w4; 655 } 656 #endif 618 657 mTwFolders->setColumnWidth(0, w0); 619 mTwFolders->setColumnWidth(1, iTotal - w0 - w2 - w3);658 mTwFolders->setColumnWidth(1, w1); 620 659 mTwFolders->setColumnWidth(2, w2); 621 660 mTwFolders->setColumnWidth(3, w3); 661 mTwFolders->setColumnWidth(4, w4); 622 662 } 623 663 … … 829 869 pItem->m_strName = sharedFolderData.m_strName; 830 870 pItem->m_strPath = sharedFolderData.m_strPath; 871 pItem->m_fWritable = sharedFolderData.m_fWritable; 831 872 pItem->m_fAutoMount = sharedFolderData.m_fAutoMount; 832 pItem->m_ fWritable = sharedFolderData.m_fWritable;873 pItem->m_strAutoMountPoint = sharedFolderData.m_strAutoMountPoint; 833 874 pItem->updateFields(); 834 875 … … 1019 1060 bool UIMachineSettingsSF::createSharedFolder(const UISettingsCacheSharedFolder &folderCache) 1020 1061 { 1021 /* Prepare result: */ 1022 bool fSuccess = true; 1023 /* Create folder: */ 1062 /* Get folder data: */ 1063 const UIDataSettingsSharedFolder &newFolderData = folderCache.data(); 1064 const UISharedFolderType enmFoldersType = newFolderData.m_enmType; 1065 const QString strFolderName = newFolderData.m_strName; 1066 const QString strFolderPath = newFolderData.m_strPath; 1067 const bool fIsWritable = newFolderData.m_fWritable; 1068 const bool fIsAutoMount = newFolderData.m_fAutoMount; 1069 const QString strAutoMountPoint = newFolderData.m_strAutoMountPoint; 1070 1071 /* Get current folders: */ 1072 CSharedFolderVector folders; 1073 bool fSuccess = getSharedFolders(enmFoldersType, folders); 1074 1075 /* Search for a folder with the same name: */ 1076 CSharedFolder comFolder; 1024 1077 if (fSuccess) 1025 { 1026 /* Get folder data: */ 1027 const UIDataSettingsSharedFolder &newFolderData = folderCache.data(); 1028 const UISharedFolderType enmFoldersType = newFolderData.m_enmType; 1029 const QString strFolderName = newFolderData.m_strName; 1030 const QString strFolderPath = newFolderData.m_strPath; 1031 const bool fIsAutoMount = newFolderData.m_fAutoMount; 1032 const bool fIsWritable = newFolderData.m_fWritable; 1033 1034 /* Get current folders: */ 1035 CSharedFolderVector folders; 1036 if (fSuccess) 1037 fSuccess = getSharedFolders(enmFoldersType, folders); 1038 1039 /* Search for a folder with the same name: */ 1040 CSharedFolder comFolder; 1041 if (fSuccess) 1042 fSuccess = getSharedFolder(strFolderName, folders, comFolder); 1043 1044 /* Make sure such folder doesn't exist: */ 1045 if (fSuccess && comFolder.isNull()) 1046 { 1047 /* Create new folder: */ 1048 switch (enmFoldersType) 1078 fSuccess = getSharedFolder(strFolderName, folders, comFolder); 1079 1080 /* Make sure such folder doesn't exist: */ 1081 if (fSuccess && comFolder.isNull()) 1082 { 1083 /* Create new folder: */ 1084 switch (enmFoldersType) 1085 { 1086 case MachineType: 1049 1087 { 1050 case MachineType: 1051 { 1052 /* Create new folder: */ 1053 m_machine.CreateSharedFolder(strFolderName, strFolderPath, fIsWritable, fIsAutoMount); 1054 /* Check that machine is OK: */ 1055 fSuccess = m_machine.isOk(); 1056 if (!fSuccess) 1057 { 1058 /* Show error message: */ 1059 notifyOperationProgressError(UIErrorString::formatErrorInfo(m_machine)); 1060 } 1061 break; 1062 } 1063 case ConsoleType: 1064 { 1065 /* Create new folder: */ 1066 m_console.CreateSharedFolder(strFolderName, strFolderPath, fIsWritable, fIsAutoMount); 1067 /* Check that console is OK: */ 1068 fSuccess = m_console.isOk(); 1069 if (!fSuccess) 1070 { 1071 /* Show error message: */ 1072 notifyOperationProgressError(UIErrorString::formatErrorInfo(m_console)); 1073 } 1074 break; 1075 } 1076 default: 1077 break; 1088 /* Create new folder: */ 1089 m_machine.CreateSharedFolder(strFolderName, strFolderPath, fIsWritable, fIsAutoMount, strAutoMountPoint); 1090 /* Show error if the operation failed: */ 1091 fSuccess = m_machine.isOk(); 1092 if (!fSuccess) 1093 notifyOperationProgressError(UIErrorString::formatErrorInfo(m_machine)); 1094 break; 1078 1095 } 1079 } 1080 } 1096 case ConsoleType: 1097 { 1098 /* Create new folder: */ 1099 m_console.CreateSharedFolder(strFolderName, strFolderPath, fIsWritable, fIsAutoMount, strAutoMountPoint); 1100 /* Show error if the operation failed: */ 1101 fSuccess = m_console.isOk(); 1102 if (!fSuccess) 1103 notifyOperationProgressError(UIErrorString::formatErrorInfo(m_console)); 1104 break; 1105 } 1106 default: 1107 break; 1108 } 1109 } 1110 1081 1111 /* Return result: */ 1082 1112 return fSuccess; -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSF.ui
r67067 r75380 87 87 <column> 88 88 <property name="text"> 89 <string>A uto-mount</string>89 <string>Access</string> 90 90 </property> 91 91 </column> 92 92 <column> 93 93 <property name="text"> 94 <string>Access</string> 94 <string>Auto Mount</string> 95 </property> 96 </column> 97 <column> 98 <property name="text"> 99 <string>At</string> 95 100 </property> 96 101 </column> -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSFDetails.cpp
r69500 r75380 110 110 } 111 111 112 void UIMachineSettingsSFDetails::setAutoMountPoint(const QString &strAutoMountPoint) 113 { 114 mLeAutoMountPoint->setText(strAutoMountPoint); 115 } 116 117 QString UIMachineSettingsSFDetails::autoMountPoint() const 118 { 119 return mLeAutoMountPoint->text(); 120 } 121 112 122 void UIMachineSettingsSFDetails::setPermanent(bool fPermanent) 113 123 { -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSFDetails.h
r72109 r75380 16 16 */ 17 17 18 #ifndef __ UIMachineSettingsSFDetails_h__19 #define __ UIMachineSettingsSFDetails_h__18 #ifndef ___UIMachineSettingsSFDetails_h___ 19 #define ___UIMachineSettingsSFDetails_h___ 20 20 21 21 /* Includes */ … … 56 56 bool isAutoMounted() const; 57 57 58 void setAutoMountPoint(const QString &strAutoMountPoint); 59 QString autoMountPoint() const; 60 58 61 void setPermanent(bool fPermanent); 59 62 bool isPermanent() const; … … 75 78 }; 76 79 77 #endif // __UIMachineSettingsSFDetails_h__80 #endif // !___UIMachineSettingsSFDetails_h___ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSFDetails.ui
r67067 r75380 74 74 </widget> 75 75 </item> 76 <item row="4" column="0" > 77 <widget class="QLabel" name="mLbAutoMountPoint" > 78 <property name="text" > 79 <string>Mount point:</string> 80 </property> 81 <property name="alignment" > 82 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 83 </property> 84 </widget> 85 </item> 76 86 <item row="4" column="1" > 87 <widget class="QLineEdit" name="mLeAutoMountPoint" > 88 <property name="toolTip" > 89 <string>Where to automatically mount the folder in the guest. A drive letter (e.g. 'G:') for Windows and OS/2 guests, path for the others. If left empty the guest will pick something fitting.</string> 90 </property> 91 </widget> 92 </item> 93 <item row="5" column="1" > 77 94 <widget class="QCheckBox" name="mCbPermanent" > 78 95 <property name="toolTip" > … … 84 101 </widget> 85 102 </item> 86 <item row=" 5" column="1" >103 <item row="6" column="1" > 87 104 <spacer> 88 105 <property name="orientation" > … … 97 114 </spacer> 98 115 </item> 99 <item row=" 6" column="0" colspan="2" >116 <item row="7" column="0" colspan="2" > 100 117 <widget class="QIDialogButtonBox" name="mButtonBox" > 101 118 <property name="standardButtons" > -
trunk/src/VBox/HostServices/SharedFolders/mappings.cpp
r69500 r75380 87 87 pLoadedMapping->pMapName->String.ucs2, pLoadedMapping->pszFolderName)); 88 88 return vbsfMappingsAdd(pLoadedMapping->pszFolderName, pLoadedMapping->pMapName, 89 pLoadedMapping->fWritable, pLoadedMapping->fAutoMount, 89 pLoadedMapping->fWritable, pLoadedMapping->fAutoMount, pLoadedMapping->pAutoMountPoint, 90 90 pLoadedMapping->fSymlinksCreate, /* fMissing = */ true, /* fPlaceholder = */ true); 91 91 } … … 200 200 * We are always executed from one specific HGCM thread. So thread safe. 201 201 */ 202 int vbsfMappingsAdd(const char *pszFolderName, PSHFLSTRING pMapName, 203 bool f Writable, bool fAutoMount, bool fSymlinksCreate, bool fMissing, bool fPlaceholder)202 int vbsfMappingsAdd(const char *pszFolderName, PSHFLSTRING pMapName, bool fWritable, 203 bool fAutoMount, PSHFLSTRING pAutoMountPoint, bool fSymlinksCreate, bool fMissing, bool fPlaceholder) 204 204 { 205 205 unsigned i; … … 232 232 AssertRCReturn(rc, rc); 233 233 234 FolderMapping[i].pszFolderName = RTStrDup(szAbsFolderName); 235 if (!FolderMapping[i].pszFolderName) 234 FolderMapping[i].pszFolderName = RTStrDup(szAbsFolderName); 235 FolderMapping[i].pMapName = ShflStringDup(pMapName); 236 FolderMapping[i].pAutoMountPoint = ShflStringDup(pAutoMountPoint); 237 if ( !FolderMapping[i].pszFolderName 238 || !FolderMapping[i].pMapName 239 || !FolderMapping[i].pAutoMountPoint) 236 240 { 241 RTStrFree(FolderMapping[i].pszFolderName); 242 RTMemFree(FolderMapping[i].pMapName); 243 RTMemFree(FolderMapping[i].pAutoMountPoint); 237 244 return VERR_NO_MEMORY; 238 245 } 239 240 FolderMapping[i].pMapName = (PSHFLSTRING)RTMemAlloc(ShflStringSizeOfBuffer(pMapName));241 if (!FolderMapping[i].pMapName)242 {243 RTStrFree(FolderMapping[i].pszFolderName);244 AssertFailed();245 return VERR_NO_MEMORY;246 }247 248 FolderMapping[i].pMapName->u16Length = pMapName->u16Length;249 FolderMapping[i].pMapName->u16Size = pMapName->u16Size;250 memcpy(FolderMapping[i].pMapName->String.ucs2, pMapName->String.ucs2, pMapName->u16Size);251 246 252 247 FolderMapping[i].fValid = true; -
trunk/src/VBox/HostServices/SharedFolders/mappings.h
r69500 r75380 1 /* $Id$ */ 1 2 /** @file 2 * Shared folders :Mappings header.3 * Shared folders service - Mappings header. 3 4 */ 4 5 … … 23 24 typedef struct 24 25 { 25 char *pszFolderName; /**< directory at the host to share with the guest */ 26 PSHFLSTRING pMapName; /**< share name for the guest */ 27 uint32_t cMappings; /**< number of mappings */ 28 bool fValid; /**< mapping entry is used/valid */ 29 bool fHostCaseSensitive; /**< host file name space is case-sensitive */ 30 bool fGuestCaseSensitive; /**< guest file name space is case-sensitive */ 31 bool fWritable; /**< folder is writable for the guest */ 32 bool fAutoMount; /**< folder will be auto-mounted by the guest */ 33 bool fSymlinksCreate; /**< guest is able to create symlinks */ 34 bool fMissing; /**< mapping not invalid but host path does not exist. 35 Any guest operation on such a folder fails! */ 36 bool fPlaceholder; /**< mapping does not exist in the VM settings but the guest 37 still has. fMissing is always true for this mapping. */ 26 char *pszFolderName; /**< Directory at the host to share with the guest. */ 27 PSHFLSTRING pMapName; /**< Share name for the guest. */ 28 uint32_t cMappings; /**< Number of mappings. */ 29 bool fValid; /**< Mapping entry is used/valid. */ 30 bool fHostCaseSensitive; /**< Host file name space is case-sensitive. */ 31 bool fGuestCaseSensitive; /**< Guest file name space is case-sensitive. */ 32 bool fWritable; /**< Folder is writable for the guest. */ 33 PSHFLSTRING pAutoMountPoint; /**< Where the guest should try auto-mount the folder. */ 34 bool fAutoMount; /**< Folder will be auto-mounted by the guest. */ 35 bool fSymlinksCreate; /**< Guest is able to create symlinks. */ 36 bool fMissing; /**< Mapping not invalid but host path does not exist. 37 Any guest operation on such a folder fails! */ 38 bool fPlaceholder; /**< Mapping does not exist in the VM settings but the guest 39 still has. fMissing is always true for this mapping. */ 38 40 } MAPPING; 39 41 /** Pointer to a MAPPING structure. */ … … 44 46 bool vbsfMappingQuery(uint32_t iMapping, PMAPPING *pMapping); 45 47 46 int vbsfMappingsAdd(const char *pszFolderName, PSHFLSTRING pMapName, 47 bool f Writable, bool fAutoMount, bool fCreateSymlinks, bool fMissing, bool fPlaceholder);48 int vbsfMappingsAdd(const char *pszFolderName, PSHFLSTRING pMapName, bool fWritable, 49 bool fAutoMount, PSHFLSTRING pAutoMountPoint, bool fCreateSymlinks, bool fMissing, bool fPlaceholder); 48 50 int vbsfMappingsRemove(PSHFLSTRING pMapName); 49 51 -
trunk/src/VBox/HostServices/SharedFolders/service.cpp
r69500 r75380 29 29 #include <VBox/vmm/pdmifs.h> 30 30 31 #define SHFL_SSM_VERSION_FOLDERNAME_UTF16 2 32 #define SHFL_SSM_VERSION 3 31 #define SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16 2 32 #define SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT 3 33 #define SHFL_SAVED_STATE_VERSION 4 33 34 34 35 … … 120 121 Log(("SharedFolders host service: saving state, u32ClientID = %u\n", u32ClientID)); 121 122 122 int rc = SSMR3PutU32(pSSM, SHFL_S SM_VERSION);123 int rc = SSMR3PutU32(pSSM, SHFL_SAVED_STATE_VERSION); 123 124 AssertRCReturn(rc, rc); 124 125 … … 147 148 if (pFolderMapping && pFolderMapping->fValid) 148 149 { 149 uint32_t len; 150 151 len = (uint32_t)strlen(pFolderMapping->pszFolderName); 152 rc = SSMR3PutU32(pSSM, len); 153 AssertRCReturn(rc, rc); 154 155 rc = SSMR3PutStrZ(pSSM, pFolderMapping->pszFolderName); 156 AssertRCReturn(rc, rc); 150 uint32_t len = (uint32_t)strlen(pFolderMapping->pszFolderName); 151 SSMR3PutU32(pSSM, len); 152 SSMR3PutStrZ(pSSM, pFolderMapping->pszFolderName); 157 153 158 154 len = ShflStringSizeOfBuffer(pFolderMapping->pMapName); 159 rc =SSMR3PutU32(pSSM, len);160 AssertRCReturn(rc, rc);161 162 rc = SSMR3PutMem(pSSM, pFolderMapping->pMapName, len);163 AssertRCReturn(rc, rc); 164 165 rc = SSMR3PutBool(pSSM, pFolderMapping->fHostCaseSensitive); 166 AssertRCReturn(rc, rc);167 168 rc = SSMR3Put Bool(pSSM, pFolderMapping->fGuestCaseSensitive);155 SSMR3PutU32(pSSM, len); 156 SSMR3PutMem(pSSM, pFolderMapping->pMapName, len); 157 158 SSMR3PutBool(pSSM, pFolderMapping->fHostCaseSensitive); 159 160 SSMR3PutBool(pSSM, pFolderMapping->fGuestCaseSensitive); 161 162 len = ShflStringSizeOfBuffer(pFolderMapping->pAutoMountPoint); 163 SSMR3PutU32(pSSM, len); 164 rc = SSMR3PutMem(pSSM, pFolderMapping->pAutoMountPoint, len); 169 165 AssertRCReturn(rc, rc); 170 166 } … … 190 186 AssertRCReturn(rc, rc); 191 187 192 if ( version > SHFL_S SM_VERSION193 || version < SHFL_S SM_VERSION_FOLDERNAME_UTF16)188 if ( version > SHFL_SAVED_STATE_VERSION 189 || version < SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16) 194 190 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 195 191 … … 214 210 /* Load the saved mapping description and try to find it in the mappings. */ 215 211 MAPPING mapping; 216 memset (&mapping, 0, sizeof (mapping));212 RT_ZERO(mapping); 217 213 218 214 /* restore the folder mapping counter. */ … … 225 221 if (mapping.fValid) 226 222 { 227 uint32_t cbFolderName; 223 uint32_t cb; 224 225 /* Load the host path name. */ 226 rc = SSMR3GetU32(pSSM, &cb); 227 AssertRCReturn(rc, rc); 228 228 229 char *pszFolderName; 229 230 uint32_t cbMapName; 231 PSHFLSTRING pMapName; 232 233 /* Load the host path name. */ 234 rc = SSMR3GetU32(pSSM, &cbFolderName); 235 AssertRCReturn(rc, rc); 236 237 if (version == SHFL_SSM_VERSION_FOLDERNAME_UTF16) 238 { 239 PSHFLSTRING pFolderName = (PSHFLSTRING)RTMemAlloc(cbFolderName); 230 if (version == SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16) 231 { 232 AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1), 233 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad folder name size: %#x\n", cb)); 234 PSHFLSTRING pFolderName = (PSHFLSTRING)RTMemAlloc(cb); 240 235 AssertReturn(pFolderName != NULL, VERR_NO_MEMORY); 241 236 242 rc = SSMR3GetMem(pSSM, pFolderName, cb FolderName);237 rc = SSMR3GetMem(pSSM, pFolderName, cb); 243 238 AssertRCReturn(rc, rc); 239 AssertReturn(pFolderName->u16Length < cb && pFolderName->u16Size < pFolderName->u16Length, 240 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, 241 "Bad folder name string: %#x/%#x cb=%#x\n", 242 pFolderName->u16Size, pFolderName->u16Length, cb)); 244 243 245 244 rc = RTUtf16ToUtf8(pFolderName->String.ucs2, &pszFolderName); … … 249 248 else 250 249 { 251 pszFolderName = (char *)RTStrAlloc(cbFolderName+ 1);250 pszFolderName = (char *)RTStrAlloc(cb + 1); 252 251 AssertReturn(pszFolderName, VERR_NO_MEMORY); 253 252 254 rc = SSMR3GetStrZ(pSSM, pszFolderName, cb FolderName+ 1);253 rc = SSMR3GetStrZ(pSSM, pszFolderName, cb + 1); 255 254 AssertRCReturn(rc, rc); 256 255 mapping.pszFolderName = pszFolderName; … … 258 257 259 258 /* Load the map name. */ 260 rc = SSMR3GetU32(pSSM, &cb MapName);259 rc = SSMR3GetU32(pSSM, &cb); 261 260 AssertRCReturn(rc, rc); 262 263 pMapName = (PSHFLSTRING)RTMemAlloc(cbMapName); 261 AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1), 262 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad map name size: %#x\n", cb)); 263 264 PSHFLSTRING pMapName = (PSHFLSTRING)RTMemAlloc(cb); 264 265 AssertReturn(pMapName != NULL, VERR_NO_MEMORY); 265 266 266 rc = SSMR3GetMem(pSSM, pMapName, cb MapName);267 rc = SSMR3GetMem(pSSM, pMapName, cb); 267 268 AssertRCReturn(rc, rc); 268 269 AssertReturn(pMapName->u16Length < cb && pMapName->u16Size < pMapName->u16Length, 270 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, 271 "Bad map name string: %#x/%#x cb=%#x\n", 272 pMapName->u16Size, pMapName->u16Length, cb)); 273 274 /* Load case sensitivity config. */ 269 275 rc = SSMR3GetBool(pSSM, &mapping.fHostCaseSensitive); 270 276 AssertRCReturn(rc, rc); … … 273 279 AssertRCReturn(rc, rc); 274 280 281 /* Load the auto mount point. */ 282 PSHFLSTRING pAutoMountPoint; 283 if (version > SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT) 284 { 285 rc = SSMR3GetU32(pSSM, &cb); 286 AssertRCReturn(rc, rc); 287 AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1), 288 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad auto mount point size: %#x\n", cb)); 289 290 pAutoMountPoint = (PSHFLSTRING)RTMemAlloc(cb); 291 AssertReturn(pAutoMountPoint != NULL, VERR_NO_MEMORY); 292 293 rc = SSMR3GetMem(pSSM, pAutoMountPoint, cb); 294 AssertRCReturn(rc, rc); 295 AssertReturn(pAutoMountPoint->u16Length < cb && pAutoMountPoint->u16Size < pAutoMountPoint->u16Length, 296 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, 297 "Bad auto mount point string: %#x/%#x cb=%#x\n", 298 pAutoMountPoint->u16Size, pAutoMountPoint->u16Length, cb)); 299 300 } 301 else 302 { 303 pAutoMountPoint = ShflStringDupUtf8(""); 304 AssertReturn(pAutoMountPoint, VERR_NO_MEMORY); 305 } 306 275 307 mapping.pszFolderName = pszFolderName; 276 308 mapping.pMapName = pMapName; 309 mapping.pAutoMountPoint = pAutoMountPoint; 277 310 278 311 /* 'i' is the root handle of the saved mapping. */ … … 284 317 } 285 318 319 RTMemFree(pAutoMountPoint); 286 320 RTMemFree(pMapName); 287 321 RTStrFree(pszFolderName); … … 1315 1349 rc = VERR_INVALID_PARAMETER; 1316 1350 } 1317 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_PTR /* host folder name*/1318 || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* guestmap name */1351 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_PTR /* host folder path */ 1352 || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* map name */ 1319 1353 || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT /* fFlags */ 1354 || paParms[3].type != VBOX_HGCM_SVC_PARM_PTR /* auto mount point */ 1320 1355 ) 1321 1356 { … … 1325 1360 { 1326 1361 /* Fetch parameters. */ 1327 SHFLSTRING *pFolderName = (SHFLSTRING *)paParms[0].u.pointer.addr; 1328 SHFLSTRING *pMapName = (SHFLSTRING *)paParms[1].u.pointer.addr; 1329 uint32_t fFlags = paParms[2].u.uint32; 1362 SHFLSTRING *pHostPath = (SHFLSTRING *)paParms[0].u.pointer.addr; 1363 SHFLSTRING *pMapName = (SHFLSTRING *)paParms[1].u.pointer.addr; 1364 uint32_t fFlags = paParms[2].u.uint32; 1365 SHFLSTRING *pAutoMountPoint = (SHFLSTRING *)paParms[3].u.pointer.addr; 1330 1366 1331 1367 /* Verify parameters values. */ 1332 if ( !ShflStringIsValidIn(p FolderName, paParms[0].u.pointer.size, false /*fUtf8Not16*/)1368 if ( !ShflStringIsValidIn(pHostPath, paParms[0].u.pointer.size, false /*fUtf8Not16*/) 1333 1369 || !ShflStringIsValidIn(pMapName, paParms[1].u.pointer.size, false /*fUtf8Not16*/) 1370 || !ShflStringIsValidIn(pAutoMountPoint, paParms[3].u.pointer.size, false /*fUtf8Not16*/) 1334 1371 ) 1335 1372 { … … 1338 1375 else 1339 1376 { 1340 LogRel((" Host path '%ls', map name '%ls', %s, automount=%s, create_symlinks=%s, missing=%s\n", 1341 ((SHFLSTRING *)paParms[0].u.pointer.addr)->String.ucs2, 1342 ((SHFLSTRING *)paParms[1].u.pointer.addr)->String.ucs2, 1377 LogRel((" Host path '%ls', map name '%ls', %s, automount=%s, automntpnt=%s, create_symlinks=%s, missing=%s\n", 1378 pHostPath->String.utf16, pMapName->String.utf16, 1343 1379 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_WRITABLE) ? "writable" : "read-only", 1344 1380 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_AUTOMOUNT) ? "true" : "false", 1381 pAutoMountPoint->String.utf16, 1345 1382 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_CREATE_SYMLINKS) ? "true" : "false", 1346 1383 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_MISSING) ? "true" : "false")); 1347 1384 1348 char *pszFolderName; 1349 rc = RTUtf16ToUtf8(pFolderName->String.ucs2, &pszFolderName); 1350 1385 char *pszHostPath; 1386 rc = RTUtf16ToUtf8(pHostPath->String.ucs2, &pszHostPath); 1351 1387 if (RT_SUCCESS(rc)) 1352 1388 { 1353 1389 /* Execute the function. */ 1354 rc = vbsfMappingsAdd(psz FolderName, pMapName,1390 rc = vbsfMappingsAdd(pszHostPath, pMapName, 1355 1391 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_WRITABLE), 1356 1392 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_AUTOMOUNT), 1393 pAutoMountPoint, 1357 1394 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_CREATE_SYMLINKS), 1358 1395 RT_BOOL(fFlags & SHFL_ADD_MAPPING_F_MISSING), … … 1363 1400 ; /* none */ 1364 1401 } 1365 RTStrFree(psz FolderName);1402 RTStrFree(pszHostPath); 1366 1403 } 1367 1404 } -
trunk/src/VBox/HostServices/SharedFolders/testcase/tstSharedFolderService.cpp
r69753 r75380 617 617 union TESTSHFLSTRING FolderName; 618 618 union TESTSHFLSTRING Mapping; 619 union TESTSHFLSTRING AutoMountPoint; 619 620 VBOXHGCMCALLHANDLE_TYPEDEF callHandle = { VINF_SUCCESS }; 620 621 int rc; … … 627 628 fillTestShflString(&FolderName, pcszFolderName); 628 629 fillTestShflString(&Mapping, pcszMapping); 630 fillTestShflString(&AutoMountPoint, ""); 629 631 aParms[0].setPointer(&FolderName, RT_UOFFSETOF(SHFLSTRING, String) 630 632 + FolderName.string.u16Size); … … 632 634 + Mapping.string.u16Size); 633 635 aParms[2].setUInt32(1); 636 aParms[3].setPointer(&AutoMountPoint, SHFLSTRING_HEADER_SIZE + AutoMountPoint.string.u16Size); 634 637 rc = psvcTable->pfnHostCall(psvcTable->pvService, SHFL_FN_ADD_MAPPING, 635 638 SHFL_CPARMS_ADD_MAPPING, aParms); -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r75371 r75380 1960 1960 <interface 1961 1961 name="IVirtualBox" extends="$unknown" 1962 uuid=" 176b85cd-4bc2-453e-9228-f408c5282267"1962 uuid="606da9e2-032b-4c82-3bf0-3675789df7b9" 1963 1963 wsmap="managed" 1964 1964 reservedMethods="7" reservedAttributes="12" … … 2692 2692 <desc>Whether the share gets automatically mounted by the guest 2693 2693 or not.</desc> 2694 </param> 2695 <param name="autoMountPoint" type="wstring" dir="in"> 2696 <desc>Where the guest should automatically mount the folder, if possible. 2697 For Windows and OS/2 guests this should be a drive letter, while other 2698 guests it should be a absolute directory. 2699 </desc> 2694 2700 </param> 2695 2701 </method> … … 5221 5227 <interface 5222 5228 name="IMachine" extends="$unknown" 5223 uuid=" BD65ADC6-7F47-4F69-B881-96EA06CF9924"5229 uuid="cfc5671a-2309-4893-8744-ba4c07d65d86" 5224 5230 wsmap="managed" 5225 5231 wrap-hint-server-addinterfaces="IInternalMachineControl" … … 7805 7811 or not.</desc> 7806 7812 </param> 7813 <param name="autoMountPoint" type="wstring" dir="in"> 7814 <desc>Where the guest should automatically mount the folder, if possible. 7815 For Windows and OS/2 guests this should be a drive letter, while other 7816 guests it should be a absolute directory. 7817 </desc> 7818 </param> 7807 7819 </method> 7808 7820 … … 9317 9329 <desc>Whether the share gets automatically mounted by the guest 9318 9330 or not.</desc> 9331 </param> 9332 <param name="autoMountPoint" type="wstring" dir="in"> 9333 <desc>Where the guest should automatically mount the folder, if possible. 9334 For Windows and OS/2 guests this should be a drive letter, while other 9335 guests it should be a absolute directory. 9336 </desc> 9319 9337 </param> 9320 9338 </method> … … 20520 20538 <interface 20521 20539 name="ISharedFolder" extends="$unknown" 20522 uuid=" 15aabe95-e594-4e18-9222-b5e83a23f1da"20540 uuid="e02c0f1e-15f4-440e-3814-bbf613f8448b" 20523 20541 wsmap="struct" 20524 20542 reservedAttributes="4" … … 20602 20620 <desc> 20603 20621 Whether the folder gets automatically mounted by the guest or not. 20622 </desc> 20623 </attribute> 20624 20625 <attribute name="autoMountPoint" type="wstring" readonly="yes"> 20626 <desc> 20627 Desired mount point in the guest for automatically mounting the folder 20628 when <link to="ISharedFolder::autoMount"/> is set. For Windows and 20629 OS/2 guests this should be a drive letter, while other guests it should 20630 be a absolute directory. 20631 20632 When empty the guest will choose a mount point. The guest may do so 20633 too should the specified mount point be in use or otherwise unusable. 20604 20634 </desc> 20605 20635 </attribute> -
trunk/src/VBox/Main/include/ConsoleImpl.h
r75361 r75380 342 342 const com::Utf8Str &aHostPath, 343 343 BOOL aWritable, 344 BOOL aAutomount); 344 BOOL aAutomount, 345 const com::Utf8Str &aAutoMountPoint); 345 346 HRESULT removeSharedFolder(const com::Utf8Str &aName); 346 347 HRESULT teleport(const com::Utf8Str &aHostname, … … 549 550 SharedFolderData(const Utf8Str &aHostPath, 550 551 bool aWritable, 551 bool aAutoMount) 552 : m_strHostPath(aHostPath), 553 m_fWritable(aWritable), 554 m_fAutoMount(aAutoMount) 552 bool aAutoMount, 553 const Utf8Str &aAutoMountPoint) 554 : m_strHostPath(aHostPath) 555 , m_fWritable(aWritable) 556 , m_fAutoMount(aAutoMount) 557 , m_strAutoMountPoint(aAutoMountPoint) 555 558 { } 556 559 557 560 // copy constructor 558 561 SharedFolderData(const SharedFolderData& aThat) 559 : m_strHostPath(aThat.m_strHostPath), 560 m_fWritable(aThat.m_fWritable), 561 m_fAutoMount(aThat.m_fAutoMount) 562 : m_strHostPath(aThat.m_strHostPath) 563 , m_fWritable(aThat.m_fWritable) 564 , m_fAutoMount(aThat.m_fAutoMount) 565 , m_strAutoMountPoint(aThat.m_strAutoMountPoint) 562 566 { } 563 567 … … 565 569 bool m_fWritable; 566 570 bool m_fAutoMount; 571 Utf8Str m_strAutoMountPoint; 567 572 }; 568 573 … … 820 825 821 826 static const char *sSSMConsoleUnit; 822 static uint32_t sSSMConsoleVer;823 827 824 828 HRESULT i_loadDataFromSavedState(); -
trunk/src/VBox/Main/include/MachineImpl.h
r75361 r75380 1115 1115 const com::Utf8Str &aHostPath, 1116 1116 BOOL aWritable, 1117 BOOL aAutomount); 1117 BOOL aAutomount, 1118 const com::Utf8Str &aAutoMountPoint); 1118 1119 HRESULT removeSharedFolder(const com::Utf8Str &aName); 1119 1120 HRESULT canShowConsoleWindow(BOOL *aCanShow); -
trunk/src/VBox/Main/include/SharedFolderImpl.h
r69500 r75380 1 1 /* $Id$ */ 2 2 /** @file 3 *4 3 * VirtualBox COM class implementation 5 4 */ … … 36 35 37 36 // public initializer/uninitializer for internal purposes only 38 HRESULT init(Machine *aMachine, const com::Utf8Str &aName, const com::Utf8Str &aHostPath, bool aWritable, bool aAutoMount, bool fFailOnError); 37 HRESULT init(Machine *aMachine, const com::Utf8Str &aName, const com::Utf8Str &aHostPath, 38 bool aWritable, bool aAutoMount, const com::Utf8Str &aAutoMountPoint, bool fFailOnError); 39 39 HRESULT initCopy(Machine *aMachine, SharedFolder *aThat); 40 HRESULT init(Console *aConsole, const com::Utf8Str &aName, const com::Utf8Str &aHostPath, bool aWritable, bool aAutoMount, bool fFailOnError); 41 // HRESULT init(VirtualBox *aVirtualBox, const Utf8Str &aName, const Utf8Str &aHostPath, bool aWritable, bool aAutoMount, bool fFailOnError); 40 HRESULT init(Console *aConsole, const com::Utf8Str &aName, const com::Utf8Str &aHostPath, 41 bool aWritable, bool aAutoMount, const com::Utf8Str &aAutoMountPoint, bool fFailOnError); 42 // HRESULT init(VirtualBox *aVirtualBox, const Utf8Str &aName, const Utf8Str &aHostPath, 43 // bool aWritable, const com::Utf8Str &aAutoMountPoint, bool aAutoMount, bool fFailOnError); 42 44 void uninit(); 43 45 … … 49 51 * @return 50 52 */ 51 const Utf8Str &i_getName() const;53 const Utf8Str &i_getName() const; 52 54 53 55 /** … … 55 57 * @return 56 58 */ 57 const Utf8Str &i_getHostPath() const;59 const Utf8Str &i_getHostPath() const; 58 60 59 61 /** … … 69 71 bool i_isAutoMounted() const; 70 72 73 /** 74 * Public internal method for getting the auto mount point. 75 */ 76 const Utf8Str &i_getAutoMountPoint() const; 77 71 78 protected: 72 79 … … 76 83 bool aWritable, 77 84 bool aAutoMount, 85 const com::Utf8Str &aAutoMountPoint, 78 86 bool fFailOnError); 79 87 private: … … 85 93 HRESULT getWritable(BOOL *aWritable); 86 94 HRESULT getAutoMount(BOOL *aAutoMount); 95 HRESULT getAutoMountPoint(com::Utf8Str &aAutoMountPoint); 87 96 HRESULT getLastAccessError(com::Utf8Str &aLastAccessError); 88 97 … … 101 110 }; 102 111 103 #endif // ____H_SHAREDFOLDERIMPL112 #endif // !____H_SHAREDFOLDERIMPL 104 113 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r73716 r75380 329 329 const com::Utf8Str &aHostPath, 330 330 BOOL aWritable, 331 BOOL aAutomount); 331 BOOL aAutomount, 332 const com::Utf8Str &aAutoMountPoint); 332 333 HRESULT removeSharedFolder(const com::Utf8Str &aName); 333 334 HRESULT getExtraDataKeys(std::vector<com::Utf8Str> &aKeys); -
trunk/src/VBox/Main/src-all/SharedFolderImpl.cpp
r73003 r75380 46 46 bool fWritable; 47 47 bool fAutoMount; 48 const Utf8Str strAutoMountPoint; 48 49 Utf8Str strLastAccessError; 49 50 }; … … 95 96 * @param aWritable writable if true, readonly otherwise 96 97 * @param aAutoMount if auto mounted by guest true, false otherwise 98 * @param aAutoMountPoint Where the guest should try auto mount it. 97 99 * @param fFailOnError Whether to fail with an error if the shared folder path is bad. 98 100 * … … 104 106 bool aWritable, 105 107 bool aAutoMount, 108 const Utf8Str &aAutoMountPoint, 106 109 bool fFailOnError) 107 110 { … … 112 115 unconst(mMachine) = aMachine; 113 116 114 HRESULT rc = i_protectedInit(aMachine, aName, aHostPath, aWritable, aAutoMount, fFailOnError);117 HRESULT rc = i_protectedInit(aMachine, aName, aHostPath, aWritable, aAutoMount, aAutoMountPoint, fFailOnError); 115 118 116 119 /* Confirm a successful initialization when it's the case */ … … 146 149 aThat->m->fWritable, 147 150 aThat->m->fAutoMount, 151 aThat->m->strAutoMountPoint, 148 152 false /* fFailOnError */ ); 149 153 … … 166 170 * @param aHostPath full path to the shared folder on the host 167 171 * @param aWritable writable if true, readonly otherwise 172 * @param aAutoMountPoint Where the guest should try auto mount it. 168 173 * @param fFailOnError Whether to fail with an error if the shared folder path is bad. 169 174 * … … 175 180 bool aWritable, 176 181 bool aAutoMount, 182 const Utf8Str &aAutoMountPoint 177 183 bool fFailOnError) 178 184 { … … 183 189 unconst(mVirtualBox) = aVirtualBox; 184 190 185 HRESULT rc = protectedInit(aVirtualBox, aName, aHostPath, aWritable, aAutoMount );191 HRESULT rc = protectedInit(aVirtualBox, aName, aHostPath, aWritable, aAutoMount, aAutoMountPoint, fFailOnError); 186 192 187 193 /* Confirm a successful initialization when it's the case */ … … 205 211 * @param aHostPath full path to the shared folder on the host 206 212 * @param aWritable writable if true, readonly otherwise 213 * @param aAutoMountPoint Where the guest should try auto mount it. 207 214 * @param fFailOnError Whether to fail with an error if the shared folder path is bad. 208 215 * … … 214 221 bool aWritable, 215 222 bool aAutoMount, 223 const Utf8Str &aAutoMountPoint, 216 224 bool fFailOnError) 217 225 { … … 222 230 unconst(mConsole) = aConsole; 223 231 224 HRESULT rc = i_protectedInit(aConsole, aName, aHostPath, aWritable, aAutoMount, fFailOnError);232 HRESULT rc = i_protectedInit(aConsole, aName, aHostPath, aWritable, aAutoMount, aAutoMountPoint, fFailOnError); 225 233 226 234 /* Confirm a successful initialization when it's the case */ … … 243 251 bool aWritable, 244 252 bool aAutoMount, 253 const Utf8Str &aAutoMountPoint, 245 254 bool fFailOnError) 246 255 { … … 260 269 * accept both the slashified paths and not. */ 261 270 #if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS) 262 if ( hostPathLen > 2 &&263 RTPATH_IS_SEP (hostPath.c_str()[hostPathLen - 1]) &&264 RTPATH_IS_VOLSEP(hostPath.c_str()[hostPathLen - 2]))271 if ( hostPathLen > 2 272 && RTPATH_IS_SEP(hostPath.c_str()[hostPathLen - 1]) 273 && RTPATH_IS_VOLSEP(hostPath.c_str()[hostPathLen - 2])) 265 274 ; 266 275 #else … … 292 301 m->fWritable = aWritable; 293 302 m->fAutoMount = aAutoMount; 303 unconst(m->strAutoMountPoint) = aAutoMountPoint; 294 304 295 305 return S_OK; … … 385 395 } 386 396 397 HRESULT SharedFolder::getAutoMountPoint(com::Utf8Str &aAutoMountPoint) 398 { 399 /* strAutoMountPoint is constant during life time, no need to lock. */ 400 aAutoMountPoint = m->strAutoMountPoint; 401 return S_OK; 402 } 403 404 387 405 HRESULT SharedFolder::getLastAccessError(com::Utf8Str &aLastAccessError) 388 406 { … … 415 433 } 416 434 435 const Utf8Str &SharedFolder::i_getAutoMountPoint() const 436 { 437 return m->strAutoMountPoint; 438 } 439 417 440 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r75361 r75380 1516 1516 //static 1517 1517 const char *Console::sSSMConsoleUnit = "ConsoleData"; 1518 //static 1519 uint32_t Console::sSSMConsoleVer = 0x00010001; 1518 /** The saved state version. */ 1519 #define CONSOLE_SAVED_STATE_VERSION UINT32_C(0x00010002) 1520 /** The saved state version, pre shared folder autoMountPoint. */ 1521 #define CONSOLE_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT UINT32_C(0x00010001) 1520 1522 1521 1523 inline static const char *networkAdapterTypeToName(NetworkAdapterType_T adapterType) … … 1569 1571 uint32_t version = 0; 1570 1572 vrc = SSMR3Seek(ssm, sSSMConsoleUnit, 0 /* iInstance */, &version); 1571 if (SSM_VERSION_MAJOR(version) == SSM_VERSION_MAJOR( sSSMConsoleVer))1573 if (SSM_VERSION_MAJOR(version) == SSM_VERSION_MAJOR(CONSOLE_SAVED_STATE_VERSION)) 1572 1574 { 1573 1575 if (RT_SUCCESS(vrc)) … … 1614 1616 AutoReadLock alock(that COMMA_LOCKVAL_SRC_POS); 1615 1617 1616 int vrc = SSMR3PutU32(pSSM, (uint32_t)that->m_mapSharedFolders.size()); 1617 AssertRC(vrc); 1618 SSMR3PutU32(pSSM, (uint32_t)that->m_mapSharedFolders.size()); 1618 1619 1619 1620 for (SharedFolderMap::const_iterator it = that->m_mapSharedFolders.begin(); … … 1625 1626 AutoReadLock sfLock(pSF COMMA_LOCKVAL_SRC_POS); 1626 1627 1627 Utf8Str name = pSF->i_getName(); 1628 vrc = SSMR3PutU32(pSSM, (uint32_t)name.length() + 1 /* term. 0 */); 1629 AssertRC(vrc); 1630 vrc = SSMR3PutStrZ(pSSM, name.c_str()); 1631 AssertRC(vrc); 1632 1633 Utf8Str hostPath = pSF->i_getHostPath(); 1634 vrc = SSMR3PutU32(pSSM, (uint32_t)hostPath.length() + 1 /* term. 0 */); 1635 AssertRC(vrc); 1636 vrc = SSMR3PutStrZ(pSSM, hostPath.c_str()); 1637 AssertRC(vrc); 1638 1639 vrc = SSMR3PutBool(pSSM, !!pSF->i_isWritable()); 1640 AssertRC(vrc); 1641 1642 vrc = SSMR3PutBool(pSSM, !!pSF->i_isAutoMounted()); 1643 AssertRC(vrc); 1644 } 1645 1646 return; 1628 const Utf8Str &name = pSF->i_getName(); 1629 SSMR3PutU32(pSSM, (uint32_t)name.length() + 1 /* term. 0 */); 1630 SSMR3PutStrZ(pSSM, name.c_str()); 1631 1632 const Utf8Str &hostPath = pSF->i_getHostPath(); 1633 SSMR3PutU32(pSSM, (uint32_t)hostPath.length() + 1 /* term. 0 */); 1634 SSMR3PutStrZ(pSSM, hostPath.c_str()); 1635 1636 SSMR3PutBool(pSSM, !!pSF->i_isWritable()); 1637 SSMR3PutBool(pSSM, !!pSF->i_isAutoMounted()); 1638 1639 const Utf8Str &rStrAutoMountPoint = pSF->i_getAutoMountPoint(); 1640 SSMR3PutU32(pSSM, (uint32_t)rStrAutoMountPoint.length() + 1 /* term. 0 */); 1641 SSMR3PutStrZ(pSSM, rStrAutoMountPoint.c_str()); 1642 } 1647 1643 } 1648 1644 … … 1665 1661 LogFlowFunc(("\n")); 1666 1662 1667 if (SSM_VERSION_MAJOR_CHANGED(uVersion, sSSMConsoleVer))1663 if (SSM_VERSION_MAJOR_CHANGED(uVersion, CONSOLE_SAVED_STATE_VERSION)) 1668 1664 return VERR_VERSION_MISMATCH; 1669 1665 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); … … 1706 1702 bool autoMount = false; 1707 1703 1708 uint32_t szBuf= 0;1704 uint32_t cbStr = 0; 1709 1705 char *buf = NULL; 1710 1706 1711 vrc = SSMR3GetU32(pSSM, & szBuf);1707 vrc = SSMR3GetU32(pSSM, &cbStr); 1712 1708 AssertRCReturn(vrc, vrc); 1713 buf = new char[ szBuf];1714 vrc = SSMR3GetStrZ(pSSM, buf, szBuf);1709 buf = new char[cbStr]; 1710 vrc = SSMR3GetStrZ(pSSM, buf, cbStr); 1715 1711 AssertRC(vrc); 1716 1712 strName = buf; 1717 1713 delete[] buf; 1718 1714 1719 vrc = SSMR3GetU32(pSSM, & szBuf);1715 vrc = SSMR3GetU32(pSSM, &cbStr); 1720 1716 AssertRCReturn(vrc, vrc); 1721 buf = new char[ szBuf];1722 vrc = SSMR3GetStrZ(pSSM, buf, szBuf);1717 buf = new char[cbStr]; 1718 vrc = SSMR3GetStrZ(pSSM, buf, cbStr); 1723 1719 AssertRC(vrc); 1724 1720 strHostPath = buf; 1725 1721 delete[] buf; 1726 1722 1727 if (u32Version > 0x00010000)1723 if (u32Version >= CONSOLE_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT) 1728 1724 SSMR3GetBool(pSSM, &writable); 1729 1725 1730 if (u32Version > 0x00010000) // ??? 1726 if ( u32Version >= CONSOLE_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT 1727 #ifndef VBOX_OSE /* This broke saved state when introduced in r63916 (4.0). */ 1728 && SSMR3HandleRevision(pSSM) >= 63916 1729 #endif 1730 ) 1731 1731 SSMR3GetBool(pSSM, &autoMount); 1732 1733 Utf8Str strAutoMountPoint; 1734 if (u32Version >= CONSOLE_SAVED_STATE_VERSION) 1735 { 1736 vrc = SSMR3GetU32(pSSM, &cbStr); 1737 AssertRCReturn(vrc, vrc); 1738 vrc = strAutoMountPoint.reserveNoThrow(cbStr); 1739 AssertRCReturn(vrc, vrc); 1740 vrc = SSMR3GetStrZ(pSSM, strAutoMountPoint.mutableRaw(), cbStr); 1741 AssertRCReturn(vrc, vrc); 1742 strAutoMountPoint.jolt(); 1743 } 1732 1744 1733 1745 ComObjPtr<SharedFolder> pSharedFolder; … … 1738 1750 writable, 1739 1751 autoMount, 1752 strAutoMountPoint, 1740 1753 false /* fFailOnError */); 1741 1754 AssertComRCReturn(rc, VERR_INTERNAL_ERROR); … … 2941 2954 } 2942 2955 2943 HRESULT Console::createSharedFolder(const com::Utf8Str &aName, const com::Utf8Str &aHostPath, BOOL aWritable, BOOL aAutomount) 2956 HRESULT Console::createSharedFolder(const com::Utf8Str &aName, const com::Utf8Str &aHostPath, BOOL aWritable, 2957 BOOL aAutomount, const com::Utf8Str &aAutoMountPoint) 2944 2958 { 2945 2959 LogFlowThisFunc(("Entering for '%s' -> '%s'\n", aName.c_str(), aHostPath.c_str())); … … 2974 2988 !!aWritable, 2975 2989 !!aAutomount, 2990 aAutoMountPoint, 2976 2991 true /* fFailOnError */); 2977 2992 if (FAILED(rc)) return rc; … … 2995 3010 2996 3011 /* second, create the given folder */ 2997 rc = i_createSharedFolder(aName, SharedFolderData(aHostPath, !!aWritable, !!aAutomount ));3012 rc = i_createSharedFolder(aName, SharedFolderData(aHostPath, !!aWritable, !!aAutomount, aAutoMountPoint)); 2998 3013 if (FAILED(rc)) 2999 3014 return rc; … … 7683 7698 sharedFolders[it->first] = SharedFolderData(pSF->i_getHostPath(), 7684 7699 pSF->i_isWritable(), 7685 pSF->i_isAutoMounted()); 7700 pSF->i_isAutoMounted(), 7701 pSF->i_getAutoMountPoint()); 7686 7702 } 7687 7703 } … … 8441 8457 ComPtr<ISharedFolder> pSharedFolder = folders[i]; 8442 8458 8443 Bstr bstrName; 8444 Bstr bstrHostPath; 8459 Bstr bstr; 8460 rc = pSharedFolder->COMGETTER(Name)(bstr.asOutParam()); 8461 if (FAILED(rc)) throw rc; 8462 Utf8Str strName(bstr); 8463 8464 rc = pSharedFolder->COMGETTER(HostPath)(bstr.asOutParam()); 8465 if (FAILED(rc)) throw rc; 8466 Utf8Str strHostPath(bstr); 8467 8445 8468 BOOL writable; 8446 BOOL autoMount;8447 8448 rc = pSharedFolder->COMGETTER(Name)(bstrName.asOutParam());8449 if (FAILED(rc)) throw rc;8450 Utf8Str strName(bstrName);8451 8452 rc = pSharedFolder->COMGETTER(HostPath)(bstrHostPath.asOutParam());8453 if (FAILED(rc)) throw rc;8454 Utf8Str strHostPath(bstrHostPath);8455 8456 8469 rc = pSharedFolder->COMGETTER(Writable)(&writable); 8457 8470 if (FAILED(rc)) throw rc; 8458 8471 8472 BOOL autoMount; 8459 8473 rc = pSharedFolder->COMGETTER(AutoMount)(&autoMount); 8460 8474 if (FAILED(rc)) throw rc; 8461 8475 8476 rc = pSharedFolder->COMGETTER(AutoMountPoint)(bstr.asOutParam()); 8477 if (FAILED(rc)) throw rc; 8478 Utf8Str strAutoMountPoint(bstr); 8479 8462 8480 m_mapMachineSharedFolders.insert(std::make_pair(strName, 8463 SharedFolderData(strHostPath, !!writable, !!autoMount))); 8481 SharedFolderData(strHostPath, !!writable, 8482 !!autoMount, strAutoMountPoint))); 8464 8483 8465 8484 /* send changes to HGCM if the VM is running */ … … 8488 8507 /* create the new machine folder */ 8489 8508 rc = i_createSharedFolder(strName, 8490 SharedFolderData(strHostPath, !!writable, !!autoMount ));8509 SharedFolderData(strHostPath, !!writable, !!autoMount, strAutoMountPoint)); 8491 8510 if (FAILED(rc)) throw rc; 8492 8511 } … … 8577 8596 HRESULT Console::i_createSharedFolder(const Utf8Str &strName, const SharedFolderData &aData) 8578 8597 { 8598 Log(("Adding shared folder '%s' -> '%s'\n", strName.c_str(), aData.m_strHostPath.c_str())); 8599 8600 /* 8601 * Sanity checks 8602 */ 8579 8603 ComAssertRet(strName.isNotEmpty(), E_FAIL); 8580 8604 ComAssertRet(aData.m_strHostPath.isNotEmpty(), E_FAIL); 8581 8605 8582 /* sanity checks */8583 8606 AssertReturn(mpUVM, E_FAIL); 8584 8607 AssertReturn(m_pVMMDev && m_pVMMDev->isShFlActive(), E_FAIL); 8585 8608 8586 VBOXHGCMSVCPARM parms[SHFL_CPARMS_ADD_MAPPING]; 8587 SHFLSTRING *pFolderName, *pMapName; 8588 size_t cbString; 8589 8590 Bstr value; 8591 HRESULT hrc = mMachine->GetExtraData(BstrFmt("VBoxInternal2/SharedFoldersEnableSymlinksCreate/%s", 8592 strName.c_str()).raw(), 8593 value.asOutParam()); 8594 bool fSymlinksCreate = hrc == S_OK && value == "1"; 8595 8596 Log(("Adding shared folder '%s' -> '%s'\n", strName.c_str(), aData.m_strHostPath.c_str())); 8597 8598 // check whether the path is valid and exists 8599 char hostPathFull[RTPATH_MAX]; 8600 int vrc = RTPathAbsEx(NULL, 8601 aData.m_strHostPath.c_str(), 8602 hostPathFull, 8603 sizeof(hostPathFull)); 8604 8605 bool fMissing = false; 8609 /* 8610 * Find out whether we should allow symbolic link creation. 8611 */ 8612 Bstr bstrValue; 8613 HRESULT hrc = mMachine->GetExtraData(BstrFmt("VBoxInternal2/SharedFoldersEnableSymlinksCreate/%s", strName.c_str()).raw(), 8614 bstrValue.asOutParam()); 8615 bool fSymlinksCreate = hrc == S_OK && bstrValue == "1"; 8616 8617 /* 8618 * Check whether the path is valid and exists. 8619 */ 8620 char szAbsHostPath[RTPATH_MAX]; 8621 int vrc = RTPathAbsEx(NULL, aData.m_strHostPath.c_str(), szAbsHostPath, sizeof(szAbsHostPath)); 8606 8622 if (RT_FAILURE(vrc)) 8607 8623 return setErrorBoth(E_INVALIDARG, vrc, tr("Invalid shared folder path: '%s' (%Rrc)"), aData.m_strHostPath.c_str(), vrc); 8608 if (!RTPathExists(hostPathFull)) 8609 fMissing = true; 8610 8611 /* Check whether the path is full (absolute) */ 8612 if (RTPathCompare(aData.m_strHostPath.c_str(), hostPathFull) != 0) 8624 8625 /* Check whether the path is full (absolute). ASSUMING a RTPATH_MAX of ~4K 8626 this also checks that the length is within bounds of a SHFLSTRING. */ 8627 if (RTPathCompare(aData.m_strHostPath.c_str(), szAbsHostPath) != 0) 8613 8628 return setError(E_INVALIDARG, 8614 8629 tr("Shared folder path '%s' is not absolute"), 8615 8630 aData.m_strHostPath.c_str()); 8616 8631 8617 // now that we know the path is good, give it to HGCM 8618 8619 Bstr bstrName(strName); 8620 Bstr bstrHostPath(aData.m_strHostPath); 8621 8622 cbString = (bstrHostPath.length() + 1) * sizeof(RTUTF16); 8623 if (cbString >= UINT16_MAX) 8624 return setError(E_INVALIDARG, tr("The name is too long")); 8625 pFolderName = (SHFLSTRING*)RTMemAllocZ(SHFLSTRING_HEADER_SIZE + cbString); 8626 Assert(pFolderName); 8627 memcpy(pFolderName->String.ucs2, bstrHostPath.raw(), cbString); 8628 8629 pFolderName->u16Size = (uint16_t)cbString; 8630 pFolderName->u16Length = (uint16_t)(cbString - sizeof(RTUTF16)); 8631 8632 parms[0].type = VBOX_HGCM_SVC_PARM_PTR; 8633 parms[0].u.pointer.addr = pFolderName; 8634 parms[0].u.pointer.size = ShflStringSizeOfBuffer(pFolderName); 8635 8636 cbString = (bstrName.length() + 1) * sizeof(RTUTF16); 8637 if (cbString >= UINT16_MAX) 8638 { 8639 RTMemFree(pFolderName); 8640 return setError(E_INVALIDARG, tr("The host path is too long")); 8641 } 8642 pMapName = (SHFLSTRING*)RTMemAllocZ(SHFLSTRING_HEADER_SIZE + cbString); 8643 Assert(pMapName); 8644 memcpy(pMapName->String.ucs2, bstrName.raw(), cbString); 8645 8646 pMapName->u16Size = (uint16_t)cbString; 8647 pMapName->u16Length = (uint16_t)(cbString - sizeof(RTUTF16)); 8648 8649 parms[1].type = VBOX_HGCM_SVC_PARM_PTR; 8650 parms[1].u.pointer.addr = pMapName; 8651 parms[1].u.pointer.size = ShflStringSizeOfBuffer(pMapName); 8652 8653 parms[2].type = VBOX_HGCM_SVC_PARM_32BIT; 8654 parms[2].u.uint32 = (aData.m_fWritable ? SHFL_ADD_MAPPING_F_WRITABLE : 0) 8655 | (aData.m_fAutoMount ? SHFL_ADD_MAPPING_F_AUTOMOUNT : 0) 8656 | (fSymlinksCreate ? SHFL_ADD_MAPPING_F_CREATE_SYMLINKS : 0) 8657 | (fMissing ? SHFL_ADD_MAPPING_F_MISSING : 0) 8658 ; 8659 8660 vrc = m_pVMMDev->hgcmHostCall("VBoxSharedFolders", 8661 SHFL_FN_ADD_MAPPING, 8662 SHFL_CPARMS_ADD_MAPPING, &parms[0]); 8663 RTMemFree(pFolderName); 8664 RTMemFree(pMapName); 8665 8666 if (RT_FAILURE(vrc)) 8667 return setErrorBoth(E_FAIL, vrc, tr("Could not create a shared folder '%s' mapped to '%s' (%Rrc)"), 8668 strName.c_str(), aData.m_strHostPath.c_str(), vrc); 8669 8670 if (fMissing) 8671 return setError(E_INVALIDARG, 8672 tr("Shared folder path '%s' does not exist on the host"), 8673 aData.m_strHostPath.c_str()); 8674 8675 return S_OK; 8632 bool const fMissing = !RTPathExists(szAbsHostPath); 8633 8634 /* 8635 * Check the other two string lengths before converting them all to SHFLSTRINGS. 8636 */ 8637 if (strName.length() >= _2K) 8638 return setError(E_INVALIDARG, tr("Shared folder name is too long: %zu bytes"), strName.length()); 8639 if (aData.m_strAutoMountPoint.length() >= RTPATH_MAX) 8640 return setError(E_INVALIDARG, tr("Shared folder mountp point too long: %zu bytes"), aData.m_strAutoMountPoint.length()); 8641 8642 PSHFLSTRING pHostPath = ShflStringDupUtf8AsUtf16(aData.m_strHostPath.c_str()); 8643 PSHFLSTRING pName = ShflStringDupUtf8AsUtf16(strName.c_str()); 8644 PSHFLSTRING pAutoMountPoint = ShflStringDupUtf8AsUtf16(aData.m_strAutoMountPoint.c_str()); 8645 if (pHostPath && pName && pAutoMountPoint) 8646 { 8647 /* 8648 * Make a SHFL_FN_ADD_MAPPING call to tell the service about folder. 8649 */ 8650 VBOXHGCMSVCPARM aParams[SHFL_CPARMS_ADD_MAPPING]; 8651 SHFLSTRING_TO_HGMC_PARAM(&aParams[0], pHostPath); 8652 SHFLSTRING_TO_HGMC_PARAM(&aParams[1], pName); 8653 aParams[2].setUInt32( (aData.m_fWritable ? SHFL_ADD_MAPPING_F_WRITABLE : 0) 8654 | (aData.m_fAutoMount ? SHFL_ADD_MAPPING_F_AUTOMOUNT : 0) 8655 | (fSymlinksCreate ? SHFL_ADD_MAPPING_F_CREATE_SYMLINKS : 0) 8656 | (fMissing ? SHFL_ADD_MAPPING_F_MISSING : 0)); 8657 SHFLSTRING_TO_HGMC_PARAM(&aParams[3], pAutoMountPoint); 8658 AssertCompile(SHFL_CPARMS_ADD_MAPPING == 4); 8659 8660 vrc = m_pVMMDev->hgcmHostCall("VBoxSharedFolders", SHFL_FN_ADD_MAPPING, SHFL_CPARMS_ADD_MAPPING, aParams); 8661 if (RT_FAILURE(vrc)) 8662 hrc = setErrorBoth(E_FAIL, vrc, tr("Could not create a shared folder '%s' mapped to '%s' (%Rrc)"), 8663 strName.c_str(), aData.m_strHostPath.c_str(), vrc); 8664 8665 else if (fMissing) 8666 hrc = setError(E_INVALIDARG, 8667 tr("Shared folder path '%s' does not exist on the host"), 8668 aData.m_strHostPath.c_str()); 8669 else 8670 hrc = S_OK; 8671 } 8672 else 8673 hrc = E_OUTOFMEMORY; 8674 RTMemFree(pAutoMountPoint); 8675 RTMemFree(pName); 8676 RTMemFree(pHostPath); 8677 return hrc; 8676 8678 } 8677 8679 … … 10176 10178 * Register our load/save state file handlers 10177 10179 */ 10178 vrc = SSMR3RegisterExternal(pConsole->mpUVM, sSSMConsoleUnit, 0 /*iInstance*/, sSSMConsoleVer, 0 /* cbGuess */, 10180 vrc = SSMR3RegisterExternal(pConsole->mpUVM, sSSMConsoleUnit, 0 /*iInstance*/, 10181 CONSOLE_SAVED_STATE_VERSION, 0 /* cbGuess */, 10179 10182 NULL, NULL, NULL, 10180 10183 NULL, i_saveStateFileExec, NULL, -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r75361 r75380 5422 5422 } 5423 5423 5424 HRESULT Machine::createSharedFolder(const com::Utf8Str &aName, const com::Utf8Str &aHostPath, BOOL aWritable, BOOL aAutomount) 5424 HRESULT Machine::createSharedFolder(const com::Utf8Str &aName, const com::Utf8Str &aHostPath, BOOL aWritable, 5425 BOOL aAutomount, const com::Utf8Str &aAutoMountPoint) 5425 5426 { 5426 5427 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 5442 5443 !!aWritable, 5443 5444 !!aAutomount, 5445 aAutoMountPoint, 5444 5446 true /* fFailOnError */); 5445 5447 if (FAILED(rc)) return rc; … … 9021 9023 RT_BOOL(sf.fWritable), 9022 9024 RT_BOOL(sf.fAutoMount), 9025 sf.strAutoMountPoint, 9023 9026 false /* fFailOnError */); 9024 9027 if (FAILED(rc)) return rc; … … 10316 10319 sf.fWritable = !!pSF->i_isWritable(); 10317 10320 sf.fAutoMount = !!pSF->i_isAutoMounted(); 10321 sf.strAutoMountPoint = pSF->i_getAutoMountPoint(); 10318 10322 10319 10323 data.llSharedFolders.push_back(sf); -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r73805 r75380 2013 2013 const com::Utf8Str &aHostPath, 2014 2014 BOOL aWritable, 2015 BOOL aAutomount) 2015 BOOL aAutomount, 2016 const com::Utf8Str &aAutoMountPoint) 2016 2017 { 2017 2018 NOREF(aName); … … 2019 2020 NOREF(aWritable); 2020 2021 NOREF(aAutomount); 2022 NOREF(aAutoMountPoint); 2021 2023 2022 2024 return setError(E_NOTIMPL, "Not yet implemented"); -
trunk/src/VBox/Main/xml/Settings.cpp
r75361 r75380 2876 2876 { 2877 2877 return (this == &g) 2878 || ( strName == g.strName 2879 && strHostPath == g.strHostPath 2880 && fWritable == g.fWritable 2881 && fAutoMount == g.fAutoMount); 2878 || ( strName == g.strName 2879 && strHostPath == g.strHostPath 2880 && fWritable == g.fWritable 2881 && fAutoMount == g.fAutoMount 2882 && strAutoMountPoint == g.strAutoMountPoint); 2882 2883 } 2883 2884 … … 4699 4700 pelmFolder->getAttributeValue("writable", sf.fWritable); 4700 4701 pelmFolder->getAttributeValue("autoMount", sf.fAutoMount); 4702 pelmFolder->getAttributeValue("autoMountPoint", sf.strAutoMountPoint); 4701 4703 hw.llSharedFolders.push_back(sf); 4702 4704 } … … 6459 6461 pelmThis->setAttribute("writable", sf.fWritable); 6460 6462 pelmThis->setAttribute("autoMount", sf.fAutoMount); 6463 if (sf.strAutoMountPoint.isNotEmpty()) 6464 pelmThis->setAttribute("autoMountPoint", sf.strAutoMountPoint); 6461 6465 } 6462 6466 } … … 7292 7296 return; 7293 7297 } 7298 if (hardwareMachine.llSharedFolders.size()) 7299 for (SharedFoldersList::const_iterator it = hardwareMachine.llSharedFolders.begin(); 7300 it != hardwareMachine.llSharedFolders.end(); 7301 ++it) 7302 if (it->strAutoMountPoint.isNotEmpty()) 7303 { 7304 m->sv = SettingsVersion_v1_17; 7305 return; 7306 } 7294 7307 7295 7308 /*
Note:
See TracChangeset
for help on using the changeset viewer.