Fires when the OS needs to unlock a range of bytes in a file.
class CBFSUnlockFileEventParams(object): @property def file_name() -> str: ... @property def byte_offset() -> int: ... @property def length() -> int: ... @property def handle_info() -> int: ... @property def file_context() -> int: ... @file_context.setter def file_context(value) -> None: ... @property def handle_context() -> int: ... @handle_context.setter def handle_context(value) -> None: ... @property def result_code() -> int: ... @result_code.setter def result_code(value) -> None: ... # In class CBFS: @property def on_unlock_file() -> Callable[[CBFSUnlockFileEventParams], None]: ... @on_unlock_file.setter def on_unlock_file(event_hook: Callable[[CBFSUnlockFileEventParams], None]) -> None: ...
This event is optional. The CBFS class automatically manages file locks in the virtual filesystem, so if the resources an application uses for backend storage (files, memory, a database, etc.) are never directly accessed by anything other than the application itself, then there is no reason to implement this event.
On the other hand, if an application's backend storage involves shared resources (i.e., those which could be accessed by something other than the application at any time), this event should be used to perform any actions needed to propagate the unlock request.
For example, if an application's backend storage implementation involves files stored on a network server, then the unlock request should be communicated to that server.
Applications that implement this event must also implement the on_lock_file event.
The ByteOffset and Length parameters specify the starting position of the range being unlocked, and the length of that range, respectively. If both values are set to -1, the system has sent IRP_MN_UNLOCK_ALL request and all regions must be unlocked. The latter behavior is used only when SupportUnlockAllRequests config setting is explicitly enabled by the application.
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: get_handle_creator_process_id, get_handle_creator_process_name, get_handle_creator_thread_id, or get_handle_creator_token.
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.
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.
Note: The OS does not expect the file unlock request to fail and ignores the error code, returned by the class.