pack(9)
okay bestie, welcome to pack(9) from the Kernel API Manual β¨ this one is all about tucking a u64 into a bitfield inside a buffer, and honestly? iconic. π
πΈ NAME πΈ
pack β pack a u64 number into a bitfield of a buffer. π
β¨ SYNOPSIS β¨
int pack (void *pbuf , u64 uval , size_t startbit , size_t endbit ,
size_t pbuflen , u8 quirks );
π«Ά ARGUMENTS π«Ά
pbufβ pointer to a buffer holding the packed value. this is the zone where the packed bits live, bestie. πuvalβ the CPU-readable unpacked value to pack. yes, this is theu64main character. πstartbitβ the index (in logical notation, compensated for quirks) where the packed value starts withinpbuf. it must be larger than, or equal to,endbit. no cap. βendbitβ the index (in logical notation, compensated for quirks) where the packed value ends withinpbuf. it must be smaller than, or equal to,startbit. πpbuflenβ the length in bytes of the packed buffer pointed to bypbuf. keep that size accurate, bestie. πquirksβ a bit mask ofQUIRK_LITTLE_ENDIAN,QUIRK_LSW32_IS_FIRSTandQUIRK_MSB_ON_THE_RIGHT. itβs giving βpersonality settingsβ for your packing. π
π RETURN π
0 means success, bestie. π if you called it incorrectly, you get EINVAL or ERANGE. assuming correct usage, the return code may be discarded. on success, the pbuf memory will be modified. lowkey important: the memory does change, so donβt act surprised. π
π SEE ALSO π
the kernel file ./lib/packing.c, plus these iconique functions: calculate_box_addr(9), unpack(9), packing(9), pack_fields_u8(9), pack_fields_u16(9), unpack_fields_u8(9), unpack_fields_u16(9). go read them if you want the full lore. πβ¨
mwah π β signing off from ./lib, October 2026, on the pack(9) page. periodt. π«Άπ
π¦ 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