Read the value of a symlink.
path_readlink() function reads the target path that a symlink points to. It requires the
PATH_READLINK right to be set on the base directory from which the symlink is understood.
On POSIX systems, a similar functionality is provided by the
readlink() function. It reads the value of a symbolic link and stores it in a buffer. The
readlink() function is part of the POSIX standard and is widely supported across different platforms.
;;; Note: This is similar to `readlinkat` in POSIX. ;;; Read the contents of a symbolic link. (@interface func (export "path_readlink") (param $fd $fd) ;;; The path of the symbolic link from which to read. (param $path string) ;;; The buffer to which to write the contents of the symbolic link. (param $buf (@witx pointer u8)) (param $buf_len $size) ;;; The number of bytes placed in the buffer. (result $error (expected $size (error $errno))) )
ctx: A mutable reference to the function environment.
dir_fd: The file descriptor representing the base directory from which the symlink is understood.
path: A wasm pointer to a null-terminated string containing the path to the symlink.
path_len: The length of the
buf: A wasm pointer to a buffer where the target path of the symlink will be written.
buf_len: The available space in the buffer pointed to by
buf_used: A wasm pointer to a variable where the number of bytes written to the buffer will be stored.
The function returns an
Errno value indicating the success or failure of the operation. If the operation is successful, it returns
Errno::Success. Otherwise, it returns an appropriate
This function has been instrumented with debug-level logging. It will log the following information:
%dir_fd: The file descriptor representing the base directory.
path: The path string.
path_readlink() function reads the target path of a symlink. It checks if the base directory has the necessary rights and reads the target path accordingly. On POSIX systems, a similar functionality is provided by the