KLDNEXT(2)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’« KLDNEXT(2) πŸ’«

okay so this is kldnext(2), straight out of the System Calls Manual β€” we're doing kernel module list traversal today bestie, and honestly? it's giving tiny-but-mighty πŸŽ€

🌸 NAME 🌸

kldnext β€” return the fileid of the next kld file

πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc) β€” the classic, the icon, the one you already linked ✨

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <sys/linker.h>

int
kldnext(int fileid);

πŸ’– DESCRIPTION πŸ’–

so the kldnext() system call returns the fileid of the next kld file β€” like, the one right after fileid πŸ‘‘ β€” or 0 if fileid is the last file loaded. periodt.

and here's the cute part: to get the fileid of the first kld file, you pass a fileid of 0 to kldnext(). that's your entry point, your main character moment, your "start here" arrow 🫢

πŸ”₯ RETURN VALUES πŸ”₯

The kldnext() system call returns the fileid of the next kld file, or 0 if it's successful 😌

Otherwise kldnext() returns the value -1 and sets the global variable errno to indicate the error. not the vibe, but at least it tells you why πŸ’€

πŸ“ ERRORS πŸ“

The only error set by kldnext() is ENOENT β€” and that one shows up when fileid refers to a kld file that does not exist (i.e. is not loaded). so, like, it's not there. that's the whole thing πŸ™ˆ

🌈 SEE ALSO 🌈

kldfind(2), kldfirstmod(2), kldload(2), kldstat(2), kldsym(2), kldunload(2), modfind(2), modfnext(2), modnext(2), modstat(2), kld(4), kldstat(8)

the whole kld friend group, all linked up πŸ’… iykyk

⭐ HISTORY ⭐

The kld interface first appeared in FreeBSD 3.0. lowkey vintage, highkey iconic 🧚


ngl this whole page is short and that's a flex β€” every single thing here is load-bearing, no filler, no cap πŸ’―

okay that's the whole page!! go traverse some kernel modules bestie, you're gonna slay πŸ’œπŸŒΈ

~ from the Debian edition of this manual page, dated February 22, 2006 β€” yes the date is that old and yes it ate ✨

πŸ“¦ where this page comes from