---
name: "getbootfile"
section: "3"
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/getbootfile"
---

# getbootfile(3)

get kernel boot file name

## NAME

**getbootfile** – get kernel boot file name

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<paths.h\>**

*const* *char* *\**\

**getbootfile**(*void*);

## DESCRIPTION

The **getbootfile**() function retrieves the full pathname of the file from which the current kernel was loaded, and returns a static pointer to the name. A read/write interface to this information is available via the [sysctl(3)](/sysctl/3.md) MIB variable “kern.bootfile”.

## RETURN VALUES

If the call succeeds a string giving the pathname is returned. If it fails, a null pointer is returned and an error code is placed in the global location *errno*.

## SEE ALSO

[sysctl(3)](/sysctl/3.md)

## HISTORY

The **getbootfile**() function appeared in FreeBSD 2.0.

## BUGS

If the boot blocks have not been modified to pass this information into the kernel at boot time, the static string “*/boot/kernel/kernel*” is returned instead of the real boot file.
