VirtualBox

Changeset 78552 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
May 17, 2019 12:08:11 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
130599
Message:

winnt/vboxsf: Converted VBoxMRxCreate to using VbglR0SfHostReqCreate. Got rid of the goto's and made some other cleanups in the create code. bugref:9172

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/path.cpp

    r78548 r78552  
    3030
    3131
    32 static NTSTATUS vbsfProcessCreate(PRX_CONTEXT RxContext,
    33                                   PUNICODE_STRING RemainingName,
    34                                   SHFLFSOBJINFO *pInfo,
    35                                   PVOID EaBuffer,
    36                                   ULONG EaLength,
    37                                   ULONG *pulCreateAction,
    38                                   SHFLHANDLE *pHandle)
    39 {
    40     NTSTATUS Status = STATUS_SUCCESS;
    41 
    42     RxCaptureFcb;
    43 
    44     PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(capFcb->pNetRoot);
    45 
    46     int vrc = VINF_SUCCESS;
     32static NTSTATUS vbsfNtCreateWorkerBail(NTSTATUS Status, VBOXSFCREATEREQ *pReq, PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension)
     33{
     34    Log(("VBOXSF: vbsfNtCreateWorker: Returns %#x (Handle was %#RX64)\n", Status, pReq->CreateParms.Handle));
     35    AssertCompile(sizeof(VBOXSFCLOSEREQ) <= RT_UOFFSETOF(VBOXSFCREATEREQ, CreateParms));
     36    VbglR0SfHostReqClose(pNetRootExtension->map.root, (VBOXSFCLOSEREQ *)pReq, pReq->CreateParms.Handle);
     37    return Status;
     38}
     39
     40
     41static NTSTATUS vbsfNtCreateWorker(PRX_CONTEXT RxContext, VBOXSFCREATEREQ *pReq, ULONG *pulCreateAction,
     42                                   PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension, PMRX_FCB pFcb)
     43{
     44    /* Mask out unsupported attribute bits. */
     45    UCHAR       FileAttributes = (UCHAR)(RxContext->Create.NtCreateParameters.FileAttributes & ~FILE_ATTRIBUTE_NORMAL); /** @todo why UCHAR? */
     46    FileAttributes &= (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE);
     47    if (FileAttributes == 0)
     48        FileAttributes = FILE_ATTRIBUTE_NORMAL;
     49
     50    ACCESS_MASK const DesiredAccess  = RxContext->Create.NtCreateParameters.DesiredAccess;
     51    ULONG       const Options        = RxContext->Create.NtCreateParameters.CreateOptions & FILE_VALID_OPTION_FLAGS;
     52    ULONG       const ShareAccess    = RxContext->Create.NtCreateParameters.ShareAccess;
    4753
    4854    /* Various boolean flags. */
     
    5763        ULONG SlashHack :1;
    5864    } bf;
    59 
    60     ACCESS_MASK DesiredAccess;
    61     ULONG Options;
    62     UCHAR FileAttributes;
    63     ULONG ShareAccess;
    64     ULONG CreateDisposition;
    65     SHFLCREATEPARMS *pCreateParms = NULL;
    66 
    67     RT_NOREF(EaBuffer);
    68 
    69     if (EaLength)
    70     {
    71         Log(("VBOXSF: vbsfProcessCreate: Unsupported: extended attributes!\n"));
    72         Status = STATUS_NOT_SUPPORTED; /// @todo STATUS_EAS_NOT_SUPPORTED ?
    73         goto failure;
    74     }
    75 
    76     if (BooleanFlagOn(capFcb->FcbState, FCB_STATE_PAGING_FILE))
    77     {
    78         Log(("VBOXSF: vbsfProcessCreate: Unsupported: paging file!\n"));
    79         Status = STATUS_NOT_IMPLEMENTED;
    80         goto failure;
    81     }
    82 
    83     Log(("VBOXSF: vbsfProcessCreate: FileAttributes = 0x%08x\n",
    84          RxContext->Create.NtCreateParameters.FileAttributes));
    85     Log(("VBOXSF: vbsfProcessCreate: CreateOptions = 0x%08x\n",
    86          RxContext->Create.NtCreateParameters.CreateOptions));
    87 
    88     RtlZeroMemory (&bf, sizeof (bf));
    89 
    90     DesiredAccess = RxContext->Create.NtCreateParameters.DesiredAccess;
    91     Options = RxContext->Create.NtCreateParameters.CreateOptions & FILE_VALID_OPTION_FLAGS;
    92     FileAttributes = (UCHAR)(RxContext->Create.NtCreateParameters.FileAttributes & ~FILE_ATTRIBUTE_NORMAL);
    93     ShareAccess = RxContext->Create.NtCreateParameters.ShareAccess;
    94 
    95     /* We do not support opens by file ids. */
    96     if (FlagOn(Options, FILE_OPEN_BY_FILE_ID))
    97     {
    98         Log(("VBOXSF: vbsfProcessCreate: Unsupported: file open by id!\n"));
    99         Status = STATUS_NOT_IMPLEMENTED;
    100         goto failure;
    101     }
    102 
    103     /* Mask out unsupported attribute bits. */
    104     FileAttributes &= (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE);
     65    RT_ZERO(bf);
    10566
    10667    bf.DirectoryFile = BooleanFlagOn(Options, FILE_DIRECTORY_FILE);
     
    11071        Log(("VBOXSF: vbsfProcessCreate: Delete on close!\n"));
    11172
    112     CreateDisposition = RxContext->Create.NtCreateParameters.Disposition;
     73    ULONG CreateDisposition = RxContext->Create.NtCreateParameters.Disposition;
    11374
    11475    bf.CreateDirectory = (bf.DirectoryFile && ((CreateDisposition == FILE_CREATE) || (CreateDisposition == FILE_OPEN_IF)));
     
    11677    bf.TemporaryFile = BooleanFlagOn(RxContext->Create.NtCreateParameters.FileAttributes, FILE_ATTRIBUTE_TEMPORARY);
    11778
    118     if (FlagOn(capFcb->FcbState, FCB_STATE_TEMPORARY))
     79    if (FlagOn(pFcb->FcbState, FCB_STATE_TEMPORARY))
    11980        bf.TemporaryFile = TRUE;
    12081
     
    12990    {
    13091        Log(("VBOXSF: vbsfProcessCreate: Not allowed: Temporary directories!\n"));
    131         Status = STATUS_INVALID_PARAMETER;
    132         goto failure;
     92        return STATUS_INVALID_PARAMETER;
    13393    }
    13494
     
    13797        /** @todo r=bird: Check if FILE_DIRECTORY_FILE+FILE_NON_DIRECTORY_FILE really is illegal in all combinations... */
    13898        Log(("VBOXSF: vbsfProcessCreate: Unsupported combination: dir && !dir\n"));
    139         Status = STATUS_INVALID_PARAMETER;
    140         goto failure;
    141     }
    142 
    143     /* Initialize create parameters. */
    144     pCreateParms = (SHFLCREATEPARMS *)vbsfNtAllocNonPagedMem(sizeof(SHFLCREATEPARMS));
    145     if (!pCreateParms)
    146     {
    147         Status = STATUS_INSUFFICIENT_RESOURCES;
    148         goto failure;
    149     }
    150 
    151     RtlZeroMemory(pCreateParms, sizeof (SHFLCREATEPARMS));
    152 
    153     pCreateParms->Handle = SHFL_HANDLE_NIL;
    154     pCreateParms->Result = SHFL_NO_RESULT;
    155 
     99        return STATUS_INVALID_PARAMETER;
     100    }
     101
     102    /*
     103     * Initialize create parameters.
     104     */
     105    RT_ZERO(pReq->CreateParms);
     106    pReq->CreateParms.Handle = SHFL_HANDLE_NIL;
     107    pReq->CreateParms.Result = SHFL_NO_RESULT;
     108
     109    /*
     110     * Directory.
     111     */
    156112    if (bf.DirectoryFile)
    157113    {
     
    160116            Log(("VBOXSF: vbsfProcessCreate: Invalid disposition 0x%08X for directory!\n",
    161117                 CreateDisposition));
    162             Status = STATUS_INVALID_PARAMETER;
    163             goto failure;
     118            return STATUS_INVALID_PARAMETER;
    164119        }
    165120
    166         pCreateParms->CreateFlags |= SHFL_CF_DIRECTORY;
    167     }
    168 
    169     Log(("VBOXSF: vbsfProcessCreate: CreateDisposition = 0x%08X\n",
    170          CreateDisposition));
    171 
     121        Log(("VBOXSF: vbsfProcessCreate: CreateFlags |= SHFL_CF_DIRECTORY\n"));
     122        pReq->CreateParms.CreateFlags |= SHFL_CF_DIRECTORY;
     123    }
     124
     125    /*
     126     * Disposition.
     127     */
    172128    switch (CreateDisposition)
    173129    {
    174130        case FILE_SUPERSEDE:
    175             pCreateParms->CreateFlags |= SHFL_CF_ACT_REPLACE_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW;
     131            pReq->CreateParms.CreateFlags |= SHFL_CF_ACT_REPLACE_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW;
    176132            Log(("VBOXSF: vbsfProcessCreate: CreateFlags |= SHFL_CF_ACT_REPLACE_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW\n"));
    177133            break;
    178134
    179135        case FILE_OPEN:
    180             pCreateParms->CreateFlags |= SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW;
     136            pReq->CreateParms.CreateFlags |= SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW;
    181137            Log(("VBOXSF: vbsfProcessCreate: CreateFlags |= SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW\n"));
    182138            break;
    183139
    184140        case FILE_CREATE:
    185             pCreateParms->CreateFlags |= SHFL_CF_ACT_FAIL_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW;
     141            pReq->CreateParms.CreateFlags |= SHFL_CF_ACT_FAIL_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW;
    186142            Log(("VBOXSF: vbsfProcessCreate: CreateFlags |= SHFL_CF_ACT_FAIL_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW\n"));
    187143            break;
    188144
    189145        case FILE_OPEN_IF:
    190             pCreateParms->CreateFlags |= SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW;
     146            pReq->CreateParms.CreateFlags |= SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW;
    191147            Log(("VBOXSF: vbsfProcessCreate: CreateFlags |= SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW\n"));
    192148            break;
    193149
    194150        case FILE_OVERWRITE:
    195             pCreateParms->CreateFlags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW;
     151            pReq->CreateParms.CreateFlags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW;
    196152            Log(("VBOXSF: vbsfProcessCreate: CreateFlags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW\n"));
    197153            break;
    198154
    199155        case FILE_OVERWRITE_IF:
    200             pCreateParms->CreateFlags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW;
     156            pReq->CreateParms.CreateFlags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW;
    201157            Log(("VBOXSF: vbsfProcessCreate: CreateFlags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW\n"));
    202158            break;
    203159
    204160        default:
    205             Log(("VBOXSF: vbsfProcessCreate: Unexpected create disposition: 0x%08X\n",
    206                  CreateDisposition));
    207             Status = STATUS_INVALID_PARAMETER;
    208             goto failure;
    209     }
    210 
    211     Log(("VBOXSF: vbsfProcessCreate: DesiredAccess = 0x%08X\n",
    212          DesiredAccess));
    213     Log(("VBOXSF: vbsfProcessCreate: ShareAccess   = 0x%08X\n",
    214          ShareAccess));
    215 
     161            Log(("VBOXSF: vbsfProcessCreate: Unexpected create disposition: 0x%08X\n", CreateDisposition));
     162            return STATUS_INVALID_PARAMETER;
     163    }
     164
     165    /*
     166     * Access mode.
     167     */
    216168    if (DesiredAccess & FILE_READ_DATA)
    217169    {
    218170        Log(("VBOXSF: vbsfProcessCreate: FILE_READ_DATA\n"));
    219         pCreateParms->CreateFlags |= SHFL_CF_ACCESS_READ;
    220     }
    221 
     171        pReq->CreateParms.CreateFlags |= SHFL_CF_ACCESS_READ;
     172    }
     173
     174    /* FILE_WRITE_DATA means write access regardless of FILE_APPEND_DATA bit.
     175       FILE_APPEND_DATA without FILE_WRITE_DATA means append only mode. */
    222176    if (DesiredAccess & FILE_WRITE_DATA)
    223177    {
    224178        Log(("VBOXSF: vbsfProcessCreate: FILE_WRITE_DATA\n"));
    225         /* FILE_WRITE_DATA means write access regardless of FILE_APPEND_DATA bit.
    226          */
    227         pCreateParms->CreateFlags |= SHFL_CF_ACCESS_WRITE;
     179        pReq->CreateParms.CreateFlags |= SHFL_CF_ACCESS_WRITE;
    228180    }
    229181    else if (DesiredAccess & FILE_APPEND_DATA)
    230182    {
     183        /* Both write and append access flags are required for shared folders,
     184         * as on Windows FILE_APPEND_DATA implies write access. */
    231185        Log(("VBOXSF: vbsfProcessCreate: FILE_APPEND_DATA\n"));
    232         /* FILE_APPEND_DATA without FILE_WRITE_DATA means append only mode.
    233          *
    234          * Both write and append access flags are required for shared folders,
    235          * as on Windows FILE_APPEND_DATA implies write access.
    236          */
    237         pCreateParms->CreateFlags |= SHFL_CF_ACCESS_WRITE | SHFL_CF_ACCESS_APPEND;
     186        pReq->CreateParms.CreateFlags |= SHFL_CF_ACCESS_WRITE | SHFL_CF_ACCESS_APPEND;
    238187    }
    239188
    240189    if (DesiredAccess & FILE_READ_ATTRIBUTES)
    241         pCreateParms->CreateFlags |= SHFL_CF_ACCESS_ATTR_READ;
     190        pReq->CreateParms.CreateFlags |= SHFL_CF_ACCESS_ATTR_READ;
    242191    if (DesiredAccess & FILE_WRITE_ATTRIBUTES)
    243         pCreateParms->CreateFlags |= SHFL_CF_ACCESS_ATTR_WRITE;
     192        pReq->CreateParms.CreateFlags |= SHFL_CF_ACCESS_ATTR_WRITE;
    244193
    245194    if (ShareAccess & (FILE_SHARE_READ | FILE_SHARE_WRITE))
    246         pCreateParms->CreateFlags |= SHFL_CF_ACCESS_DENYNONE;
     195        pReq->CreateParms.CreateFlags |= SHFL_CF_ACCESS_DENYNONE;
    247196    else if (ShareAccess & FILE_SHARE_READ)
    248         pCreateParms->CreateFlags |= SHFL_CF_ACCESS_DENYWRITE;
     197        pReq->CreateParms.CreateFlags |= SHFL_CF_ACCESS_DENYWRITE;
    249198    else if (ShareAccess & FILE_SHARE_WRITE)
    250         pCreateParms->CreateFlags |= SHFL_CF_ACCESS_DENYREAD;
    251     else pCreateParms->CreateFlags |= SHFL_CF_ACCESS_DENYALL;
    252 
    253     /* Set initial allocation size. */
    254     pCreateParms->Info.cbObject = RxContext->Create.NtCreateParameters.AllocationSize.QuadPart;
    255 
    256     if (FileAttributes == 0)
    257         FileAttributes = FILE_ATTRIBUTE_NORMAL;
    258 
    259     pCreateParms->Info.Attr.fMode = NTToVBoxFileAttributes(FileAttributes);
    260 
    261     {
    262         PSHFLSTRING ParsedPath;
    263         Log(("VBOXSF: vbsfProcessCreate: RemainingName->Length = %d\n", RemainingName->Length));
    264 
    265 
    266         if (!bf.SlashHack)
    267         {
    268             Status = vbsfNtShflStringFromUnicodeAlloc(&ParsedPath, RemainingName->Buffer, RemainingName->Length);
    269             if (Status != STATUS_SUCCESS)
    270                 goto failure;
    271         }
    272         else
    273         {
    274             /* Add back the slash we had to hide from RDBSS. */
    275             Status = vbsfNtShflStringFromUnicodeAlloc(&ParsedPath, NULL, RemainingName->Length + sizeof(RTUTF16));
    276             if (Status != STATUS_SUCCESS)
    277                 goto failure;
    278             memcpy(ParsedPath->String.utf16, RemainingName->Buffer, RemainingName->Length);
    279             ParsedPath->String.utf16[RemainingName->Length / sizeof(RTUTF16)] = '\\';
    280             ParsedPath->String.utf16[RemainingName->Length / sizeof(RTUTF16) + 1] = '\0';
    281             ParsedPath->u16Length = RemainingName->Length + sizeof(RTUTF16);
    282         }
    283 
    284         Log(("VBOXSF: ParsedPath: %.*ls\n",
    285              ParsedPath->u16Length / sizeof(WCHAR), ParsedPath->String.ucs2));
    286 
    287         /* Call host. */
    288         Log(("VBOXSF: vbsfProcessCreate: VbglR0SfCreate called.\n"));
    289         vrc = VbglR0SfCreate(&g_SfClient, &pNetRootExtension->map, ParsedPath, pCreateParms);
    290 
    291         vbsfNtFreeNonPagedMem(ParsedPath);
    292     }
    293 
    294     Log(("VBOXSF: vbsfProcessCreate: VbglR0SfCreate returns vrc = %Rrc, Result = 0x%x\n",
    295          vrc, pCreateParms->Result));
     199        pReq->CreateParms.CreateFlags |= SHFL_CF_ACCESS_DENYREAD;
     200    else
     201        pReq->CreateParms.CreateFlags |= SHFL_CF_ACCESS_DENYALL;
     202
     203    /*
     204     * Set initial allocation size and attributes.
     205     */
     206    pReq->CreateParms.Info.cbObject   = RxContext->Create.NtCreateParameters.AllocationSize.QuadPart;
     207    pReq->CreateParms.Info.Attr.fMode = NTToVBoxFileAttributes(FileAttributes);
     208
     209    /*
     210     * Call the host.
     211     */
     212    Log(("VBOXSF: vbsfProcessCreate: Calling VbglR0SfHostReqCreate...\n"));
     213    int vrc = VbglR0SfHostReqCreate(pNetRootExtension->map.root, pReq);
     214    Log(("VBOXSF: vbsfProcessCreate: VbglR0SfCreate returns vrc = %Rrc, Result = 0x%x\n", vrc, pReq->CreateParms.Result));
    296215
    297216    if (RT_FAILURE(vrc))
     
    301220        {
    302221            case VERR_ALREADY_EXISTS:
    303             {
     222                Log(("VBOXSF: vbsfProcessCreate: VERR_ALREADY_EXISTS -> STATUS_OBJECT_NAME_COLLISION + FILE_EXISTS\n"));
    304223                *pulCreateAction = FILE_EXISTS;
    305                 Status = STATUS_OBJECT_NAME_COLLISION;
    306                 goto failure;
    307             }
     224                return STATUS_OBJECT_NAME_COLLISION;
    308225
    309226            /* On POSIX systems, the "mkdir" command returns VERR_FILE_NOT_FOUND when
     
    314231                     so that FsPerf is happy. */
    315232            case VERR_FILE_NOT_FOUND: /** @todo r=bird: this is a host bug, isn't it? */
    316             {
    317                 pCreateParms->Result = SHFL_FILE_NOT_FOUND;
    318                 break;
    319             }
     233                pReq->CreateParms.Result = SHFL_FILE_NOT_FOUND;
     234                pReq->CreateParms.Handle = SHFL_HANDLE_NIL;
     235                *pulCreateAction = FILE_DOES_NOT_EXIST;
     236                Log(("VBOXSF: vbsfProcessCreate: VERR_FILE_NOT_FOUND -> STATUS_OBJECT_NAME_NOT_FOUND + FILE_DOES_NOT_EXIST\n"));
     237                return STATUS_OBJECT_NAME_NOT_FOUND;
    320238
    321239            default:
    322240            {
    323241                *pulCreateAction = FILE_DOES_NOT_EXIST;
    324                 Status = vbsfNtVBoxStatusToNt(vrc);
    325                 goto failure;
     242                NTSTATUS Status = vbsfNtVBoxStatusToNt(vrc);
     243                Log(("VBOXSF: vbsfProcessCreate: %Rrc -> %#010x + FILE_DOES_NOT_EXIST\n", vrc, Status));
     244                return Status;
    326245            }
    327246        }
     
    331250     * The request succeeded. Analyze host response,
    332251     */
    333     switch (pCreateParms->Result)
     252    switch (pReq->CreateParms.Result)
    334253    {
    335254        case SHFL_PATH_NOT_FOUND:
    336         {
    337255            /* Path to the object does not exist. */
    338             Log(("VBOXSF: vbsfProcessCreate: Path not found\n"));
     256            Log(("VBOXSF: vbsfProcessCreate: Path not found -> STATUS_OBJECT_PATH_NOT_FOUND + FILE_DOES_NOT_EXIST\n"));
    339257            *pulCreateAction = FILE_DOES_NOT_EXIST;
    340             Status = STATUS_OBJECT_PATH_NOT_FOUND;
    341             goto failure;
    342         }
     258            return STATUS_OBJECT_PATH_NOT_FOUND;
    343259
    344260        case SHFL_FILE_NOT_FOUND:
    345         {
    346             Log(("VBOXSF: vbsfProcessCreate: File not found\n"));
    347261            *pulCreateAction = FILE_DOES_NOT_EXIST;
    348             if (pCreateParms->Handle == SHFL_HANDLE_NIL)
     262            if (pReq->CreateParms.Handle == SHFL_HANDLE_NIL)
    349263            {
    350                 Status = STATUS_OBJECT_NAME_NOT_FOUND;
    351                 goto failure;
     264                Log(("VBOXSF: vbsfProcessCreate: File not found -> STATUS_OBJECT_NAME_NOT_FOUND + FILE_DOES_NOT_EXIST\n"));
     265                return STATUS_OBJECT_NAME_NOT_FOUND;
    352266            }
    353 
    354             Log(("VBOXSF: vbsfProcessCreate: File not found but have a handle!\n"));
    355             Status = STATUS_UNSUCCESSFUL;
    356             goto failure;
    357         }
     267            AssertMsgFailed(("VBOXSF: vbsfProcessCreate: WTF? File not found but have a handle!\n"));
     268            return vbsfNtCreateWorkerBail(STATUS_UNSUCCESSFUL, pReq, pNetRootExtension);
    358269
    359270        case SHFL_FILE_EXISTS:
    360         {
    361             Log(("VBOXSF: vbsfProcessCreate: File exists, Handle = 0x%RX64\n",
    362                  pCreateParms->Handle));
    363             if (pCreateParms->Handle == SHFL_HANDLE_NIL)
     271            Log(("VBOXSF: vbsfProcessCreate: File exists, Handle = %#RX64\n", pReq->CreateParms.Handle));
     272            if (pReq->CreateParms.Handle == SHFL_HANDLE_NIL)
    364273            {
    365274                *pulCreateAction = FILE_EXISTS;
     
    367276                {
    368277                    /* File was not opened because we requested a create. */
    369                     Status = STATUS_OBJECT_NAME_COLLISION;
    370                     goto failure;
     278                    Log(("VBOXSF: vbsfProcessCreate: File exists already, create failed -> STATUS_OBJECT_NAME_COLLISION\n"));
     279                    return STATUS_OBJECT_NAME_COLLISION;
    371280                }
    372281
    373282                /* Actually we should not go here, unless we have no rights to open the object. */
    374                 Log(("VBOXSF: vbsfProcessCreate: Existing file was not opened!\n"));
    375                 Status = STATUS_ACCESS_DENIED;
    376                 goto failure;
     283                Log(("VBOXSF: vbsfProcessCreate: Existing file was not opened! -> STATUS_ACCESS_DENIED\n"));
     284                return STATUS_ACCESS_DENIED;
    377285            }
    378286
     287            /* An existing file was opened. */
    379288            *pulCreateAction = FILE_OPENED;
    380 
    381             /* Existing file was opened. Go check flags and create FCB. */
    382289            break;
    383         }
    384290
    385291        case SHFL_FILE_CREATED:
    386         {
    387292            /* A new file was created. */
    388             Assert(pCreateParms->Handle != SHFL_HANDLE_NIL);
    389 
     293            Assert(pReq->CreateParms.Handle != SHFL_HANDLE_NIL);
    390294            *pulCreateAction = FILE_CREATED;
    391 
    392             /* Go check flags and create FCB. */
    393295            break;
    394         }
    395296
    396297        case SHFL_FILE_REPLACED:
    397         {
    398             /* Existing file was replaced or overwriting. */
    399             Assert(pCreateParms->Handle != SHFL_HANDLE_NIL);
    400 
     298            /* An existing file was replaced or overwritten. */
     299            Assert(pReq->CreateParms.Handle != SHFL_HANDLE_NIL);
    401300            if (CreateDisposition == FILE_SUPERSEDE)
    402301                *pulCreateAction = FILE_SUPERSEDED;
    403302            else
    404303                *pulCreateAction = FILE_OVERWRITTEN;
    405             /* Go check flags and create FCB. */
    406304            break;
    407         }
    408305
    409306        default:
    410         {
    411307            Log(("VBOXSF: vbsfProcessCreate: Invalid CreateResult from host (0x%08X)\n",
    412                  pCreateParms->Result));
     308                 pReq->CreateParms.Result));
    413309            *pulCreateAction = FILE_DOES_NOT_EXIST;
    414             Status = STATUS_OBJECT_PATH_NOT_FOUND;
    415             goto failure;
    416         }
    417     }
    418 
    419     /* Check flags. */
    420     if (bf.NonDirectoryFile && FlagOn(pCreateParms->Info.Attr.fMode, RTFS_DOS_DIRECTORY))
     310            return vbsfNtCreateWorkerBail(STATUS_OBJECT_PATH_NOT_FOUND, pReq, pNetRootExtension);
     311    }
     312
     313    /*
     314     * Check flags.
     315    */
     316    if (bf.NonDirectoryFile && FlagOn(pReq->CreateParms.Info.Attr.fMode, RTFS_DOS_DIRECTORY))
    421317    {
    422318        /* Caller wanted only a file, but the object is a directory. */
    423319        Log(("VBOXSF: vbsfProcessCreate: File is a directory!\n"));
    424         Status = STATUS_FILE_IS_A_DIRECTORY;
    425         goto failure;
    426     }
    427 
    428     if (bf.DirectoryFile && !FlagOn(pCreateParms->Info.Attr.fMode, RTFS_DOS_DIRECTORY))
     320        return vbsfNtCreateWorkerBail(STATUS_FILE_IS_A_DIRECTORY, pReq, pNetRootExtension);
     321    }
     322
     323    if (bf.DirectoryFile && !FlagOn(pReq->CreateParms.Info.Attr.fMode, RTFS_DOS_DIRECTORY))
    429324    {
    430325        /* Caller wanted only a directory, but the object is not a directory. */
    431326        Log(("VBOXSF: vbsfProcessCreate: File is not a directory!\n"));
    432         Status = STATUS_NOT_A_DIRECTORY;
    433         goto failure;
    434     }
    435 
    436     *pHandle = pCreateParms->Handle;
    437     *pInfo = pCreateParms->Info;
    438 
    439     vbsfNtFreeNonPagedMem(pCreateParms);
    440 
    441     return Status;
    442 
    443 failure:
    444 
    445     Log(("VBOXSF: vbsfProcessCreate: Returned with status = 0x%08X\n",
    446           Status));
    447 
    448     if (pCreateParms && pCreateParms->Handle != SHFL_HANDLE_NIL)
    449     {
    450         VbglR0SfClose(&g_SfClient, &pNetRootExtension->map, pCreateParms->Handle);
    451         *pHandle = SHFL_HANDLE_NIL;
    452     }
    453 
    454     if (pCreateParms)
    455         vbsfNtFreeNonPagedMem(pCreateParms);
    456 
    457     return Status;
     327        return vbsfNtCreateWorkerBail(STATUS_NOT_A_DIRECTORY, pReq, pNetRootExtension);
     328    }
     329
     330    return STATUS_SUCCESS;
    458331}
    459332
     
    472345{
    473346    RxCaptureFcb;
    474     RxCaptureFobx;
    475347    PMRX_NET_ROOT               pNetRoot          = capFcb->pNetRoot;
    476     PMRX_SRV_OPEN               SrvOpen           = RxContext->pRelevantSrvOpen;
     348    PMRX_SRV_OPEN               pSrvOpen          = RxContext->pRelevantSrvOpen;
    477349    PUNICODE_STRING             RemainingName     = GET_ALREADY_PREFIXED_NAME_FROM_CONTEXT(RxContext);
    478350    PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(capFcb->pNetRoot);
    479     ULONG                       CreateAction      = FILE_CREATED;
    480     SHFLHANDLE                  Handle            = SHFL_HANDLE_NIL;
    481     SHFLFSOBJINFO               Info              = {0};
    482     NTSTATUS                    Status            = STATUS_SUCCESS;
    483     PMRX_VBOX_FOBX              pVBoxFobx;
    484 
    485     RT_NOREF(capFobx); /* RxCaptureFobx */
    486 
    487     Log(("VBOXSF: MRxCreate: name ptr %p length=%d, SrvOpen->Flags 0x%08X\n",
    488          RemainingName, RemainingName->Length, SrvOpen->Flags));
     351
     352
     353    /*
     354     * Log stuff and make some small adjustments to empty paths and caching flags.
     355     */
     356    Log(("VBOXSF: VBoxMRxCreate: FileAttributes = %#010x\n", RxContext->Create.NtCreateParameters.FileAttributes));
     357    Log(("VBOXSF: VBoxMRxCreate:  DesiredAccess = %#010x\n", RxContext->Create.NtCreateParameters.DesiredAccess));
     358    Log(("VBOXSF: VBoxMRxCreate:    ShareAccess = %#010x\n", RxContext->Create.NtCreateParameters.ShareAccess));
     359    Log(("VBOXSF: VBoxMRxCreate:    Disposition = %#010x\n", RxContext->Create.NtCreateParameters.Disposition));
     360    Log(("VBOXSF: VBoxMRxCreate:  CreateOptions = %#010x\n", RxContext->Create.NtCreateParameters.CreateOptions));
     361    Log(("VBOXSF: VBoxMRxCreate: AllocationSize = %#RX64\n", RxContext->Create.NtCreateParameters.AllocationSize.QuadPart));
     362    Log(("VBOXSF: VBoxMRxCreate: name ptr %p length=%d, SrvOpen->Flags %#010x\n",
     363         RemainingName, RemainingName->Length, pSrvOpen->Flags));
    489364
    490365    /* Disable FastIO. It causes a verifier bugcheck. */
    491366#ifdef SRVOPEN_FLAG_DONTUSE_READ_CACHING
    492     SetFlag(SrvOpen->Flags, SRVOPEN_FLAG_DONTUSE_READ_CACHING | SRVOPEN_FLAG_DONTUSE_WRITE_CACHING);
     367    SetFlag(pSrvOpen->Flags, SRVOPEN_FLAG_DONTUSE_READ_CACHING | SRVOPEN_FLAG_DONTUSE_WRITE_CACHING);
    493368#else
    494     SetFlag(SrvOpen->Flags, SRVOPEN_FLAG_DONTUSE_READ_CACHEING | SRVOPEN_FLAG_DONTUSE_WRITE_CACHEING);
     369    SetFlag(pSrvOpen->Flags, SRVOPEN_FLAG_DONTUSE_READ_CACHEING | SRVOPEN_FLAG_DONTUSE_WRITE_CACHEING);
    495370#endif
    496371
    497372    if (RemainingName->Length)
    498         Log(("VBOXSF: MRxCreate: Attempt to open %.*ls\n",
     373        Log(("VBOXSF: VBoxMRxCreate: Attempt to open %.*ls\n",
    499374             RemainingName->Length/sizeof(WCHAR), RemainingName->Buffer));
    500375    else if (FlagOn(RxContext->Create.Flags, RX_CONTEXT_CREATE_FLAG_STRIPPED_TRAILING_BACKSLASH))
    501376    {
    502         Log(("VBOXSF: MRxCreate: Empty name -> Only backslash used\n"));
     377        Log(("VBOXSF: VBoxMRxCreate: Empty name -> Only backslash used\n"));
    503378        RemainingName = &g_UnicodeBackslash;
    504379    }
    505380
     381    /*
     382     * Fend off unsupported and invalid requests before we start allocating memory.
     383     */
    506384    if (   pNetRoot->Type != NET_ROOT_WILD
    507385        && pNetRoot->Type != NET_ROOT_DISK)
    508386    {
    509         Log(("VBOXSF: MRxCreate: netroot type %d not supported\n",
     387        Log(("VBOXSF: VBoxMRxCreate: netroot type %d not supported\n",
    510388             pNetRoot->Type));
    511389        return STATUS_NOT_IMPLEMENTED;
    512390    }
    513391
    514     Status = vbsfProcessCreate(RxContext,
    515                                RemainingName,
    516                                &Info,
    517                                RxContext->Create.EaBuffer,
    518                                RxContext->Create.EaLength,
    519                                &CreateAction,
    520                                &Handle);
    521 
    522     if (Status != STATUS_SUCCESS)
    523     {
    524         Log(("VBOXSF: MRxCreate: vbsfProcessCreate failed 0x%08X\n",
    525              Status));
    526         return Status;
    527     }
    528 
    529     Log(("VBOXSF: MRxCreate: EOF is 0x%RX64 AllocSize is 0x%RX64\n",
    530          Info.cbObject, Info.cbAllocated));
    531 
    532     RxContext->pFobx = RxCreateNetFobx(RxContext, SrvOpen);
    533     if (!RxContext->pFobx)
    534     {
    535         Log(("VBOXSF: MRxCreate: RxCreateNetFobx failed\n"));
    536         VbglR0SfHostReqCloseSimple(pNetRootExtension->map.root, Handle);
     392    if (RxContext->Create.EaLength == 0)
     393    { /* likely */ }
     394    else
     395    {
     396        Log(("VBOXSF: VBoxMRxCreate: Unsupported: extended attributes!\n"));
     397        return STATUS_EAS_NOT_SUPPORTED;
     398    }
     399
     400    if (!(capFcb->FcbState & FCB_STATE_PAGING_FILE))
     401    { /* likely */ }
     402    else
     403    {
     404        Log(("VBOXSF: VBoxMRxCreate: Unsupported: paging file!\n"));
     405        return STATUS_NOT_IMPLEMENTED;
     406    }
     407
     408    if (!(RxContext->Create.NtCreateParameters.CreateOptions & FILE_OPEN_BY_FILE_ID))
     409    { /* likely */ }
     410    else
     411    {
     412        Log(("VBOXSF: VBoxMRxCreate: Unsupported: file open by id!\n"));
     413        return STATUS_NOT_IMPLEMENTED;
     414    }
     415
     416    /*
     417     * Allocate memory for the request.
     418     */
     419    bool const     fSlashHack = RxContext->CurrentIrpSp
     420                             && (RxContext->CurrentIrpSp->Parameters.Create.ShareAccess & VBOX_MJ_CREATE_SLASH_HACK);
     421    uint16_t const  cbPath    = RemainingName->Length;
     422    uint32_t const  cbPathAll = cbPath + fSlashHack * sizeof(RTUTF16) + sizeof(RTUTF16);
     423    AssertReturn(cbPathAll < _64K, STATUS_NAME_TOO_LONG);
     424
     425    uint32_t const  cbReq     = RT_UOFFSETOF(VBOXSFCREATEREQ, StrPath.String) + cbPathAll;
     426    VBOXSFCREATEREQ *pReq     = (VBOXSFCREATEREQ *)VbglR0PhysHeapAlloc(cbReq);
     427    if (pReq)
     428    { }
     429    else
    537430        return STATUS_INSUFFICIENT_RESOURCES;
    538     }
    539     pVBoxFobx = VBoxMRxGetFileObjectExtension(RxContext->pFobx);
    540     Log(("VBOXSF: MRxCreate: VBoxFobx = %p\n",
    541          pVBoxFobx));
    542     AssertReturnStmt(pVBoxFobx, VbglR0SfHostReqCloseSimple(pNetRootExtension->map.root, Handle), STATUS_INTERNAL_ERROR);
    543 
    544 
    545     Log(("VBOXSF: MRxCreate: CreateAction = 0x%08X\n",
    546          CreateAction));
    547 
    548     RxContext->Create.ReturnedCreateInformation = CreateAction;
    549 
    550     /*
    551      * Make sure we've got the FCB locked exclusivly before updating it and returning.
    552      * (bird: not entirely sure if this is needed for the W10 RDBSS, but cannot hurt.)
    553      */
    554     if (!RxIsFcbAcquiredExclusive(capFcb))
    555         RxAcquireExclusiveFcbResourceInMRx(capFcb);
    556 
    557 
    558     /* Initialize the FCB if this is the first open.
    559        Note! The RxFinishFcbInitialization call expects node types as the 2nd parameter, but is for
    560              some reason given enum RX_FILE_TYPE as type. */
    561     if (capFcb->OpenCount == 0)
    562     {
    563         Log(("VBOXSF: MRxCreate: Initializing the FCB.\n"));
    564         FCB_INIT_PACKET               InitPacket;
    565         FILE_NETWORK_OPEN_INFORMATION Data;
    566         ULONG                         NumberOfLinks = 0; /** @todo ?? */
    567         Data.CreationTime.QuadPart   = RTTimeSpecGetNtTime(&Info.BirthTime);
    568         Data.LastAccessTime.QuadPart = RTTimeSpecGetNtTime(&Info.AccessTime);
    569         Data.LastWriteTime.QuadPart  = RTTimeSpecGetNtTime(&Info.ModificationTime);
    570         Data.ChangeTime.QuadPart     = RTTimeSpecGetNtTime(&Info.ChangeTime);
    571         Data.AllocationSize.QuadPart = Info.cbAllocated; /** @todo test sparse files.  CcSetFileSizes is documented to not want allocation size smaller than EOF offset. */
    572         Data.EndOfFile.QuadPart      = Info.cbObject;
    573         Data.FileAttributes          = VBoxToNTFileAttributes(Info.Attr.fMode);
    574         RxFormInitPacket(InitPacket,
    575                          &Data.FileAttributes,
    576                          &NumberOfLinks,
    577                          &Data.CreationTime,
    578                          &Data.LastAccessTime,
    579                          &Data.LastWriteTime,
    580                          &Data.ChangeTime,
    581                          &Data.AllocationSize,
    582                          &Data.EndOfFile,
    583                          &Data.EndOfFile);
    584         if (Info.Attr.fMode & RTFS_DOS_DIRECTORY)
    585             RxFinishFcbInitialization(capFcb, (RX_FILE_TYPE)RDBSS_NTC_STORAGE_TYPE_DIRECTORY, &InitPacket);
     431
     432    /*
     433     * Copy out the path string.
     434     */
     435    pReq->StrPath.u16Size = (uint16_t)cbPathAll;
     436    if (!fSlashHack)
     437    {
     438        pReq->StrPath.u16Length = cbPath;
     439        memcpy(&pReq->StrPath.String, RemainingName->Buffer, cbPath);
     440        pReq->StrPath.String.utf16[cbPath / sizeof(RTUTF16)] = '\0';
     441    }
     442    else
     443    {
     444        /* HACK ALERT! Here we add back the lsash we had to hide from RDBSS. */
     445        pReq->StrPath.u16Length = cbPath + sizeof(RTUTF16);
     446        memcpy(&pReq->StrPath.String, RemainingName->Buffer, cbPath);
     447        pReq->StrPath.String.utf16[cbPath / sizeof(RTUTF16)] = '\\';
     448        pReq->StrPath.String.utf16[cbPath / sizeof(RTUTF16) + 1] = '\0';
     449    }
     450    Log(("VBOXSF: VBoxMRxCreate: %.*ls\n", pReq->StrPath.u16Length / sizeof(RTUTF16), pReq->StrPath.String.utf16));
     451
     452    /*
     453     * Hand the bulk work off to a worker function to simplify bailout and cleanup.
     454     */
     455    ULONG       CreateAction = FILE_CREATED;
     456    NTSTATUS    Status = vbsfNtCreateWorker(RxContext, pReq, &CreateAction, pNetRootExtension, capFcb);
     457    if (Status == STATUS_SUCCESS)
     458    {
     459        Log(("VBOXSF: VBoxMRxCreate: EOF is 0x%RX64 AllocSize is 0x%RX64\n",
     460             pReq->CreateParms.Info.cbObject, pReq->CreateParms.Info.cbAllocated));
     461        Log(("VBOXSF: VBoxMRxCreate: CreateAction = %#010x\n", CreateAction));
     462
     463        /*
     464         * Create the file object extension.
     465         * After this we're out of the woods and nothing more can go wrong.
     466         */
     467        PMRX_FOBX pFobx;
     468        RxContext->pFobx = pFobx = RxCreateNetFobx(RxContext, pSrvOpen);
     469        PMRX_VBOX_FOBX pVBoxFobx = pFobx ? VBoxMRxGetFileObjectExtension(pFobx) : NULL;
     470        if (pFobx && pVBoxFobx)
     471        {
     472            /*
     473             * Make sure we've got the FCB locked exclusivly before updating it and returning.
     474             * (bird: not entirely sure if this is needed for the W10 RDBSS, but cannot hurt.)
     475             */
     476            if (!RxIsFcbAcquiredExclusive(capFcb))
     477                RxAcquireExclusiveFcbResourceInMRx(capFcb);
     478
     479            /*
     480             * Initialize our file object extension data.
     481             */
     482            pVBoxFobx->Info     = pReq->CreateParms.Info;
     483            pVBoxFobx->hFile    = pReq->CreateParms.Handle;
     484            pVBoxFobx->pSrvCall = RxContext->Create.pSrvCall;
     485
     486            /* bird: Dunno what this really's about. */
     487            pFobx->OffsetOfNextEaToReturn = 1;
     488
     489            /*
     490             * Initialize the FCB if this is the first open.
     491             *
     492             * Note! The RxFinishFcbInitialization call expects node types as the 2nd parameter,
     493             *       but is for  some reason given enum RX_FILE_TYPE as type.
     494             */
     495            if (capFcb->OpenCount == 0)
     496            {
     497                Log(("VBOXSF: VBoxMRxCreate: Initializing the FCB.\n"));
     498                FCB_INIT_PACKET               InitPacket;
     499                FILE_NETWORK_OPEN_INFORMATION Data;
     500                ULONG                         NumberOfLinks = 0; /** @todo ?? */
     501                Data.CreationTime.QuadPart   = RTTimeSpecGetNtTime(&pReq->CreateParms.Info.BirthTime);
     502                Data.LastAccessTime.QuadPart = RTTimeSpecGetNtTime(&pReq->CreateParms.Info.AccessTime);
     503                Data.LastWriteTime.QuadPart  = RTTimeSpecGetNtTime(&pReq->CreateParms.Info.ModificationTime);
     504                Data.ChangeTime.QuadPart     = RTTimeSpecGetNtTime(&pReq->CreateParms.Info.ChangeTime);
     505                /** @todo test sparse files.  CcSetFileSizes is documented to not want allocation size smaller than EOF offset. */
     506                Data.AllocationSize.QuadPart = pReq->CreateParms.Info.cbAllocated;
     507                Data.EndOfFile.QuadPart      = pReq->CreateParms.Info.cbObject;
     508                Data.FileAttributes          = VBoxToNTFileAttributes(pReq->CreateParms.Info.Attr.fMode);
     509                RxFormInitPacket(InitPacket,
     510                                 &Data.FileAttributes,
     511                                 &NumberOfLinks,
     512                                 &Data.CreationTime,
     513                                 &Data.LastAccessTime,
     514                                 &Data.LastWriteTime,
     515                                 &Data.ChangeTime,
     516                                 &Data.AllocationSize,
     517                                 &Data.EndOfFile,
     518                                 &Data.EndOfFile);
     519                if (pReq->CreateParms.Info.Attr.fMode & RTFS_DOS_DIRECTORY)
     520                    RxFinishFcbInitialization(capFcb, (RX_FILE_TYPE)RDBSS_NTC_STORAGE_TYPE_DIRECTORY, &InitPacket);
     521                else
     522                    RxFinishFcbInitialization(capFcb, (RX_FILE_TYPE)RDBSS_NTC_STORAGE_TYPE_FILE, &InitPacket);
     523            }
     524
     525
     526            /*
     527             * See if the size has changed and update the FCB if it has.
     528             */
     529            if (   capFcb->OpenCount > 0
     530                && capFcb->Header.FileSize.QuadPart != pReq->CreateParms.Info.cbObject)
     531            {
     532                PFILE_OBJECT pFileObj = RxContext->CurrentIrpSp->FileObject;
     533                Assert(pFileObj);
     534                if (pFileObj)
     535                    vbsfNtUpdateFcbSize(pFileObj, capFcb, pVBoxFobx, pReq->CreateParms.Info.cbObject,
     536                                        capFcb->Header.FileSize.QuadPart, pReq->CreateParms.Info.cbAllocated);
     537            }
     538
     539            /*
     540             * Set various return values.
     541             */
     542
     543            /* This is "our" contribution to the buffering flags (no buffering, please). */
     544            pSrvOpen->BufferingFlags = 0;
     545
     546            /* This is the IO_STATUS_BLOCK::Information value, I think. */
     547            RxContext->Create.ReturnedCreateInformation = CreateAction;
     548
     549            /*
     550             * Do logging.
     551             */
     552            Log(("VBOXSF: VBoxMRxCreate: Info: BirthTime        %RI64\n", RTTimeSpecGetNano(&pVBoxFobx->Info.BirthTime)));
     553            Log(("VBOXSF: VBoxMRxCreate: Info: ChangeTime       %RI64\n", RTTimeSpecGetNano(&pVBoxFobx->Info.ChangeTime)));
     554            Log(("VBOXSF: VBoxMRxCreate: Info: ModificationTime %RI64\n", RTTimeSpecGetNano(&pVBoxFobx->Info.ModificationTime)));
     555            Log(("VBOXSF: VBoxMRxCreate: Info: AccessTime       %RI64\n", RTTimeSpecGetNano(&pVBoxFobx->Info.AccessTime)));
     556            Log(("VBOXSF: VBoxMRxCreate: Info: fMode            %#RX32\n", pVBoxFobx->Info.Attr.fMode));
     557            if (!(pVBoxFobx->Info.Attr.fMode & RTFS_DOS_DIRECTORY))
     558            {
     559                Log(("VBOXSF: VBoxMRxCreate: Info: cbObject         %#RX64\n", pVBoxFobx->Info.cbObject));
     560                Log(("VBOXSF: VBoxMRxCreate: Info: cbAllocated      %#RX64\n", pVBoxFobx->Info.cbAllocated));
     561            }
     562            Log(("VBOXSF: VBoxMRxCreate: NetRoot is %p, Fcb is %p, pSrvOpen is %p, Fobx is %p\n",
     563                 pNetRoot, capFcb, pSrvOpen, RxContext->pFobx));
     564            Log(("VBOXSF: VBoxMRxCreate: returns %#010x\n", Status));
     565        }
    586566        else
    587             RxFinishFcbInitialization(capFcb, (RX_FILE_TYPE)RDBSS_NTC_STORAGE_TYPE_FILE, &InitPacket);
    588     }
    589 
    590     SrvOpen->BufferingFlags = 0;
    591 
    592     RxContext->pFobx->OffsetOfNextEaToReturn = 1;
    593 
    594     pVBoxFobx->hFile = Handle;
    595     pVBoxFobx->pSrvCall = RxContext->Create.pSrvCall;
    596     pVBoxFobx->Info = Info;
    597 
    598     /*
    599      * See if the size has changed and update the FCB if it has.
    600      */
    601     if (   capFcb->OpenCount > 0
    602         && capFcb->Header.FileSize.QuadPart != Info.cbObject)
    603     {
    604         PFILE_OBJECT pFileObj = RxContext->CurrentIrpSp->FileObject;
    605         Assert(pFileObj);
    606         if (pFileObj)
    607             vbsfNtUpdateFcbSize(pFileObj, capFcb, pVBoxFobx, Info.cbObject, capFcb->Header.FileSize.QuadPart, Info.cbAllocated);
    608     }
    609 
    610     /*
    611      * Do logging.
    612      */
    613     Log(("VBOXSF: MRxCreate: Info: BirthTime        %RI64\n", RTTimeSpecGetNano(&pVBoxFobx->Info.BirthTime)));
    614     Log(("VBOXSF: MRxCreate: Info: ChangeTime       %RI64\n", RTTimeSpecGetNano(&pVBoxFobx->Info.ChangeTime)));
    615     Log(("VBOXSF: MRxCreate: Info: ModificationTime %RI64\n", RTTimeSpecGetNano(&pVBoxFobx->Info.ModificationTime)));
    616     Log(("VBOXSF: MRxCreate: Info: AccessTime       %RI64\n", RTTimeSpecGetNano(&pVBoxFobx->Info.AccessTime)));
    617     Log(("VBOXSF: MRxCreate: Info: fMode            %#RX32\n", pVBoxFobx->Info.Attr.fMode));
    618     if (!(Info.Attr.fMode & RTFS_DOS_DIRECTORY))
    619     {
    620         Log(("VBOXSF: MRxCreate: Info: cbObject         %#RX64\n", pVBoxFobx->Info.cbObject));
    621         Log(("VBOXSF: MRxCreate: Info: cbAllocated      %#RX64\n", pVBoxFobx->Info.cbAllocated));
    622     }
    623 
    624     Log(("VBOXSF: MRxCreate: NetRoot is %p, Fcb is %p, SrvOpen is %p, Fobx is %p\n",
    625          pNetRoot, capFcb, SrvOpen, RxContext->pFobx));
    626     Log(("VBOXSF: MRxCreate: return 0x%08X\n",
    627          Status));
    628 
     567        {
     568            Log(("VBOXSF: VBoxMRxCreate: RxCreateNetFobx failed (pFobx=%p)\n", pFobx));
     569            Assert(!pFobx);
     570            AssertCompile(sizeof(VBOXSFCLOSEREQ) <= RT_UOFFSETOF(VBOXSFCREATEREQ, CreateParms));
     571            VbglR0SfHostReqClose(pNetRootExtension->map.root, (VBOXSFCLOSEREQ *)pReq, pReq->CreateParms.Handle);
     572            Status = STATUS_INSUFFICIENT_RESOURCES;
     573        }
     574    }
     575    else
     576        Log(("VBOXSF: VBoxMRxCreate: vbsfProcessCreate failed %#010x\n", Status));
     577    VbglR0PhysHeapFree(pReq);
    629578    return Status;
    630579}
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