nbcon_contex...quire_direct(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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