VirtualBox

Changeset 105018 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jun 25, 2024 11:06:29 AM (5 months ago)
Author:
vboxsync
Message:

doc/manual,include/VBox,Frontends/VBoxManage,HostServices/SharedFolders,
Main/{include,SharedFolder,Console,Machine,VirtualBox.xidl}: Backout
changeset r163634 since it introduces a build dependency on
VirtualBox_XPCOM.h which needs to be built from the VirtualBox.xidl
changes before it can be referenced by the src/VBox/HostServices code.
Need to putback the changes in two parts. bugref:10619

Location:
trunk/src/VBox/Frontends/VBoxManage
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r105016 r105018  
    799799}
    800800
    801 static const char *symlinkPolicyToName(SymlinkPolicy_T enmSymlinkPolicy)
    802 {
    803     switch (enmSymlinkPolicy)
    804     {
    805         case SymlinkPolicy_AllowedToAnyTarget:
    806             return ("any");
    807         case SymlinkPolicy_AllowedInShareSubtree:
    808             return ("subtree");
    809         case SymlinkPolicy_AllowedToRelativeTargets:
    810             return ("relative");
    811         case SymlinkPolicy_Forbidden:
    812             return("forbidden");
    813         default:
    814             return("none");
    815     }
    816 }
    817 
    818801/** Shows a shared folder.   */
    819802static HRESULT showSharedFolder(ComPtr<ISharedFolder> &sf, VMINFO_DETAILS details, const char *pszDesc,
     
    822805    Bstr name, hostPath, bstrAutoMountPoint;
    823806    BOOL writable = FALSE, fAutoMount = FALSE;
    824     SymlinkPolicy_T enmSymlinkPolicy = SymlinkPolicy_None;
    825807    CHECK_ERROR2I_RET(sf, COMGETTER(Name)(name.asOutParam()), hrcCheck);
    826808    CHECK_ERROR2I_RET(sf, COMGETTER(HostPath)(hostPath.asOutParam()), hrcCheck);
     
    828810    CHECK_ERROR2I_RET(sf, COMGETTER(AutoMount)(&fAutoMount), hrcCheck);
    829811    CHECK_ERROR2I_RET(sf, COMGETTER(AutoMountPoint)(bstrAutoMountPoint.asOutParam()), hrcCheck);
    830     CHECK_ERROR2I_RET(sf, COMGETTER(SymlinkPolicy)(&enmSymlinkPolicy), hrcCheck);
    831812
    832813    if (fFirst && details != VMINFO_MACHINEREADABLE)
     
    843824                 name.raw(), hostPath.raw(), pszDesc, writable ? Info::tr("writable") : Info::tr("readonly"),
    844825                 fAutoMount ? Info::tr(", auto-mount") : "");
    845         if (enmSymlinkPolicy != SymlinkPolicy_None)
    846             RTPrintf(Info::tr(", symlink-policy: %s"), symlinkPolicyToName(enmSymlinkPolicy));
    847826        if (bstrAutoMountPoint.isNotEmpty())
    848827            RTPrintf(Info::tr(", mount-point: '%ls'\n"), bstrAutoMountPoint.raw());
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r105016 r105018  
    16371637            case VINF_GETOPT_NOT_OPTION:
    16381638                if (pszMachineName)
    1639                     return errorArgument(Misc::tr("Machine name given more than once: first '%s', then '%s'"),
     1639                    return errorArgument(Misc::tr("Machine name is given more than once: first '%s', then '%s'"),
    16401640                                         pszMachineName, ValueUnion.psz);
    16411641                pszMachineName = ValueUnion.psz;
     
    17491749            case VINF_GETOPT_NOT_OPTION:
    17501750                if (pszMachineName)
    1751                     return errorArgument(Misc::tr("Machine name given more than once: first '%s', then '%s'"),
     1751                    return errorArgument(Misc::tr("Machine name is given more than once: first '%s', then '%s'"),
    17521752                                         pszMachineName, ValueUnion.psz);
    17531753                pszMachineName = ValueUnion.psz;
     
    18101810}
    18111811
    1812 static SymlinkPolicy_T nameToSymlinkPolicy(const char *pszName)
    1813 {
    1814     if (!RTStrICmp(pszName, "forbidden"))
    1815         return SymlinkPolicy_Forbidden;
    1816     if (!RTStrICmp(pszName, "subtree"))
    1817         return SymlinkPolicy_AllowedInShareSubtree;
    1818     if (!RTStrICmp(pszName, "relative"))
    1819         return SymlinkPolicy_AllowedToRelativeTargets;
    1820     if (!RTStrICmp(pszName, "any"))
    1821         return SymlinkPolicy_AllowedToAnyTarget;
    1822 
    1823     return SymlinkPolicy_None;
    1824 }
    1825 
    1826 /**
    1827  * modify shared folder properties
    1828  */
    1829 static RTEXITCODE handleSharedFolderModify(HandlerArg *a)
    1830 {
    1831     /*
    1832      * Parse arguments (argv[0] == subcommand).
    1833      */
    1834     static const RTGETOPTDEF s_aModifyOptions[] =
    1835     {
    1836         { "--name",             'n', RTGETOPT_REQ_STRING },
    1837         { "-name",              'n', RTGETOPT_REQ_STRING },     // deprecated
    1838         { "--transient",        't', RTGETOPT_REQ_NOTHING },
    1839         { "-transient",         't', RTGETOPT_REQ_NOTHING },    // deprecated
    1840         { "--symlink-policy",   's', RTGETOPT_REQ_STRING },
    1841         { "-symlink-policy",    's', RTGETOPT_REQ_STRING },     // deprecated
    1842     };
    1843     const char *pszMachineName    = NULL;
    1844     const char *pszName           = NULL;
    1845     bool        fTransient        = false;
    1846     SymlinkPolicy_T enmSymlinkPolicy = SymlinkPolicy_None;
    1847 
    1848     RTGETOPTSTATE GetState;
    1849     RTGetOptInit(&GetState, a->argc, a->argv, s_aModifyOptions, RT_ELEMENTS(s_aModifyOptions), 1 /*iFirst*/, 0 /*fFlags*/);
    1850     int c;
    1851     RTGETOPTUNION ValueUnion;
    1852     while ((c = RTGetOpt(&GetState, &ValueUnion)))
    1853     {
    1854         switch (c)
    1855         {
    1856             case 'n':
    1857                 pszName = ValueUnion.psz;
    1858                 break;
    1859             case 't':
    1860                 fTransient = true;
    1861                 break;
    1862             case 's':
    1863                 enmSymlinkPolicy = nameToSymlinkPolicy(ValueUnion.psz);
    1864                 if (enmSymlinkPolicy == SymlinkPolicy_None)
    1865                     return errorArgument(Misc::tr("Invalid --symlink-policy argument '%s'"), ValueUnion.psz);
    1866                 break;
    1867             case VINF_GETOPT_NOT_OPTION:
    1868                 if (pszMachineName)
    1869                     return errorArgument(Misc::tr("Machine name given more than once: first '%s', then '%s'"),
    1870                                          pszMachineName, ValueUnion.psz);
    1871                 pszMachineName = ValueUnion.psz;
    1872                 break;
    1873             default:
    1874                 return errorGetOpt(c, &ValueUnion);
    1875         }
    1876     }
    1877 
    1878     if (!pszMachineName)
    1879         return errorSyntax(Misc::tr("No machine was specified"));
    1880     if (!pszName)
    1881         return errorSyntax(Misc::tr("No shared folder name (--name) was supplied."));
    1882 
    1883     /* the only supported option at the moment so it must be set */
    1884     if (enmSymlinkPolicy == SymlinkPolicy_None)
    1885         return errorSyntax(Misc::tr("No symbolic link policy (--symlink-policy) was supplied."));
    1886 
    1887     /*
    1888      * Done parsing, do some real work.
    1889      */
    1890     ComPtr<IMachine> ptrMachine;
    1891     CHECK_ERROR2I_RET(a->virtualBox, FindMachine(Bstr(pszMachineName).raw(), ptrMachine.asOutParam()), RTEXITCODE_FAILURE);
    1892     AssertReturn(ptrMachine.isNotNull(), RTEXITCODE_FAILURE);
    1893 
    1894     HRESULT hrc;
    1895     if (fTransient)
    1896     {
    1897         /* open an existing session for the VM */
    1898         CHECK_ERROR_RET(ptrMachine, LockMachine(a->session, LockType_Shared), RTEXITCODE_FAILURE);
    1899 
    1900         /* get the session machine */
    1901         ComPtr<IMachine> ptrSessionMachine;
    1902         CHECK_ERROR_RET(a->session, COMGETTER(Machine)(ptrSessionMachine.asOutParam()), RTEXITCODE_FAILURE);
    1903 
    1904         /* get the session console */
    1905         ComPtr<IConsole> ptrConsole;
    1906         CHECK_ERROR_RET(a->session, COMGETTER(Console)(ptrConsole.asOutParam()), RTEXITCODE_FAILURE);
    1907         if (ptrConsole.isNull())
    1908             return RTMsgErrorExit(RTEXITCODE_FAILURE, Misc::tr("Machine '%s' is not currently running.\n"), pszMachineName);
    1909 
    1910         /* find the desired transient shared folder to modify */
    1911         com::SafeIfaceArray <ISharedFolder> sharedFolders;
    1912         CHECK_ERROR_RET(ptrConsole, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(sharedFolders)), RTEXITCODE_FAILURE);
    1913         if (sharedFolders.size() == 0)
    1914             return RTMsgErrorExit(RTEXITCODE_FAILURE, Misc::tr("Machine '%s' has no transient shared folders configured.\n"),
    1915                                   pszMachineName);
    1916 
    1917         bool fFound = false;
    1918         for (size_t i = 0; i < sharedFolders.size(); ++i)
    1919         {
    1920             ComPtr<ISharedFolder> sharedFolder = sharedFolders[i];
    1921             Bstr bstrSharedFolderName;
    1922             CHECK_ERROR_RET(sharedFolder, COMGETTER(Name)(bstrSharedFolderName.asOutParam()), RTEXITCODE_FAILURE);
    1923             Utf8Str strSharedFolderName(bstrSharedFolderName);
    1924             if (!RTStrCmp(strSharedFolderName.c_str(), pszName))
    1925             {
    1926                 CHECK_ERROR_RET(sharedFolder, COMSETTER(SymlinkPolicy)(enmSymlinkPolicy), RTEXITCODE_FAILURE);
    1927                 fFound = true;
    1928                 break;
    1929             }
    1930         }
    1931         if (!fFound)
    1932             return RTMsgErrorExit(RTEXITCODE_FAILURE, Misc::tr("Could not find a transient shared folder named '%s'.\n"),
    1933                                   pszName);
    1934 
    1935         CHECK_ERROR_RET(a->session, UnlockMachine(), RTEXITCODE_FAILURE);
    1936     }
    1937     else
    1938     {
    1939         /* open a session for the VM */
    1940         CHECK_ERROR_RET(ptrMachine, LockMachine(a->session, LockType_Write), RTEXITCODE_FAILURE);
    1941 
    1942         /* get the mutable session machine */
    1943         ComPtr<IMachine> ptrSessionMachine;
    1944         CHECK_ERROR_RET(a->session, COMGETTER(Machine)(ptrSessionMachine.asOutParam()), RTEXITCODE_FAILURE);
    1945 
    1946         /* find the desired shared folder to modify */
    1947         com::SafeIfaceArray <ISharedFolder> sharedFolders;
    1948         CHECK_ERROR_RET(ptrSessionMachine, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(sharedFolders)), RTEXITCODE_FAILURE);
    1949         if (sharedFolders.size() == 0)
    1950             return RTMsgErrorExit(RTEXITCODE_FAILURE, Misc::tr("Machine '%s' has no shared folders configured.\n"),
    1951                                   pszMachineName);
    1952 
    1953         bool fFound = false;
    1954         for (size_t i = 0; i < sharedFolders.size(); ++i)
    1955         {
    1956             ComPtr<ISharedFolder> sharedFolder = sharedFolders[i];
    1957             Bstr bstrSharedFolderName;
    1958             CHECK_ERROR_RET(sharedFolder, COMGETTER(Name)(bstrSharedFolderName.asOutParam()), RTEXITCODE_FAILURE);
    1959             Utf8Str strSharedFolderName(bstrSharedFolderName);
    1960             if (!RTStrCmp(strSharedFolderName.c_str(), pszName))
    1961             {
    1962                 CHECK_ERROR_RET(sharedFolder, COMSETTER(SymlinkPolicy)(enmSymlinkPolicy), RTEXITCODE_FAILURE);
    1963                 fFound = true;
    1964                 break;
    1965             }
    1966         }
    1967         if (!fFound)
    1968             return RTMsgErrorExit(RTEXITCODE_FAILURE, Misc::tr("Could not find a shared folder named '%s'.\n"), pszName);
    1969 
    1970         /* commit and close the session */
    1971         if (SUCCEEDED(hrc))
    1972             CHECK_ERROR(ptrSessionMachine, SaveSettings());
    1973 
    1974         CHECK_ERROR_RET(a->session, UnlockMachine(), RTEXITCODE_FAILURE);
    1975     }
    1976 
    1977     return SUCCEEDED(hrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
    1978 }
    19791812
    19801813RTEXITCODE handleSharedFolder(HandlerArg *a)
     
    19931826        setCurrentSubcommand(HELP_SCOPE_SHAREDFOLDER_REMOVE);
    19941827        return handleSharedFolderRemove(a);
    1995     }
    1996 
    1997     if (!strcmp(a->argv[0], "modify"))
    1998     {
    1999         setCurrentSubcommand(HELP_SCOPE_SHAREDFOLDER_MODIFY);
    2000         return handleSharedFolderModify(a);
    20011828    }
    20021829
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette