VirtualBox

Changeset 79155 in vbox for trunk/src/VBox/Runtime/r3/fs.cpp


Ignore:
Timestamp:
Jun 14, 2019 4:33:05 PM (5 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
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