---
name: "vn_fullpath_jail"
section: "9"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/vn_fullpath"
---

# vn\_fullpath\_jail(9)

convert a vnode reference to a full pathname, given a process context

Part of [vn\_fullpath(9)](/vn_fullpath/9.md).

## NAME

**vn\_fullpath** – convert a vnode reference to a full pathname, given a process context

## SYNOPSIS

**#include \<sys/param.h\>**

**#include \<sys/vnode.h\>**

*int*\

**vn\_fullpath**(*struct vnode \*vp*, *char \*\*retbuf*, *char \*\*freebuf*);

*int*\

**vn\_fullpath\_jail**(*struct vnode \*vp*, *char \*\*retbuf*, *char \*\*freebuf*);

*int*\

**vn\_fullpath\_global**(*struct vnode \*vp*, *char \*\*retbuf*, *char \*\*freebuf*);

*int*\

**vn\_fullpath\_hardlink**(*struct vnode \*vp*, *struct vnode \*dvp*, *const char \*hrdl\_name*, *size\_t hrdl\_name\_length*, *char \*\*retbuf*, *char \*\*freebuf*, *size\_t \*buflen*);

## DESCRIPTION

The **vn\_fullpath**(), **vn\_fullpath\_jail**(), **vn\_fullpath\_global**() and **vn\_fullpath\_hardlink**() functions make a “best effort” attempt at generating a string pathname for the passed vnode. They differ in which directory the returned path is relative to, except for **vn\_fullpath\_hardlink**() which behaves like **vn\_fullpath**() in this respect and is described at the end.

The **vn\_fullpath**() function returns a path relative to the root directory of the process associated with the passed thread pointer. That root directory is either the system's or the thread's process' containing jail's root directory, or some descendant directory of such established by some [chroot(2)](/chroot/2.md) call. The **vn\_fullpath\_jail**() function returns a path relative to the passed thread's process' current jail's root, ignoring intervening [chroot(2)](/chroot/2.md) calls possibly made inside that jail. The **vn\_fullpath\_global**() function returns the full path from the system root, ignoring all jail roots and [chroot(2)](/chroot/2.md) calls.

Paths that the kernel intends to communicate to the passed user thread should exclusively be obtained via **vn\_fullpath**(). Paths obtained via **vn\_fullpath\_jail**() or **vn\_fullpath\_global**() are only useful for specific kernel checks or auditing purposes.

All these functions are implemented by inspecting the VFS name cache, and attempting to reconstruct a path from the process root to the object. This process is necessarily unreliable for several reasons: intermediate entries in the path may not be found in the cache; files may have more than one name (hard links), not all file systems use the name cache (specifically, most synthetic file systems do not); a single name may be used for more than one file (in the context of file systems covering other file systems); a file may have no name (if deleted but still open or referenced). However, the resulting string may still be more usable to a user than a vnode pointer value, or a device number and inode number. Code consuming the results of this function should anticipate (and properly handle) failure.

These functions take the following arguments:

- *vp*

  The vnode to search for. No need to be locked by the caller.

- *retbuf*

  Pointer to a *char \** that may be set (on success) to point at a newly allocated buffer containing the resulting pathname.

- *freebuf*

  Pointer to a *char \** that may be set (on success) to point at a buffer to be freed, when the caller is done with *retbuf*.

Typical consumers will declare two character pointers: *fullpath* and *freepath*; they will set *freepath* to NULL, and *fullpath* to a name to use in the event that the call to **vn\_fullpath**() fails. After done with the value of *fullpath*, the caller will check if *freepath* is non-NULL, and if so, invoke [free(9)](/free/9.md) with a pool type of M\_TEMP.

The **vn\_fullpath\_hardlink**() function is a convenience wrapper which automatically appends the hardlink name passed via arguments *hrdl\_name* and *hrdl\_name\_length* to the result of calling **vn\_fullpath**() on the vnode's parent directory. It requires the results of a prior call to [namei(9)](/namei/9.md) with flag WANTPARENT to be passed in the *vp* and *dvp* arguments. Argument *buflen* must point to a valid storage containing the size of the desired buffer, which will be reduced to MAXPATHLEN if in excess of it.

## RETURN VALUES

If the vnode is successfully converted to a pathname, 0 is returned; otherwise, an error number is returned.

## SEE ALSO

[free(9)](/free/9.md)

## AUTHORS

This manual page was initially written by Robert Watson ⟨*rwatson@FreeBSD.org*⟩ to describe the **vn\_fullpath**() function. The descriptions of the other related functions were added by Olivier Certner ⟨*olce@FreeBSD.org*⟩.
