list_entry(9)
π list_entry(9) π
okay so bestie, welcome to the Kernel API Manual β yes, we're doing kernel stuff today, and yes you're gonna slay it. this page is all about list_entry, and honestly? it's giving "glow-up for a pointer." let's get into it β¨
πΈ NAME πΈ
list_entry β get the struct for this entry π«Ά
like, you have a struct list_head and you wanna know which bigger struct it's cozy inside of? that's the whole vibe. main character energy fr.
π¦ SYNOPSIS π¦
list_entry (ptr , type , member );
no cap, that's the whole thing. three args, one iconic little macro π
π ARGUMENTS π
ptrβ thestruct list_headpointer. this is your starting point, your little anchor in the list, the pointer you already have π«typeβ the type of the struct this is embedded in. as in, what's the bigger struct called β the one yourlist_headis living inside πmemberβ the name of thelist_headwithin the struct. the actual field name, so the macro knows where to look π―
and that's it! three things, all named, all necessary. don't skip any of them, bestie, it will not go well π
π SEE ALSO π
- Kernel file
./tools/usb/usbip/libsrc/list.h list_add(9)list_del(9)list_for_each(9)list_for_each_safe(9)container_of(9)
the whole linked-list friend group honestly π₯ container_of(9) is literally the sibling of this one, iykyk.
lowkey reminder: all the real details live above, and the macro is list_entry (ptr , type , member ); β keep the args in that order, periodt π
and that's the page!! mwah π this beauty comes from ./tools/usb/usbip/libsrc, version dated October 2026, and it's filed under list_entry(9) β go forth and get that struct, queen ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms