Skip to content

Latest commit

 

History

History
101 lines (73 loc) · 5.52 KB

nf-projectedfslib-prjwritefiledata.md

File metadata and controls

101 lines (73 loc) · 5.52 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:projectedfslib.PrjWriteFileData
PrjWriteFileData function (projectedfslib.h)
The PrjWriteFileData function provides the data requested in an invocation of the PRJ_GET_FILE_DATA_CB callback. (PrjWriteFileData)
PrjWriteFileData
PrjWriteFileData function
ProjFS.prjwritefiledata
projectedfslib/PrjWriteFileData
projfs\prjwritefiledata.htm
ProjFS
A09D8E74-D574-41C6-A586-86E03839DA89
08/03/2022
PrjWriteFileData, PrjWriteFileData function, ProjFS.prjwritefiledata, projectedfslib/PrjWriteFileData
projectedfslib.h
Windows
Windows 10, version 1809 [desktop apps only]
Windows Server [desktop apps only]
Windows
RS5, 19H1
PrjWriteFileData
projectedfslib/PrjWriteFileData
c++
APIRef
kbSyntax
HeaderDef
projectedfslib.h
PrjWriteFileData

PrjWriteFileData function

-description

Provides the data requested in an invocation of the PRJ_GET_FILE_DATA_CB callback.

-parameters

-param namespaceVirtualizationContext [in]

Opaque handle for the virtualization instance.

If the provider is servicing a PRJ_GET_FILE_DATA_CB callback, this must be the value from the VirtualizationInstanceHandle member of the callbackData passed to the provider in the callback.

-param dataStreamId [in]

Identifier for the data stream to write to.

If the provider is servicing a PRJ_GET_FILE_DATA_CB callback, this must be the value from the DataStreamId member of the callbackData passed to the provider in the callback.

-param buffer [in]

Pointer to a buffer containing the data to write. The buffer must be at least as large as the value of the length parameter in bytes. The provider should use PrjAllocateAlignedBuffer to ensure that the buffer meets the storage device's alignment requirements.

-param byteOffset [in]

Byte offset from the beginning of the file at which to write the data.

-param length [in]

The number of bytes to write to the file.

-returns

HRESULT_FROM_WIN32(ERROR_OFFSET_ALIGNMENT_VIOLATION) indicates that the user's handle was opened for unbuffered I/O and byteOffset is not aligned to the sector size of the storage device.

-remarks

The provider uses this routine to provide the data requested in an invocation of its PRJ_GET_FILE_DATA_CB callback.

The provider’s PRJ_GET_FILE_DATA_CB callback is invoked when the system needs to ensure that a file contains data. When the provider calls PrjWriteFileData to supply the requested data the system uses the user’s FILE_OBJECT to write that data to the file. However the system cannot control whether that FILE_OBJECT was opened for buffered or unbuffered I/O. If the FILE_OBJECT was opened for unbuffered I/O, reads and writes to the file must adhere to certain alignment requirements. The provider can meet those alignment requirements by doing two things:

  • Use PrjAllocateAlignedBuffer to allocate the buffer to pass to buffer.
  • Ensure that byteOffset and length are integer multiples of the storage device’s alignment requirement (length does not have to meet this requirement if byteOffset + length is equal to the end of the file). The provider can use PrjGetVirtualizationInstanceInfo to retrieve the storage device’s alignment requirement.

The system leaves it up to the provider to calculate proper alignment because when processing a PRJ_GET_FILE_DATA_CB callback the provider may opt to return the requested data across multiple PrjWriteFileData calls, each returning part of the total requested data.

Note that if the provider is going to write the entire file in a single call to PrjWriteFileData, i.e. from byteOffset = 0 to length = size of the file, the provider does not have to do any alignment calculations. However it must still use PrjAllocateAlignedBuffer to ensure that buffer meets the storage device's alignment requirements. See the File Buffering topic for more information on buffered vs unbuffered I/O.