container_of(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

Okay so bestie, welcome to container_of(9) from the Kernel API Manual β€” this is the page where you cast a member of a structure out to the containing structure, and honestly? Iconic behavior πŸ’…

🌸 NAME 🌸

container_of β€” cast a member of a structure out to the containing structure. Periodt.

✨ SYNOPSIS ✨

Here's the exact shape of it, no cap:

container_of (ptr , type , member );

πŸŽ€ ARGUMENTS πŸŽ€

Three little besties walk into the call:

  • ptr β€” the pointer to the member.
  • type β€” the type of the container struct this is embedded in.
  • member β€” the name of the member within the struct.

πŸ”₯ SEE ALSO πŸ”₯

Go peek at the kernel file ./tools/usb/usbip/libsrc/list.h β€” that's the spot. The related references are list_add(9), list_del(9), list_entry(9), list_for_each(9), and list_for_each_safe(9). Obsessed 🫢


Source/version vibes: ./tools/usb/usbip/libsrc. Date on the page: October 2026. Signed with glitter, container_of(9) style πŸŽ€βœ¨

πŸ“¦ where this page comes from