VirtualBox

Changeset 78279 in vbox for trunk


Ignore:
Timestamp:
Apr 24, 2019 4:19:10 PM (6 years ago)
Author:
vboxsync
Message:

winnt/vboxsf: Simplified file attribute conversion and made sure the result is never zero. bugref:9172

Location:
trunk/src/VBox/Additions/WINNT/SharedFolders/driver
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/file.c

    r76553 r78279  
    261261#endif
    262262    {
     263/** @todo r=bird: How is this file size accurate given that the file resides
     264 *        on the host and be grown/shrunk independently there?   Why is this
     265 *        only done when FCB_STATE_READCACHEING_ENABLED is clear? */
    263266        if (ByteOffset >= FileSize)
    264267        {
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/path.c

    r76553 r78279  
    6363    {
    6464        Log(("VBOXSF: vbsfProcessCreate: Unsupported: extended attributes!\n"));
    65         Status = STATUS_NOT_SUPPORTED;
     65        Status = STATUS_NOT_SUPPORTED; /// @todo STATUS_EAS_NOT_SUPPORTED ?
    6666        goto failure;
    6767    }
     
    105105    CreateDisposition = RxContext->Create.NtCreateParameters.Disposition;
    106106
    107     bf.CreateDirectory = (BOOLEAN)(bf.DirectoryFile && ((CreateDisposition == FILE_CREATE) || (CreateDisposition == FILE_OPEN_IF)));
    108     bf.OpenDirectory = (BOOLEAN)(bf.DirectoryFile && ((CreateDisposition == FILE_OPEN) || (CreateDisposition == FILE_OPEN_IF)));
     107    bf.CreateDirectory = (bf.DirectoryFile && ((CreateDisposition == FILE_CREATE) || (CreateDisposition == FILE_OPEN_IF)));
     108    bf.OpenDirectory = (bf.DirectoryFile && ((CreateDisposition == FILE_OPEN) || (CreateDisposition == FILE_OPEN_IF)));
    109109    bf.TemporaryFile = BooleanFlagOn(RxContext->Create.NtCreateParameters.FileAttributes, FILE_ATTRIBUTE_TEMPORARY);
    110110
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsfhlp.c

    r76553 r78279  
    3939
    4040/**
    41  * Convert VBox IRT file attributes to NT file attributes
     41 * Converts VBox (IPRT) file mode to NT file attributes.
    4242 *
    4343 * @returns NT file attributes
    44  * @param   fMode       IRT file attributes
    45  *
    46  */
    47 uint32_t VBoxToNTFileAttributes(uint32_t fMode)
    48 {
    49     uint32_t FileAttributes = 0;
    50 
    51     if (fMode & RTFS_DOS_READONLY)
    52         FileAttributes |= FILE_ATTRIBUTE_READONLY;
    53     if (fMode & RTFS_DOS_HIDDEN)
    54         FileAttributes |= FILE_ATTRIBUTE_HIDDEN;
    55     if (fMode & RTFS_DOS_SYSTEM)
    56         FileAttributes |= FILE_ATTRIBUTE_SYSTEM;
    57     if (fMode & RTFS_DOS_DIRECTORY)
    58         FileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
    59     if (fMode & RTFS_DOS_ARCHIVED)
    60         FileAttributes |= FILE_ATTRIBUTE_ARCHIVE;
    61     if (fMode & RTFS_DOS_NT_TEMPORARY)
    62         FileAttributes |= FILE_ATTRIBUTE_TEMPORARY;
    63     if (fMode & RTFS_DOS_NT_SPARSE_FILE)
    64         FileAttributes |= FILE_ATTRIBUTE_SPARSE_FILE;
    65     if (fMode & RTFS_DOS_NT_REPARSE_POINT)
    66         FileAttributes |= FILE_ATTRIBUTE_REPARSE_POINT;
    67     if (fMode & RTFS_DOS_NT_COMPRESSED)
    68         FileAttributes |= FILE_ATTRIBUTE_COMPRESSED;
    69     /*    if (fMode & RTFS_DOS_NT_OFFLINE) */
    70     if (fMode & RTFS_DOS_NT_NOT_CONTENT_INDEXED)
    71         FileAttributes |= FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
    72     if (fMode & RTFS_DOS_NT_ENCRYPTED)
    73         FileAttributes |= FILE_ATTRIBUTE_ENCRYPTED;
    74     if (fMode & RTFS_DOS_NT_NORMAL)
    75         FileAttributes |= FILE_ATTRIBUTE_NORMAL;
    76     return FileAttributes;
     44 * @param   fIprtMode   IPRT file mode.
     45 *
     46 */
     47uint32_t VBoxToNTFileAttributes(uint32_t fIprtMode)
     48{
     49    AssertCompile((RTFS_DOS_READONLY               >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_READONLY);
     50    AssertCompile((RTFS_DOS_HIDDEN                 >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_HIDDEN);
     51    AssertCompile((RTFS_DOS_SYSTEM                 >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_SYSTEM);
     52    AssertCompile((RTFS_DOS_DIRECTORY              >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_DIRECTORY);
     53    AssertCompile((RTFS_DOS_ARCHIVED               >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_ARCHIVE);
     54    /* skipping:   RTFS_DOS_NT_DEVICE */
     55    AssertCompile((RTFS_DOS_NT_NORMAL              >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_NORMAL);
     56    AssertCompile((RTFS_DOS_NT_TEMPORARY           >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_TEMPORARY);
     57    AssertCompile((RTFS_DOS_NT_SPARSE_FILE         >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_SPARSE_FILE);
     58    AssertCompile((RTFS_DOS_NT_REPARSE_POINT       >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_REPARSE_POINT);
     59    AssertCompile((RTFS_DOS_NT_COMPRESSED          >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_COMPRESSED);
     60    /* skipping:   RTFS_DOS_NT_OFFLINE */
     61    AssertCompile((RTFS_DOS_NT_NOT_CONTENT_INDEXED >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_NOT_CONTENT_INDEXED);
     62    AssertCompile((RTFS_DOS_NT_ENCRYPTED           >> RTFS_DOS_SHIFT) == FILE_ATTRIBUTE_ENCRYPTED);
     63
     64    uint32_t fNtAttribs = (fIprtMode & (RTFS_DOS_MASK_NT & ~(RTFS_DOS_NT_OFFLINE | RTFS_DOS_NT_DEVICE)) >> RTFS_DOS_SHIFT);
     65    return fNtAttribs ? fNtAttribs : FILE_ATTRIBUTE_NORMAL;
    7766}
    7867
    7968/**
    80  * Convert VBox IRT file attributes to NT file attributes
    81  *
    82  * @returns NT file attributes
    83  * @param   fMode       IRT file attributes
    84  *
    85  */
    86 uint32_t NTToVBoxFileAttributes(uint32_t fMode)
    87 {
    88     uint32_t FileAttributes = 0;
    89 
    90     if (fMode & FILE_ATTRIBUTE_READONLY)
    91         FileAttributes |= RTFS_DOS_READONLY;
    92     if (fMode & FILE_ATTRIBUTE_HIDDEN)
    93         FileAttributes |= RTFS_DOS_HIDDEN;
    94     if (fMode & FILE_ATTRIBUTE_SYSTEM)
    95         FileAttributes |= RTFS_DOS_SYSTEM;
    96     if (fMode & FILE_ATTRIBUTE_DIRECTORY)
    97         FileAttributes |= RTFS_DOS_DIRECTORY;
    98     if (fMode & FILE_ATTRIBUTE_ARCHIVE)
    99         FileAttributes |= RTFS_DOS_ARCHIVED;
    100     if (fMode & FILE_ATTRIBUTE_TEMPORARY)
    101         FileAttributes |= RTFS_DOS_NT_TEMPORARY;
    102     if (fMode & FILE_ATTRIBUTE_SPARSE_FILE)
    103         FileAttributes |= RTFS_DOS_NT_SPARSE_FILE;
    104     if (fMode & FILE_ATTRIBUTE_REPARSE_POINT)
    105         FileAttributes |= RTFS_DOS_NT_REPARSE_POINT;
    106     if (fMode & FILE_ATTRIBUTE_COMPRESSED)
    107         FileAttributes |= RTFS_DOS_NT_COMPRESSED;
    108     if (fMode & FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)
    109         FileAttributes |= RTFS_DOS_NT_NOT_CONTENT_INDEXED;
    110     if (fMode & FILE_ATTRIBUTE_ENCRYPTED)
    111         FileAttributes |= RTFS_DOS_NT_ENCRYPTED;
    112     if (fMode & FILE_ATTRIBUTE_NORMAL)
    113     {
    114         FileAttributes |= RTFS_DOS_NT_NORMAL;
    115     }
    116     return FileAttributes;
     69 * Converts NT file attributes to VBox (IPRT) ones.
     70 *
     71 * @returns IPRT file mode
     72 * @param   fNtAttribs      NT file attributes
     73 */
     74uint32_t NTToVBoxFileAttributes(uint32_t fNtAttribs)
     75{
     76    uint32_t fIprtMode = (fNtAttribs << RTFS_DOS_SHIFT) & RTFS_DOS_MASK_NT;
     77    return fIprtMode ? fIprtMode : RTFS_DOS_NT_NORMAL;
    11778}
    11879
     
    139100}
    140101
    141     /**
    142      * Convert VBox error code to NT status code
    143      *
    144      * @returns NT status code
    145      * @param   vboxRC          VBox error code
    146      *
    147      */
     102/**
     103 * Convert VBox error code to NT status code
     104 *
     105 * @returns NT status code
     106 * @param   vboxRC          VBox error code
     107 *
     108 */
    148109NTSTATUS VBoxErrorToNTStatus(int vboxRC)
    149110{
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsfhlp.h

    r76563 r78279  
    3232NTSTATUS vbsfHlpCreateDriveLetter(WCHAR Letter, UNICODE_STRING *pDeviceName);
    3333NTSTATUS vbsfHlpDeleteDriveLetter(WCHAR Letter);
    34 
    35 /**
    36  * Convert VBox IRT file attributes to NT file attributes
    37  *
    38  * @returns NT file attributes
    39  * @param   fMode       IRT file attributes
    40  *
    41  */
    42 uint32_t VBoxToNTFileAttributes(uint32_t fMode);
    43 
    44 /**
    45  * Convert VBox IRT file attributes to NT file attributes
    46  *
    47  * @returns NT file attributes
    48  * @param   fMode       IRT file attributes
    49  *
    50  */
    51 uint32_t NTToVBoxFileAttributes(uint32_t fMode);
     34uint32_t VBoxToNTFileAttributes(uint32_t fIprtMode);
     35uint32_t NTToVBoxFileAttributes(uint32_t fNtAttribs);
    5236
    5337/**
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