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
Change the size of an open file, zeroing out any new bytes
fd_filestat_set_size (
fd: i32The file descriptor of the open file to adjustst_size: i32The new size to set for the file
) =>
error: i32 

The fd_filestat_set_size() function is used to modify the size of an open file identified by a file descriptor. It allows adjusting the size of the file and zeroing out any newly allocated bytes.

In POSIX systems, files have a size attribute that represents the amount of data stored in the file. The fd_filestat_set_size() function enables applications to change the size of an open file. When increasing the file size, any newly allocated bytes are automatically filled with zeros.

Parameters

  • ctx: A mutable reference to the function environment.
  • fd: The file descriptor of the open file to adjust.
  • st_size: The new size to set for the file.

Note

The fd_filestat_set_size() function allows changing the size of an open file identified by the provided file descriptor. If the file size is increased, any newly allocated bytes are zeroed out. This function requires appropriate access rights on the file descriptor, and failure to meet the access requirements will result in an Errno::Access error.

Read More