CBFS Connect 2020 .NET Edition

Questions / Feedback?

OffloadWriteFile Event

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

Syntax

public event OnOffloadWriteFileHandler OnOffloadWriteFile;

public delegate void OnOffloadWriteFileHandler(object sender, CbfsOffloadWriteFileEventArgs e);

public class CbfsOffloadWriteFileEventArgs : EventArgs {
  public string FileName { get; }
  public long Position { get; }
  public long CopyLength { get; }
  public long TransferOffset { get; }
  public long TransferLength { get; set; }
  public int TokenType { get; }
  public IntPtr Token { get; }
  public long TokenLength { get; }
  public int ResultFlags { get; set; }
  public long HandleInfo { get; }
  public IntPtr FileContext { get; set; }
  public IntPtr HandleContext { get; set; }
  public int ResultCode { get; set; }
}
Public Event OnOffloadWriteFile As OnOffloadWriteFileHandler

Public Delegate Sub OnOffloadWriteFileHandler(sender As Object, e As CbfsOffloadWriteFileEventArgs)

Public Class CbfsOffloadWriteFileEventArgs Inherits EventArgs
  Public ReadOnly Property FileName As String
  Public ReadOnly Property Position As Long
  Public ReadOnly Property CopyLength As Long
  Public ReadOnly Property TransferOffset As Long
  Public Property TransferLength As Long
  Public ReadOnly Property TokenType As Integer
  Public ReadOnly Property Token As IntPtr
  Public ReadOnly Property TokenLength As Long
  Public Property ResultFlags As Integer
  Public ReadOnly Property HandleInfo As Long
  Public Property FileContext As IntPtr
  Public Property HandleContext As IntPtr
  Public Property ResultCode As Integer
End Class

Remarks

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

To handle this event properly, applications should perform any actions needed to handle the offloaded write based on the specified parameters, and then return the result information. Please refer to the parameter descriptions below for more information.

The Position and CopyLength parameters specify the byte offset and length (respectively) of the data chunk that should be written in the specified file. The CopyLength parameter's value may be smaller than the total amount of data represented by the token (in which case TransferOffset may be greater than 0).

The TransferOffset parameters specifies the byte offset, in the chunk of data represented by the token, from which to begin writing.

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

The TokenType parameter indicates the type of token stored in the Token buffer. A value of STORAGE_OFFLOAD_TOKEN_TYPE_ZERO_DATA (0xFFFF0001) indicates that the token represents data which is all zeros; while any other value (outside of the reserved range 0xFFFF0002 to 0xFFFFFFFF) indicates an application-defined token format.

The Token parameter points to a memory buffer that contains the token returned in response to an earlier offload read request. The token identifies the chunk of data that has been read/prepared for transfer; refer to the OffloadReadFile event for more information. The TokenLength parameter specifies the length, in bytes, of the data in Token.

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_WRITE_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 IntPtr.Zero.)

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 .NET Edition - Version 20.0 [Build 8348]