unpack(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… unpack(9) β€” the unpack girlies know ✨

okay so bestie, welcome to unpack(9), aka the Kernel API Manual's own little unboxing video πŸŽ€ this is the one that pulls a u64 out of a packed buffer. no cap, she's iconic.


✨ SYNOPSIS ✨

int unpack (const void *pbuf , u64 *uval , size_t startbit , size_t endbit , size_t pbuflen , u8 quirks );

that's the whole vibe check right there 🫢 six arguments, one int coming back at you.


🌸 ARGUMENTS 🌸

okay let's meet the cast, main character energy for each of them:

  • pbuf β€” pointer to a buffer that's holding the packed value. she's the container, the gift box, the whole point 🎁
  • uval β€” pointer to an u64 that's gonna hold the unpacked value once you're done. this is where the reveal happens πŸ’–
  • startbit β€” the index (in logical notation, compensated for quirks β€” yes, quirks, we'll get there) where the packed value starts within pbuf. must be larger than, or equal to, endbit. literally just keep that in mind, bestie 😭
  • endbit β€” the index (in logical notation, compensated for quirks, same deal) where the packed value ends within pbuf. must be smaller than, or equal to, startbit. yeah. fr fr. that's what it says πŸ’€
  • pbuflen β€” the length in bytes of the packed buffer that pbuf points to. count the bytes, don't guess πŸ“
  • quirks β€” a bit mask of QUIRK_LITTLE_ENDIAN, QUIRK_LSW32_IS_FIRST and QUIRK_MSB_ON_THE_RIGHT. this is the ✨personality✨ parameter, and honestly she's carrying the whole function πŸ”₯

πŸ‘‘ RETURN πŸ‘‘

  • 0 on success πŸŽ‰
  • EINVAL or ERANGE if you called it incorrectly πŸ™ˆ (that's on you, not on her)
  • Assuming correct usage, the return code may be discarded. yes bestie, if you know you're doing it right, you can just throw it away πŸ’…
  • The uval will be modified on success. that's the whole point β€” she writes back into your u64 and it's giving transformation arc πŸ¦‹
⚠️ real talk though: EINVAL and ERANGE only show up if something's wrong with how you called her. don't discard the check unless you're genuinely sure your usage is correct.

🌈 SEE ALSO 🌈

go follow her friends, they're all in the same squad:

like, the whole packing friend group, iykyk πŸ’œ


okay and that's the tea, bestie 🧚 this little page comes to you from ./lib, dated October 2026 β€” so yes, she's from the future and she still slays. mwah, go unpack something πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from