|
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
|
|
|
8c7d23 |
--- ./src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp.orig 2018-11-25 02:36:31.829306539 +0000
|
|
|
8c7d23 |
+++ ./src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp 2018-11-25 02:41:41.632973288 +0000
|
|
|
8c7d23 |
@@ -40,6 +40,7 @@
|
|
|
8c7d23 |
#include <iprt/ctype.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/semaphore.h>
|
|
|
8c7d23 |
#include <iprt/sort.h>
|
|
|
8c7d23 |
@@ -117,6 +118,9 @@ RT_C_DECLS_END
|
|
|
8c7d23 |
# define VBOXSERVICE_AUTOMOUNT_MIQF SHFL_MIQF_PATH
|
|
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 |
/*********************************************************************************************************************************
|
|
|
8c7d23 |
* Structures and Typedefs *
|
|
|
8c7d23 |
@@ -398,13 +402,13 @@ static int vbsvcAutoMountSharedFolderOld
|
|
|
8c7d23 |
int rc = vbsvcAutoMountPrepareMountPointOld(pszMountPoint, pszShareName, &Opts);
|
|
|
8c7d23 |
if (RT_SUCCESS(rc))
|
|
Hans de Goede |
32e434 |
{
|
|
|
8c7d23 |
+ 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",
|
|
|
8c7d23 |
+ Opts.uid, Opts.gid, Opts.dmode, Opts.fmode, Opts.dmask, Opts.fmask);
|
|
|
8c7d23 |
# ifdef RT_OS_SOLARIS
|
|
Hans de Goede |
32e434 |
int fFlags = 0;
|
|
|
8c7d23 |
if (Opts.ronly)
|
|
Hans de Goede |
32e434 |
fFlags |= MS_RDONLY;
|
|
|
8c7d23 |
- 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",
|
|
|
8c7d23 |
- Opts.uid, Opts.gid, Opts.dmode, Opts.fmode, Opts.dmask, Opts.fmask);
|
|
Hans de Goede |
32e434 |
int r = mount(pszShareName,
|
|
Hans de Goede |
32e434 |
pszMountPoint,
|
|
Hans de Goede |
32e434 |
fFlags | MS_OPTIONSTR,
|
|
|
8c7d23 |
@@ -421,34 +425,11 @@ static int vbsvcAutoMountSharedFolderOld
|
|
Hans de Goede |
32e434 |
|
|
|
8c7d23 |
# else /* 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;
|
|
|
8c7d23 |
- RT_ZERO(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 |
-
|
|
|
8c7d23 |
- mntinf.uid = Opts.uid;
|
|
|
8c7d23 |
- mntinf.gid = Opts.gid;
|
|
|
8c7d23 |
- mntinf.ttl = Opts.ttl;
|
|
|
8c7d23 |
- mntinf.dmode = Opts.dmode;
|
|
|
8c7d23 |
- mntinf.fmode = Opts.fmode;
|
|
|
8c7d23 |
- mntinf.dmask = Opts.dmask;
|
|
|
8c7d23 |
- mntinf.fmask = Opts.fmask;
|
|
|
8c7d23 |
- mntinf.tag[0] = '\0';
|
|
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);
|
|
|
8c7d23 |
@@ -481,34 +462,6 @@ static int vbsvcAutoMountSharedFolderOld
|
|
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
|
|
|
8c7d23 |
@@ -527,7 +480,6 @@ static int vbsvcAutoMountSharedFolderOld
|
|
Hans de Goede |
32e434 |
rc = RTErrConvertFromErrno(errno);
|
|
Hans de Goede |
32e434 |
break;
|
|
Hans de Goede |
32e434 |
}
|
|
Hans de Goede |
32e434 |
- }
|
|
Hans de Goede |
32e434 |
}
|
|
|
8c7d23 |
# endif
|
|
|
8c7d23 |
}
|
|
Hans de Goede |
32e434 |
--
|
|
Hans de Goede |
32e434 |
2.14.3
|
|
Hans de Goede |
32e434 |
|