VirtualBox

儲存庫 vbox 的更動 40532


忽略:
時間撮記:
2012-3-19 上午11:18:53 (13 年 以前)
作者:
vboxsync
訊息:

VBOXSF: update timestamps when a file handle is closed.

位置:
trunk/src/VBox/Additions/WINNT/SharedFolders/driver
檔案:
修改 4 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/Makefile.kmk

    r40269 r40532  
    55
    66#
    7 # Copyright (C) 2006-2007 Oracle Corporation
     7# Copyright (C) 2006-2012 Oracle Corporation
    88#
    99# This file is part of VirtualBox Open Source Edition (OSE), as
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/info.c

    r40278 r40532  
    14341434            {
    14351435                pVBoxFobx->fKeepCreationTime = TRUE;
     1436                pVBoxFobx->SetFileInfoOnCloseFlags |= VBOX_FOBX_F_INFO_CREATION_TIME;
    14361437            }
    14371438            if (pInfo->LastAccessTime.QuadPart == -1)
    14381439            {
    14391440                pVBoxFobx->fKeepLastAccessTime = TRUE;
     1441                pVBoxFobx->SetFileInfoOnCloseFlags |= VBOX_FOBX_F_INFO_LASTACCESS_TIME;
    14401442            }
    14411443            if (pInfo->LastWriteTime.QuadPart == -1)
    14421444            {
    14431445                pVBoxFobx->fKeepLastWriteTime = TRUE;
     1446                pVBoxFobx->SetFileInfoOnCloseFlags |= VBOX_FOBX_F_INFO_LASTWRITE_TIME;
    14441447            }
    14451448            if (pInfo->ChangeTime.QuadPart == -1)
    14461449            {
    14471450                pVBoxFobx->fKeepChangeTime = TRUE;
     1451                pVBoxFobx->SetFileInfoOnCloseFlags |= VBOX_FOBX_F_INFO_CHANGE_TIME;
    14481452            }
    14491453
     
    14651469            {
    14661470                RTTimeSpecSetNtTime(&pSHFLFileInfo->BirthTime, pInfo->CreationTime.QuadPart);
     1471                pVBoxFobx->SetFileInfoOnCloseFlags |= VBOX_FOBX_F_INFO_CREATION_TIME;
    14671472            }
    14681473            if (pInfo->LastAccessTime.QuadPart && !pVBoxFobx->fKeepLastAccessTime)
    14691474            {
    14701475                RTTimeSpecSetNtTime(&pSHFLFileInfo->AccessTime, pInfo->LastAccessTime.QuadPart);
     1476                pVBoxFobx->SetFileInfoOnCloseFlags |= VBOX_FOBX_F_INFO_LASTACCESS_TIME;
    14711477            }
    14721478            if (pInfo->LastWriteTime.QuadPart && !pVBoxFobx->fKeepLastWriteTime)
    14731479            {
    14741480                RTTimeSpecSetNtTime(&pSHFLFileInfo->ModificationTime, pInfo->LastWriteTime.QuadPart);
     1481                pVBoxFobx->SetFileInfoOnCloseFlags |= VBOX_FOBX_F_INFO_LASTWRITE_TIME;
    14751482            }
    14761483            if (pInfo->ChangeTime.QuadPart && !pVBoxFobx->fKeepChangeTime)
    14771484            {
    14781485                RTTimeSpecSetNtTime(&pSHFLFileInfo->ChangeTime, pInfo->ChangeTime.QuadPart);
     1486                pVBoxFobx->SetFileInfoOnCloseFlags |= VBOX_FOBX_F_INFO_CHANGE_TIME;
    14791487            }
    14801488            if (pInfo->FileAttributes)
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/path.c

    r40269 r40532  
    587587    }
    588588
     589    Log(("VBOXSF: MRxCreate: FileBasicInformation: CreationTime   %RX64\n", FileBasicInfo.CreationTime.QuadPart));
     590    Log(("VBOXSF: MRxCreate: FileBasicInformation: LastAccessTime %RX64\n", FileBasicInfo.LastAccessTime.QuadPart));
     591    Log(("VBOXSF: MRxCreate: FileBasicInformation: LastWriteTime  %RX64\n", FileBasicInfo.LastWriteTime.QuadPart));
     592    Log(("VBOXSF: MRxCreate: FileBasicInformation: ChangeTime     %RX64\n", FileBasicInfo.ChangeTime.QuadPart));
     593    Log(("VBOXSF: MRxCreate: FileBasicInformation: FileAttributes %RX32\n", FileBasicInfo.FileAttributes));
     594
    589595    pVBoxFobx->hFile = Handle;
    590596    pVBoxFobx->pSrvCall = RxContext->Create.pSrvCall;
     
    595601    pVBoxFobx->fKeepLastWriteTime = FALSE;
    596602    pVBoxFobx->fKeepChangeTime = FALSE;
     603    pVBoxFobx->SetFileInfoOnCloseFlags = 0;
    597604
    598605    if (!RxIsFcbAcquiredExclusive(capFcb))
     
    655662    Log(("VBOXSF: MRxForceClosed\n"));
    656663    return STATUS_NOT_IMPLEMENTED;
     664}
     665
     666NTSTATUS vbsfSetFileInfo(PMRX_VBOX_DEVICE_EXTENSION pDeviceExtension,
     667                         PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension,
     668                         PMRX_VBOX_FOBX pVBoxFobx,
     669                         PFILE_BASIC_INFORMATION pInfo,
     670                         BYTE SetAttrFlags)
     671{
     672    NTSTATUS Status = STATUS_SUCCESS;
     673
     674    int vboxRC;
     675    PSHFLFSOBJINFO pSHFLFileInfo;
     676
     677    uint8_t *pHGCMBuffer = NULL;
     678    uint32_t cbBuffer = 0;
     679
     680    Log(("VBOXSF: vbsfSetFileInfo: SetAttrFlags 0x%02X\n", SetAttrFlags));
     681    Log(("VBOXSF: vbsfSetFileInfo: FileBasicInformation: CreationTime   %RX64\n", pInfo->CreationTime.QuadPart));
     682    Log(("VBOXSF: vbsfSetFileInfo: FileBasicInformation: LastAccessTime %RX64\n", pInfo->LastAccessTime.QuadPart));
     683    Log(("VBOXSF: vbsfSetFileInfo: FileBasicInformation: LastWriteTime  %RX64\n", pInfo->LastWriteTime.QuadPart));
     684    Log(("VBOXSF: vbsfSetFileInfo: FileBasicInformation: ChangeTime     %RX64\n", pInfo->ChangeTime.QuadPart));
     685    Log(("VBOXSF: vbsfSetFileInfo: FileBasicInformation: FileAttributes %RX32\n", pInfo->FileAttributes));
     686
     687    if (SetAttrFlags == 0)
     688    {
     689        Log(("VBOXSF: vbsfSetFileInfo: nothing to set\n"));
     690        return STATUS_SUCCESS;
     691    }
     692
     693    cbBuffer = sizeof(SHFLFSOBJINFO);
     694    pHGCMBuffer = (uint8_t *)vbsfAllocNonPagedMem(cbBuffer);
     695    if (pHGCMBuffer == NULL)
     696    {
     697        AssertFailed();
     698        return STATUS_INSUFFICIENT_RESOURCES;
     699    }
     700    RtlZeroMemory(pHGCMBuffer, cbBuffer);
     701    pSHFLFileInfo = (PSHFLFSOBJINFO)pHGCMBuffer;
     702
     703    /* The properties, that need to be changed, are set to something other than zero */
     704    if (pInfo->CreationTime.QuadPart && (SetAttrFlags & VBOX_FOBX_F_INFO_CREATION_TIME) != 0)
     705    {
     706        RTTimeSpecSetNtTime(&pSHFLFileInfo->BirthTime, pInfo->CreationTime.QuadPart);
     707    }
     708    if (pInfo->LastAccessTime.QuadPart && (SetAttrFlags & VBOX_FOBX_F_INFO_LASTACCESS_TIME) != 0)
     709    {
     710        RTTimeSpecSetNtTime(&pSHFLFileInfo->AccessTime, pInfo->LastAccessTime.QuadPart);
     711    }
     712    if (pInfo->LastWriteTime.QuadPart && (SetAttrFlags & VBOX_FOBX_F_INFO_LASTWRITE_TIME) != 0)
     713    {
     714        RTTimeSpecSetNtTime(&pSHFLFileInfo->ModificationTime, pInfo->LastWriteTime.QuadPart);
     715    }
     716    if (pInfo->ChangeTime.QuadPart && (SetAttrFlags & VBOX_FOBX_F_INFO_CHANGE_TIME) != 0)
     717    {
     718        RTTimeSpecSetNtTime(&pSHFLFileInfo->ChangeTime, pInfo->ChangeTime.QuadPart);
     719    }
     720    if (pInfo->FileAttributes && (SetAttrFlags & VBOX_FOBX_F_INFO_ATTRIBUTES) != 0)
     721    {
     722        pSHFLFileInfo->Attr.fMode = NTToVBoxFileAttributes(pInfo->FileAttributes);
     723    }
     724
     725    vboxRC = vboxCallFSInfo(&pDeviceExtension->hgcmClient, &pNetRootExtension->map, pVBoxFobx->hFile,
     726                            SHFL_INFO_SET | SHFL_INFO_FILE, &cbBuffer, (PSHFLDIRINFO)pSHFLFileInfo);
     727
     728    if (vboxRC != VINF_SUCCESS)
     729    {
     730        Status = VBoxErrorToNTStatus(vboxRC);
     731    }
     732
     733    if (pHGCMBuffer)
     734    {
     735        vbsfFreeNonPagedMem(pHGCMBuffer);
     736    }
     737
     738    Log(("VBOXSF: vbsfSetFileInfo: Returned 0x%08X\n",
     739         Status));
     740    return Status;
     741}
     742
     743/*
     744 * Closes an opened file handle of a MRX_VBOX_FOBX.
     745 * Updates file attributes if necessary.
     746 */
     747NTSTATUS vbsfCloseFileHandle(PMRX_VBOX_DEVICE_EXTENSION pDeviceExtension,
     748                             PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension,
     749                             PMRX_VBOX_FOBX pVBoxFobx)
     750{
     751    NTSTATUS Status = STATUS_SUCCESS;
     752
     753    int vboxRC;
     754
     755    if (pVBoxFobx->hFile == SHFL_HANDLE_NIL)
     756    {
     757        Log(("VBOXSF: vbsfCloseFileHandle: SHFL_HANDLE_NIL\n"));
     758        return STATUS_SUCCESS;
     759    }
     760
     761    Log(("VBOXSF: vbsfCloseFileHandle: 0x%RX64, on close info 0x%02X\n",
     762         pVBoxFobx->hFile, pVBoxFobx->SetFileInfoOnCloseFlags));
     763
     764    if (pVBoxFobx->SetFileInfoOnCloseFlags)
     765    {
     766        /* If the file timestamps were set by the user, then update them before closing the handle,
     767         * to cancel any effect of the file read/write operations on the host.
     768         */
     769        Status = vbsfSetFileInfo(pDeviceExtension,
     770                                 pNetRootExtension,
     771                                 pVBoxFobx,
     772                                 &pVBoxFobx->FileBasicInfo,
     773                                 pVBoxFobx->SetFileInfoOnCloseFlags);
     774    }
     775
     776    vboxRC = vboxCallClose(&pDeviceExtension->hgcmClient,
     777                           &pNetRootExtension->map,
     778                           pVBoxFobx->hFile);
     779
     780    pVBoxFobx->hFile = SHFL_HANDLE_NIL;
     781
     782    if (vboxRC != VINF_SUCCESS)
     783    {
     784        Status = VBoxErrorToNTStatus(vboxRC);
     785    }
     786
     787    Log(("VBOXSF: vbsfCloseFileHandle: Returned 0x%08X\n",
     788         Status));
     789    return Status;
    657790}
    658791
     
    697830    if (pVBoxFobx->hFile != SHFL_HANDLE_NIL)
    698831    {
    699         vboxRC = vboxCallClose(&pDeviceExtension->hgcmClient, &pNetRootExtension->map, pVBoxFobx->hFile);
    700         pVBoxFobx->hFile = SHFL_HANDLE_NIL;
     832        vbsfCloseFileHandle(pDeviceExtension, pNetRootExtension, pVBoxFobx);
    701833    }
    702834
     
    739871    if (pVBoxFobx->hFile != SHFL_HANDLE_NIL)
    740872    {
    741         vboxRC = vboxCallClose(&pDeviceExtension->hgcmClient, &pNetRootExtension->map, pVBoxFobx->hFile);
    742         pVBoxFobx->hFile = SHFL_HANDLE_NIL;
     873        vbsfCloseFileHandle(pDeviceExtension, pNetRootExtension, pVBoxFobx);
    743874    }
    744875
     
    820951    if (pVBoxFobx->hFile != SHFL_HANDLE_NIL)
    821952    {
    822         vboxRC = vboxCallClose(&pDeviceExtension->hgcmClient, &pNetRootExtension->map, pVBoxFobx->hFile);
    823         pVBoxFobx->hFile = SHFL_HANDLE_NIL;
     953        vbsfCloseFileHandle(pDeviceExtension, pNetRootExtension, pVBoxFobx);
    824954    }
    825955
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsf.h

    r40269 r40532  
    8383    VBSFMAP map;
    8484} MRX_VBOX_NETROOT_EXTENSION, *PMRX_VBOX_NETROOT_EXTENSION;
     85
     86#define VBOX_FOBX_F_INFO_CREATION_TIME   0x01
     87#define VBOX_FOBX_F_INFO_LASTACCESS_TIME 0x02
     88#define VBOX_FOBX_F_INFO_LASTWRITE_TIME  0x04
     89#define VBOX_FOBX_F_INFO_CHANGE_TIME     0x08
     90#define VBOX_FOBX_F_INFO_ATTRIBUTES      0x10
    8591
    8692/*
     
    97103    BOOLEAN fKeepLastWriteTime;
    98104    BOOLEAN fKeepChangeTime;
     105    BYTE SetFileInfoOnCloseFlags;
    99106} MRX_VBOX_FOBX, *PMRX_VBOX_FOBX;
    100107
     
    195202                    IN ULONG BufferLength);
    196203NTSTATUS vbsfRemove(IN PRX_CONTEXT RxContext);
     204NTSTATUS vbsfCloseFileHandle(PMRX_VBOX_DEVICE_EXTENSION pDeviceExtension,
     205                             PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension,
     206                             PMRX_VBOX_FOBX pVBoxFobx);
    197207
    198208#endif /* VBSF_H */
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette