OffloadReadFile Event

Fires when the OS wants the virtual filesystem to perform an offloaded data transfer (ODX) read operation.

Syntax

// CBFSOffloadReadFileEventArgs carries the CBFS OffloadReadFile event's parameters.
type CBFSOffloadReadFileEventArgs struct {...}

func (args *CBFSOffloadReadFileEventArgs) FileName() string
func (args *CBFSOffloadReadFileEventArgs) TokenTimeToLive() int32
func (args *CBFSOffloadReadFileEventArgs) Position() int64
func (args *CBFSOffloadReadFileEventArgs) CopyLength() int64
func (args *CBFSOffloadReadFileEventArgs) TransferLength() int64
func (args *CBFSOffloadReadFileEventArgs) SetTransferLength(value int64)
func (args *CBFSOffloadReadFileEventArgs) TokenType() int32
func (args *CBFSOffloadReadFileEventArgs) SetTokenType(value int32)
func (args *CBFSOffloadReadFileEventArgs) TokenBuffer() []byte
func (args *CBFSOffloadReadFileEventArgs) SetTokenBuffer(value []byte)
func (args *CBFSOffloadReadFileEventArgs) BufferLength() int64
func (args *CBFSOffloadReadFileEventArgs) TokenLength() int32
func (args *CBFSOffloadReadFileEventArgs) SetTokenLength(value int32)
func (args *CBFSOffloadReadFileEventArgs) ResultFlags() int32
func (args *CBFSOffloadReadFileEventArgs) SetResultFlags(value int32)
func (args *CBFSOffloadReadFileEventArgs) HandleInfo() int64
func (args *CBFSOffloadReadFileEventArgs) FileContext() int64
func (args *CBFSOffloadReadFileEventArgs) SetFileContext(value int64)
func (args *CBFSOffloadReadFileEventArgs) HandleContext() int64
func (args *CBFSOffloadReadFileEventArgs) SetHandleContext(value int64)
func (args *CBFSOffloadReadFileEventArgs) ResultCode() int32
func (args *CBFSOffloadReadFileEventArgs) SetResultCode(value int32)

// CBFSOffloadReadFileEvent defines the signature of the CBFS OffloadReadFile event's handler function.
type CBFSOffloadReadFileEvent func(sender *CBFS, args *CBFSOffloadReadFileEventArgs)

func (obj *CBFS) GetOnOffloadReadFileHandler() CBFSOffloadReadFileEvent
func (obj *CBFS) SetOnOffloadReadFileHandler(handlerFunc CBFSOffloadReadFileEvent)

Remarks

This events fires when the OS wants the virtual filesystem to perform an offload read for the file specified by FileName as part of an offloaded data transfer.

To handle this event properly, applications should first verify whether the specified file supports offload operations, returning the ERROR_OFFLOAD_READ_FILE_NOT_SUPPORTED error code via ResultCode if not. Assuming the file does support offload operations, the application should perform any actions needed to prepare for the offloaded read based on the specified parameters, and then return the requested information. Please refer to the parameter descriptions below for more information.

The TokenTimeToLive parameter indicates the duration, in milliseconds, that the offload read operation remains valid. Multiple writes can be performed with the token returned in TokenBuffer until this time expires.

The Position and CopyLength parameters specify the byte offset and length (respectively) of a data chunk in the specified file that should be read, or in some other way prepared, for transferring.

The TransferLength parameter must be set to the number of bytes actually read/prepared as a result of this request. It may be less than CopyLength.

The TokenType parameter must be set to either the Microsoft-defined value of STORAGE_OFFLOAD_TOKEN_TYPE_ZERO_DATA (0xFFFF0001) if the token represents data which is all zeros; or an application-defined value outside of the reserved range 0xFFFF0002 to 0xFFFFFFFF to denote an application-defined token format. (Note: Use of the STORAGE_OFFLOAD_TOKEN_TYPE_ZERO_DATA token type is not required.)

The TokenBuffer parameter points to a memory buffer that receives some application-defined token that identifies the data that has been read/prepared for transfer. The returned token will be passed to an offload write operation in order to actually transfer the data it represents. The BufferLength parameter specifies the capacity, in bytes, of TokenBuffer; applications must set the TokenLength parameter to the number of bytes written to TokenBuffer.

Please refer to the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

The ResultFlags parameter must be set to a combination of zero or more of the flags described in the FSCTL_OFFLOAD_READ_OUTPUT structure's documentation.

The HandleInfo parameter carries a handle to an object with information about the file handle. While within the event handler, it can be used to call any of the following methods: GetHandleCreatorProcessId, GetHandleCreatorProcessName, GetHandleCreatorThreadId, or GetHandleCreatorToken. (This parameter may be absent, in which case it will be 0.)

The FileContext and HandleContext parameters are placeholders for application-defined data associated with the file and specific handle, respectively. Please refer to the Contexts topic for more information. (HandleContext may be absent, in which case it will be nil.)

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource isn't available, security checks failed, etc.), set it to a non-zero value to report an appropriate error. Please refer to the Error Reporting and Handling topic for more information.

Copyright (c) 2022 Callback Technologies, Inc. - All rights reserved.
CBFS Connect 2020 Go Edition - Version 20.0 [Build 8348]