VirtualBox

Changeset 75470 in vbox


Ignore:
Timestamp:
Nov 14, 2018 9:05:25 PM (6 years ago)
Author:
vboxsync
Message:

VBoxControl: sharedfolder fixes and extensions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp

    r75469 r75470  
    16131613 * Lists the Shared Folders provided by the host.
    16141614 */
    1615 static RTEXITCODE listSharedFolders(int argc, char **argv)
     1615static RTEXITCODE sharedFolder_list(int argc, char **argv)
    16161616{
    16171617    bool fUsageOK = true;
     
    16731673                    if (*pszMntPt)
    16741674                        RTPrintf(" mnt-pt=%s", pszMntPt);
     1675                    RTPrintf("]");
     1676# ifdef RT_OS_OS2
     1677                    /* Show drive letters: */
     1678                    const char *pszOn = " on";
     1679                    for (char chDrive = 'A'; chDrive <= 'Z'; chDrive++)
     1680                    {
     1681                        char szDrive[4] = { chDrive, ':', '\0', '\0' };
     1682                        union
     1683                        {
     1684                            FSQBUFFER2  FsQueryBuf;
     1685                            char        achPadding[512];
     1686                        } uBuf;
     1687                        RT_ZERO(uBuf);
     1688                        ULONG cbBuf = sizeof(uBuf) - 2;
     1689                        APIRET rcOs2 = DosQueryFSAttach(szDrive, 0, FSAIL_QUERYNAME, &uBuf.FsQueryBuf, &cbBuf);
     1690                        if (rcOs2 == NO_ERROR)
     1691                        {
     1692                            const char *pszFsdName = (const char *)&uBuf.FsQueryBuf.szName[uBuf.FsQueryBuf.cbName + 1];
     1693                            if (   uBuf.FsQueryBuf.iType == FSAT_REMOTEDRV
     1694                                && RTStrICmpAscii(pszFsdName, "VBOXSF") == 0)
     1695                            {
     1696                                const char *pszMountedName = (const char *)&pszFsdName[uBuf.FsQueryBuf.cbFSDName + 1];
     1697                                if (RTStrICmp(pszMountedName, pszName) == 0)
     1698                                {
     1699                                    const char *pszTag = pszMountedName + strlen(pszMountedName) + 1; /* safe */
     1700                                    if (strcmp(pszTag, "VBoxAutomounter") == 0)
     1701                                        RTPrintf("%s %s*", pszOn, szDrive);
     1702                                    else
     1703                                        RTPrintf("%s %s", pszOn, szDrive);
     1704                                    pszOn = ",";
     1705                                }
     1706                            }
     1707                        }
     1708                    }
     1709# endif
     1710                    RTPrintf("\n");
     1711
    16751712                    RTStrFree(pszName);
    16761713                    RTStrFree(pszMntPt);
     
    16951732 * Attaches a shared folder to a drive letter.
    16961733 */
    1697 static RTEXITCODE sharedFolders_use(int argc, char **argv)
     1734static RTEXITCODE sharedFolder_use(int argc, char **argv)
    16981735{
    16991736    /*
     
    17011738     */
    17021739    if (argc != 2)
    1703         return VBoxControlSyntaxError("sharedfolders use: expected a drive letter and a shared folder name\n");
     1740        return VBoxControlSyntaxError("sharedfolder use: expected a drive letter and a shared folder name\n");
    17041741
    17051742    const char *pszDrive  = argv[0];
    17061743    if (!RT_C_IS_ALPHA(pszDrive[0]) || pszDrive[1] != ':' || pszDrive[2] != '\0')
    1707         return VBoxControlSyntaxError("sharedfolders use: not a drive letter: %s\n", pszDrive);
     1744        return VBoxControlSyntaxError("sharedfolder use: not a drive letter: %s\n", pszDrive);
    17081745
    17091746    static const char s_szTag[] = "VBoxControl";
     
    17121749    size_t cchName = strlen(pszName);
    17131750    if (cchName < 1)
    1714         return VBoxControlSyntaxError("sharedfolders use: shared folder name cannot be empty!\n");
     1751        return VBoxControlSyntaxError("sharedfolder use: shared folder name cannot be empty!\n");
    17151752    if (cchName + 1 + sizeof(s_szTag) >= sizeof(szzNameAndTag))
    1716         return VBoxControlSyntaxError("sharedfolders use: shared folder name is too long! (%s)\n", pszName);
     1753        return VBoxControlSyntaxError("sharedfolder use: shared folder name is too long! (%s)\n", pszName);
    17171754
    17181755    /*
     
    17261763    if (rcOs2 == NO_ERROR)
    17271764        return RTEXITCODE_SUCCESS;
     1765    if (rcOs2 == ERROR_INVALID_FSD_NAME)
     1766        return VBoxControlError("Shared folders IFS not installed?\n");
    17281767    return VBoxControlError("DosFSAttach/FS_ATTACH failed to attach '%s' to '%s': %u\n", pszName, pszDrive, rcOs2);
    17291768}
     
    17321771 * Detaches a shared folder from a drive letter.
    17331772 */
    1734 static RTEXITCODE sharedFolders_unuse(int argc, char **argv)
     1773static RTEXITCODE sharedFolder_unuse(int argc, char **argv)
    17351774{
    17361775    /*
     
    17381777     */
    17391778    if (argc != 1)
    1740         return VBoxControlSyntaxError("sharedfolders unuse: expected drive letter\n");
     1779        return VBoxControlSyntaxError("sharedfolder unuse: expected drive letter\n");
    17411780    const char *pszDrive = argv[0];
    17421781    if (!RT_C_IS_ALPHA(pszDrive[0]) || pszDrive[1] != ':' || pszDrive[2] != '\0')
    1743         return VBoxControlSyntaxError("sharedfolders unuse: not a drive letter: %s\n", pszDrive);
     1782        return VBoxControlSyntaxError("sharedfolder unuse: not a drive letter: %s\n", pszDrive);
    17441783
    17451784    /*
     
    17701809    }
    17711810    if (!strcmp(argv[0], "list"))
    1772         return listSharedFolders(argc - 1, argv + 1);
     1811        return sharedFolder_list(argc - 1, argv + 1);
    17731812# ifdef RT_OS_OS2
    17741813    if (!strcmp(argv[0], "use"))
    1775         return sharedFolders_use(argc - 1, argv + 1);
     1814        return sharedFolder_use(argc - 1, argv + 1);
    17761815    if (!strcmp(argv[0], "unuse"))
    1777         return sharedFolders_unuse(argc - 1, argv + 1);
     1816        return sharedFolder_unuse(argc - 1, argv + 1);
    17781817# endif
    17791818
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