err_pos(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ err_pos(9) β€” like, the Kernel API Manual page, bestie πŸ¦‹

okay so we're in the <pink>Kernel API Manual</pink> today and the star of the show is err_pos(9) β€” yes, that's the manual section, she's a kernel function, it's giving very "I live in ./kernel/trace/trace.c" energy πŸ’…


✨ NAME ✨

err_pos β€” find the position of a string within a command for error careting 🎯

no fr, that's literally it. you give her a command and a string, she tells you where in that command the string is so your error message can point at it with a little caret. iconic behaviour honestly.


🌸 SYNOPSIS 🌸

unsigned int err_pos (char *cmd , const char *str );

that's the whole vibe. two args, one unsigned int coming back at you 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • cmd β€” the tracing command that caused the error πŸ’€ like, the actual command string that did the oopsie.
  • str β€” the string you wanna position the caret at, within cmd. that's the thing you're hunting for πŸ‘‘

πŸ’– DESCRIPTION πŸ’–

okay so here's the tea, bestie: err_pos finds the position of the first occurrence of str within cmd. first one, not all of them β€” she's not doing a whole search party, just the first match πŸ’…

and the return value? you can pass it straight to tracing_log_err for caret placement within cmd. so like, your error message can go:

here's the command
        ^
    right there

which is honestly so helpful and lowkey main character energy ✨

the details, fr fr:

  • returns the index within cmd of the first occurrence of str 🎯
  • returns 0 if str was not found πŸ™ˆ
⚠️ okay important little heads up: 0 is the "not found" answer, so don't go assuming index 0 means "it's at the very start" without thinking about it, iykyk. that's just what the page says, no cap.

🌈 SEE ALSO 🌈

the whole friend group πŸ’œ β€” and yes, we're listing every single one, because they all matter:

Kernel file ./kernel/trace/trace.c : trace_array_put(9), tracing_is_enabled(9), tracing_on(9), tracing_snapshot(9), tracing_alloc_snapshot(9), tracer_tracing_disable(9), tracer_tracing_enable(9), tracing_off(9), tracer_tracing_is_on(9), tracing_is_on(9), register_tracer(9), tracing_start(9), tracing_stop(9), trace_buffered_event_enable(9), trace_buffered_event_disable(9), trace_dump_stack(9), ignore_event(9), trace_adjust_address(9), tracing_update_buffers(9), trace_user_fault_destroy(9), trace_user_fault_init(9), trace_user_fault_get(9), trace_user_fault_put(9), trace_user_fault_read(9), tracing_log_err(9), trace_array_get_by_name(9), tracing_init_dentry(9)

like, go read them, they're all slaying in their own way 🧚


and that's the page!! πŸŽ€ sign-off time: this one lives in <cyan>./kernel/trace</cyan>, dated October 2026, and yes she's err_pos(9) all the way down β€” mwah πŸ’‹βœ¨ πŸ¦‹

πŸ“¦ where this page comes from