VirtualBox

Opened 4 years ago

Closed 4 years ago

#19800 closed defect (fixed)

make sharedfolder option argument --auto-mount-point public

Reported by: Frank Batschulat (Oracle) Owned by:
Component: shared folders Version: VirtualBox 6.1.10
Keywords: Cc:
Guest type: other Host type: other

Description

From: "Timothy Tacker" <> To: vbox-dev@… Subject: [vbox-dev] [PATCH] document --auto-mount-point Date: Wed, 22 Jul 2020 04:28:43 +0200

The VBoxManage sharedfolder command supports an optional --auto-mount-point parameter, but it is not documented. The parameter was previously implemented and functions as expected on CentOS 8. Per the documentation, when the --automount parameter is used on Linux distributions, the default mount point will be either /media/USER/sf_share-name or /media/sf_share-name, where share-name is the share named. The --auto-mount-point parameter can be used to override the default mount point and use another one specified instead.

The below patch documents the --auto-mount-point parameter in both the manual and in VirtualBox itself. In addition, VBoxManageMisc.cpp was modified to handle -auto-mount-point in addition to --auto-mount-point, consistent with the other parameters for the sharedfolder command in the same file.

I'm licensing this patch under the MIT license. Please review. Feedback is welcome. Thanks!

Timothy Tacker

---
  doc/manual/en_US/man_VBoxManage-sharedfolder.xml | 10 +++++++++-
  doc/manual/en_US/user_VBoxManage.xml             | 11 ++++++++++-
  src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp |  1 +
  src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp |  3 ++-
  4 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/doc/manual/en_US/man_VBoxManage-sharedfolder.xml
b/doc/manual/en_US/man_VBoxManage-sharedfolder.xml
index bfa2c52b..7615eb6e 100644
--- a/doc/manual/en_US/man_VBoxManage-sharedfolder.xml
+++ b/doc/manual/en_US/man_VBoxManage-sharedfolder.xml
@@ -47,6 +47,7 @@
        <arg>--automount</arg>
        <arg>--readonly</arg>
        <arg>--transient</arg>
+      <arg>--auto-mount-point=<replaceable>mountpoint</replaceable></arg>
      </cmdsynopsis>

      <cmdsynopsis id="synopsis-vboxmanage-sharedfolder-remove">
@@ -111,7 +112,8 @@

  <filename>/var/run/media/<replaceable>username</replaceable>/sf_<replaceable>sharename</replaceable></filename>
                or

  <filename>/media/sf_<replaceable>sharename</replaceable></filename>,
-              depending on your guest OS.
+              depending on your guest OS, unless
+              <option>--auto-mount-point</option> is used.
              </para></listitem>
          </varlistentry>
          <varlistentry>
@@ -136,6 +138,12 @@
                after the VM stops.
              </para></listitem>
          </varlistentry>
+        <varlistentry>
+
  <term>--auto-mount-point=<replaceable>mountpoint</replaceable></term>
+          <listitem><para>
+              Specifies the mount point of the share.
+            </para></listitem>
+        </varlistentry>
        </variablelist>
      </refsect2>
      <refsect2 id="vboxmanage-sharedfolder-remove">
diff --git a/doc/manual/en_US/user_VBoxManage.xml
b/doc/manual/en_US/user_VBoxManage.xml
index 350709f4..60e4b987 100644
--- a/doc/manual/en_US/user_VBoxManage.xml
+++ b/doc/manual/en_US/user_VBoxManage.xml
@@ -6385,6 +6385,7 @@ Value: 2006.01.01</screen>
  VBoxManage sharedfolder     add &lt;uuid|vmname&gt;
                                  --name &lt;name&gt; --hostpath
&lt;hostpath&gt;
                                  [--transient] [--readonly] [--automount]
+                                [--auto-mount-point &lt;mountpoint&gt;]
  </screen>

      <para>
@@ -6454,7 +6455,8 @@ VBoxManage sharedfolder     add &lt;uuid|vmname&gt;
          <para>
            <computeroutput>-automount</computeroutput>: Specifies that
            the share will be automatically mounted. On Linux
-          distributions, this will be to either
+          distributions, unless
<computeroutput>--auto-mount-point</computeroutput>
+          is used, this will be to either

  <filename>/media/USER/sf_<replaceable>share-name</replaceable></filename>
            or

  <filename>/media/sf_<replaceable>share-name</replaceable></filename>,
@@ -6463,6 +6465,13 @@ VBoxManage sharedfolder     add &lt;uuid|vmname&gt;
          </para>
        </listitem>

+      <listitem>
+        <para>
+          <computeroutput>-auto-mount-point
&lt;mountpoint&gt;</computeroutput>:
+          Specifies the mount point of the share.
+        </para>
+      </listitem>
+
      </itemizedlist>

  <screen>
