DEVCLASS_GET_DEVICES(9)

πŸ’– DEVCLASS_GET_DEVICES πŸ’–

okay bestie, so this one lives in the Kernel Developer's Manual (section 9, kernel devs only, iykyk) and it's literally just "hey, gimme all the devices in this devclass" πŸ¦‹


✨ NAME ✨

devclass_get_devices β€” get a list of devices in a devclass πŸ’…


🌸 SYNOPSIS 🌸

#include <sys/param.h>
#include <sys/bus.h>

int
devclass_get_devices(devclass_t dc, device_t **devlistp,
    int *devcountp);

like, you gotta include both of those headers, no skipping πŸ™ˆ


πŸŽ€ DESCRIPTION πŸŽ€

So basically you call this and it retrieves a list of all device instances that are currently chillin' in the devclass, then hands you back:

  • the list itself in *devlistp 🌈
  • the count in *devcountp πŸ”’
⚠️ okay this part is IMPORTANT, no cap: the memory that gets allocated for that list has to be freed with free(*devlistp, M_TEMP) β€” and yes, you do this even if *devcountp is 0. Zero devices still means allocated memory, bestie. don't leak on me 😭

πŸ’œ RETURN VALUES πŸ’œ

Zero on success, slay ✨ otherwise it returns whatever appropriate error fits the situation. not zero = something went sideways, periodt.


πŸ¦‹ SEE ALSO πŸ¦‹

the girlies that go with this one πŸ‘‘ go read 'em, fr fr


πŸ‘‘ AUTHORS πŸ‘‘

This manual page was written by Doug Rabson. iconic behavior honestly πŸ’–


k bye this page came from the Debian crew, dated May 19, 2005, and it's DEVCLASS_GET_DEVICES(9) all the way through πŸŽ€βœ¨

πŸ“¦ where this page comes from