nbcon_contex...quire_direct(9)
π nbcon_context_try_acquire_direct β from the Kernel API Manual (9)
okay so bestie, we're in the Kernel API Manual, section 9, and today's main character is nbcon_context_try_acquire_direct. yes it's a mouthful, no you don't have to say it out loud at parties. it's giving "try to grab the console directly" and honestly? it kinda ate. π
β¨ NAME β¨
nbcon_context_try_acquire_direct β Try to acquire directly
literally that's it. that's the whole vibe. she tries. directly. π¦
πΈ SYNOPSIS πΈ
int nbcon_context_try_acquire_direct (struct nbcon_context *ctxt ,
struct nbcon_state *cur , bool is_reacquire );
yes the return type is int, yes she takes three args, no we are not skipping any of them, keep reading π
π«Ά ARGUMENTS π«Ά
ctxtβ The context of the caller. it's you. it's literally your whole situation going into this call πcurβ The current console state. the state. as it is. right now. no cap.is_reacquireβ This acquire is a reacquire. so like, a re-acquire. if you're coming back for seconds, set this. π
π₯ DESCRIPTION π₯
so here's the tea, and I need you to lock in for a sec β
This function acquires the console when it is released. simple, iconic, no notes.
It also acquires the console when the current owner has a lower priority and the console is in a safe state. both. not one or the other. both. the way that this is a two-condition situation, periodt.
Now the errors, and bestie, these matter so much:
-EPERMβ A panic is in progress and this is neither the panic CPU nor is this a reacquire. Or the current owner or waiter has the same or higher priority. No acquire method can be successful in these cases. π like genuinely, don't even try, every method loses here.-EBUSYβ The current owner has a lower priority but the console in an unsafe state. The caller should try using the handover acquire method. so close!! but you gotta take the other route, bestie π§
the -EBUSY case is your cue to switch methods β go hit up the handover acquire method instead. no shame in it. π«Ά
β RETURN β
0 on success. Otherwise, an error code on failure. π
Also cur is updated to the latest state when failed to modify it. yes, even on the failure path she's keeping you informed. communication! we love to see it. π
π SEE ALSO π
Kernel file ./kernel/printk/nbcon.c, plus the whole friend group β they all showed up to the group chat:
nbcon_state_set(9), nbcon_state_read(9), nbcon_state_try_cmpxchg(9), nbcon_seq_read(9), nbcon_seq_force(9), nbcon_seq_try_update(9), nbcon_context_try_acquire_requested(9), nbcon_context_try_acquire_handover(9), nbcon_context_try_acquire_hostile(9), nbcon_context_try_acquire(9), nbcon_context_release(9), nbcon_context_can_proceed(9), nbcon_can_proceed(9), __nbcon_context_update_unsafe(9), nbcon_enter_unsafe(9), nbcon_exit_unsafe(9), nbcon_reacquire_nobuf(9), nbcon_emit_next_record(9), nbcon_kthread_should_wakeup(9), nbcon_kthread_func(9), nbcon_irq_work(9), nbcon_kthreads_wake(9), nbcon_kthread_create(9), nbcon_get_cpu_emergency_nesting(9), nbcon_get_default_prio(9), nbcon_allow_unsafe_takeover(9), nbcon_legacy_emit_next_record(9), __nbcon_atomic_flush_pending_con(9), nbcon_atomic_flush_pending_con(9), __nbcon_atomic_flush_pending(9), nbcon_atomic_flush_pending(9), nbcon_atomic_flush_unsafe(9), nbcon_cpu_emergency_enter(9), nbcon_cpu_emergency_exit(9), nbcon_alloc(9), nbcon_free(9), nbcon_device_try_acquire(9), nbcon_device_release(9), nbcon_kdb_try_acquire(9), nbcon_kdb_release(9), nbcon_write_context_is_braille(9), nbcon_braille_try_acquire(9), nbcon_braille_release(9)
iykyk. and yes nbcon_write_context_is_braille(9) is real and she's everything to me π§β¨
okay that's the whole page, go forth and acquire responsibly. this drop is brought to you by ./kernel/printk, dated October 2026 β so mark your calendars bestie, the future is now π
πΈπ
π¦ 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