string_get_size(9)
π
string_get_size(9) β get the size in the specified units β¨
Okay so bestie, this is string_get_size(9) from the Kernel API Manual, and it's literally here to turn a size into a cute formatted string in the units you want. π
πΈ NAME πΈ
string_get_size β get the size in the specified units. Periodt. π
β¨ SYNOPSIS β¨
int string_get_size (u64 size , u64 blk_size , const enum
string_size_units units , char *buf , int len );
π¦ ARGUMENTS π¦
sizeβ the size to be converted in blocks, bestie.blk_sizeβ size of the block (use1for size in bytes). Lowkey important.unitsβ units to use (powers of1000or1024), whether to include space separator. So many choices, iconic.bufβ buffer to format to. That's where the string goes. πlenβ length of buffer.
π DESCRIPTION π
This function returns a string formatted to 3 significant figures giving the size in the required units. Slay.
buf should have room for at least 9 bytes and will always be zero terminated. No cap, it's always null-terminated. π«Ά
Return value: number of characters of output that would have been written (which may be greater than len, if output was truncated). So yeah, if it got cut off, the return value can still be bigger than len β that's the vibe. π
π SEE ALSO π
Kernel file ./lib/string_helpers.c and the whole squad:
parse_int_array_user(9)string_unescape(9)string_escape_mem(9)kasprintf_strarray(9)kfree_strarray(9)skip_spaces(9)strim(9)sysfs_streq(9)match_string(9)__sysfs_match_string(9)strreplace(9)memcpy_and_pad(9)
Signed off from ./lib, dated October 2026 β string_get_size(9) out, mwah πβ¨
π¦ 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