Skip to main content

translate

Function translate 

Source
pub fn translate(
    fs: &Fs,
    pid: u32,
    dirfd: i32,
    path: &[u8],
    deref_final: bool,
) -> Result<Resolved, i32>
Expand description

Translates a path as seen by a tracee into the object to operate on.

Relative paths are resolved against dirfd (AT_FDCWD means the tracee’s cwd) by reading the descriptor’s own path from /proc, so the whole path is canonicalized inside the guest namespace, on the descriptors the view holds open (see resolve). An empty path fails with ENOENT, as the kernel’s lookup fails it; a call that lets it name dirfd itself resolves guest_dirfd_path instead.

§Arguments

  • fs - Guest filesystem view.
  • pid - Tracee thread id.
  • dirfd - Base descriptor for relative paths, or libc::AT_FDCWD.
  • path - Path bytes as read from the tracee, without NUL.
  • deref_final - Follow a symlink in the final component.

§Returns

The canonical guest path, its host path, and the pinned directory and name to act on.

§Errors

ENOENT for an empty path, errno from the walk, or EBADF when dirfd cannot be resolved.