/* * We are always executed from one specific HGCM thread. So thread safe. */ int vbsfMappingsAdd(PSHFLSTRING pFolderName, PSHFLSTRING pMapName, bool fWritable, bool fAutoMount, bool fSymlinksCreate, bool fMissing) { unsigned i; Assert(pFolderName && pMapName); Log(("vbsfMappingsAdd %ls\n", pMapName->String.ucs2)); /* check for duplicates */ for (i=0; i<SHFL_MAX_MAPPINGS; i++) { if (FolderMapping[i].fValid == true) { if (!RTUtf16LocaleICmp(FolderMapping[i].pMapName->String.ucs2, pMapName->String.ucs2)) { AssertMsgFailed(("vbsfMappingsAdd: %ls mapping already exists!!\n", pMapName->String.ucs2)); return VERR_ALREADY_EXISTS; } } } for (i=0; i<SHFL_MAX_MAPPINGS; i++) { if (FolderMapping[i].fValid == false) { int rc = RTUtf16ToUtf8(pFolderName->String.ucs2, &FolderMapping[i].pszFolderName); AssertRCReturn(rc, rc); FolderMapping[i].pMapName = (PSHFLSTRING)RTMemAlloc(ShflStringSizeOfBuffer(pMapName)); if (!FolderMapping[i].pMapName) { RTStrFree(FolderMapping[i].pszFolderName); AssertFailed(); return VERR_NO_MEMORY; } FolderMapping[i].pMapName->u16Length = pMapName->u16Length; FolderMapping[i].pMapName->u16Size = pMapName->u16Size; memcpy(FolderMapping[i].pMapName->String.ucs2, pMapName->String.ucs2, pMapName->u16Size); FolderMapping[i].fValid = true; FolderMapping[i].cMappings = 0; FolderMapping[i].fWritable = fWritable; FolderMapping[i].fAutoMount = fAutoMount; FolderMapping[i].fSymlinksCreate = fSymlinksCreate; FolderMapping[i].fMissing = fMissing; /* Check if the host file system is case sensitive */ RTFSPROPERTIES prop; char *pszAsciiRoot; rc = RTStrUtf8ToCurrentCP(&pszAsciiRoot, FolderMapping[i].pszFolderName); if (RT_SUCCESS(rc)) { rc = RTFsQueryProperties(pszAsciiRoot, &prop); AssertRC(rc); RTStrFree(pszAsciiRoot); } FolderMapping[i].fHostCaseSensitive = RT_SUCCESS(rc) ? prop.fCaseSensitive : false; vbsfRootHandleAdd(i); break; } } if (i == SHFL_MAX_MAPPINGS) { AssertMsgFailed(("vbsfMappingsAdd: no more room to add mapping %ls to %ls!!\n", pFolderName->String.ucs2, pMapName->String.ucs2)); return VERR_TOO_MUCH_DATA; } Log(("vbsfMappingsAdd: added mapping %ls to %ls\n", pFolderName->String.ucs2, pMapName->String.ucs2)); return VINF_SUCCESS; }
int main(int argc, char **argv) { RTR3InitExe(argc, &argv, 0); /* * Process all arguments (including the executable). */ int cErrors = 0; for (int i = 0; i < argc; i++) { RTPrintf("tstRTFsQueries: '%s'...\n", argv[i]); uint32_t u32Serial; int rc = RTFsQuerySerial(argv[i], &u32Serial); if (RT_SUCCESS(rc)) RTPrintf("tstRTFsQueries: u32Serial=%#010RX32\n", u32Serial); else { RTPrintf("tstRTFsQueries: RTFsQuerySerial failed, rc=%Rrc\n", rc); cErrors++; } RTFOFF cbTotal = 42; RTFOFF cbFree = 42; uint32_t cbBlock = 42; uint32_t cbSector = 42; rc = RTFsQuerySizes(argv[i], &cbTotal, &cbFree, &cbBlock, &cbSector); if (RT_SUCCESS(rc)) RTPrintf("tstRTFsQueries: cbTotal=%RTfoff cbFree=%RTfoff cbBlock=%d cbSector=%d\n", cbTotal, cbFree, cbBlock, cbSector); else { RTPrintf("tstRTFsQueries: RTFsQuerySerial failed, rc=%Rrc\n", rc); cErrors++; } rc = RTFsQuerySizes(argv[i], NULL, NULL, NULL, NULL); if (RT_FAILURE(rc)) { RTPrintf("tstRTFsQueries: RTFsQuerySizes(nop) failed, rc=%Rrc\n", rc); cErrors++; } RTFSTYPE enmType; rc = RTFsQueryType(argv[i], &enmType); if (RT_SUCCESS(rc)) RTPrintf("tstRTFsQueries: file system type is '%s'\n", RTFsTypeName(enmType)); else { RTPrintf("tstRTFsQueries: RTFsQueryType failed, rc=%Rrc\n", rc); cErrors++; } RTFSPROPERTIES Props; rc = RTFsQueryProperties(argv[i], &Props); if (RT_SUCCESS(rc)) RTPrintf("tstRTFsQueries: cbMaxComponent=%u %s %s %s %s %s %s\n", Props.cbMaxComponent, Props.fCaseSensitive ? "case" : "not-case", Props.fCompressed ? "compressed" : "not-compressed", Props.fFileCompression ? "file-compression" : "no-file-compression", Props.fReadOnly ? "readonly" : "readwrite", Props.fRemote ? "remote" : "not-remote", Props.fSupportsUnicode ? "supports-unicode" : "doesn't-support-unicode"); else { RTPrintf("tstRTFsQueries: RTFsQueryProperties failed, rc=%Rrc\n", rc); cErrors++; } } if (!cErrors) RTPrintf("tstRTFsQueries: SUCCESS\n"); else RTPrintf("tstRTFsQueries: FAIlURE - %u errors\n", cErrors); return !!cErrors; }