hex_dump_to_buffer(9)
π hex_dump_to_buffer(9) β the kernel API manual, but make it make sense
okay so bestie, welcome to hex_dump_to_buffer(9). that's the kernel API manual page, and no i'm not gonna make you read raw manpage prose, we're doing this together π«Ά
β¨ NAME β¨
hex_dump_to_buffer β converts a blob of data into "hex ASCII" in memory. that's it. that's the whole vibe. β¨
πΈ SYNOPSIS πΈ
int hex_dump_to_buffer (const void *buf , size_t len , int rowsize , int
groupsize , char *linebuf , size_t linebuflen , bool ascii );
seven arguments. yeah. seven. but each one is doing its little job and honestly? iconic behavior π
π ARGUMENTS π
bufβ the data blob you're dumping. the main character of this whole operation πlenβ how many bytes are inbuf. literally the count, no cap.rowsizeβ number of bytes printed per line; must be 16 or 32. like, that's not a suggestion bestie, those are the only two options π¨groupsizeβ number of bytes printed at a time (1, 2, 4, 8; default = 1). grouping is self care πlinebufβ where you put the converted data. the destination. the moment. β¨linebuflenβ total size oflinebuf, including space for the terminating NUL. yes, the NUL counts, don't forget the NUL, we've all forgotten the NUL πasciiβ include ASCII after the hex output. say yes and you get the cute little letters on the right π¦
π¦ DESCRIPTION π¦
so the way hex_dump_to_buffer works: it operates on one "line" of output at a time, i.e. 16 or 32 bytes of input data converted to hex + ASCII output. one line. one moment. one vibe. π
given a buffer of u8 data, hex_dump_to_buffer converts the input data into a hex + ASCII dump at the supplied memory location. and the converted output is always NUL-terminated β always, periodt.
E.g.:
hex_dump_to_buffer(frame->data, frame->len, 16, 1, linebuf,
sizeof(linebuf), true);
and the example output buffer is giving:
40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f ABCDEFGHIJKLMNO
look at that. hex on the left, ASCII on the right, chef's kiss π₯
π RETURN π
the return value is the amount of bytes placed in the buffer without the terminating NUL. (no NUL in the count, we discussed this π)
and here's the important part: if the output was truncated, then the return value is the number of bytes (excluding the terminating NUL) which would have been written to the final string if enough space had been available. so it tells you how much room it actually wanted. very "i could have slayed harder if you'd given me space" of it, honestly π
π§ SEE ALSO π§
- kernel file
./lib/hexdump.c hex_to_bin(9)hex2bin(9)bin2hex(9)print_hex_dump(9)
go read those too, they're the friend group π«Ά
okay that's the whole page bestie, you understood it, i'm proud of you π
β signed off from ./lib, dated October 2026, on the manual page hex_dump_to_buffer(9) β slay, go dump some hex π
β¨
π¦ 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