printk_parse_prefix(9)
π printk_parse_prefix(9) β a Kernel API Manual moment π
okay so bestie, we're in the Kernel API Manual today and the star of the show is printk_parse_prefix(9). she's a little parser, she's got main character energy, and honestly? she ate.
β¨ NAME β¨
printk_parse_prefix β parse the level and the control flags. that's it, that's the whole job. π
β¨ SYNOPSIS β¨
u16 printk_parse_prefix (const char *text , int *level , enum
printk_info_flags *flags );
like, look at her signature. so clean. π
β¨ ARGUMENTS β¨
textβ the terminated text message. yes, terminated, as in null-terminated, please don't send her a rogue unterminated string, that's not the vibe πlevelβ a pointer to the current level value, and she will be updating it. coming for that variable, respectfully. π₯flagsβ a pointer to the currentprintk_infoflags, and same deal, she's updating it too. β¨
β¨ DESCRIPTION β¨
okay so the rules of engagement, listen up π«Ά
level may be NULL if the caller is genuinely not interested in the parsed value β no hard feelings, she gets it. Otherwise? the variable pointed to by level must be set to LOGLEVEL_DEFAULT in order to be updated with the parsed value. like, that's the entry fee. no LOGLEVEL_DEFAULT, no update. periodt. π
flags may also be NULL if you're not interested in the parsed value β also fine, also valid. Otherwise, the variable pointed to by flags will be OR'd with the parsed value. not overwritten, not replaced β OR'd. lowkey important distinction, iykyk. πΈ
β¨ RETURN β¨
she returns the length of the parsed level and control flags. the way that's literally the whole return value. iconic. π
β¨ SEE ALSO β¨
so. many. friends. she runs with a whole crowd π¦ β the kernel file ./kernel/printk/printk.c plus:
console_list_lock(9)console_list_unlock(9)console_srcu_read_lock(9)console_srcu_read_unlock(9)console_lock_spinning_enable(9)console_lock_spinning_disable_and_check(9)console_trylock_spinning(9)add_preferred_console(9)match_devname_and_update_preferred_console(9)console_suspend_all(9)console_cpu_notify(9)console_lock(9)console_trylock(9)console_unlock(9)console_flush_on_panic(9)printk_kthreads_shutdown(9)console_force_preferred_locked(9)pr_flush(9)wake_up_klogd(9)defer_console_output(9)printk_trigger_flush(9)printk_timed_ratelimit(9)kmsg_dump_register(9)kmsg_dump_unregister(9)kmsg_dump_desc(9)kmsg_dump_get_line(9)kmsg_dump_get_buffer(9)kmsg_dump_rewind(9)console_try_replay_all(9)__printk_cpu_sync_wait(9)__printk_cpu_sync_try_get(9)__printk_cpu_sync_put(9)
ngl bestie, read the whole squad's pages before you go touching console locking. she's not gatekeeping but the kernel absolutely will. π
π that's the whole page, you're so welcome π
this little fairy godmother of a page lives in ./kernel/printk, and the calendar says October 2026 β so go forth, parse those prefixes, and slay. π§ββοΈβπ
π¦ 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