summaryrefslogtreecommitdiff
path: root/src/VBox/HostServices
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2017-03-08 20:03:24 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2017-03-08 20:03:24 +0000
commit6f06595f312b9130317428c92cfd129ad98213d0 (patch)
tree4e98eb688eabe27d38955176acc97933e95f0c0b /src/VBox/HostServices
parent738bcc6de5479cbe016e3134cee588762ff861e7 (diff)
downloadVirtualBox-svn-6f06595f312b9130317428c92cfd129ad98213d0.tar.gz
SharedFolders: Do RTAbsPath on folder roots, don't double convert to UTF-8 when calling RTFsQueryProperties, testcase workarounds for new absolute path handling.
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@65998 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/HostServices')
-rw-r--r--src/VBox/HostServices/SharedFolders/mappings.cpp21
-rw-r--r--src/VBox/HostServices/SharedFolders/testcase/tstSharedFolderService.cpp20
2 files changed, 22 insertions, 19 deletions
diff --git a/src/VBox/HostServices/SharedFolders/mappings.cpp b/src/VBox/HostServices/SharedFolders/mappings.cpp
index 4b666ba067b..00ec3ab0efa 100644
--- a/src/VBox/HostServices/SharedFolders/mappings.cpp
+++ b/src/VBox/HostServices/SharedFolders/mappings.cpp
@@ -21,6 +21,7 @@
#include "mappings.h"
#include <iprt/alloc.h>
#include <iprt/assert.h>
+#include <iprt/path.h>
#include <iprt/string.h>
#ifdef UNITTEST
@@ -223,7 +224,13 @@ int vbsfMappingsAdd(const char *pszFolderName, PSHFLSTRING pMapName,
{
if (FolderMapping[i].fValid == false)
{
- FolderMapping[i].pszFolderName = RTStrDup(pszFolderName);
+ /* Make sure the folder name is an absolute path, otherwise we're
+ likely to get into trouble with buffer sizes in vbsfPathGuestToHost. */
+ char szAbsFolderName[RTPATH_MAX];
+ int rc = RTPathAbs(pszFolderName, szAbsFolderName, sizeof(szAbsFolderName));
+ AssertRCReturn(rc, rc);
+
+ FolderMapping[i].pszFolderName = RTStrDup(szAbsFolderName);
if (!FolderMapping[i].pszFolderName)
{
return VERR_NO_MEMORY;
@@ -252,16 +259,8 @@ int vbsfMappingsAdd(const char *pszFolderName, PSHFLSTRING pMapName,
/* Check if the host file system is case sensitive */
RTFSPROPERTIES prop;
prop.fCaseSensitive = false; /* Shut up MSC. */
- char *pszAsciiRoot;
-
- int rc = RTStrUtf8ToCurrentCP(&pszAsciiRoot, FolderMapping[i].pszFolderName);
- if (RT_SUCCESS(rc))
- {
- rc = RTFsQueryProperties(pszAsciiRoot, &prop);
- AssertRC(rc);
- RTStrFree(pszAsciiRoot);
- }
-
+ rc = RTFsQueryProperties(FolderMapping[i].pszFolderName, &prop);
+ AssertRC(rc);
FolderMapping[i].fHostCaseSensitive = RT_SUCCESS(rc) ? prop.fCaseSensitive : false;
vbsfRootHandleAdd(i);
break;
diff --git a/src/VBox/HostServices/SharedFolders/testcase/tstSharedFolderService.cpp b/src/VBox/HostServices/SharedFolders/testcase/tstSharedFolderService.cpp
index e553ec3476c..244aa02dd37 100644
--- a/src/VBox/HostServices/SharedFolders/testcase/tstSharedFolderService.cpp
+++ b/src/VBox/HostServices/SharedFolders/testcase/tstSharedFolderService.cpp
@@ -750,8 +750,9 @@ void testCreateFileSimple(RTTEST hTest)
&Result);
RTTEST_CHECK_RC_OK(hTest, rc);
RTTEST_CHECK_MSG(hTest,
- !strcmp(testRTFileOpenName, "/test/mapping/test/file"),
- (hTest, "pszFilename=%s\n", testRTFileOpenName));
+ !strcmp(&testRTFileOpenName[RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS ? 2 : 0],
+ "/test/mapping/test/file"),
+ (hTest, "pszFilename=%s\n", &testRTFileOpenName[RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS ? 2 : 0]));
RTTEST_CHECK_MSG(hTest, testRTFileOpenFlags == 0x181,
(hTest, "fOpen=%llu\n", LLUIFY(testRTFileOpenFlags)));
RTTEST_CHECK_MSG(hTest, Result == SHFL_FILE_CREATED,
@@ -780,11 +781,13 @@ void testCreateDirSimple(RTTEST hTest)
SHFL_CF_DIRECTORY | SHFL_CF_ACCESS_READ, NULL, &Result);
RTTEST_CHECK_RC_OK(hTest, rc);
RTTEST_CHECK_MSG(hTest,
- !strcmp(testRTDirCreatePath, "/test/mapping/test/dir"),
- (hTest, "pszPath=%s\n", testRTDirCreatePath));
+ !strcmp(&testRTDirCreatePath[RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS ? 2 : 0],
+ "/test/mapping/test/dir"),
+ (hTest, "pszPath=%s\n", &testRTDirCreatePath[RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS ? 2 : 0]));
RTTEST_CHECK_MSG(hTest,
- !strcmp(testRTDirOpenName, "/test/mapping/test/dir"),
- (hTest, "pszFilename=%s\n", testRTDirOpenName));
+ !strcmp(&testRTDirOpenName[RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS ? 2 : 0],
+ "/test/mapping/test/dir"),
+ (hTest, "pszFilename=%s\n", &testRTDirOpenName[RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS ? 2 : 0]));
RTTEST_CHECK_MSG(hTest, Result == SHFL_FILE_CREATED,
(hTest, "Result=%d\n", (int) Result));
unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
@@ -923,16 +926,17 @@ void testFSInfoQuerySetFMode(RTTEST hTest)
const RTFILE hcFile = (RTFILE) 0x10000;
const uint32_t fMode = 0660;
SHFLFSOBJINFO Info;
- SHFLHANDLE Handle;
int rc;
RTTestSub(hTest, "Query and set file size");
Root = initWithWritableMapping(hTest, &svcTable, &svcHelpers,
"/test/mapping", "testname");
+ SHFLHANDLE Handle = SHFL_HANDLE_NIL;
testRTFileOpenpFile = hcFile;
rc = createFile(&svcTable, Root, "/test/file", SHFL_CF_ACCESS_READ,
&Handle, NULL);
- RTTEST_CHECK_RC_OK(hTest, rc);
+ RTTEST_CHECK_RC_OK_RETV(hTest, rc);
+
RT_ZERO(Info);
testRTFileQueryInfoFMode = fMode;
rc = sfInformation(&svcTable, Root, Handle, SHFL_INFO_FILE, sizeof(Info),