DEVCLASS_GET_DEVICES(9)
π DEVCLASS_GET_DEVICES π
ok so this is a page from the Kernel Developer's Manual (section 9, kernel-adjacent besties rise up π«Ά) and it's all about devclass_get_devices β yes that whole mouthful, we'll get through it together.
πΈ NAME πΈ
devclass_get_devices β bestie, it literally just gets you a list of the devices chillin' in a devclass. that's it. that's the whole vibe check. β¨
π SYNOPSIS π
ok first things first, you gotta invite the right headers to the party:
#include <sys/param.h>
#include <sys/bus.h>
and then the actual function, iconic signature and all:
int
devclass_get_devices(devclass_t dc, device_t **devlistp,
int *devcountp);
π¦ DESCRIPTION π¦
so the tea is: you call this bad boy and it goes and retrieves a list of, like, all the device instances currently in the devclass. every single one. no cap. π
it hands you back the list in *devlistp and the count in *devcountp β so you know exactly how many little device besties you're dealing with. so considerate honestly. π
β οΈ okay this part is important, don't skip it: the memory allocated for the list needs to be freed usingfree(*devlistp, M_TEMP)β and yes, you have to do it even if*devcountpis 0. like, even when the list is empty. no excuses, free it. the way that memory leaks are not the move π
β RETURN VALUES β
0β slay, you did it, success π- anything else β an appropriate error got returned, soβ¦ rude, but okay π
π SEE ALSO π
go read those too, iykyk π§
π AUTHORS π
this absolute legend wrote this manual page: Doug Rabson. give him his flowers fr fr π
and that's the whole page bestie, you ate that π This little gem came from the Debian crew and it's dated May 19, 2005 β vintage but still serving, periodt π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 1998 Doug Rabson
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms