Blame 0001-VBoxServiceAutoMount-Change-Linux-mount-code-to-use-.patch

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