MODSTAT(2)
β¨ NAME β¨
okay so bestie, this is modstat(2), a System Calls Manual page β and it's literally the system call that gets you the status of a kernel module. yes, the whole vibe is "tell me about this module by its id." π
π LIBRARY π
Standard C Library (libc, -lc) β she's right there in libc, link with -lc. π«Ά
πΈ SYNOPSIS πΈ
#include <sys/param.h>
#include <sys/module.h>
int
modstat(int modid, struct module_stat *stat);
π DESCRIPTION π
okay so modstat() is the system call that writes the info for the kernel module referred to by modid into stat. no cap, that's the whole job.
here's the struct situation, and yes you need to know it:
struct module_stat {
int version; /* set to sizeof(module_stat) */
char name[MAXMODNAME];
int refs;
int id;
modspecific_t data;
};
typedef union modspecific {
int intval;
u_int uintval;
long longval;
u_long ulongval;
} modspecific_t;
versionβ this field is set to the size of the structure mentioned above by the code callingmodstat(), and not bymodstat()itself. so like, you set it, bestie. πnameβ the name of the module referred to bymodid.refsβ the number of modules referenced bymodid.idβ the id of the module specified inmodid.dataβ module specific data.
π RETURN VALUES π
modstat() returns the value 0 if successful; otherwise, the value -1 is returned and the global variable errno is set to indicate the error. that's the whole deal. π
π₯ ERRORS π₯
the information for the module referred to by modid is filled into the structure pointed to by stat unless one of these pops off:
ENOENTβ the module was not found (probably not loaded). π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. yes, that's the dramatic part. πEFAULTβ there was a problem copying one, some, or all of the fields intostatin thecopyout(9)function. π
π¦ SEE ALSO π¦
kldfind(2),kldfirstmod(2),kldload(2),kldnext(2),kldstat(2),kldsym(2),kldunload(2),modfind(2),modfnext(2),modnext(2),kld(4),kldstat(8)β go read these too, iykyk. π
β HISTORY β
the kld interface first appeared in FreeBSD 3.0. periodt. π
xoxo, your Debian bestie π β source/version: Debian, page date: July 15, 2008, manual: MODSTAT(2). π«Ά
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 1999 Chris Costello
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms