- Timestamp:
- Apr 28, 2019 11:38:32 AM (6 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/SharedFolders/driver
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/file.cpp
r78338 r78339 260 260 ByteCount, ByteOffset, FileSize)); 261 261 262 /** @todo check if this is necessary. */ 262 /** @todo r=bird: This check is incorrect as we must let the host do these 263 * checks with up-to-date end-of-file data. What we've got cached here is 264 * potentially out of date. (This code is here because someone saw it in some 265 * sample, I suspect and didn't quite understand what it was all about. The 266 * thing is that when FCB_STATE_READCACHING_ENABLED is set, the caller 267 * already checks and the sample probably wanted to cover its bases. We, 268 * don't want to do that as already explained earlier.) */ 263 269 #ifdef FCB_STATE_READCACHING_ENABLED /* Correct spelling for Vista 6001 SDK. */ 264 270 if (!FlagOn(capFcb->FcbState, FCB_STATE_READCACHING_ENABLED)) … … 267 273 #endif 268 274 { 269 /** @todo r=bird: How is this file size accurate given that the file resides270 * on the host and be grown/shrunk independently there? Why is this271 * only done when FCB_STATE_READCACHEING_ENABLED is clear? */272 275 if (ByteOffset >= FileSize) 273 276 { … … 313 316 RxContext->InformationToReturn = ByteCount; 314 317 318 /** @todo if we read past the end-of-file as we know it, or if we reached 319 * end-of-file earlier than we though, update the file size. The 320 * RxLowIoReadShellCompletion() routine does not seem to do this for is and 321 * I (bird) couldn't find anyone else doing it either. */ 322 315 323 Log(("VBOXSF: vbsfReadInternal: Status = 0x%08X, ByteCount = 0x%X\n", 316 324 Status, ByteCount)); … … 554 562 } 555 563 556 NTSTATUS vbsfNtSetEndOfFile(IN OUT struct _RX_CONTEXT * RxContext,557 IN uint64_t cbNewFileSize)558 {559 NTSTATUS Status = STATUS_SUCCESS;560 561 RxCaptureFcb;562 RxCaptureFobx;563 564 PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(capFcb->pNetRoot);565 PMRX_VBOX_FOBX pVBoxFobx = VBoxMRxGetFileObjectExtension(capFobx);566 567 PSHFLFSOBJINFO pObjInfo;568 uint32_t cbBuffer;569 int vrc;570 571 Log(("VBOXSF: vbsfNtSetEndOfFile: New size = %RX64\n",572 cbNewFileSize));573 574 Assert(pVBoxFobx && pNetRootExtension);575 576 cbBuffer = sizeof(SHFLFSOBJINFO);577 pObjInfo = (SHFLFSOBJINFO *)vbsfNtAllocNonPagedMem(cbBuffer);578 if (!pObjInfo)579 {580 AssertFailed();581 return STATUS_INSUFFICIENT_RESOURCES;582 }583 584 RtlZeroMemory(pObjInfo, cbBuffer);585 pObjInfo->cbObject = cbNewFileSize;586 587 vrc = VbglR0SfFsInfo(&g_SfClient, &pNetRootExtension->map, pVBoxFobx->hFile,588 SHFL_INFO_SET | SHFL_INFO_SIZE, &cbBuffer, (PSHFLDIRINFO)pObjInfo);589 590 Log(("VBOXSF: vbsfNtSetEndOfFile: VbglR0SfFsInfo returned %Rrc\n", vrc));591 592 Status = vbsfNtVBoxStatusToNt(vrc);593 if (Status == STATUS_SUCCESS)594 {595 Log(("VBOXSF: vbsfNtSetEndOfFile: VbglR0SfFsInfo new allocation size = %RX64\n",596 pObjInfo->cbAllocated));597 598 /** @todo update the file stats! */599 }600 601 if (pObjInfo)602 vbsfNtFreeNonPagedMem(pObjInfo);603 604 Log(("VBOXSF: vbsfNtSetEndOfFile: Returned 0x%08X\n", Status));605 return Status;606 }607 608 564 /** See PMRX_EXTENDFILE_CALLDOWN in ddk/mrx.h 609 565 * -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/info.cpp
r78338 r78339 1273 1273 } 1274 1274 1275 /** 1276 * Worker for vbsfNtSetBasicInfo. 1277 */ 1275 1278 static NTSTATUS vbsfNtSetBasicInfo(PMRX_VBOX_FOBX pVBoxFobx, PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension, 1276 1279 PFILE_BASIC_INFORMATION pBasicInfo) … … 1407 1410 } 1408 1411 1412 /** 1413 * Worker for vbsfNtSetBasicInfo. 1414 */ 1415 static NTSTATUS vbsfNtSetEndOfFile(IN OUT struct _RX_CONTEXT * RxContext, IN uint64_t cbNewFileSize) 1416 { 1417 NTSTATUS Status = STATUS_SUCCESS; 1418 1419 RxCaptureFcb; 1420 RxCaptureFobx; 1421 1422 PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(capFcb->pNetRoot); 1423 PMRX_VBOX_FOBX pVBoxFobx = VBoxMRxGetFileObjectExtension(capFobx); 1424 1425 PSHFLFSOBJINFO pObjInfo; 1426 uint32_t cbBuffer; 1427 int vrc; 1428 1429 Log(("VBOXSF: vbsfNtSetEndOfFile: New size = %RX64\n", 1430 cbNewFileSize)); 1431 1432 Assert(pVBoxFobx && pNetRootExtension); 1433 1434 cbBuffer = sizeof(SHFLFSOBJINFO); 1435 pObjInfo = (SHFLFSOBJINFO *)vbsfNtAllocNonPagedMem(cbBuffer); 1436 if (!pObjInfo) 1437 { 1438 AssertFailed(); 1439 return STATUS_INSUFFICIENT_RESOURCES; 1440 } 1441 1442 RtlZeroMemory(pObjInfo, cbBuffer); 1443 pObjInfo->cbObject = cbNewFileSize; 1444 1445 vrc = VbglR0SfFsInfo(&g_SfClient, &pNetRootExtension->map, pVBoxFobx->hFile, 1446 SHFL_INFO_SET | SHFL_INFO_SIZE, &cbBuffer, (PSHFLDIRINFO)pObjInfo); 1447 1448 Log(("VBOXSF: vbsfNtSetEndOfFile: VbglR0SfFsInfo returned %Rrc\n", vrc)); 1449 1450 Status = vbsfNtVBoxStatusToNt(vrc); 1451 if (Status == STATUS_SUCCESS) 1452 { 1453 Log(("VBOXSF: vbsfNtSetEndOfFile: VbglR0SfFsInfo new allocation size = %RX64\n", 1454 pObjInfo->cbAllocated)); 1455 1456 /** @todo update the file stats! */ 1457 } 1458 1459 if (pObjInfo) 1460 vbsfNtFreeNonPagedMem(pObjInfo); 1461 1462 Log(("VBOXSF: vbsfNtSetEndOfFile: Returned 0x%08X\n", Status)); 1463 return Status; 1464 } 1465 1466 /** 1467 * Worker for vbsfNtSetBasicInfo. 1468 */ 1469 static NTSTATUS vbsfNtRename(IN PRX_CONTEXT RxContext, 1470 IN FILE_INFORMATION_CLASS FileInformationClass, 1471 IN PVOID pBuffer, 1472 IN ULONG BufferLength) 1473 { 1474 NTSTATUS Status = STATUS_SUCCESS; 1475 1476 RxCaptureFcb; 1477 RxCaptureFobx; 1478 1479 PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(capFcb->pNetRoot); 1480 PMRX_VBOX_FOBX pVBoxFobx = VBoxMRxGetFileObjectExtension(capFobx); 1481 PMRX_SRV_OPEN pSrvOpen = capFobx->pSrvOpen; 1482 1483 PFILE_RENAME_INFORMATION RenameInformation = (PFILE_RENAME_INFORMATION)RxContext->Info.Buffer; 1484 PUNICODE_STRING RemainingName = GET_ALREADY_PREFIXED_NAME(pSrvOpen, capFcb); 1485 1486 int vrc; 1487 PSHFLSTRING SrcPath = 0, DestPath = 0; 1488 ULONG flags; 1489 1490 RT_NOREF(FileInformationClass, pBuffer, BufferLength); 1491 1492 Assert(FileInformationClass == FileRenameInformation); 1493 1494 Log(("VBOXSF: vbsfNtRename: FileName = %.*ls\n", 1495 RenameInformation->FileNameLength / sizeof(WCHAR), &RenameInformation->FileName[0])); 1496 1497 /* Must close the file before renaming it! */ 1498 if (pVBoxFobx->hFile != SHFL_HANDLE_NIL) 1499 vbsfNtCloseFileHandle(pNetRootExtension, pVBoxFobx); 1500 1501 /* Mark it as renamed, so we do nothing during close */ 1502 SetFlag(pSrvOpen->Flags, SRVOPEN_FLAG_FILE_RENAMED); 1503 1504 Log(("VBOXSF: vbsfNtRename: RenameInformation->FileNameLength = %d\n", RenameInformation->FileNameLength)); 1505 Status = vbsfNtShflStringFromUnicodeAlloc(&DestPath, RenameInformation->FileName, (uint16_t)RenameInformation->FileNameLength); 1506 if (Status != STATUS_SUCCESS) 1507 return Status; 1508 1509 Log(("VBOXSF: vbsfNtRename: Destination path = %.*ls\n", 1510 DestPath->u16Length / sizeof(WCHAR), &DestPath->String.ucs2[0])); 1511 1512 Log(("VBOXSF: vbsfNtRename: RemainingName->Length = %d\n", RemainingName->Length)); 1513 Status = vbsfNtShflStringFromUnicodeAlloc(&SrcPath, RemainingName->Buffer, RemainingName->Length); 1514 if (Status != STATUS_SUCCESS) 1515 { 1516 vbsfNtFreeNonPagedMem(DestPath); 1517 return Status; 1518 } 1519 1520 Log(("VBOXSF: vbsfNtRename: Source path = %.*ls\n", 1521 SrcPath->u16Length / sizeof(WCHAR), &SrcPath->String.ucs2[0])); 1522 1523 /* Call host. */ 1524 flags = pVBoxFobx->Info.Attr.fMode & RTFS_DOS_DIRECTORY ? SHFL_RENAME_DIR : SHFL_RENAME_FILE; 1525 if (RenameInformation->ReplaceIfExists) 1526 flags |= SHFL_RENAME_REPLACE_IF_EXISTS; 1527 1528 Log(("VBOXSF: vbsfNtRename: Calling VbglR0SfRename\n")); 1529 vrc = VbglR0SfRename(&g_SfClient, &pNetRootExtension->map, SrcPath, DestPath, flags); 1530 1531 vbsfNtFreeNonPagedMem(SrcPath); 1532 vbsfNtFreeNonPagedMem(DestPath); 1533 1534 Status = vbsfNtVBoxStatusToNt(vrc); 1535 if (vrc != VINF_SUCCESS) 1536 Log(("VBOXSF: vbsfNtRename: VbglR0SfRename failed with %Rrc\n", vrc)); 1537 1538 Log(("VBOXSF: vbsfNtRename: Returned 0x%08X\n", Status)); 1539 return Status; 1540 } 1541 1542 1409 1543 NTSTATUS VBoxMRxSetFileInfo(IN PRX_CONTEXT RxContext) 1410 1544 { … … 1465 1599 } 1466 1600 1601 /* 1602 * Prior to calling us, RxSetEndOfFileInfo will have updated the FCB fields space.FileSize, 1603 * Header.AllocationSize and (if old value was larger) Header.ValidDataLength. On success 1604 * it will inform the cache manager, while on failure the old values will be restored. 1605 * 1606 * Note! RxSetEndOfFileInfo assumes that the old Header.FileSize value is up to date and 1607 * will hide calls which does not change the size from us. This is of course not 1608 * the case for non-local file systems, as the server is the only which up-to-date 1609 * information. Don't see an easy way of working around it, so ignoring it for now. 1610 */ 1467 1611 case FileEndOfFileInformation: 1468 1612 { -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/path.cpp
r78329 r78339 724 724 } 725 725 726 /* 726 /** 727 727 * Closes an opened file handle of a MRX_VBOX_FOBX. 728 * 728 729 * Updates file attributes if necessary. 730 * 731 * Used by VBoxMRxCloseSrvOpen, vbsfNtRemove and vbsfNtRename. 729 732 */ 730 static NTSTATUS vbsfCloseFileHandle(PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension,731 733 NTSTATUS vbsfNtCloseFileHandle(PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension, 734 PMRX_VBOX_FOBX pVBoxFobx) 732 735 { 733 736 NTSTATUS Status = STATUS_SUCCESS; … … 803 806 /* Close file */ 804 807 if (pVBoxFobx->hFile != SHFL_HANDLE_NIL) 805 vbsf CloseFileHandle(pNetRootExtension, pVBoxFobx);808 vbsfNtCloseFileHandle(pNetRootExtension, pVBoxFobx); 806 809 807 810 if (capFcb->FcbState & FCB_STATE_DELETE_ON_CLOSE) … … 818 821 } 819 822 823 /** 824 * Worker for vbsfNtSetBasicInfo and VBoxMRxCloseSrvOpen. 825 */ 820 826 NTSTATUS vbsfNtRemove(IN PRX_CONTEXT RxContext) 821 827 { … … 838 844 /* Close file first if not already done. */ 839 845 if (pVBoxFobx->hFile != SHFL_HANDLE_NIL) 840 vbsf CloseFileHandle(pNetRootExtension, pVBoxFobx);846 vbsfNtCloseFileHandle(pNetRootExtension, pVBoxFobx); 841 847 842 848 Log(("VBOXSF: vbsfNtRemove: RemainingName->Length %d\n", RemainingName->Length)); … … 864 870 } 865 871 866 NTSTATUS vbsfNtRename(IN PRX_CONTEXT RxContext,867 IN FILE_INFORMATION_CLASS FileInformationClass,868 IN PVOID pBuffer,869 IN ULONG BufferLength)870 {871 NTSTATUS Status = STATUS_SUCCESS;872 873 RxCaptureFcb;874 RxCaptureFobx;875 876 PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(capFcb->pNetRoot);877 PMRX_VBOX_FOBX pVBoxFobx = VBoxMRxGetFileObjectExtension(capFobx);878 PMRX_SRV_OPEN pSrvOpen = capFobx->pSrvOpen;879 880 PFILE_RENAME_INFORMATION RenameInformation = (PFILE_RENAME_INFORMATION)RxContext->Info.Buffer;881 PUNICODE_STRING RemainingName = GET_ALREADY_PREFIXED_NAME(pSrvOpen, capFcb);882 883 int vrc;884 PSHFLSTRING SrcPath = 0, DestPath = 0;885 ULONG flags;886 887 RT_NOREF(FileInformationClass, pBuffer, BufferLength);888 889 Assert(FileInformationClass == FileRenameInformation);890 891 Log(("VBOXSF: vbsfNtRename: FileName = %.*ls\n",892 RenameInformation->FileNameLength / sizeof(WCHAR), &RenameInformation->FileName[0]));893 894 /* Must close the file before renaming it! */895 if (pVBoxFobx->hFile != SHFL_HANDLE_NIL)896 vbsfCloseFileHandle(pNetRootExtension, pVBoxFobx);897 898 /* Mark it as renamed, so we do nothing during close */899 SetFlag(pSrvOpen->Flags, SRVOPEN_FLAG_FILE_RENAMED);900 901 Log(("VBOXSF: vbsfNtRename: RenameInformation->FileNameLength = %d\n", RenameInformation->FileNameLength));902 Status = vbsfNtShflStringFromUnicodeAlloc(&DestPath, RenameInformation->FileName, (uint16_t)RenameInformation->FileNameLength);903 if (Status != STATUS_SUCCESS)904 return Status;905 906 Log(("VBOXSF: vbsfNtRename: Destination path = %.*ls\n",907 DestPath->u16Length / sizeof(WCHAR), &DestPath->String.ucs2[0]));908 909 Log(("VBOXSF: vbsfNtRename: RemainingName->Length = %d\n", RemainingName->Length));910 Status = vbsfNtShflStringFromUnicodeAlloc(&SrcPath, RemainingName->Buffer, RemainingName->Length);911 if (Status != STATUS_SUCCESS)912 {913 vbsfNtFreeNonPagedMem(DestPath);914 return Status;915 }916 917 Log(("VBOXSF: vbsfNtRename: Source path = %.*ls\n",918 SrcPath->u16Length / sizeof(WCHAR), &SrcPath->String.ucs2[0]));919 920 /* Call host. */921 flags = pVBoxFobx->Info.Attr.fMode & RTFS_DOS_DIRECTORY ? SHFL_RENAME_DIR : SHFL_RENAME_FILE;922 if (RenameInformation->ReplaceIfExists)923 flags |= SHFL_RENAME_REPLACE_IF_EXISTS;924 925 Log(("VBOXSF: vbsfNtRename: Calling VbglR0SfRename\n"));926 vrc = VbglR0SfRename(&g_SfClient, &pNetRootExtension->map, SrcPath, DestPath, flags);927 928 vbsfNtFreeNonPagedMem(SrcPath);929 vbsfNtFreeNonPagedMem(DestPath);930 931 Status = vbsfNtVBoxStatusToNt(vrc);932 if (vrc != VINF_SUCCESS)933 Log(("VBOXSF: vbsfNtRename: VbglR0SfRename failed with %Rrc\n", vrc));934 935 Log(("VBOXSF: vbsfNtRename: Returned 0x%08X\n", Status));936 return Status;937 }938 939 872 NTSTATUS VBoxMRxShouldTryToCollapseThisOpen(IN PRX_CONTEXT RxContext) 940 873 { -
trunk/src/VBox/Additions/WINNT/SharedFolders/driver/vbsf.h
r78338 r78339 219 219 NTSTATUS vbsfNtCreateConnection(IN PRX_CONTEXT RxContext, 220 220 OUT PBOOLEAN PostToFsp); 221 222 NTSTATUS vbsfNtSetEndOfFile(IN OUT struct _RX_CONTEXT * RxContext, 223 IN uint64_t cbNewFileSize); 224 NTSTATUS vbsfNtRename(IN PRX_CONTEXT RxContext, 225 IN FILE_INFORMATION_CLASS FileInformationClass, 226 IN PVOID pBuffer, 227 IN ULONG BufferLength); 221 NTSTATUS vbsfNtCloseFileHandle(PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension, 222 PMRX_VBOX_FOBX pVBoxFobx); 228 223 NTSTATUS vbsfNtRemove(IN PRX_CONTEXT RxContext); 229 230 224 void vbsfNtCopyInfoToLegacy(PMRX_VBOX_FOBX pVBoxFobx, PCSHFLFSOBJINFO pInfo); 231 232 225 NTSTATUS vbsfNtVBoxStatusToNt(int vrc); 233 226 PVOID vbsfNtAllocNonPagedMem(ULONG ulSize);
Note:
See TracChangeset
for help on using the changeset viewer.