DEVICE_GET_CHILDREN(9)
π 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_childrenreturns zero on success, and an appropriate error otherwise. zero = slay, anything else = check yourself π₯device_has_childrenreturnstrueif the specified device has at least one child, andfalseotherwise. 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
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 1998 Doug Rabson
- Copyright (c) 2025 Dag-Erling SmΓΈrgrav <des@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms