kstrtobool(9)
π kstrtobool(9) β the kernel API manual, bestie edition π
okay so real talk, this one is a kstrtobool(9) situation and it's literally the most useful little gremlin in ./lib β it takes whatever chaos a user typed and turns it into a clean lil bool. no cap, it's giving "translator for the group chat". π¦
β¨ SYNOPSIS β¨
int kstrtobool (const char *s , bool *res );
like, that's it. that's the whole vibe. π
πΈ ARGUMENTS πΈ
sβ the input string, aka whatever unhinged text the user handed you. the star of the show, main character energy fr.resβ the result. this is where the answer lands, so bestie better be pointing somewhere real. π«Ά
π₯ DESCRIPTION π₯
okay so here's the tea β β this routine returns 0 if and only if the first character is one of:
'EeYyTt1DdNnFf0'
...or it's [oO][NnFf] for "on" and "off". so yes, it's out here accepting y, Y, e, E, t, T, 1, d, D, n, N, f, F, 0, and the whole on/off duo β iconic, honestly. π
Otherwise it will return -EINVAL. no match, no mercy. π
and the value pointed to by res gets updated upon finding a match β so like, the moment it vibes with your input, it writes the result through the pointer. slay. β¨
ngl, notice it says first character β so it's checking the start of the string, not doing a deep read of the whole thing. don't come for me, that's just what the page says. π
π SEE ALSO π
- Kernel file
./lib/kstrtox.c _parse_integer_limit(9)kstrtoull(9)kstrtoll(9)kstrtouint(9)kstrtoint(9)kstrtoudec64(9)kstrtodec64(9)
the whole kstrto* friend group is there, go say hi. π
and that's the whole page, bestie β brought to you straight outta ./lib, dated October 2026, in the Kernel API Manual. mwah, go forth and convert those booleans πβπ
π¦ 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