DEVCLASS_GET_DEVICES(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… 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 using free(*devlistp, M_TEMP) β€” and yes, you have to do it even if *devcountp is 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