VirtualBox

Changeset 78703 in vbox


Ignore:
Timestamp:
May 24, 2019 12:23:13 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
130781
Message:

SharedFoldersSvc: Two VERR_FILE_NOT_FOUND/VERR_PATH_NOT_FOUND tweaks for windows guests on non-windows hosts. bugref:9172

Location:
trunk/src/VBox/HostServices/SharedFolders
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedFolders/shfl.h

    r78698 r78703  
    6666typedef SHFLCLIENTDATA *PSHFLCLIENTDATA;
    6767
     68
     69/** @def SHFL_CLIENT_NEED_WINDOWS_ERROR_STYLE_ADJUST
     70 * Whether to make windows error style adjustments on a posix host.
     71 * This always returns false on windows hosts. */
     72#ifdef RT_OS_WINDOWS
     73# define SHFL_CLIENT_NEED_WINDOWS_ERROR_STYLE_ADJUST_ON_POSIX(a_pClient) (false)
     74#else
     75# define SHFL_CLIENT_NEED_WINDOWS_ERROR_STYLE_ADJUST_ON_POSIX(a_pClient) ((a_pClient)->enmErrorStyle == kShflErrorStyle_Windows)
     76#endif
     77
    6878#endif /* !VBOX_INCLUDED_SRC_SharedFolders_shfl_h */
    6979
  • trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp

    r78467 r78703  
    5656*********************************************************************************************************************************/
    5757#define SHFL_RT_LINK(pClient) ((pClient)->fu32Flags & SHFL_CF_SYMLINKS ? RTPATH_F_ON_LINK : RTPATH_F_FOLLOW_LINK)
     58
     59
     60#ifndef RT_OS_WINDOWS
     61/**
     62 * Helps to check if pszPath deserves a VERR_PATH_NOT_FOUND status when catering
     63 * to windows guests.
     64 */
     65static bool vbsfErrorStyleIsWindowsPathNotFound(char *pszPath)
     66{
     67    /*
     68     * Check if the parent directory actually exists.  We temporarily modify the path here.
     69     */
     70    size_t cchParent = RTPathParentLength(pszPath);
     71    char chSaved = pszPath[cchParent];
     72    pszPath[cchParent] = '\0';
     73    RTFSOBJINFO ObjInfo;
     74    int vrc = RTPathQueryInfoEx(pszPath, &ObjInfo, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK);
     75    pszPath[cchParent] = chSaved;
     76    if (RT_SUCCESS(vrc))
     77    {
     78        if (RTFS_IS_DIRECTORY(ObjInfo.Attr.fMode))
     79            return false;
     80        return true;
     81    }
     82    if (vrc == VERR_FILE_NOT_FOUND || vrc == VERR_PATH_NOT_FOUND)
     83        return true;
     84    return false;
     85}
     86#endif /* RT_OS_WINDOWS */
    5887
    5988
     
    451480 * @retval pParms @a Info        On success the parameters of the file opened or created
    452481 */
    453 static int vbsfOpenFile(SHFLCLIENTDATA *pClient, SHFLROOT root, const char *pszPath, SHFLCREATEPARMS *pParms)
     482static int vbsfOpenFile(SHFLCLIENTDATA *pClient, SHFLROOT root, char *pszPath, SHFLCREATEPARMS *pParms)
    454483{
    455484    LogFlow(("vbsfOpenFile: pszPath = %s, pParms = %p\n", pszPath, pParms));
     
    490519            case VERR_FILE_NOT_FOUND:
    491520                pParms->Result = SHFL_FILE_NOT_FOUND;
    492 
     521#ifndef RT_OS_WINDOWS
     522                if (   SHFL_CLIENT_NEED_WINDOWS_ERROR_STYLE_ADJUST_ON_POSIX(pClient)
     523                    && vbsfErrorStyleIsWindowsPathNotFound(pszPath))
     524                    pParms->Result = SHFL_PATH_NOT_FOUND;
     525#endif
    493526                /* This actually isn't an error, so correct the rc before return later,
    494527                   because the driver (VBoxSF.sys) expects rc = VINF_SUCCESS and checks the result code. */
     
    645678 * @note folders are created with fMode = 0777
    646679 */
    647 static int vbsfOpenDir(SHFLCLIENTDATA *pClient, SHFLROOT root, const char *pszPath,
     680static int vbsfOpenDir(SHFLCLIENTDATA *pClient, SHFLROOT root, char *pszPath,
    648681                       SHFLCREATEPARMS *pParms)
    649682{
     
    705738            else
    706739            {
     740                /** @todo we still return 'rc' as failure here, so this is mostly pointless.  */
    707741                switch (rc)
    708742                {
    709743                case VERR_FILE_NOT_FOUND:  /* Does this make sense? */
    710744                    pParms->Result = SHFL_FILE_NOT_FOUND;
     745#ifndef RT_OS_WINDOWS
     746                    if (   SHFL_CLIENT_NEED_WINDOWS_ERROR_STYLE_ADJUST_ON_POSIX(pClient)
     747                        && vbsfErrorStyleIsWindowsPathNotFound(pszPath))
     748                    {
     749                        pParms->Result = SHFL_PATH_NOT_FOUND;
     750                        rc = VERR_PATH_NOT_FOUND;
     751                    }
     752#endif
    711753                    break;
    712754                case VERR_PATH_NOT_FOUND:
Note: See TracChangeset for help on using the changeset viewer.

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