Read Event

Fires when the OS needs to read data from an open file.

Syntax

// FUSEReadEventArgs carries the FUSE Read event's parameters.
type FUSEReadEventArgs struct {...}

func (args *FUSEReadEventArgs) Path() string
func (args *FUSEReadEventArgs) FileContext() int32
func (args *FUSEReadEventArgs) Buffer() []byte
func (args *FUSEReadEventArgs) SetBuffer(value []byte)
func (args *FUSEReadEventArgs) Size() int64
func (args *FUSEReadEventArgs) Offset() int64
func (args *FUSEReadEventArgs) Result() int32
func (args *FUSEReadEventArgs) SetResult(value int32)

// FUSEReadEvent defines the signature of the FUSE Read event's handler function.
type FUSEReadEvent func(sender *FUSE, args *FUSEReadEventArgs)

func (obj *FUSE) GetOnReadHandler() FUSEReadEvent
func (obj *FUSE) SetOnReadHandler(handlerFunc FUSEReadEvent)

Remarks

This event fires when the OS needs to read data from the already-open file, identified by either Path or FileContext.

To handle this event properly, applications should read Size bytes of data from the specified file into the memory region pointed to by Buffer. Reading must begin at the specified Offset in the file and all of the requested data is expected to be read. Applications must not attempt to copy more than Size bytes of data into Buffer.

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

When reading is complete, applications must set Result to the actual number of bytes written to Buffer. Note: While it is technically possible for an application to return fewer than Size bytes of data, doing so is abnormal, and should be avoided. Most processes treat read requests as "all or nothing", so returning less data than requested is likely to cause an ungraceful failure.

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 negative error code value (e.g. -ENOENT to indicate that the file does not exist) 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 FUSE 2020 Go Edition - Version 20.0 [Build 8348]