KLDSTAT(2)
π KLDSTAT(2) π
okay so bestie, we're in the System Calls Manual section of the Debian man pages, and today's main character is kldstat β the syscall that gives you the tea on your kld files π«β¨
β¨ NAME β¨
kldstat β get status of kld file π
π LIBRARY π
Standard C Library (libc, -lc) β she's built in, no extra credit needed π
π SYNOPSIS π
#include <sys/param.h>
#include <sys/linker.h>
int
kldstat(int fileid, struct kld_file_stat *stat);
π¦ DESCRIPTION π¦
So the kldstat() system call writes the info for the file referred to by fileid into stat. Like, it literally fills in the whole glow-up report for you β¨
struct kld_file_stat {
int version; /* set to sizeof(struct kld_file_stat) */
char name[MAXPATHLEN];
int refs;
int id;
caddr_t address;
size_t size;
char pathname[MAXPATHLEN];
};
okay let's go field by field, no skipping bestie:
versionβ this field is set to the size of the structure mentioned above by the code callingkldstat(), and not bykldstat()itself. so like, you fill this in, not her πnameβ the name of the file referred to byfileid.refsβ the number of modules referenced byfileid.idβ the id of the file specified infileid.addressβ the load address of the kld file.sizeβ the amount of memory in bytes allocated by the file.pathnameβ the full name of the file referred to byfileid, including the path. the whole thing, no crumbs π
π RETURN VALUES π
The kldstat() function returns the value 0 if successful π otherwise the value -1 is returned and the global variable errno is set to indicate the error π classic.
π ERRORS π
The information for the file referred to by fileid is filled into the structure pointed to by stat unless:
[ENOENT]β The file was not found (probably not loaded). she's simply not there bestie π[EINVAL]β The version specified in theversionfield ofstatis not the proper version. You would need to rebuild world, the kernel, or your application, if this error occurs, given that you did properly fill in theversionfield. like it's giving "time to rebuild everything" energy π[EFAULT]β There was a problem copying one, some, or all of the fields intostatin thecopyout(9)function. oops, copy didn't slay π
π SEE ALSO π
kldfind(2), kldfirstmod(2), kldload(2), kldnext(2), kldsym(2), kldunload(2), modfind(2), modfnext(2), modnext(2), modstat(2), kld(4), kldstat(8) β go read the whole friend group, they all ate π
π HISTORY π
The kld interface first appeared in FreeBSD 3.0. vintage icon behavior, no cap π
π BUGS π
β οΈ Thepathnamemay not be accurate if the file system mounts have changed since the module was loaded, or if this function is called within achrootedenvironment. so like, don't trust that path with your whole heart if things moved around bestie π
and that's the whole page!! mwah π this one came from the Debian crew and is dated March 28, 2012 β stay hydrated, keep your structs zeroed, and slay the day away β¨π«Άπ
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1999 Chris Costello
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms