Index wasi args_get args_sizes_get clock_res_get clock_time_get environ_get environ_sizes_get fd_advise fd_allocate fd_close fd_datasync fd_fdstat_get fd_fdstat_set_flags fd_fdstat_set_rights fd_filestat_get fd_filestat_set_size fd_filestat_set_times fd_pread fd_prestat_dir_name fd_prestat_get fd_pwrite fd_read fd_readdir fd_renumber fd_seek fd_sync fd_tell fd_write file_stat_flags filestat iovec lookup_flags path_create_directory path_filestat_get path_filestat_set_times path_link path_open path_readlink path_remove_directory path_rename path_symlink path_unlink_file poll_oneoff proc_exit proc_raise random_get sched_yield sock_accept sock_recv sock_send sock_shutdown
Read data from a file descriptor
fd_read (
fd: i32The file descriptor of the file to read fromiovs: i32A pointer to an array of iovec structures describing the buffers where the data will be storediovs_len: i32The number of vectors iovec in the `iovs` arraynread: i32
) =>
error: i32 

Description

The fd_read() function is used to read data from a file identified by the provided file descriptor (fd). It takes an array of iovec structures (iovec) describing the buffers where the data will be stored, the number of vectors (iovs_len) in the iovec array, and a pointer to store the number of bytes read. The function reads data from the file into the specified buffers and returns the number of bytes read.

In POSIX systems, reading data from a file typically involves updating the file cursor, which determines the next position from which data will be read. The fd_read() function allows reading data from a file without modifying the file cursor's position. This can be useful in scenarios where applications need to read data from a specific location in a file without altering the cursor's state.

Note

The fd_read() function allows reading data from a file identified by the file descriptor fd. It takes the file descriptor, an array of buffers where the data will be stored, the number of vectors in the iovec array, and a pointer to store the number of bytes read. The function reads data from the file into the specified buffers without modifying the file cursor's position. It returns an error code to indicate the success or failure of the operation. If the data is successfully read from the file, it returns Errno::Success. Otherwise, it returns an appropriate error code.

Read More