unpack(9)
π
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 anu64that'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 withinpbuf. 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 withinpbuf. 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 thatpbufpoints to. count the bytes, don't guess πquirksβ a bit mask ofQUIRK_LITTLE_ENDIAN,QUIRK_LSW32_IS_FIRSTandQUIRK_MSB_ON_THE_RIGHT. this is the β¨personalityβ¨ parameter, and honestly she's carrying the whole function π₯
π RETURN π
0on success πEINVALorERANGEif 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
uvalwill be modified on success. that's the whole point β she writes back into youru64and it's giving transformation arc π¦
β οΈ real talk though:EINVALandERANGEonly 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:
- Kernel file
./lib/packing.c calculate_box_addr(9)pack(9)packing(9)pack_fields_u8(9)pack_fields_u16(9)unpack_fields_u8(9)unpack_fields_u16(9)
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
- 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