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
Atomically copy a file descriptor
fd_renumber (
from: i32The file descriptor to copyto: i32The location to copy the file descriptor to
) =>
error: i32 

The fd_renumber() function atomically copies a file descriptor from one location to another. It ensures that the copying operation is performed atomically and returns an Errno value indicating the success or failure of the operation.

Note

The fd_renumber() function atomically copies a file descriptor from one location to another. It takes the source file descriptor from and the destination file descriptor to. If the from and to file descriptors are the same, the function returns Errno::Success without performing any copying operation.

The function retrieves the file descriptor map from the WASI environment and attempts to find the file descriptor entry corresponding to from. If the entry is found, a new file descriptor entry is created with the same properties as the original entry, except for the file descriptor number, which is set to to. The new entry is then inserted into the file descriptor map with the to file descriptor number.

The function returns an Errno value to indicate the success or failure of the operation. If the file descriptor is successfully copied, it returns Errno::Success. Otherwise, it returns an appropriate error code.

Read More