VirtualBox

Changeset 20316 in vbox


Ignore:
Timestamp:
Jun 5, 2009 12:15:59 PM (16 years ago)
Author:
vboxsync
Message:

Shared folders host service: use unix create mode bits only with additions, which support them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp

    r20292 r20316  
    607607 * @retval pfOpen     iprt create flags
    608608 */
    609 static int vbsfConvertFileOpenFlags(unsigned fShflFlags, RTFMODE fMode, unsigned *pfOpen)
     609static int vbsfConvertFileOpenFlags(unsigned fShflFlags, RTFMODE fMode, SHFLHANDLE handleInitial, unsigned *pfOpen)
    610610{
    611611    unsigned fOpen = 0;
     
    626626        if (!(fMode & RTFS_DOS_READONLY))
    627627            fMode |= RTFS_UNIX_IWUSR | RTFS_UNIX_IWGRP | RTFS_UNIX_IWOTH;
    628     }
    629    
    630     /* Set the requested mode. */
    631     fOpen |= (fMode & RTFS_UNIX_MASK) << RTFILE_O_CREATE_MODE_SHIFT;
     628
     629        /* Set the requested mode using only allowed bits. */
     630        fOpen |= ((fMode & RTFS_UNIX_MASK) << RTFILE_O_CREATE_MODE_SHIFT) & RTFILE_O_CREATE_MODE_MASK;
     631    }
     632    else
     633    {
     634        /* Old linux and solaris additions did not initialize the Info.Attr.fMode field
     635         * and it contained random bits from stack. Detect this using the handle field value
     636         * passed from the guest: old additions set it (incorrectly) to 0, new additions
     637         * set it to SHFL_HANDLE_NIL(~0).
     638         */
     639        if (handleInitial == 0)
     640        {
     641            /* Old additions. Do nothing, use default mode. */
     642        }
     643        else
     644        {
     645            /* New additions or Windows additions. Set the requested mode using only allowed bits.
     646             * Note: Windows guest set RTFS_UNIX_MASK bits to 0, which means a default mode
     647             *       will be set in fOpen.
     648             */
     649            fOpen |= ((fMode & RTFS_UNIX_MASK) << RTFILE_O_CREATE_MODE_SHIFT) & RTFILE_O_CREATE_MODE_MASK;
     650        }
     651    }
    632652
    633653    switch (BIT_FLAG(fShflFlags, SHFL_CF_ACCESS_MASK_RW))
     
    825845    static int cErrors;
    826846
    827     int rc = vbsfConvertFileOpenFlags(pParms->CreateFlags, pParms->Info.Attr.fMode, &fOpen);
     847    int rc = vbsfConvertFileOpenFlags(pParms->CreateFlags, pParms->Info.Attr.fMode, pParms->Handle, &fOpen);
    828848    if (RT_SUCCESS(rc))
    829849    {
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