KLDSTAT(2)

๐Ÿ“ฆ version 15.1, in freebsd 14.5, freebsd 15.1

๐Ÿ’– NAME ๐Ÿ’–

  • kldstat โ€” get status of kld file

okay so bestie, this is the KLDSTAT(2) page from the System Calls Manual, and we're here to get the status of a kld file. no cap, it's giving kernel-loader realness. โœจ

๐Ÿฆ‹ LIBRARY ๐Ÿฆ‹

Standard C Library (libc, -lc). yes bestie, she lives in libc. ๐Ÿซถ

๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <sys/linker.h>

int
kldstat(int fileid, struct kld_file_stat *stat);

๐ŸŒธ DESCRIPTION ๐ŸŒธ

The kldstat() system call writes the info for the file referred to by fileid into stat. simple as that, icon behavior. ๐Ÿ’…

here's the struct, looking exactly like this:

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];
};

and the fields mean:

  • version โ€” this field is set to the size of the structure mentioned above by the code calling kldstat(), and not kldstat() itself. yes, read that again. ๐Ÿ‘‘
  • name โ€” the name of the file referred to by fileid.
  • refs โ€” the number of modules referenced by fileid.
  • id โ€” the id of the file specified in fileid.
  • 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 by fileid, including the path.

โญ 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. slay when it works, errno when it doesn't. ๐Ÿ˜ญ

๐Ÿ’€ 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).
  • [EINVAL] โ€” the version specified in the version field of stat is 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 the version field.
  • [EFAULT] โ€” there was a problem copying one, some, or all of the fields into stat in the copyout(9) function.

๐Ÿ”ฎ 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 off, related pages. ๐Ÿ’œ

๐Ÿงš HISTORY ๐Ÿงš

The kld interface first appeared in FreeBSD 3.0. vintage but still iconic. ๐Ÿ’œ

๐Ÿ™ˆ BUGS ๐Ÿ™ˆ

The pathname may not be accurate if the file system mounts have changed since the module was loaded, or if this function is called within a chrooted environment. so like, keep that in mind bestie. ๐Ÿ˜ญ


source/version: Debian ยท date: March 28, 2012 โ€” mwah, love u, bye! ๐Ÿ’‹โœจ

๐Ÿ“ฆ where this page comes from