|
Hans de Goede |
32e434 |
From 369dd2ee3c82c4417fee04aeec933c74fd198e78 Mon Sep 17 00:00:00 2001
|
|
Hans de Goede |
32e434 |
From: Hans de Goede <hdegoede@redhat.com>
|
|
Hans de Goede |
32e434 |
Date: Tue, 23 Jan 2018 15:09:20 +0100
|
|
Hans de Goede |
32e434 |
Subject: [PATCH resend] VBoxServiceAutoMount: Change Linux mount code to use
|
|
Hans de Goede |
32e434 |
an options string
|
|
Hans de Goede |
32e434 |
|
|
Hans de Goede |
32e434 |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Hans de Goede |
32e434 |
---
|
|
Hans de Goede |
32e434 |
.../common/VBoxService/VBoxServiceAutoMount.cpp | 62 +++-------------------
|
|
Hans de Goede |
32e434 |
1 file changed, 8 insertions(+), 54 deletions(-)
|
|
Hans de Goede |
32e434 |
|
|
Hans de Goede |
32e434 |
diff --git a/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp b/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp
|
|
Hans de Goede |
32e434 |
index aa15d8b1..551edd4a 100644
|
|
Hans de Goede |
32e434 |
--- a/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp
|
|
Hans de Goede |
32e434 |
+++ b/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp
|
|
Hans de Goede |
32e434 |
@@ -39,6 +39,7 @@
|
|
Hans de Goede |
32e434 |
#include <iprt/assert.h>
|
|
Hans de Goede |
32e434 |
#include <iprt/dir.h>
|
|
Hans de Goede |
32e434 |
#include <iprt/mem.h>
|
|
Hans de Goede |
32e434 |
+#include <iprt/param.h>
|
|
Hans de Goede |
32e434 |
#include <iprt/path.h>
|
|
Hans de Goede |
32e434 |
#include <iprt/string.h>
|
|
Hans de Goede |
32e434 |
#include <iprt/semaphore.h>
|
|
Hans de Goede |
32e434 |
@@ -77,6 +78,9 @@ RT_C_DECLS_END
|
|
Hans de Goede |
32e434 |
# endif
|
|
Hans de Goede |
32e434 |
#endif
|
|
Hans de Goede |
32e434 |
|
|
Hans de Goede |
32e434 |
+#ifndef MAX_MNTOPT_STR
|
|
Hans de Goede |
32e434 |
+#define MAX_MNTOPT_STR PAGE_SIZE
|
|
Hans de Goede |
32e434 |
+#endif
|
|
Hans de Goede |
32e434 |
|
|
Hans de Goede |
32e434 |
/*********************************************************************************************************************************
|
|
Hans de Goede |
32e434 |
* Global Variables *
|
|
Hans de Goede |
32e434 |
@@ -297,13 +301,13 @@ static int vbsvcAutoMountSharedFolder(const char *pszShareName, const char *pszM
|
|
Hans de Goede |
32e434 |
rc = vbsvcAutoMountPrepareMountPoint(pszMountPoint, pszShareName, pOpts);
|
|
Hans de Goede |
32e434 |
if (!fSkip && RT_SUCCESS(rc))
|
|
Hans de Goede |
32e434 |
{
|
|
Hans de Goede |
32e434 |
-#ifdef RT_OS_SOLARIS
|
|
Hans de Goede |
32e434 |
char szOptBuf[MAX_MNTOPT_STR] = { '\0', };
|
|
Hans de Goede |
32e434 |
+ RTStrPrintf(szOptBuf, sizeof(szOptBuf), "uid=%d,gid=%d,dmode=%0o,fmode=%0o,dmask=%0o,fmask=%0o",
|
|
Hans de Goede |
32e434 |
+ pOpts->uid, pOpts->gid, pOpts->dmode, pOpts->fmode, pOpts->dmask, pOpts->fmask);
|
|
Hans de Goede |
32e434 |
+#ifdef RT_OS_SOLARIS
|
|
Hans de Goede |
32e434 |
int fFlags = 0;
|
|
Hans de Goede |
32e434 |
if (pOpts->ronly)
|
|
Hans de Goede |
32e434 |
fFlags |= MS_RDONLY;
|
|
Hans de Goede |
32e434 |
- RTStrPrintf(szOptBuf, sizeof(szOptBuf), "uid=%d,gid=%d,dmode=%0o,fmode=%0o,dmask=%0o,fmask=%0o",
|
|
Hans de Goede |
32e434 |
- pOpts->uid, pOpts->gid, pOpts->dmode, pOpts->fmode, pOpts->dmask, pOpts->fmask);
|
|
Hans de Goede |
32e434 |
int r = mount(pszShareName,
|
|
Hans de Goede |
32e434 |
pszMountPoint,
|
|
Hans de Goede |
32e434 |
fFlags | MS_OPTIONSTR,
|
|
Hans de Goede |
32e434 |
@@ -320,32 +324,11 @@ static int vbsvcAutoMountSharedFolder(const char *pszShareName, const char *pszM
|
|
Hans de Goede |
32e434 |
|
|
Hans de Goede |
32e434 |
#elif defined(RT_OS_LINUX)
|
|
Hans de Goede |
32e434 |
unsigned long fFlags = MS_NODEV;
|
|
Hans de Goede |
32e434 |
-
|
|
Hans de Goede |
32e434 |
- /*const char *szOptions = { "rw" }; - ??? */
|
|
Hans de Goede |
32e434 |
- struct vbsf_mount_info_new mntinf;
|
|
Hans de Goede |
32e434 |
-
|
|
Hans de Goede |
32e434 |
- mntinf.nullchar = '\0';
|
|
Hans de Goede |
32e434 |
- mntinf.signature[0] = VBSF_MOUNT_SIGNATURE_BYTE_0;
|
|
Hans de Goede |
32e434 |
- mntinf.signature[1] = VBSF_MOUNT_SIGNATURE_BYTE_1;
|
|
Hans de Goede |
32e434 |
- mntinf.signature[2] = VBSF_MOUNT_SIGNATURE_BYTE_2;
|
|
Hans de Goede |
32e434 |
- mntinf.length = sizeof(mntinf);
|
|
Hans de Goede |
32e434 |
-
|
|
Hans de Goede |
32e434 |
- mntinf.uid = pOpts->uid;
|
|
Hans de Goede |
32e434 |
- mntinf.gid = pOpts->gid;
|
|
Hans de Goede |
32e434 |
- mntinf.ttl = pOpts->ttl;
|
|
Hans de Goede |
32e434 |
- mntinf.dmode = pOpts->dmode;
|
|
Hans de Goede |
32e434 |
- mntinf.fmode = pOpts->fmode;
|
|
Hans de Goede |
32e434 |
- mntinf.dmask = pOpts->dmask;
|
|
Hans de Goede |
32e434 |
- mntinf.fmask = pOpts->fmask;
|
|
Hans de Goede |
32e434 |
-
|
|
Hans de Goede |
32e434 |
- strcpy(mntinf.name, pszShareName);
|
|
Hans de Goede |
32e434 |
- strcpy(mntinf.nls_name, "\0");
|
|
Hans de Goede |
32e434 |
-
|
|
Hans de Goede |
32e434 |
int r = mount(pszShareName,
|
|
Hans de Goede |
32e434 |
pszMountPoint,
|
|
Hans de Goede |
32e434 |
"vboxsf",
|
|
Hans de Goede |
32e434 |
fFlags,
|
|
Hans de Goede |
32e434 |
- &mntinf);
|
|
Hans de Goede |
32e434 |
+ szOptBuf);
|
|
Hans de Goede |
32e434 |
if (r == 0)
|
|
Hans de Goede |
32e434 |
{
|
|
Hans de Goede |
32e434 |
VGSvcVerbose(0, "vbsvcAutoMountWorker: Shared folder '%s' was mounted to '%s'\n", pszShareName, pszMountPoint);
|
|
Hans de Goede |
32e434 |
@@ -378,34 +361,6 @@ static int vbsvcAutoMountSharedFolder(const char *pszShareName, const char *pszM
|
|
Hans de Goede |
32e434 |
}
|
|
Hans de Goede |
32e434 |
else /* r == -1, we got some error in errno. */
|
|
Hans de Goede |
32e434 |
{
|
|
Hans de Goede |
32e434 |
- if (errno == EPROTO)
|
|
Hans de Goede |
32e434 |
- {
|
|
Hans de Goede |
32e434 |
- VGSvcVerbose(3, "vbsvcAutoMountWorker: Messed up share name, re-trying ...\n");
|
|
Hans de Goede |
32e434 |
-
|
|
Hans de Goede |
32e434 |
- /** @todo r=bird: What on earth is going on here????? Why can't you
|
|
Hans de Goede |
32e434 |
- * strcpy(mntinf.name, pszShareName) to fix it again? */
|
|
Hans de Goede |
32e434 |
-
|
|
Hans de Goede |
32e434 |
- /* Sometimes the mount utility messes up the share name. Try to
|
|
Hans de Goede |
32e434 |
- * un-mangle it again. */
|
|
Hans de Goede |
32e434 |
- char szCWD[RTPATH_MAX];
|
|
Hans de Goede |
32e434 |
- size_t cchCWD;
|
|
Hans de Goede |
32e434 |
- if (!getcwd(szCWD, sizeof(szCWD)))
|
|
Hans de Goede |
32e434 |
- {
|
|
Hans de Goede |
32e434 |
- VGSvcError("vbsvcAutoMountWorker: Failed to get the current working directory\n");
|
|
Hans de Goede |
32e434 |
- szCWD[0] = '\0';
|
|
Hans de Goede |
32e434 |
- }
|
|
Hans de Goede |
32e434 |
- cchCWD = strlen(szCWD);
|
|
Hans de Goede |
32e434 |
- if (!strncmp(pszMountPoint, szCWD, cchCWD))
|
|
Hans de Goede |
32e434 |
- {
|
|
Hans de Goede |
32e434 |
- while (pszMountPoint[cchCWD] == '/')
|
|
Hans de Goede |
32e434 |
- ++cchCWD;
|
|
Hans de Goede |
32e434 |
- /* We checked before that we have enough space */
|
|
Hans de Goede |
32e434 |
- strcpy(mntinf.name, pszMountPoint + cchCWD);
|
|
Hans de Goede |
32e434 |
- }
|
|
Hans de Goede |
32e434 |
- r = mount(mntinf.name, pszMountPoint, "vboxsf", fFlags, &mntinf);
|
|
Hans de Goede |
32e434 |
- }
|
|
Hans de Goede |
32e434 |
- if (r == -1) /* Was there some error from one of the tries above? */
|
|
Hans de Goede |
32e434 |
- {
|
|
Hans de Goede |
32e434 |
switch (errno)
|
|
Hans de Goede |
32e434 |
{
|
|
Hans de Goede |
32e434 |
/* If we get EINVAL here, the system already has mounted the Shared Folder to another
|
|
Hans de Goede |
32e434 |
@@ -424,7 +379,6 @@ static int vbsvcAutoMountSharedFolder(const char *pszShareName, const char *pszM
|
|
Hans de Goede |
32e434 |
rc = RTErrConvertFromErrno(errno);
|
|
Hans de Goede |
32e434 |
break;
|
|
Hans de Goede |
32e434 |
}
|
|
Hans de Goede |
32e434 |
- }
|
|
Hans de Goede |
32e434 |
}
|
|
Hans de Goede |
32e434 |
#else
|
|
Hans de Goede |
32e434 |
# error "PORTME"
|
|
Hans de Goede |
32e434 |
--
|
|
Hans de Goede |
32e434 |
2.14.3
|
|
Hans de Goede |
32e434 |
|