VirtualBox

Ignore:
Timestamp:
Apr 17, 2019 9:36:59 PM (6 years ago)
Author:
vboxsync
Message:

IPRT,FsPerf: Added RTDIR_F_NO_ABS_PATH and RTDIRRMREC_F_NO_ABS_PATH to help FsPerf work below PATH_MAX on linux. bugref:9172

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/dir2.cpp

    r78178 r78186  
    5656 * @param   pDirEntry           The dir entry buffer.  (Shared to save stack.)
    5757 * @param   pObjInfo            The object info buffer.  (ditto)
     58 * @param   fFlags              RTDIRRMREC_F_XXX.
    5859 */
    59 static int rtDirRemoveRecursiveSub(char *pszBuf, size_t cchDir, size_t cbBuf, PRTDIRENTRY pDirEntry, PRTFSOBJINFO pObjInfo)
     60static int rtDirRemoveRecursiveSub(char *pszBuf, size_t cchDir, size_t cbBuf, PRTDIRENTRY pDirEntry, PRTFSOBJINFO pObjInfo,
     61                                   uint32_t fFlags)
    6062{
    6163    AssertReturn(RTPATH_IS_SLASH(pszBuf[cchDir - 1]), VERR_INTERNAL_ERROR_4);
     
    6567     */
    6668    RTDIR hDir;
    67     int rc = RTDirOpen(&hDir, pszBuf);
     69    int rc = RTDirOpenFiltered(&hDir, pszBuf, RTDIRFILTER_NONE, fFlags & RTDIRRMREC_F_NO_ABS_PATH ? RTDIR_F_NO_ABS_PATH : 0);
    6870    if (RT_FAILURE(rc))
    6971        return rc;
     
    104106                    pszBuf[cchSubDir++] = '/';
    105107                    pszBuf[cchSubDir]   = '\0';
    106                     rc = rtDirRemoveRecursiveSub(pszBuf, cchSubDir, cbBuf, pDirEntry, pObjInfo);
     108                    rc = rtDirRemoveRecursiveSub(pszBuf, cchSubDir, cbBuf, pDirEntry, pObjInfo, fFlags);
    107109                    if (RT_SUCCESS(rc))
    108110                    {
     
    153155     * eliminates any races with changing CWD.
    154156     */
    155     /** @todo use RTPathReal here instead? */
    156     int rc = RTPathAbs(pszPath, pszAbsPath, cbAbsPathBuf);
     157    int rc;
     158    if (!(fFlags & RTDIRRMREC_F_NO_ABS_PATH))
     159        rc = RTPathAbs(pszPath, pszAbsPath, cbAbsPathBuf);
     160    else if (*pszPath != '\0')
     161        rc = RTStrCopy(pszAbsPath, cbAbsPathBuf, pszPath);
     162    else
     163        rc = VERR_PATH_ZERO_LENGTH;
    157164    if (RT_SUCCESS(rc))
    158165    {
     
    160167         * This API is not permitted applied to the root of anything.
    161168         */
    162         if (RTPathCountComponents(pszAbsPath) <= 1)
     169        union
     170        {
     171            RTPATHPARSED    Parsed;
     172            uint8_t         abParsed[RT_UOFFSETOF(RTPATHPARSED, aComps[1])];
     173        } uBuf;
     174        RTPathParse(pszPath, &uBuf.Parsed, sizeof(uBuf), RTPATH_STR_F_STYLE_HOST);
     175        if (   uBuf.Parsed.cComps <= 1
     176            && (uBuf.Parsed.fProps & RTPATH_PROP_ROOT_SLASH))
    163177            rc = VERR_ACCESS_DENIED;
    164178        else
     
    191205                     */
    192206                    RTDIRENTRY SharedDirEntryBuf;
    193                     rc = rtDirRemoveRecursiveSub(pszAbsPath, cchAbsPath, cbAbsPathBuf, &SharedDirEntryBuf, &SharedObjInfoBuf);
     207                    rc = rtDirRemoveRecursiveSub(pszAbsPath, cchAbsPath, cbAbsPathBuf,
     208                                                 &SharedDirEntryBuf, &SharedObjInfoBuf, fFlags);
    194209
    195210                    /*
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