list_entry(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 β€” the struct list_head pointer. 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 your list_head is living inside 🏠
  • member β€” the name of the list_head within 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 🌈

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