VirtualBox

Changeset 79155 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jun 14, 2019 4:33:05 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/rtFsModeFromDos: Pass desired object type when normalizing mode masks where the type is implicit (e.g. RTDirCreate). ticketref:18345 bugref:9172

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/fs/fatvfs.cpp

    r76553 r79155  
    19511951    pObj->offEntryInDir     = offEntryInDir;
    19521952    pObj->fAttrib           = ((RTFMODE)pDirEntry->fAttrib << RTFS_DOS_SHIFT) & RTFS_DOS_MASK_OS2;
    1953     pObj->fAttrib           = rtFsModeFromDos(pObj->fAttrib, (char *)&pDirEntry->achName[0], sizeof(pDirEntry->achName), 0);
     1953    pObj->fAttrib           = rtFsModeFromDos(pObj->fAttrib, (char *)&pDirEntry->achName[0], sizeof(pDirEntry->achName), 0, 0);
    19541954    pObj->cbObject          = pDirEntry->cbFile;
    19551955    pObj->fMaybeDirtyFat    = false;
  • trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp

    r77047 r79155  
    13221322    AssertReturn(pThis->uMagic == RTVFSOBJ_MAGIC, VERR_INVALID_HANDLE);
    13231323
    1324     fMode = rtFsModeNormalize(fMode, NULL, 0);
     1324    fMode = rtFsModeNormalize(fMode, NULL, 0, 0);
    13251325    if (!rtFsModeIsValid(fMode))
    13261326        return VERR_INVALID_PARAMETER;
     
    27492749    AssertPtrNullReturn(phVfsDir, VERR_INVALID_POINTER);
    27502750    AssertReturn(!(fFlags & ~RTDIRCREATE_FLAGS_VALID_MASK), VERR_INVALID_FLAGS);
    2751     fMode = rtFsModeNormalize(fMode, pszRelPath, 0);
     2751    fMode = rtFsModeNormalize(fMode, pszRelPath, 0, RTFS_TYPE_DIRECTORY);
    27522752    AssertReturn(rtFsModeIsValidPermissions(fMode), VERR_INVALID_FMODE);
    27532753    if (!(fFlags & RTDIRCREATE_FLAGS_NOT_CONTENT_INDEXED_DONT_SET))
     
    33023302    AssertReturn(pThis->uMagic == RTVFSSYMLINK_MAGIC, VERR_INVALID_HANDLE);
    33033303
    3304     fMode = rtFsModeNormalize(fMode, NULL, 0);
     3304    fMode = rtFsModeNormalize(fMode, NULL, 0, RTFS_TYPE_SYMLINK);
    33053305    if (!rtFsModeIsValid(fMode))
    33063306        return VERR_INVALID_PARAMETER;
  • trunk/src/VBox/Runtime/generic/RTDirSetMode-generic.cpp

    r78947 r79155  
    5353    if (!rtDirValidHandle(hDir))
    5454        return VERR_INVALID_PARAMETER;
     55
     56    /* Make sure we flag it as a directory so that it will be converted correctly: */
     57    if (!(fMode & RTFS_UNIX_MASK))
     58        fMode |= RTFS_DOS_DIRECTORY;
     59    else if (!(fMode & RTFS_TYPE_MASK))
     60        fMode |= RTFS_TYPE_DIRECTORY;
     61
    5562    return RTPathSetMode(hDir->pszPath, fMode);
    5663}
  • trunk/src/VBox/Runtime/include/internal/fs.h

    r77754 r79155  
    4444#define RTFSMODE_SYMLINK_REPARSE_TAG UINT32_C(0xa000000c)
    4545
    46 RTFMODE rtFsModeFromDos(RTFMODE fMode, const char *pszName, size_t cbName, uint32_t uReparseTag);
    47 RTFMODE rtFsModeFromUnix(RTFMODE fMode, const char *pszName, size_t cbName);
    48 RTFMODE rtFsModeNormalize(RTFMODE fMode, const char *pszName, size_t cbName);
     46RTFMODE rtFsModeFromDos(RTFMODE fMode, const char *pszName, size_t cbName, uint32_t uReparseTag, RTFMODE fType);
     47RTFMODE rtFsModeFromUnix(RTFMODE fMode, const char *pszName, size_t cbName, RTFMODE fType);
     48RTFMODE rtFsModeNormalize(RTFMODE fMode, const char *pszName, size_t cbName, RTFMODE fType);
    4949bool    rtFsModeIsValid(RTFMODE fMode);
    5050bool    rtFsModeIsValidPermissions(RTFMODE fMode);
  • trunk/src/VBox/Runtime/r3/fs.cpp

    r78205 r79155  
    4444 * Converts dos-style attributes to Unix attributes.
    4545 *
    46  * @returns
     46 * @returns Normalized mode mask.
    4747 * @param   fMode       The mode mask containing dos-style attributes only.
    4848 * @param   pszName     The filename which this applies to (exe check).
    4949 * @param   cbName      The length of that filename. (optional, set 0)
    5050 * @param   uReparseTag The reparse tag if RTFS_DOS_NT_REPARSE_POINT is set.
    51  */
    52 RTFMODE rtFsModeFromDos(RTFMODE fMode, const char *pszName, size_t cbName, uint32_t uReparseTag)
    53 {
     51 * @param   fType       RTFS_TYPE_XXX to normalize against, 0 if not known.
     52 */
     53RTFMODE rtFsModeFromDos(RTFMODE fMode, const char *pszName, size_t cbName, uint32_t uReparseTag, RTFMODE fType)
     54{
     55    Assert(!(fType & ~RTFS_TYPE_MASK));
     56
    5457    fMode &= ~((1 << RTFS_DOS_SHIFT) - 1);
    5558
    56     /* everything is readable. */
     59    /* Forcibly set the directory attribute if caller desires it. */
     60    if (fType == RTFS_TYPE_DIRECTORY)
     61        fMode |= RTFS_DOS_DIRECTORY;
     62
     63    /* Everything is readable. */
    5764    fMode |= RTFS_UNIX_IRUSR | RTFS_UNIX_IRGRP | RTFS_UNIX_IROTH;
    5865    if (fMode & RTFS_DOS_DIRECTORY)
    59         /* directories are executable. */
     66        /* Directories are executable. */
    6067        fMode |= RTFS_TYPE_DIRECTORY | RTFS_UNIX_IXUSR | RTFS_UNIX_IXGRP | RTFS_UNIX_IXOTH;
    6168    else
     
    108115 * @param   pszName     The filename which this applies to (hidden check).
    109116 * @param   cbName      The length of that filename. (optional, set 0)
    110  */
    111 RTFMODE rtFsModeFromUnix(RTFMODE fMode, const char *pszName, size_t cbName)
    112 {
     117 * @param   fType       RTFS_TYPE_XXX to normalize against, 0 if not known.
     118 */
     119RTFMODE rtFsModeFromUnix(RTFMODE fMode, const char *pszName, size_t cbName, RTFMODE fType)
     120{
     121    Assert(!(fType & ~RTFS_TYPE_MASK));
    113122    NOREF(cbName);
    114123
    115124    fMode &= RTFS_UNIX_MASK;
     125
     126    if (!(fType & RTFS_TYPE_MASK) && fType)
     127        fMode |= fType;
    116128
    117129    if (!(fMode & (RTFS_UNIX_IWUSR | RTFS_UNIX_IWGRP | RTFS_UNIX_IWOTH)))
     
    142154 * @param   pszName     The filename which this applies to (exe check).
    143155 * @param   cbName      The length of that filename. (optional, set 0)
    144  */
    145 RTFMODE rtFsModeNormalize(RTFMODE fMode, const char *pszName, size_t cbName)
    146 {
     156 * @param   fType       RTFS_TYPE_XXX to normalize against, 0 if not known.
     157 */
     158RTFMODE rtFsModeNormalize(RTFMODE fMode, const char *pszName, size_t cbName, RTFMODE fType)
     159{
     160    Assert(!(fType & ~RTFS_TYPE_MASK));
     161
    147162    if (!(fMode & RTFS_UNIX_MASK))
    148         fMode = rtFsModeFromDos(fMode, pszName, cbName, RTFSMODE_SYMLINK_REPARSE_TAG);
     163        fMode = rtFsModeFromDos(fMode, pszName, cbName, RTFSMODE_SYMLINK_REPARSE_TAG, fType);
    149164    else if (!(fMode & RTFS_DOS_MASK))
    150         fMode = rtFsModeFromUnix(fMode, pszName, cbName);
     165        fMode = rtFsModeFromUnix(fMode, pszName, cbName, fType);
    151166    else if (!(fMode & RTFS_TYPE_MASK))
    152167        fMode |= fMode & RTFS_DOS_DIRECTORY ? RTFS_TYPE_DIRECTORY : RTFS_TYPE_FILE;
  • trunk/src/VBox/Runtime/r3/nt/RTFileSetMode-r3-nt.cpp

    r76553 r79155  
    7676    HANDLE hNative = (HANDLE)RTFileToNative(hFile);
    7777    AssertReturn(hNative != RTNT_INVALID_HANDLE_VALUE, VERR_INVALID_HANDLE);
    78     fMode = rtFsModeNormalize(fMode, NULL, 0);
     78    fMode = rtFsModeNormalize(fMode, NULL, 0, RTFS_TYPE_FILE);
    7979    AssertReturn(rtFsModeIsValidPermissions(fMode), VERR_INVALID_FMODE);
    8080
  • trunk/src/VBox/Runtime/r3/nt/RTPathQueryInfo-nt.cpp

    r76553 r79155  
    316316        pObjInfo->Attr.fMode = rtFsModeFromDos(  (pAllInfo->BasicInformation.FileAttributes << RTFS_DOS_SHIFT)
    317317                                               & RTFS_DOS_MASK_NT,
    318                                                pszPath, pszPath ? strlen(pszPath) : 0, uReparseTag);
     318                                               pszPath, pszPath ? strlen(pszPath) : 0, uReparseTag, 0);
    319319        pObjInfo->Attr.enmAdditional = enmAddAttr;
    320320        if (enmAddAttr == RTFSOBJATTRADD_UNIX)
     
    403403                RTTimeSpecSetNtTime(&pObjInfo->ChangeTime,        uBuf.NetOpenInfo.ChangeTime.QuadPart);
    404404                pObjInfo->Attr.fMode = rtFsModeFromDos((uBuf.NetOpenInfo.FileAttributes << RTFS_DOS_SHIFT) & RTFS_DOS_MASK_NT,
    405                                                        pszPath, strlen(pszPath), 0 /*uReparseTag*/);
     405                                                       pszPath, strlen(pszPath), 0 /*uReparseTag*/, 0);
    406406                pObjInfo->Attr.enmAdditional = enmAddAttr;
    407407
     
    585585
    586586                pObjInfo->Attr.fMode  = rtFsModeFromDos((uBuf.Both.FileAttributes << RTFS_DOS_SHIFT) & RTFS_DOS_MASK_NT,
    587                                                         pszPath, strlen(pszPath), uBuf.Both.EaSize);
     587                                                        pszPath, strlen(pszPath), uBuf.Both.EaSize, 0);
    588588
    589589                pObjInfo->Attr.enmAdditional = enmAddAttr;
  • trunk/src/VBox/Runtime/r3/nt/RTPathSetMode-r3-nt.cpp

    r76553 r79155  
    4141RTDECL(int) RTPathSetMode(const char *pszPath, RTFMODE fMode)
    4242{
    43     fMode = rtFsModeNormalize(fMode, pszPath, 0);
     43    fMode = rtFsModeNormalize(fMode, pszPath, 0, 0);
    4444    AssertReturn(rtFsModeIsValidPermissions(fMode), VERR_INVALID_FMODE);
    4545
  • trunk/src/VBox/Runtime/r3/nt/direnum-r3-nt.cpp

    r78050 r79155  
    814814
    815815        pDirEntry->Info.Attr.fMode  = rtFsModeFromDos((pBoth->FileAttributes << RTFS_DOS_SHIFT) & RTFS_DOS_MASK_NT,
    816                                                        pszName, cchName, pBoth->EaSize);
     816                                                       pszName, cchName, pBoth->EaSize, 0);
    817817    }
    818818#ifdef IPRT_WITH_NT_PATH_PASSTHRU
  • trunk/src/VBox/Runtime/r3/nt/dirrel-r3-nt.cpp

    r78098 r79155  
    293293    AssertReturn(pThis->u32Magic == RTDIR_MAGIC, VERR_INVALID_HANDLE);
    294294    AssertReturn(!(fCreate & ~RTDIRCREATE_FLAGS_VALID_MASK), VERR_INVALID_FLAGS);
    295     fMode = rtFsModeNormalize(fMode, pszRelPath, 0);
     295    fMode = rtFsModeNormalize(fMode, pszRelPath, 0, RTFS_TYPE_DIRECTORY);
    296296    AssertReturn(rtFsModeIsValidPermissions(fMode), VERR_INVALID_FMODE);
    297297    AssertPtrNullReturn(phSubDir, VERR_INVALID_POINTER);
     
    491491    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    492492    AssertReturn(pThis->u32Magic == RTDIR_MAGIC, VERR_INVALID_HANDLE);
    493     fMode = rtFsModeNormalize(fMode, pszRelPath, 0);
     493    fMode = rtFsModeNormalize(fMode, pszRelPath, 0, 0);
    494494    AssertReturn(rtFsModeIsValidPermissions(fMode), VERR_INVALID_FMODE);
    495495    AssertMsgReturn(RTPATH_F_IS_VALID(fFlags, 0), ("%#x\n", fFlags), VERR_INVALID_FLAGS);
  • trunk/src/VBox/Runtime/r3/posix/dir-posix.cpp

    r78730 r79155  
    8484
    8585    int rc;
    86     fMode = rtFsModeNormalize(fMode, pszPath, 0);
     86    fMode = rtFsModeNormalize(fMode, pszPath, 0, RTFS_TYPE_DIRECTORY);
    8787    if (rtFsModeIsValidPermissions(fMode))
    8888    {
  • trunk/src/VBox/Runtime/r3/posix/fileio-posix.cpp

    r77684 r79155  
    819819     * Normalize the mode and call the API.
    820820     */
    821     fMode = rtFsModeNormalize(fMode, NULL, 0);
     821    fMode = rtFsModeNormalize(fMode, NULL, 0, RTFS_TYPE_FILE);
    822822    if (!rtFsModeIsValid(fMode))
    823823        return VERR_INVALID_PARAMETER;
  • trunk/src/VBox/Runtime/r3/posix/fs2-posix.cpp

    r77754 r79155  
    132132    Assert(RTFS_TYPE_MASK == S_IFMT);
    133133
    134     pObjInfo->Attr.fMode  = rtFsModeFromUnix(fMode, pszName, cbName);
     134    pObjInfo->Attr.fMode  = rtFsModeFromUnix(fMode, pszName, cbName, 0);
    135135
    136136    /* additional unix attribs */
  • trunk/src/VBox/Runtime/r3/posix/path-posix.cpp

    r78178 r79155  
    8787
    8888    int rc;
    89     fMode = rtFsModeNormalize(fMode, pszPath, 0);
     89    fMode = rtFsModeNormalize(fMode, pszPath, 0, 0);
    9090    if (rtFsModeIsValidPermissions(fMode))
    9191    {
  • trunk/src/VBox/Runtime/r3/win/dir-win.cpp

    r76553 r79155  
    5151     */
    5252    int rc;
    53     fMode = rtFsModeNormalize(fMode, pszPath, 0);
     53    fMode = rtFsModeNormalize(fMode, pszPath, 0, RTFS_TYPE_DIRECTORY);
    5454    if (rtFsModeIsValidPermissions(fMode))
    5555    {
  • trunk/src/VBox/Runtime/r3/win/direnum-win.cpp

    r78050 r79155  
    345345
    346346    pDirEntry->Info.Attr.fMode  = rtFsModeFromDos((pDir->Data.dwFileAttributes << RTFS_DOS_SHIFT) & RTFS_DOS_MASK_NT,
    347                                                    pszName, cchName, pDir->Data.dwReserved0);
     347                                                   pszName, cchName, pDir->Data.dwReserved0, 0);
    348348
    349349    /*
  • trunk/src/VBox/Runtime/r3/win/fileio-win.cpp

    r77681 r79155  
    10381038    RT_ZERO(*pObjInfo);
    10391039    pObjInfo->Attr.enmAdditional = enmAdditionalAttribs;
    1040     pObjInfo->Attr.fMode = rtFsModeFromDos(RTFS_DOS_NT_DEVICE, "", 0, 0);
     1040    pObjInfo->Attr.fMode = rtFsModeFromDos(RTFS_DOS_NT_DEVICE, "", 0, 0, 0);
    10411041    return VINF_SUCCESS;
    10421042#else
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