Changeset 78698 in vbox for trunk/src/VBox/HostServices
- Timestamp:
- May 23, 2019 4:44:05 PM (6 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedFolders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedFolders/VBoxSharedFoldersSvc.cpp
r78467 r78698 40 40 #define SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16 2 41 41 #define SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT 3 42 #define SHFL_SAVED_STATE_VERSION 4 42 #define SHFL_SAVED_STATE_VERSION_PRE_ERROR_STYLE 4 43 #define SHFL_SAVED_STATE_VERSION 5 43 44 44 45 … … 92 93 static STAMPROFILE g_StatFlush; 93 94 static STAMPROFILE g_StatFlushFail; 95 static STAMPROFILE g_StatSetErrorStyle; 94 96 static STAMPROFILE g_StatSetUtf8; 95 97 static STAMPROFILE g_StatSetFileSize; … … 170 172 171 173 pClient->fHasMappingCounts = true; 174 pClient->enmErrorStyle = SHFLERRORSTYLE_NATIVE; 172 175 return VINF_SUCCESS; 173 176 } … … 257 260 uint32_t nrMappings; 258 261 SHFLCLIENTDATA *pClient = (SHFLCLIENTDATA *)pvClient; 259 uint32_t len , version;262 uint32_t len; 260 263 261 264 Log(("SharedFolders host service: loading state, u32ClientID = %u\n", u32ClientID)); 262 265 263 int rc = SSMR3GetU32(pSSM, &version); 266 uint32_t uShfVersion = 0; 267 int rc = SSMR3GetU32(pSSM, &uShfVersion); 264 268 AssertRCReturn(rc, rc); 265 269 266 if ( version > SHFL_SAVED_STATE_VERSION 267 || version < SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16) 268 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 270 if ( uShfVersion > SHFL_SAVED_STATE_VERSION 271 || uShfVersion < SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16) 272 return SSMR3SetLoadError(pSSM, VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION, RT_SRC_POS, 273 "Unknown shared folders state version %u!", uShfVersion); 269 274 270 275 rc = SSMR3GetU32(pSSM, &nrMappings); … … 281 286 else if (len != sizeof(*pClient)) 282 287 return SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, 283 "Saved SHFLCLIENTDATA size %u differs from current %u! \n", len, sizeof(*pClient));288 "Saved SHFLCLIENTDATA size %u differs from current %u!", len, sizeof(*pClient)); 284 289 285 290 rc = SSMR3GetMem(pSSM, pClient, len); 286 291 AssertRCReturn(rc, rc); 287 292 293 /* For older saved state, use the default native error style, otherwise 294 check that the restored value makes sense to us. */ 295 if (uShfVersion <= SHFL_SAVED_STATE_VERSION_PRE_ERROR_STYLE) 296 pClient->enmErrorStyle = SHFLERRORSTYLE_NATIVE; 297 else if ( pClient->enmErrorStyle <= kShflErrorStyle_Invalid 298 || pClient->enmErrorStyle >= kShflErrorStyle_End) 299 return SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, 300 "Saved SHFLCLIENTDATA enmErrorStyle value %d is not known/valid!", pClient->enmErrorStyle); 301 288 302 /* We don't actually (fully) restore the state; we simply check if the current state is as we it expect it to be. */ 289 for ( int i=0;i<SHFL_MAX_MAPPINGS;i++)303 for (size_t i = 0; i < SHFL_MAX_MAPPINGS; i++) 290 304 { 291 305 /* Load the saved mapping description and try to find it in the mappings. */ … … 302 316 if (mapping.fValid) 303 317 { 318 /* Load the host path name. */ 304 319 uint32_t cb; 305 306 /* Load the host path name. */307 320 rc = SSMR3GetU32(pSSM, &cb); 308 321 AssertRCReturn(rc, rc); 309 322 310 323 char *pszFolderName; 311 if ( version == SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16)324 if (uShfVersion == SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16) /* (See version range check above.) */ 312 325 { 313 326 AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1), 314 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad folder name size: %#x \n", cb));327 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad folder name size: %#x", cb)); 315 328 PSHFLSTRING pFolderName = (PSHFLSTRING)RTMemAlloc(cb); 316 329 AssertReturn(pFolderName != NULL, VERR_NO_MEMORY); … … 320 333 AssertReturn(pFolderName->u16Size < cb && pFolderName->u16Length < pFolderName->u16Size, 321 334 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, 322 "Bad folder name string: %#x/%#x cb=%#x \n",335 "Bad folder name string: %#x/%#x cb=%#x", 323 336 pFolderName->u16Size, pFolderName->u16Length, cb)); 324 337 … … 341 354 AssertRCReturn(rc, rc); 342 355 AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1), 343 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad map name size: %#x \n", cb));356 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad map name size: %#x", cb)); 344 357 345 358 PSHFLSTRING pMapName = (PSHFLSTRING)RTMemAlloc(cb); … … 350 363 AssertReturn(pMapName->u16Size < cb && pMapName->u16Length < pMapName->u16Size, 351 364 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, 352 "Bad map name string: %#x/%#x cb=%#x \n",365 "Bad map name string: %#x/%#x cb=%#x", 353 366 pMapName->u16Size, pMapName->u16Length, cb)); 354 367 … … 362 375 /* Load the auto mount point. */ 363 376 PSHFLSTRING pAutoMountPoint; 364 if ( version > SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT)377 if (uShfVersion > SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT) 365 378 { 366 379 rc = SSMR3GetU32(pSSM, &cb); 367 380 AssertRCReturn(rc, rc); 368 381 AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1), 369 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad auto mount point size: %#x \n", cb));382 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad auto mount point size: %#x", cb)); 370 383 371 384 pAutoMountPoint = (PSHFLSTRING)RTMemAlloc(cb); … … 376 389 AssertReturn(pAutoMountPoint->u16Size < cb && pAutoMountPoint->u16Length < pAutoMountPoint->u16Size, 377 390 SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, 378 "Bad auto mount point string: %#x/%#x cb=%#x \n",391 "Bad auto mount point string: %#x/%#x cb=%#x", 379 392 pAutoMountPoint->u16Size, pAutoMountPoint->u16Length, cb)); 380 393 … … 1566 1579 paParms[3].u.uint32, paParms[4].u.uint64, paParms[5].u.uint64, 1567 1580 &paParms[6].u.uint64, paParms[7].u.uint64); 1581 break; 1582 } 1583 1584 case SHFL_FN_SET_ERROR_STYLE: 1585 { 1586 pStatFail = pStat = &g_StatSetErrorStyle; 1587 1588 /* Validate input: */ 1589 ASSERT_GUEST_STMT_BREAK(cParms == SHFL_CPARMS_SET_ERROR_STYLE, rc = VERR_WRONG_PARAMETER_COUNT); 1590 ASSERT_GUEST_STMT_BREAK(paParms[0].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* enm32Style */ 1591 ASSERT_GUEST_STMT_BREAK( paParms[0].u.uint32 > (uint32_t)kShflErrorStyle_Invalid 1592 && paParms[0].u.uint32 < (uint32_t)kShflErrorStyle_End, rc = VERR_WRONG_PARAMETER_TYPE); 1593 ASSERT_GUEST_STMT_BREAK(paParms[1].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* u32Reserved */ 1594 ASSERT_GUEST_STMT_BREAK(paParms[1].u.uint32 == 0, rc = VERR_WRONG_PARAMETER_TYPE); 1595 1596 /* Do the work: */ 1597 pClient->enmErrorStyle = (uint8_t)paParms[0].u.uint32; 1598 rc = VINF_SUCCESS; 1568 1599 break; 1569 1600 } … … 1873 1904 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatFlush, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_FLUSH successes", "/HGCM/VBoxSharedFolders/FnFlush"); 1874 1905 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatFlushFail, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_FLUSH failures", "/HGCM/VBoxSharedFolders/FnFlushFail"); 1906 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatSetErrorStyle, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_SET_ERROR_STYLE", "/HGCM/VBoxSharedFolders/FnSetErrorStyle"); 1875 1907 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatSetUtf8, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_SET_UTF8", "/HGCM/VBoxSharedFolders/FnSetUtf8"); 1876 1908 HGCMSvcHlpStamRegister(g_pHelpers, &g_StatSymlink, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_SYMLINK successes", "/HGCM/VBoxSharedFolders/FnSymlink"); -
trunk/src/VBox/HostServices/SharedFolders/shfl.h
r76570 r78698 27 27 #include <VBox/log.h> 28 28 29 /** 30 * Shared Folders client flags. 29 /** Shared Folders client flags. 31 30 * @{ 32 31 */ 33 34 /** Client has queried mappings at least once and, therefore, 35 * the service can process its other requests too. 36 */ 32 /** Client has queried mappings at least once and, therefore, the service can 33 * process its other requests too. */ 37 34 #define SHFL_CF_MAPPINGS_QUERIED (0x00000001) 38 39 35 /** Mappings have been changed since last query. */ 40 36 #define SHFL_CF_MAPPINGS_CHANGED (0x00000002) 41 42 37 /** Client uses UTF8 encoding, if not set then unicode 16 bit (UCS2) is used. */ 43 38 #define SHFL_CF_UTF8 (0x00000004) 44 45 39 /** Client both supports and wants to use symlinks. */ 46 40 #define SHFL_CF_SYMLINKS (0x00000008) 47 48 41 /** The call to SHFL_FN_WAIT_FOR_MAPPINGS_CHANGES will return immediately 49 42 * because of a SHFL_FN_CANCEL_MAPPINGS_CHANGES_WAITS call. */ 50 43 #define SHFL_CF_CANCEL_NEXT_WAIT (0x00000010) 51 52 44 /** @} */ 53 45 54 typedef struct _SHFLCLIENTDATA 46 /** 47 * @note This structure is dumped directly into the saved state, so care must be 48 * taken when extending it! 49 */ 50 typedef struct SHFLCLIENTDATA 55 51 { 56 52 /** Client flags */ … … 58 54 /** Path delimiter. */ 59 55 RTUTF16 PathDelimiter; 60 /** Currently unused.*/61 uint8_t bPadding;56 /** The error style, SHFLERRORSTYLE. */ 57 uint8_t enmErrorStyle; 62 58 /** Set if the client has mapping usage counts. 63 59 * This is for helping with saved state. */
Note:
See TracChangeset
for help on using the changeset viewer.