DEVICE_GET_CHILDREN(9)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 14.5, freebsd 15.1

πŸ’– DEVICE_GET_CHILDREN(9) πŸ’–

okay so bestie, welcome to the Kernel Developer's Manual β€” this is DEVICE_GET_CHILDREN(9), and it's literally about peeking at all the little devices that are connected to a bigger device. family tree energy fr fr 🌳✨


✨ NAME ✨

device_get_children, device_has_children β€” the functions that let you examine devices connected to a device. yes it's devices all the way down, don't think about it too hard πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

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

int
device_get_children(device_t dev, device_t **devlistp, int *devcountp);

bool
device_has_children(device_t dev);

🌸 DESCRIPTION 🌸

device_get_children is the main character here πŸ‘‘ β€” it retrieves a list of all the device instances currently connected to dev. not some of them, not the ones it likes best, all of them. it hands you back the list in *devlistp and the count in *devcountp.

🚨 important bestie alert: the memory that gets allocated for that list? you gotta free it yourself using free(*devlistp, M_TEMP). it's not gonna clean itself up, that's on you πŸ’€

also, devlistp and devcountp are not changed when an error is returned β€” so if it fails, they stay exactly how you left them, no surprise edits πŸ™ˆ

special case time ✨ as a special case, if devlistp is null, no memory is allocated at all β€” but the count is still returned in *devcountp. so you can absolutely just ask "how many kids you got?" without adopting the whole list 🫢

then there's device_has_children, the low-effort queen of the pair β€” it returns true if dev has at least one child, and false if it has none. that's it. that's the whole function. iconic honestly πŸ’œ


⭐ RETURN VALUES ⭐

  • device_get_children returns zero on success, and an appropriate error otherwise. zero = slay, anything else = check yourself πŸ”₯
  • device_has_children returns true if the specified device has at least one child, and false otherwise. simple, clean, no notes 🌈

πŸ¦‹ SEE ALSO πŸ¦‹

go read those too, iykyk πŸ“š


πŸ‘‘ AUTHORS πŸ‘‘

this manual page was written by Doug Rabson <dfr@FreeBSD.org> and Dag-Erling Smørgrav <des@FreeBSD.org>. absolute legends, we stan 🫢✨


okay that's the whole page bestie, go free your devlists and stay hydrated πŸ“πŸ’–

Debian Β· November 28, 2025 Β· that's the version and date, mwah πŸ’…πŸŽ€

πŸ“¦ where this page comes from