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
Advise the system about how a file will be used
fd_advise (
fd: i32The file descriptor to which the advice appliesoffset: i32The offset from which the advice applieslen: i32The length from the offset to which the advice appliesadvice: i32The advice to be given to the operating system
) =>
error: i32 

The fd_advise() function is used to provide advice to the operating system about the intended usage of a file. This advice can help the system optimize performance or memory usage based on the specified parameters.

Advice Value Description
Normal 0 Indicates that the application has no advice to give about its access pattern for the specified data. If no advice is given for an open file, this is the default assumption
Random 1 The application expects to access the specified data sequentially (with lower offsets read before higher ones)
Sequential 2 The specified data will be accessed in random order
Will Need 3 The specified data will be accessed only once
Don't Need 4 The specified data will be accessed in the near future
NOR Use 5 The specified data will not be accessed in the near future
Error Value Description
EBADF 9 The fd argument was not a valid file descriptor
EINVAL 22 An invalid value was specified for advice
ESPIPE 29 The specified file descriptor refers to a pipe or FIFO. (Linux actually returns EINVAL in this case.)

Read More