VirtualBox

Changeset 78355 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 30, 2019 3:48:46 AM (6 years ago)
Author:
vboxsync
Message:

winnt/vboxsf: Reworked the set-timestamp handling. Need testcase and some host service tinkering. Also optimized handle closing. bugref:9172

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

Legend:

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

    r78339 r78355  
    234234
    235235    PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(capFcb->pNetRoot);
     236    PVBSFNTFCBEXT pVBoxFcbx = VBoxMRxGetFcbExtension(capFcb);
    236237    PMRX_VBOX_FOBX pVBoxFobx = VBoxMRxGetFileObjectExtension(capFobx);
    237238
     
    308309    Status = vbsfNtVBoxStatusToNt(vrc);
    309310
    310     if (Status != STATUS_SUCCESS)
    311     {
    312         /* Nothing read. */
    313         ByteCount = 0;
    314     }
     311    if (Status == STATUS_SUCCESS)
     312    {
     313        pVBoxFobx->fTimestampsImplicitlyUpdated |= VBOX_FOBX_F_INFO_LASTACCESS_TIME;
     314        if (pVBoxFcbx->pFobxLastAccessTime != pVBoxFobx)
     315            pVBoxFcbx->pFobxLastAccessTime = NULL;
     316    }
     317    else
     318        ByteCount = 0; /* Nothing read. */
    315319
    316320    RxContext->InformationToReturn = ByteCount;
     
    378382
    379383    PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(capFcb->pNetRoot);
     384    PVBSFNTFCBEXT pVBoxFcbx = VBoxMRxGetFcbExtension(capFcb);
    380385    PMRX_VBOX_FOBX pVBoxFobx = VBoxMRxGetFileObjectExtension(capFobx);
    381386
     
    429434    Status = vbsfNtVBoxStatusToNt(vrc);
    430435
    431     if (Status != STATUS_SUCCESS)
    432     {
    433         /* Nothing written. */
    434         ByteCount = 0;
    435     }
     436    if (Status == STATUS_SUCCESS)
     437    {
     438        pVBoxFobx->fTimestampsImplicitlyUpdated |= VBOX_FOBX_F_INFO_LASTWRITE_TIME;
     439        if (pVBoxFcbx->pFobxLastWriteTime != pVBoxFobx)
     440            pVBoxFcbx->pFobxLastWriteTime = NULL;
     441    }
     442    else
     443        ByteCount = 0; /* Nothing written. */
    436444
    437445    RxContext->InformationToReturn = ByteCount;
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/info.cpp

    r78350 r78355  
    925925}
    926926
    927 void vbsfNtCopyInfoToLegacy(PMRX_VBOX_FOBX pVBoxFobx, PCSHFLFSOBJINFO pInfo)
     927/**
     928 * Updates the object info to the VBox file object extension data.
     929 *
     930 * @param   pVBoxFobx               The VBox file object extension data.
     931 * @param   pObjInfo                The fresh data from the host.  Okay to modify.
     932 * @param   pVBoxFcbx               The VBox FCB extension data.
     933 * @param   fTimestampsToCopyAnyway VBOX_FOBX_F_INFO_XXX mask of timestamps to
     934 *                                  copy regardless of their suppressed state.
     935 *                                  This is used by the info setter function to
     936 *                                  get current copies of newly modified and
     937 *                                  suppressed fields.
     938 */
     939static void vbsfNtCopyInfo(PMRX_VBOX_FOBX pVBoxFobx, PSHFLFSOBJINFO pObjInfo,
     940                           PVBSFNTFCBEXT pVBoxFcbx, uint8_t fTimestampsToCopyAnyway)
    928941{
    929     pVBoxFobx->FileBasicInfo.CreationTime.QuadPart   = RTTimeSpecGetNtTime(&pInfo->BirthTime);
    930     pVBoxFobx->FileBasicInfo.LastAccessTime.QuadPart = RTTimeSpecGetNtTime(&pInfo->AccessTime);
    931     pVBoxFobx->FileBasicInfo.LastWriteTime.QuadPart  = RTTimeSpecGetNtTime(&pInfo->ModificationTime);
    932     pVBoxFobx->FileBasicInfo.ChangeTime.QuadPart     = RTTimeSpecGetNtTime(&pInfo->ChangeTime);
    933     pVBoxFobx->FileBasicInfo.FileAttributes          = VBoxToNTFileAttributes(pInfo->Attr.fMode);
    934 }
    935 
    936 static void vbsfNtCopyInfo(PMRX_VBOX_FOBX pVBoxFobx, PSHFLFSOBJINFO pObjInfo, uint32_t fOverrides)
    937 {
     942    /*
     943     * Check if the size changed.
     944     */
    938945    if (pObjInfo->cbObject != pVBoxFobx->Info.cbObject)
    939946    {
    940         /** @todo tell RDBSS about this? */
    941     }
    942 
    943     /* To simplify stuff, copy user timestamps to the input structure before copying. */
    944     if (   pVBoxFobx->fKeepCreationTime
    945         || pVBoxFobx->fKeepLastAccessTime
    946         || pVBoxFobx->fKeepLastWriteTime
    947         || pVBoxFobx->fKeepChangeTime)
    948     {
    949         if (pVBoxFobx->fKeepCreationTime   && !(fOverrides & VBOX_FOBX_F_INFO_CREATION_TIME))
    950             pObjInfo->BirthTime         = pVBoxFobx->Info.BirthTime;
    951         if (pVBoxFobx->fKeepLastAccessTime && !(fOverrides & VBOX_FOBX_F_INFO_LASTACCESS_TIME))
     947        /** @todo Tell RDBSS about this?  Seems we have to tell the cache manager
     948         *        ourselves, which sucks considering that RDBSS was supposed to
     949         *        shield us from crap like that (see the MS sales brochure). */
     950    }
     951
     952    /*
     953     * Check if the modified timestamp changed and try guess if it was the host.
     954     */
     955    /** @todo use modification timestamp to detect host changes?  We do on linux. */
     956
     957    /*
     958     * Copy the object info over.  To simplify preserving the value of timestamps
     959     * which implict updating is currently disabled, copy them over to the source
     960     * structure before preforming the copy.
     961     */
     962    Assert((pVBoxFobx->fTimestampsSetByUser & ~pVBoxFobx->fTimestampsUpdatingSuppressed) == 0);
     963    uint8_t fCopyTs = pVBoxFobx->fTimestampsUpdatingSuppressed & ~fTimestampsToCopyAnyway;
     964    if (fCopyTs)
     965    {
     966        if (  (fCopyTs & VBOX_FOBX_F_INFO_LASTACCESS_TIME)
     967            && pVBoxFcbx->pFobxLastAccessTime == pVBoxFobx)
    952968            pObjInfo->AccessTime        = pVBoxFobx->Info.AccessTime;
    953         if (pVBoxFobx->fKeepLastWriteTime  && !(fOverrides & VBOX_FOBX_F_INFO_LASTWRITE_TIME))
     969
     970        if (   (fCopyTs & VBOX_FOBX_F_INFO_LASTWRITE_TIME)
     971            && pVBoxFcbx->pFobxLastWriteTime  == pVBoxFobx)
    954972            pObjInfo->ModificationTime  = pVBoxFobx->Info.ModificationTime;
    955         if (pVBoxFobx->fKeepChangeTime     && !(fOverrides & VBOX_FOBX_F_INFO_CHANGE_TIME))
     973
     974        if (   (fCopyTs & VBOX_FOBX_F_INFO_CHANGE_TIME)
     975            && pVBoxFcbx->pFobxChangeTime     == pVBoxFobx)
    956976            pObjInfo->ChangeTime        = pVBoxFobx->Info.ChangeTime;
    957977    }
    958978    pVBoxFobx->Info = *pObjInfo;
    959979
    960     vbsfNtCopyInfoToLegacy(pVBoxFobx, pObjInfo);
     980    /*
     981     * Try eliminate this one.
     982     */
     983    vbsfNtBasicInfoFromVBoxObjInfo(&pVBoxFobx->FileBasicInfo, pObjInfo);
    961984}
    962985
     
    10861109                    || pVBoxFobx->nsUpToDate - RTTimeSystemNanoTS() < RT_NS_100US /** @todo implement proper TTL */ ) )
    10871110            {
    1088                 int               vrc;
     1111                PVBSFNTFCBEXT pVBoxFcbx = VBoxMRxGetFcbExtension(capFcb);
     1112                AssertReturn(pVBoxFcbx, STATUS_INTERNAL_ERROR);
     1113
    10891114                VBOXSFOBJINFOREQ *pReq = (VBOXSFOBJINFOREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq));
    10901115                AssertBreakStmt(pReq, Status = STATUS_NO_MEMORY);
    10911116
    1092                 vrc = VbglR0SfHostReqQueryObjInfo(pNetRootExtension->map.root, pReq, pVBoxFobx->hFile);
     1117                int vrc = VbglR0SfHostReqQueryObjInfo(pNetRootExtension->map.root, pReq, pVBoxFobx->hFile);
    10931118                if (RT_SUCCESS(vrc))
    1094                     vbsfNtCopyInfo(pVBoxFobx, &pReq->ObjInfo, 0);
     1119                    vbsfNtCopyInfo(pVBoxFobx, &pReq->ObjInfo, pVBoxFcbx, 0);
    10951120                else
    10961121                {
     
    12801305 */
    12811306static NTSTATUS vbsfNtSetBasicInfo(PMRX_VBOX_FOBX pVBoxFobx, PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension,
    1282                                    PFILE_BASIC_INFORMATION pBasicInfo)
     1307                                   PVBSFNTFCBEXT pVBoxFcbx, PFILE_BASIC_INFORMATION pBasicInfo)
    12831308{
    1284     PSHFLFSOBJINFO          pSHFLFileInfo;
    1285     uint8_t                *pHGCMBuffer = NULL;
    1286     uint32_t                cbBuffer = 0;
    1287     uint32_t                fModified;
    1288     int                     vrc;
    1289 
    12901309    Log(("VBOXSF: MRxSetFileInfo: FileBasicInformation: CreationTime   %RX64\n", pBasicInfo->CreationTime.QuadPart));
    12911310    Log(("VBOXSF: MRxSetFileInfo: FileBasicInformation: LastAccessTime %RX64\n", pBasicInfo->LastAccessTime.QuadPart));
     
    12931312    Log(("VBOXSF: MRxSetFileInfo: FileBasicInformation: ChangeTime     %RX64\n", pBasicInfo->ChangeTime.QuadPart));
    12941313    Log(("VBOXSF: MRxSetFileInfo: FileBasicInformation: FileAttributes %RX32\n", pBasicInfo->FileAttributes));
    1295 
    1296     /*
    1297      * Note! If a timestamp value is non-zero, the client disables implicit updating of
    1298      *       that timestamp via this handle when reading, writing and changing attributes.
    1299      *       The special -1 value is used to just disable implicit updating without
    1300      *       modifying the timestamp.  While the value is allowed for the CreationTime
    1301      *       field, it will be treated as zero.
    1302      *
    1303      *       More clues can be found here:
    1304      * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/16023025-8a78-492f-8b96-c873b042ac50
    1305      * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/d4bc551b-7aaf-4b4f-ba0e-3a75e7c528f0#Appendix_A_86
    1306      */
     1314    AssertReturn(pVBoxFobx, STATUS_INTERNAL_ERROR);
     1315    AssertReturn(pVBoxFcbx, STATUS_INTERNAL_ERROR);
     1316    AssertReturn(pNetRootExtension, STATUS_INTERNAL_ERROR);
    13071317
    13081318    /** @todo r=bird: The attempt at implementing the disable-timestamp-update
     
    13111321     * Reminders:
    13121322     *
    1313      *  1. Drop VBOX_FOBX_F_INFO_CREATION_TIME.
     1323     *  X1. Drop VBOX_FOBX_F_INFO_CREATION_TIME.
    13141324     *
    1315      *  2. Drop unused VBOX_FOBX_F_INFO_ATTRIBUTES.
     1325     *  X2. Drop unused VBOX_FOBX_F_INFO_ATTRIBUTES.
    13161326     *
    1317      *  3. Only act on VBOX_FOBX_F_INFO_CHANGE_TIME if modified attributes or grown
     1327     *  X3. Only act on VBOX_FOBX_F_INFO_CHANGE_TIME if modified attributes or grown
    13181328     *     the file (?) so we don't cancel out updates by other parties (like the
    13191329     *     host).
    13201330     *
    1321      *  4. Only act on VBOX_FOBX_F_INFO_LASTWRITE_TIME if we've written to the file.
     1331     *  X4. Only act on VBOX_FOBX_F_INFO_LASTWRITE_TIME if we've written to the
     1332     *  file.
    13221333     *
    1323      *  5. Only act on VBOX_FOBX_F_INFO_LASTACCESS_TIME if we've read from the file
     1334     *  X5. Only act on VBOX_FOBX_F_INFO_LASTACCESS_TIME if we've read from the file
    13241335     *     or done whatever else might modify the access time.
    13251336     *
    13261337     *  6. Don't bother calling the host if there are only zeros and -1 values.
     1338     *  => Not done / better use it to update FCB info?
    13271339     *
    1328      *  7. Client application should probably be allowed to modify the timestamps
     1340     *  X7. Client application should probably be allowed to modify the timestamps
    13291341     *     explicitly using this API after disabling updating, given the wording of
    13301342     *     the footnote referenced above.
     1343     *  => Only verified via fastfat sample, need FsPerf test.
    13311344     *
    13321345     *  8. Extend the host interface to let the host handle this crap instead as it
    13331346     *     can do a better job, like on windows it's done implicitly if we let -1
    13341347     *     pass thru IPRT.
     1348     *  => We're actually better equipped to handle it than the host, given the
     1349     *     FCB/inode.  New plan is to detect windows host and let it implement -1,
     1350     *     but use the old stuff as fallback for non-windows hosts.
    13351351     *
    13361352     * One worry here is that we hide timestamp updates made by the host or other
     
    13391355     */
    13401356
    1341     if (pBasicInfo->CreationTime.QuadPart == -1)
    1342     {
    1343         pVBoxFobx->fKeepCreationTime = TRUE;
    1344         pVBoxFobx->SetFileInfoOnCloseFlags |= VBOX_FOBX_F_INFO_CREATION_TIME;
    1345     }
    1346     if (pBasicInfo->LastAccessTime.QuadPart == -1)
    1347     {
    1348         pVBoxFobx->fKeepLastAccessTime = TRUE;
    1349         pVBoxFobx->SetFileInfoOnCloseFlags |= VBOX_FOBX_F_INFO_LASTACCESS_TIME;
    1350     }
    1351     if (pBasicInfo->LastWriteTime.QuadPart == -1)
    1352     {
    1353         pVBoxFobx->fKeepLastWriteTime = TRUE;
    1354         pVBoxFobx->SetFileInfoOnCloseFlags |= VBOX_FOBX_F_INFO_LASTWRITE_TIME;
    1355     }
    1356     if (pBasicInfo->ChangeTime.QuadPart == -1)
    1357     {
    1358         pVBoxFobx->fKeepChangeTime = TRUE;
    1359         pVBoxFobx->SetFileInfoOnCloseFlags |= VBOX_FOBX_F_INFO_CHANGE_TIME;
    1360     }
    1361 
    1362     cbBuffer = sizeof(SHFLFSOBJINFO);
    1363     pHGCMBuffer = (uint8_t *)vbsfNtAllocNonPagedMem(cbBuffer);
    1364     AssertReturn(pHGCMBuffer, STATUS_INSUFFICIENT_RESOURCES);
    1365     RtlZeroMemory(pHGCMBuffer, cbBuffer);
    1366     pSHFLFileInfo = (PSHFLFSOBJINFO)pHGCMBuffer;
    1367 
    1368     Log(("VBOXSF: MrxSetFileInfo: FileBasicInformation: keeps %d %d %d %d\n",
    1369          pVBoxFobx->fKeepCreationTime, pVBoxFobx->fKeepLastAccessTime, pVBoxFobx->fKeepLastWriteTime, pVBoxFobx->fKeepChangeTime));
    1370 
    1371     /* The properties, that need to be changed, are set to something other than zero */
    1372     fModified = 0;
    1373     if (pBasicInfo->CreationTime.QuadPart && !pVBoxFobx->fKeepCreationTime)
    1374     {
    1375         RTTimeSpecSetNtTime(&pSHFLFileInfo->BirthTime, pBasicInfo->CreationTime.QuadPart);
    1376         fModified |= VBOX_FOBX_F_INFO_CREATION_TIME;
    1377     }
     1357
     1358    /*
     1359     * The properties that need to be changed are set to something other
     1360     * than zero and -1.  (According to the fastfat sample code, -1 only
     1361     * disable implicit timestamp updating, not explicit thru this code.)
     1362     */
     1363
     1364    /*
     1365     * In the host request, zero values are ignored.
     1366     *
     1367     * As for the NT request, the same is true but with a slight twist for the
     1368     * timestamp fields.  If a timestamp value is non-zero, the client disables
     1369     * implicit updating of that timestamp via this handle when reading, writing
     1370     * and * changing attributes.  The special -1 value is used to just disable
     1371     * implicit updating without modifying the timestamp.  While the value is
     1372     * allowed for the CreationTime field, it will be treated as zero.
     1373     *
     1374     * More clues to the NT behaviour can be found here:
     1375     * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/16023025-8a78-492f-8b96-c873b042ac50
     1376     * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/d4bc551b-7aaf-4b4f-ba0e-3a75e7c528f0#Appendix_A_86
     1377     *
     1378     * P.S. One of the reasons behind suppressing of timestamp updating after setting
     1379     *      them is likely related to the need of opening objects to modify them. There are
     1380     *      no utimes() or chmod() function in NT, on the futimes() and fchmod() variants.
     1381     */
     1382    VBOXSFOBJINFOREQ *pReq = (VBOXSFOBJINFOREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq));
     1383    if (pReq)
     1384        RT_ZERO(pReq->ObjInfo);
     1385    else
     1386        return STATUS_INSUFFICIENT_RESOURCES;
     1387    uint32_t fModified   = 0;
     1388    uint32_t fSuppressed = 0;
     1389
    13781390    /** @todo FsPerf need to check what is supposed to happen if modified
    1379      *        against after -1 is specified.  */
    1380     if (pBasicInfo->LastAccessTime.QuadPart && !pVBoxFobx->fKeepLastAccessTime)
    1381     {
    1382         RTTimeSpecSetNtTime(&pSHFLFileInfo->AccessTime, pBasicInfo->LastAccessTime.QuadPart);
    1383         fModified |= VBOX_FOBX_F_INFO_LASTACCESS_TIME;
    1384     }
    1385     if (pBasicInfo->LastWriteTime.QuadPart && !pVBoxFobx->fKeepLastWriteTime)
    1386     {
    1387         RTTimeSpecSetNtTime(&pSHFLFileInfo->ModificationTime, pBasicInfo->LastWriteTime.QuadPart);
    1388         fModified |= VBOX_FOBX_F_INFO_LASTWRITE_TIME;
    1389     }
    1390     if (pBasicInfo->ChangeTime.QuadPart && !pVBoxFobx->fKeepChangeTime)
    1391     {
    1392         RTTimeSpecSetNtTime(&pSHFLFileInfo->ChangeTime, pBasicInfo->ChangeTime.QuadPart);
    1393         fModified |= VBOX_FOBX_F_INFO_CHANGE_TIME;
    1394     }
     1391     * against after -1 is specified.  As state above, fastfat will not suppress
     1392     * further setting of the timestamp like we used to do prior to revision
     1393     * r130337 or thereabouts. */
     1394
     1395    if (pBasicInfo->CreationTime.QuadPart && pBasicInfo->CreationTime.QuadPart != -1)
     1396        RTTimeSpecSetNtTime(&pReq->ObjInfo.BirthTime, pBasicInfo->CreationTime.QuadPart);
     1397
     1398    if (pBasicInfo->LastAccessTime.QuadPart)
     1399    {
     1400        if (pBasicInfo->LastAccessTime.QuadPart != -1)
     1401        {
     1402            RTTimeSpecSetNtTime(&pReq->ObjInfo.AccessTime, pBasicInfo->LastAccessTime.QuadPart);
     1403            fModified |= VBOX_FOBX_F_INFO_LASTACCESS_TIME;
     1404        }
     1405        fSuppressed |= VBOX_FOBX_F_INFO_LASTACCESS_TIME;
     1406    }
     1407
     1408    if (pBasicInfo->LastWriteTime.QuadPart)
     1409    {
     1410        if (pBasicInfo->LastWriteTime.QuadPart != -1)
     1411        {
     1412            RTTimeSpecSetNtTime(&pReq->ObjInfo.ModificationTime, pBasicInfo->LastWriteTime.QuadPart);
     1413            fModified |= VBOX_FOBX_F_INFO_LASTWRITE_TIME;
     1414        }
     1415        fSuppressed |= VBOX_FOBX_F_INFO_LASTWRITE_TIME;
     1416    }
     1417
     1418    if (pBasicInfo->ChangeTime.QuadPart)
     1419    {
     1420        if (pBasicInfo->ChangeTime.QuadPart != -1)
     1421        {
     1422            RTTimeSpecSetNtTime(&pReq->ObjInfo.ChangeTime, pBasicInfo->ChangeTime.QuadPart);
     1423            fModified |= VBOX_FOBX_F_INFO_CHANGE_TIME;
     1424        }
     1425        fSuppressed |= VBOX_FOBX_F_INFO_CHANGE_TIME;
     1426    }
     1427
    13951428    if (pBasicInfo->FileAttributes)
    1396         pSHFLFileInfo->Attr.fMode = NTToVBoxFileAttributes(pBasicInfo->FileAttributes);
    1397 
    1398     Assert(pVBoxFobx && pNetRootExtension);
    1399     vrc = VbglR0SfFsInfo(&g_SfClient, &pNetRootExtension->map, pVBoxFobx->hFile,
    1400                          SHFL_INFO_SET | SHFL_INFO_FILE, &cbBuffer, (PSHFLDIRINFO)pSHFLFileInfo);
    1401 
     1429    {
     1430        pReq->ObjInfo.Attr.fMode = NTToVBoxFileAttributes(pBasicInfo->FileAttributes);
     1431        Assert(pReq->ObjInfo.Attr.fMode != 0);
     1432    }
     1433
     1434    /*
     1435     * Call the host to do the actual updating.
     1436     * Note! This may be a noop, but we want up-to-date info for any -1 timestamp.
     1437     */
     1438    int vrc = VbglR0SfHostReqSetObjInfo(pNetRootExtension->map.root, pReq, pVBoxFobx->hFile);
    14021439    NTSTATUS Status;
    14031440    if (RT_SUCCESS(vrc))
    14041441    {
    1405         vbsfNtCopyInfo(pVBoxFobx, pSHFLFileInfo, fModified);
    1406         pVBoxFobx->SetFileInfoOnCloseFlags |= fModified;
     1442        /*
     1443         * Update our timestamp state tracking both in the file object and the file
     1444         * control block extensions.
     1445         */
     1446        if (pBasicInfo->FileAttributes || fModified)
     1447        {
     1448            if (   pVBoxFcbx->pFobxChangeTime != pVBoxFobx
     1449                && !(pVBoxFobx->fTimestampsUpdatingSuppressed & VBOX_FOBX_F_INFO_CHANGE_TIME))
     1450                pVBoxFcbx->pFobxChangeTime = NULL;
     1451            pVBoxFobx->fTimestampsImplicitlyUpdated |= VBOX_FOBX_F_INFO_CHANGE_TIME;
     1452        }
     1453        pVBoxFobx->fTimestampsImplicitlyUpdated  &= ~fModified;
     1454        pVBoxFobx->fTimestampsSetByUser          |= fModified;
     1455        pVBoxFobx->fTimestampsUpdatingSuppressed |= fSuppressed;
     1456
     1457        if (fSuppressed)
     1458        {
     1459            if (fSuppressed & VBOX_FOBX_F_INFO_LASTACCESS_TIME)
     1460                pVBoxFcbx->pFobxLastAccessTime = pVBoxFobx;
     1461            if (fSuppressed & VBOX_FOBX_F_INFO_LASTWRITE_TIME)
     1462                pVBoxFcbx->pFobxLastWriteTime  = pVBoxFobx;
     1463            if (fSuppressed & VBOX_FOBX_F_INFO_CHANGE_TIME)
     1464                pVBoxFcbx->pFobxChangeTime     = pVBoxFobx;
     1465        }
     1466
     1467        vbsfNtCopyInfo(pVBoxFobx, &pReq->ObjInfo, pVBoxFcbx, fSuppressed);
     1468
     1469        /*
     1470         * Copy timestamps and attributes from the host into the return buffer to let
     1471         * RDBSS update the FCB data when we return.   Not sure if the FCB timestamps
     1472         * are ever used for anything, but caller doesn't check for -1 so there will
     1473         * be some funny/invalid timestamps in the FCB it ever does.  (I seriously
     1474         * doubt -1 is supposed to be there given that the FCB is shared and the -1
     1475         * only applies to a given FILE_OBJECT/HANDLE.)
     1476         */
     1477        if (pBasicInfo->FileAttributes)
     1478            pBasicInfo->FileAttributes          = (pBasicInfo->FileAttributes & FILE_ATTRIBUTE_TEMPORARY)
     1479                                                | VBoxToNTFileAttributes(pReq->ObjInfo.Attr.fMode);
     1480        if (pBasicInfo->CreationTime.QuadPart)
     1481            pBasicInfo->CreationTime.QuadPart   = RTTimeSpecGetNtTime(&pReq->ObjInfo.BirthTime);
     1482        if (pBasicInfo->LastAccessTime.QuadPart)
     1483            pBasicInfo->LastAccessTime.QuadPart = RTTimeSpecGetNtTime(&pReq->ObjInfo.AccessTime);
     1484        if (pBasicInfo->LastWriteTime.QuadPart)
     1485            pBasicInfo->LastWriteTime.QuadPart  = RTTimeSpecGetNtTime(&pReq->ObjInfo.ModificationTime);
     1486        if (pBasicInfo->ChangeTime.QuadPart)
     1487            pBasicInfo->ChangeTime.QuadPart     = RTTimeSpecGetNtTime(&pReq->ObjInfo.ChangeTime);
     1488
    14071489        Status = STATUS_SUCCESS;
    14081490    }
    14091491    else
    14101492        Status = vbsfNtVBoxStatusToNt(vrc);
    1411     vbsfNtFreeNonPagedMem(pHGCMBuffer);
     1493
     1494    VbglR0PhysHeapFree(pReq);
    14121495    return Status;
    14131496}
     
    14241507
    14251508    PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(capFcb->pNetRoot);
     1509    PVBSFNTFCBEXT pVBoxFcbx = VBoxMRxGetFcbExtension(capFcb);
    14261510    PMRX_VBOX_FOBX pVBoxFobx = VBoxMRxGetFileObjectExtension(capFobx);
    14271511
     
    14541538    if (Status == STATUS_SUCCESS)
    14551539    {
     1540        pVBoxFobx->fTimestampsImplicitlyUpdated |= VBOX_FOBX_F_INFO_LASTWRITE_TIME;
     1541        if (pVBoxFcbx->pFobxLastWriteTime != pVBoxFobx)
     1542            pVBoxFcbx->pFobxLastWriteTime = NULL;
     1543
    14561544        Log(("VBOXSF: vbsfNtSetEndOfFile: VbglR0SfFsInfo new allocation size = %RX64\n",
    14571545             pObjInfo->cbAllocated));
     
    15001588    /* Must close the file before renaming it! */
    15011589    if (pVBoxFobx->hFile != SHFL_HANDLE_NIL)
    1502         vbsfNtCloseFileHandle(pNetRootExtension, pVBoxFobx);
     1590        vbsfNtCloseFileHandle(pNetRootExtension, pVBoxFobx, VBoxMRxGetFcbExtension(capFcb));
    15031591
    15041592    /* Mark it as renamed, so we do nothing during close */
     
    15481636 *
    15491637 * The RDBSS code has done various things before we get here wrt locking and
    1550  * request pre-processing.
     1638 * request pre-processing.  It will normally acquire an exclusive lock, but not
     1639 * if this is related to a page file (FCB_STATE_PAGING_FILE set).
    15511640 */
    15521641NTSTATUS VBoxMRxSetFileInfo(IN PRX_CONTEXT RxContext)
     
    15961685     *     db 4                    ; 75      FileCaseSensitiveInformationForceAccessCheck, - for the i/o manager, w10-1809.
    15971686     */
    1598 
    15991687    switch (RxContext->Info.FileInformationClass)
    16001688    {
    16011689        /*
    16021690         * This is used to modify timestamps and attributes.
     1691         *
     1692         * Upon successful return, RDBSS will ensure that FILE_ATTRIBUTE_DIRECTORY is set
     1693         * according to the FCB object type (see RxFinishFcbInitialization in path.cpp),
     1694         * and that the  FILE_ATTRIBUTE_TEMPORARY attribute is reflected in  FcbState
     1695         * (FCB_STATE_TEMPORARY) and the file object flags (FO_TEMPORARY_FILE).  It will
     1696         * also copy each non-zero timestamp into the FCB and set the corresponding
     1697         * FOBX_FLAG_USER_SET_xxxx flag in the FOBX.
     1698         *
     1699         * RDBSS behaviour is idential between 16299.0/w10 and 7600.16385.1/wnet.
    16031700         */
    16041701        case FileBasicInformation:
    16051702        {
    16061703            Assert(RxContext->Info.Length >= sizeof(FILE_BASIC_INFORMATION));
    1607             Status = vbsfNtSetBasicInfo(pVBoxFobx, pNetRootExtension, (PFILE_BASIC_INFORMATION)RxContext->Info.Buffer);
     1704            Status = vbsfNtSetBasicInfo(pVBoxFobx, pNetRootExtension, VBoxMRxGetFcbExtension(capFcb),
     1705                                        (PFILE_BASIC_INFORMATION)RxContext->Info.Buffer);
    16081706            break;
    16091707        }
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/path.cpp

    r78339 r78355  
    592592    pVBoxFobx->pSrvCall = RxContext->Create.pSrvCall;
    593593    pVBoxFobx->Info = Info;
    594     vbsfNtCopyInfoToLegacy(pVBoxFobx, &Info);
     594    vbsfNtBasicInfoFromVBoxObjInfo(&pVBoxFobx->FileBasicInfo, &Info);
    595595    Log(("VBOXSF: MRxCreate: FileBasicInformation: CreationTime   %RX64\n", pVBoxFobx->FileBasicInfo.CreationTime.QuadPart));
    596596    Log(("VBOXSF: MRxCreate: FileBasicInformation: LastAccessTime %RX64\n", pVBoxFobx->FileBasicInfo.LastAccessTime.QuadPart));
     
    663663}
    664664
    665 static NTSTATUS vbsfSetFileInfoOnClose(PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension,
    666                                        PMRX_VBOX_FOBX pVBoxFobx,
    667                                        PFILE_BASIC_INFORMATION pInfo,
    668                                        BYTE SetAttrFlags)
    669 {
    670     NTSTATUS Status = STATUS_SUCCESS;
    671 
    672     int vrc;
    673     PSHFLFSOBJINFO pSHFLFileInfo;
    674 
    675     uint8_t *pHGCMBuffer = NULL;
    676     uint32_t cbBuffer = 0;
    677 
    678     Log(("VBOXSF: vbsfSetFileInfoOnClose: SetAttrFlags 0x%02X\n", SetAttrFlags));
    679     Log(("VBOXSF: vbsfSetFileInfoOnClose: FileBasicInformation: CreationTime   %RX64\n", pInfo->CreationTime.QuadPart));
    680     Log(("VBOXSF: vbsfSetFileInfoOnClose: FileBasicInformation: LastAccessTime %RX64\n", pInfo->LastAccessTime.QuadPart));
    681     Log(("VBOXSF: vbsfSetFileInfoOnClose: FileBasicInformation: LastWriteTime  %RX64\n", pInfo->LastWriteTime.QuadPart));
    682     Log(("VBOXSF: vbsfSetFileInfoOnClose: FileBasicInformation: ChangeTime     %RX64\n", pInfo->ChangeTime.QuadPart));
    683     Log(("VBOXSF: vbsfSetFileInfoOnClose: FileBasicInformation: FileAttributes %RX32\n", pInfo->FileAttributes));
    684 
    685     if (SetAttrFlags == 0)
    686     {
    687         Log(("VBOXSF: vbsfSetFileInfo: nothing to set\n"));
    688         return STATUS_SUCCESS;
    689     }
    690 
    691     cbBuffer = sizeof(SHFLFSOBJINFO);
    692     pHGCMBuffer = (uint8_t *)vbsfNtAllocNonPagedMem(cbBuffer);
    693     if (!pHGCMBuffer)
    694     {
    695         AssertFailed();
    696         return STATUS_INSUFFICIENT_RESOURCES;
    697     }
    698     RtlZeroMemory(pHGCMBuffer, cbBuffer);
    699     pSHFLFileInfo = (PSHFLFSOBJINFO)pHGCMBuffer;
    700 
    701     /* The properties, that need to be changed, are set to something other than zero */
    702     if (pInfo->CreationTime.QuadPart && (SetAttrFlags & VBOX_FOBX_F_INFO_CREATION_TIME) != 0)
    703         RTTimeSpecSetNtTime(&pSHFLFileInfo->BirthTime, pInfo->CreationTime.QuadPart);
    704     if (pInfo->LastAccessTime.QuadPart && (SetAttrFlags & VBOX_FOBX_F_INFO_LASTACCESS_TIME) != 0)
    705         RTTimeSpecSetNtTime(&pSHFLFileInfo->AccessTime, pInfo->LastAccessTime.QuadPart);
    706     if (pInfo->LastWriteTime.QuadPart && (SetAttrFlags & VBOX_FOBX_F_INFO_LASTWRITE_TIME) != 0)
    707         RTTimeSpecSetNtTime(&pSHFLFileInfo->ModificationTime, pInfo->LastWriteTime.QuadPart);
    708     if (pInfo->ChangeTime.QuadPart && (SetAttrFlags & VBOX_FOBX_F_INFO_CHANGE_TIME) != 0)
    709         RTTimeSpecSetNtTime(&pSHFLFileInfo->ChangeTime, pInfo->ChangeTime.QuadPart);
    710     if (pInfo->FileAttributes && (SetAttrFlags & VBOX_FOBX_F_INFO_ATTRIBUTES) != 0) /// @todo r=bird: never ever set.
    711         pSHFLFileInfo->Attr.fMode = NTToVBoxFileAttributes(pInfo->FileAttributes);
    712 
    713     vrc = VbglR0SfFsInfo(&g_SfClient, &pNetRootExtension->map, pVBoxFobx->hFile,
    714                          SHFL_INFO_SET | SHFL_INFO_FILE, &cbBuffer, (PSHFLDIRINFO)pSHFLFileInfo);
    715 
    716     if (vrc != VINF_SUCCESS)
    717         Status = vbsfNtVBoxStatusToNt(vrc);
    718 
    719     if (pHGCMBuffer)
    720         vbsfNtFreeNonPagedMem(pHGCMBuffer);
    721 
    722     Log(("VBOXSF: vbsfSetFileInfo: Returned 0x%08X\n", Status));
    723     return Status;
    724 }
    725 
    726665/**
    727666 * Closes an opened file handle of a MRX_VBOX_FOBX.
     
    732671 */
    733672NTSTATUS vbsfNtCloseFileHandle(PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension,
    734                                PMRX_VBOX_FOBX pVBoxFobx)
    735 {
    736     NTSTATUS Status = STATUS_SUCCESS;
    737 
    738     int vrc;
    739 
     673                               PMRX_VBOX_FOBX pVBoxFobx,
     674                               PVBSFNTFCBEXT pVBoxFcbx)
     675{
    740676    if (pVBoxFobx->hFile == SHFL_HANDLE_NIL)
    741677    {
     
    744680    }
    745681
    746     Log(("VBOXSF: vbsfCloseFileHandle: 0x%RX64, on close info 0x%02X\n",
    747          pVBoxFobx->hFile, pVBoxFobx->SetFileInfoOnCloseFlags));
    748 
    749     if (pVBoxFobx->SetFileInfoOnCloseFlags)
    750     {
    751         /* If the file timestamps were set by the user, then update them before closing the handle,
    752          * to cancel any effect of the file read/write operations on the host.
    753          */
    754         Status = vbsfSetFileInfoOnClose(pNetRootExtension,
    755                                         pVBoxFobx,
    756                                         &pVBoxFobx->FileBasicInfo,
    757                                         pVBoxFobx->SetFileInfoOnCloseFlags);
    758     }
    759 
    760     vrc = VbglR0SfClose(&g_SfClient,
    761                         &pNetRootExtension->map,
    762                         pVBoxFobx->hFile);
     682    Log(("VBOXSF: vbsfCloseFileHandle: 0x%RX64, fTimestampsUpdatingSuppressed = %#x, fTimestampsImplicitlyUpdated = %#x\n",
     683         pVBoxFobx->hFile, pVBoxFobx->fTimestampsUpdatingSuppressed, pVBoxFobx->fTimestampsImplicitlyUpdated));
     684
     685    /*
     686     * We allocate a single request buffer for the timestamp updating and the closing
     687     * to save time (at the risk of running out of heap, but whatever).
     688     */
     689    union MyCloseAndInfoReq
     690    {
     691        VBOXSFCLOSEREQ   Close;
     692        VBOXSFOBJINFOREQ Info;
     693    } *pReq = (union MyCloseAndInfoReq *)VbglR0PhysHeapAlloc(sizeof(*pReq));
     694    if (pReq)
     695        RT_ZERO(*pReq);
     696    else
     697        return STATUS_INSUFF_SERVER_RESOURCES;
     698
     699    /*
     700     * Restore timestamp that we may implicitly been updated via this handle
     701     * after the user explicitly set them or turn off implict updating (the -1 value).
     702     *
     703     * Note! We ignore the status of this operation.
     704     */
     705    Assert(pVBoxFcbx);
     706    uint8_t fUpdateTs = pVBoxFobx->fTimestampsUpdatingSuppressed & pVBoxFobx->fTimestampsImplicitlyUpdated;
     707    if (fUpdateTs)
     708    {
     709        /** @todo skip this if the host is windows and fTimestampsUpdatingSuppressed == fTimestampsSetByUser */
     710        /** @todo pass -1 timestamps thru so we can always skip this on windows hosts! */
     711        if (   (fUpdateTs & VBOX_FOBX_F_INFO_LASTACCESS_TIME)
     712            && pVBoxFcbx->pFobxLastAccessTime == pVBoxFobx)
     713            pReq->Info.ObjInfo.AccessTime        = pVBoxFobx->Info.AccessTime;
     714        else
     715            fUpdateTs &= ~VBOX_FOBX_F_INFO_LASTACCESS_TIME;
     716
     717        if (   (fUpdateTs & VBOX_FOBX_F_INFO_LASTWRITE_TIME)
     718            && pVBoxFcbx->pFobxLastWriteTime  == pVBoxFobx)
     719            pReq->Info.ObjInfo.ModificationTime  = pVBoxFobx->Info.ModificationTime;
     720        else
     721            fUpdateTs &= ~VBOX_FOBX_F_INFO_LASTWRITE_TIME;
     722
     723        if (   (fUpdateTs & VBOX_FOBX_F_INFO_CHANGE_TIME)
     724            && pVBoxFcbx->pFobxChangeTime     == pVBoxFobx)
     725            pReq->Info.ObjInfo.ChangeTime        = pVBoxFobx->Info.ChangeTime;
     726        else
     727            fUpdateTs &= ~VBOX_FOBX_F_INFO_CHANGE_TIME;
     728        if (fUpdateTs)
     729        {
     730            Log(("VBOXSF: vbsfCloseFileHandle: Updating timestamp: %#x\n", fUpdateTs));
     731            int vrc = VbglR0SfHostReqSetObjInfo(pNetRootExtension->map.root, &pReq->Info, pVBoxFobx->hFile);
     732            if (RT_FAILURE(vrc))
     733                Log(("VBOXSF: vbsfCloseFileHandle: VbglR0SfHostReqSetObjInfo failed for fUpdateTs=%#x: %Rrc\n", fUpdateTs, vrc));
     734            RT_NOREF(vrc);
     735        }
     736        else
     737            Log(("VBOXSF: vbsfCloseFileHandle: no timestamp needing updating\n"));
     738    }
     739
     740    /* This isn't strictly necessary, but best to keep things clean. */
     741    pVBoxFobx->fTimestampsSetByUser          = 0;
     742    pVBoxFobx->fTimestampsUpdatingSuppressed = 0;
     743    pVBoxFobx->fTimestampsImplicitlyUpdated  = 0;
     744    if (pVBoxFcbx->pFobxLastAccessTime == pVBoxFobx)
     745        pVBoxFcbx->pFobxLastAccessTime = NULL;
     746    if (pVBoxFcbx->pFobxLastWriteTime  == pVBoxFobx)
     747        pVBoxFcbx->pFobxLastWriteTime  = NULL;
     748    if (pVBoxFcbx->pFobxChangeTime     == pVBoxFobx)
     749        pVBoxFcbx->pFobxChangeTime     = NULL;
     750
     751    /*
     752     * Now close the handle.
     753     */
     754    int vrc = VbglR0SfHostReqClose(pNetRootExtension->map.root, &pReq->Close, pVBoxFobx->hFile);
    763755
    764756    pVBoxFobx->hFile = SHFL_HANDLE_NIL;
    765757
    766     if (vrc != VINF_SUCCESS)
    767         Status = vbsfNtVBoxStatusToNt(vrc);
    768 
    769     Log(("VBOXSF: vbsfCloseFileHandle: Returned 0x%08X\n", Status));
     758    VbglR0PhysHeapFree(pReq);
     759
     760    NTSTATUS const Status = RT_SUCCESS(vrc) ? STATUS_SUCCESS : vbsfNtVBoxStatusToNt(vrc);
     761    Log(("VBOXSF: vbsfCloseFileHandle: Returned 0x%08X (vrc=%Rrc)\n", Status, vrc));
    770762    return Status;
    771763}
     
    806798    /* Close file */
    807799    if (pVBoxFobx->hFile != SHFL_HANDLE_NIL)
    808         vbsfNtCloseFileHandle(pNetRootExtension, pVBoxFobx);
     800        vbsfNtCloseFileHandle(pNetRootExtension, pVBoxFobx, VBoxMRxGetFcbExtension(capFcb));
    809801
    810802    if (capFcb->FcbState & FCB_STATE_DELETE_ON_CLOSE)
     
    844836    /* Close file first if not already done. */
    845837    if (pVBoxFobx->hFile != SHFL_HANDLE_NIL)
    846         vbsfNtCloseFileHandle(pNetRootExtension, pVBoxFobx);
     838        vbsfNtCloseFileHandle(pNetRootExtension, pVBoxFobx, VBoxMRxGetFcbExtension(capFcb));
    847839
    848840    Log(("VBOXSF: vbsfNtRemove: RemainingName->Length %d\n", RemainingName->Length));
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsf.cpp

    r78326 r78355  
    155155    ZeroAndInitializeNodeType(&VBoxMRxDispatch, RDBSS_NTC_MINIRDR_DISPATCH, sizeof(MINIRDR_DISPATCH));
    156156
    157     VBoxMRxDispatch.MRxFlags = (RDBSS_MANAGE_NET_ROOT_EXTENSION | RDBSS_MANAGE_FOBX_EXTENSION);
     157    VBoxMRxDispatch.MRxFlags = RDBSS_MANAGE_NET_ROOT_EXTENSION | RDBSS_MANAGE_FCB_EXTENSION | RDBSS_MANAGE_FOBX_EXTENSION;
    158158
    159159    VBoxMRxDispatch.MRxSrvCallSize = 0;
    160160    VBoxMRxDispatch.MRxNetRootSize = sizeof(MRX_VBOX_NETROOT_EXTENSION);
    161161    VBoxMRxDispatch.MRxVNetRootSize = 0;
    162     VBoxMRxDispatch.MRxFcbSize = 0;
     162    VBoxMRxDispatch.MRxFcbSize = sizeof(VBSFNTFCBEXT);
    163163    VBoxMRxDispatch.MRxSrvOpenSize = 0;
    164164    VBoxMRxDispatch.MRxFobxSize = sizeof(MRX_VBOX_FOBX);
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsf.h

    r78339 r78355  
    9797} MRX_VBOX_NETROOT_EXTENSION, *PMRX_VBOX_NETROOT_EXTENSION;
    9898
    99 #define VBOX_FOBX_F_INFO_CREATION_TIME   0x01
    100 #define VBOX_FOBX_F_INFO_LASTACCESS_TIME 0x02
    101 #define VBOX_FOBX_F_INFO_LASTWRITE_TIME  0x04
    102 #define VBOX_FOBX_F_INFO_CHANGE_TIME     0x08
    103 #define VBOX_FOBX_F_INFO_ATTRIBUTES      0x10
     99
     100/** Pointer to the VBox file object extension data. */
     101typedef struct MRX_VBOX_FOBX *PMRX_VBOX_FOBX;
     102
     103/**
     104 * VBox extension data to the file control block (FCB).
     105 *
     106 * @note To unix people, think of the FCB as the inode structure.  This is our
     107 *       private addition to the inode info.
     108 */
     109typedef struct VBSFNTFCBEXT
     110{
     111    /** @name Pointers to file object extensions currently sitting on the given timestamps.
     112     *
     113     * The file object extensions pointed to have disabled implicit updating the
     114     * respective timestamp due to a FileBasicInformation set request.  Should these
     115     * timestamps be modified via any other file handle, these pointers will be
     116     * updated or set to NULL to reflect this.  So, when the cleaning up a file
     117     * object it can be more accurately determined whether to restore timestamps on
     118     * non-windows host systems or not.
     119     *
     120     * @{ */
     121    MRX_VBOX_FOBX            *pFobxLastAccessTime;
     122    MRX_VBOX_FOBX            *pFobxLastWriteTime;
     123    MRX_VBOX_FOBX            *pFobxChangeTime;
     124    /** @} */
     125} VBSFNTFCBEXT;
     126/** Pointer to the VBox FCB extension data. */
     127typedef VBSFNTFCBEXT *PVBSFNTFCBEXT;
     128
     129
     130/** @name  VBOX_FOBX_F_INFO_XXX
     131 * @{ */
     132#define VBOX_FOBX_F_INFO_LASTACCESS_TIME UINT8_C(0x01)
     133#define VBOX_FOBX_F_INFO_LASTWRITE_TIME  UINT8_C(0x02)
     134#define VBOX_FOBX_F_INFO_CHANGE_TIME     UINT8_C(0x04)
     135/** @} */
    104136
    105137/**
     
    119151    FILE_BASIC_INFORMATION      FileBasicInfo;
    120152
    121     BOOLEAN fKeepCreationTime;
    122     BOOLEAN fKeepLastAccessTime;
    123     BOOLEAN fKeepLastWriteTime;
    124     BOOLEAN fKeepChangeTime;
    125     BYTE SetFileInfoOnCloseFlags;
    126 } MRX_VBOX_FOBX, *PMRX_VBOX_FOBX;
     153    /** VBOX_FOBX_F_INFO_XXX of timestamps which may need setting on close. */
     154    uint8_t                     fTimestampsSetByUser;
     155    /** VBOX_FOBX_F_INFO_XXX of timestamps which implicit updating is suppressed. */
     156    uint8_t                     fTimestampsUpdatingSuppressed;
     157    /** VBOX_FOBX_F_INFO_XXX of timestamps which may have implicitly update. */
     158    uint8_t                     fTimestampsImplicitlyUpdated;
     159} MRX_VBOX_FOBX;
    127160
    128161#define VBoxMRxGetDeviceExtension(RxContext) \
    129         (PMRX_VBOX_DEVICE_EXTENSION)((PBYTE)(RxContext->RxDeviceObject) + sizeof(RDBSS_DEVICE_OBJECT))
    130 
    131 #define VBoxMRxGetNetRootExtension(pNetRoot) \
    132         (((pNetRoot) == NULL) ? NULL : (PMRX_VBOX_NETROOT_EXTENSION)((pNetRoot)->Context))
    133 
    134 #define VBoxMRxGetSrvOpenExtension(pSrvOpen)  \
    135         (((pSrvOpen) == NULL) ? NULL : (PMRX_VBOX_SRV_OPEN)((pSrvOpen)->Context))
    136 
    137 #define VBoxMRxGetFileObjectExtension(pFobx)  \
    138         (((pFobx) == NULL) ? NULL : (PMRX_VBOX_FOBX)((pFobx)->Context))
     162        ((PMRX_VBOX_DEVICE_EXTENSION)((PBYTE)(RxContext)->RxDeviceObject + sizeof(RDBSS_DEVICE_OBJECT)))
     163
     164#define VBoxMRxGetNetRootExtension(pNetRoot)    ((pNetRoot) != NULL ? (PMRX_VBOX_NETROOT_EXTENSION)(pNetRoot)->Context : NULL)
     165
     166#define VBoxMRxGetFcbExtension(pFcb)            ((pFcb)     != NULL ?                   (PVBSFNTFCBEXT)(pFcb)->Context : NULL)
     167
     168#define VBoxMRxGetSrvOpenExtension(pSrvOpen)    ((pSrvOpen) != NULL ?          (PMRX_VBOX_SRV_OPEN)(pSrvOpen)->Context : NULL)
     169
     170#define VBoxMRxGetFileObjectExtension(pFobx)    ((pFobx)    != NULL ?                 (PMRX_VBOX_FOBX)(pFobx)->Context : NULL)
    139171
    140172/** HACK ALERT: Special Create.ShareAccess indicating trailing slash for
     
    220252                                OUT PBOOLEAN PostToFsp);
    221253NTSTATUS vbsfNtCloseFileHandle(PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension,
    222                                PMRX_VBOX_FOBX pVBoxFobx);
     254                               PMRX_VBOX_FOBX pVBoxFobx,
     255                               PVBSFNTFCBEXT pVBoxFcbx);
    223256NTSTATUS vbsfNtRemove(IN PRX_CONTEXT RxContext);
    224 void     vbsfNtCopyInfoToLegacy(PMRX_VBOX_FOBX pVBoxFobx, PCSHFLFSOBJINFO pInfo);
    225257NTSTATUS vbsfNtVBoxStatusToNt(int vrc);
    226258PVOID    vbsfNtAllocNonPagedMem(ULONG ulSize);
     
    273305}
    274306
     307/**
     308 * Helper for converting VBox object info to NT basic file info.
     309 */
     310DECLINLINE(void) vbsfNtBasicInfoFromVBoxObjInfo(FILE_BASIC_INFORMATION *pNtBasicInfo, PCSHFLFSOBJINFO pVBoxInfo)
     311{
     312    pNtBasicInfo->CreationTime.QuadPart   = RTTimeSpecGetNtTime(&pVBoxInfo->BirthTime);
     313    pNtBasicInfo->LastAccessTime.QuadPart = RTTimeSpecGetNtTime(&pVBoxInfo->AccessTime);
     314    pNtBasicInfo->LastWriteTime.QuadPart  = RTTimeSpecGetNtTime(&pVBoxInfo->ModificationTime);
     315    pNtBasicInfo->ChangeTime.QuadPart     = RTTimeSpecGetNtTime(&pVBoxInfo->ChangeTime);
     316    pNtBasicInfo->FileAttributes          = VBoxToNTFileAttributes(pVBoxInfo->Attr.fMode);
     317}
     318
     319
    275320/** @} */
    276321
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