diff --git a/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
b/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
index d3c15586..7f90e322 100644
--- a/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
+++ b/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
@@ -1152,6 +1152,7 @@ void printUsage(USAGECATEGORY enmCommand, uint64_t
fSubcommandScope, PRTSTREAM p
                                 "%s sharedfolder %s    add <uuid|vmname>\n"
                           "                            --name <name>
--hostpath <hostpath>\n"
                           "                            [--transient]
[--readonly] [--automount]\n"
+                         "                            [--auto-mount-point
<mountpoint>]\n"
                           "\n", SEP);

          if (fSubcommandScope & HELP_SCOPE_SHAREDFOLDER_REMOVE)
diff --git a/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
b/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
index 3655d077..4631a801 100644
--- a/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
+++ b/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
@@ -1128,7 +1128,8 @@ RTEXITCODE handleSharedFolder(HandlerArg *a)
              {
                  fAutoMount = true;
              }
-            else if (!strcmp(a->argv[i], "--auto-mount-point"))
+            else if (   !strcmp(a->argv[i], "--auto-mount-point")
+                     || !strcmp(a->argv[i], "-auto-mount-point"))
              {
                  if (a->argc <= i + 1 || !*a->argv[i+1])
                      return errorArgument("Missing argument to '%s'",
a->argv[i]);

https://www.virtualbox.org/pipermail/vbox-dev/2020-July/015525.html

Change History (3)

comment:1 by Frank Batschulat (Oracle), 4 years ago

Summary: make optional sharedfolder command --auto-mount-point publicmake sharedfolder option argument --auto-mount-point public

comment:2 by Frank Batschulat (Oracle), 4 years ago

curently we have:

Usage:

VBoxManage sharedfolder     add <uuid|vmname>
                            --name <name> --hostpath <hostpath>
                            [--transient] [--readonly] [--automount]

the code however already does:

trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

1071 RTEXITCODE handleSharedFolder(HandlerArg *a)                                                                                       
...
1131             else if (!strcmp(a->argv[i], "--auto-mount-point"))                                                                    
1132             {                                                                                                                      
1133                 if (a->argc <= i + 1 || !*a->argv[i+1])                                                                            
1134                     return errorArgument("Missing argument to '%s'", a->argv[i]);                                                  
1135                 i++;                                                                                                               
1136                 pszAutoMountPoint = a->argv[i];                                                                                    
1137             }    
...
1168             CHECK_ERROR(console, CreateSharedFolder(Bstr(name).raw(), Bstr(hostpath).raw(),                                        
1169                                                     fWritable, fAutoMount, Bstr(pszAutoMountPoint).raw()));     
...
1181             CHECK_ERROR(sessionMachine, CreateSharedFolder(Bstr(name).raw(), Bstr(hostpath).raw(),                                 
1182                                                            fWritable, fAutoMount, Bstr(pszAutoMountPoint).raw()));  

The feature was introduced 2 years ago with:

------------------------------------------------------------------------                                                           
r126515 | bird | 2018-11-09 23:25:30 +0100 (Fri, 09 Nov 2018) | 1 line                                                             
                                                                                                                                   
Main,VBoxManage,FE/Qt: Extended the createSharedFolder and ISharedFolder methods with a
mount poit parameter/attribute for use when auto-mounting.  
This is especially useful for Windows and OS/2 guests which operates with drive letters.  
The change has not yet trickled down to the guest interface and VBoxService.
                                                                                                                                   
Index: trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp                                                                      
===================================================================                                                                
--- trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp      (revision 126514)                                                  
+++ trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp      (revision 126515)                                                  
@@ -1095,6 +1095,7 @@                                                                                                              
         bool fTransient = false;                                                                                                  
         bool fWritable = true;                                                                                                    
         bool fAutoMount = false;                                                                                                  
+        char *pszAutoMountPoint = "";                                                                                             
                                                                                                                                   
         for (int i = 2; i < a->argc; i++)                                                                                         
         {                                                                                                                         
@@ -1129,6 +1130,13 @@                                                                                                             
             {                                                                                                                     
                 fAutoMount = true;                                                                                                
             }                                                                                                                     
+            else if (!strcmp(a->argv[i], "--auto-mount-point"))                                                                   
+            {                                                                                                                     
+                if (a->argc <= i + 1 || !*a->argv[i+1])                                                                           
+                    return errorArgument("Missing argument to '%s'", a->argv[i]);                                                 
+                i++;                                                                                                              
+                pszAutoMountPoint = a->argv[i];                                                                                   
+            }                                                                                                                     
             else                                                                                                                  
                 return errorSyntax(USAGE_SHAREDFOLDER_ADD, "Invalid parameter '%s'", Utf8Str(a->argv[i]).c_str());                
         }                                                                                                

Today the GUI already knows about the additional "mounpoint" and has an input field for it.

comment:3 by bird, 4 years ago

Resolution: fixed
Status: newclosed

My bad for forgetting to document this option, thanks a lot for the reminder. There was also some additional cleanup pending in the option parsing for the VBoxManage snapshot add/remove commands, so I've done that as well (understands 'VBoxManage snapshot add vm --name=sharedfolder ...' as well as 'VBoxManage snapshot add vm --name sharedfolder ...' now).

r85665, r85666, r85667 & r85670.

Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use