getbootfile(3)

getbootfile3

Get kernel boot file name

Usage

#include <paths.h>

const char *

getbootfile(void);

Library

Standard C Library (libc, -lc)

Overview

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) 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.

Releases

87 releases since FreeBSD 2.0.5-RELEASE; the text changed 47 times.

  1. 2.0.5
  2. 2.1.5–2.1.7.1
  3. 2.2.2–2.2.8
  4. 2.2.9
  5. 3.0–3.2
  6. 3.3–3.4
  7. 3.5–3.5.1
  8. 4.0
  9. 4.1–4.3
  10. 4.4
  11. 4.5–4.11
  12. 5.0
  13. 5.1–5.2.1
  14. 5.3–5.5
  15. 6.0–6.3
  16. 6.4
  17. 7.0
  18. 7.1
  19. 7.2
  20. 7.3
  21. 7.4
  22. 8.0
  23. 8.1
  24. 8.2
  25. 8.3
  26. 8.4
  27. 9.0
  28. 9.1
  29. 9.2
  30. 9.3
  31. 10.0
  32. 10.1
  33. 10.2
  34. 10.3
  35. 10.4
  36. 11.0
  37. 11.1
  38. 11.2
  39. 11.3
  40. 11.4
  41. 12.0
  42. 12.1
  43. 12.2
  44. 12.3
  45. 12.4
  46. 13.0–13.2
  47. 13.3–14.5
  48. 15.0–16.0

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.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.