VirtualBox

Changeset 64620 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 9, 2016 5:44:36 PM (8 years ago)
Author:
vboxsync
Message:

IPRT: Distinguish between actual symbolic links and other reparse points on NT/Windows.

Location:
trunk/src/VBox/Runtime
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/include/internal/fs.h

    r62477 r64620  
    3535RT_C_DECLS_BEGIN
    3636
    37 RTFMODE rtFsModeFromDos(RTFMODE fMode, const char *pszName, size_t cbName);
     37/** IO_REPARSE_TAG_SYMLINK */
     38#define RTFSMODE_SYMLINK_REPARSE_TAG UINT32_C(0xa000000c)
     39
     40RTFMODE rtFsModeFromDos(RTFMODE fMode, const char *pszName, size_t cbName, uint32_t uReparseTag);
    3841RTFMODE rtFsModeFromUnix(RTFMODE fMode, const char *pszName, size_t cbName);
    3942RTFMODE rtFsModeNormalize(RTFMODE fMode, const char *pszName, size_t cbName);
  • trunk/src/VBox/Runtime/r3/fs.cpp

    r62477 r64620  
    4848 * @param   pszName     The filename which this applies to (exe check).
    4949 * @param   cbName      The length of that filename. (optional, set 0)
    50  */
    51 RTFMODE rtFsModeFromDos(RTFMODE fMode, const char *pszName, size_t cbName)
     50 * @param   uReparseTag The reparse tag if RTFS_DOS_NT_REPARSE_POINT is set.
     51 */
     52RTFMODE rtFsModeFromDos(RTFMODE fMode, const char *pszName, size_t cbName, uint32_t uReparseTag)
    5253{
    5354    fMode &= ~((1 << RTFS_DOS_SHIFT) - 1);
     
    8384
    8485    /* Is it really a symbolic link? */
    85     if (fMode & RTFS_DOS_NT_REPARSE_POINT)
     86    if ((fMode & RTFS_DOS_NT_REPARSE_POINT) && uReparseTag == RTFSMODE_SYMLINK_REPARSE_TAG)
    8687        fMode = (fMode & ~RTFS_TYPE_MASK) | RTFS_TYPE_SYMLINK;
    8788
     
    138139{
    139140    if (!(fMode & RTFS_UNIX_MASK))
    140         fMode = rtFsModeFromDos(fMode, pszName, cbName);
     141        fMode = rtFsModeFromDos(fMode, pszName, cbName, RTFSMODE_SYMLINK_REPARSE_TAG);
    141142    else if (!(fMode & RTFS_DOS_MASK))
    142143        fMode = rtFsModeFromUnix(fMode, pszName, cbName);
  • trunk/src/VBox/Runtime/r3/nt/direnum-r3-nt.cpp

    r62592 r64620  
    580580            case FILE_ATTRIBUTE_REPARSE_POINT:
    581581            case FILE_ATTRIBUTE_REPARSE_POINT | FILE_ATTRIBUTE_DIRECTORY:
    582                 pDirEntry->enmType = RTDIRENTRYTYPE_SYMLINK;
     582                /* EaSize is here reused for returning the repharse tag value. */
     583                if (pDir->uCurData.pBoth->EaSize == IO_REPARSE_TAG_SYMLINK)
     584                    pDirEntry->enmType = RTDIRENTRYTYPE_SYMLINK;
    583585                break;
    584586        }
     
    686688
    687689        pDirEntry->Info.Attr.fMode  = rtFsModeFromDos((pBoth->FileAttributes << RTFS_DOS_SHIFT) & RTFS_DOS_MASK_NT,
    688                                                        pszName, cchName);
     690                                                       pszName, cchName, pBoth->EaSize);
    689691    }
    690692#ifdef IPRT_WITH_NT_PATH_PASSTHRU
  • trunk/src/VBox/Runtime/r3/win/direnum-win.cpp

    r62592 r64620  
    340340
    341341    pDirEntry->Info.Attr.fMode  = rtFsModeFromDos((pDir->Data.dwFileAttributes << RTFS_DOS_SHIFT) & RTFS_DOS_MASK_NT,
    342                                                    pszName, cchName);
     342                                                   pszName, cchName, pDir->Data.dwReserved0);
    343343
    344344    /*
  • trunk/src/VBox/Runtime/r3/win/fileio-win.cpp

    r64619 r64620  
    892892    pObjInfo->ChangeTime  = pObjInfo->ModificationTime;
    893893
    894     pObjInfo->Attr.fMode  = rtFsModeFromDos((Data.dwFileAttributes << RTFS_DOS_SHIFT) & RTFS_DOS_MASK_NT, "", 0);
     894    pObjInfo->Attr.fMode  = rtFsModeFromDos((Data.dwFileAttributes << RTFS_DOS_SHIFT) & RTFS_DOS_MASK_NT, "", 0,
     895                                            RTFSMODE_SYMLINK_REPARSE_TAG /* (symlink or not, doesn't usually matter here) */);
    895896
    896897    /*
  • trunk/src/VBox/Runtime/r3/win/path-win.cpp

    r63311 r64620  
    271271     * Query file info.
    272272     */
     273    uint32_t uReparseTag = RTFSMODE_SYMLINK_REPARSE_TAG;
    273274    WIN32_FILE_ATTRIBUTE_DATA Data;
    274275    PRTUTF16 pwszPath;
     
    297298            Data.nFileSizeHigh      = FindData.nFileSizeHigh;
    298299            Data.nFileSizeLow       = FindData.nFileSizeLow;
     300            uReparseTag             = FindData.dwReserved0;
    299301        }
    300302        else
     
    311313     */
    312314    /** @todo we're too lazy wrt to error paths here... */
    313     if (   (fFlags & RTPATH_F_FOLLOW_LINK)
    314         && (Data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
     315    if (   (Data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
     316        && ((fFlags & RTPATH_F_FOLLOW_LINK) || uReparseTag != RTFSMODE_SYMLINK_REPARSE_TAG))
    315317    {
    316318        HANDLE hFinal = CreateFileW(pwszPath,
     
    332334                Data.nFileSizeHigh      = FileData.nFileSizeHigh;
    333335                Data.nFileSizeLow       = FileData.nFileSizeLow;
     336                uReparseTag             = 0;
    334337            }
    335338            CloseHandle(hFinal);
     
    359362
    360363    pObjInfo->Attr.fMode  = rtFsModeFromDos((Data.dwFileAttributes << RTFS_DOS_SHIFT) & RTFS_DOS_MASK_NT,
    361                                             pszPath, strlen(pszPath));
     364                                            pszPath, strlen(pszPath), uReparseTag);
    362365
    363366    /*
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