tty_dev_name_to_number(9)
π tty_dev_name_to_number(9) β a Kernel API Manual moment π
okay so bestie, welcome to tty_dev_name_to_number(9), straight out of the Kernel API Manual, and it's giving "tiny function, big responsibilities" energy. let's get into it β¨
πΈ NAME πΈ
tty_dev_name_to_number β return dev_t for device name
like, that's literally the whole vibe. you hand it a name, it hands you back a dev_t. iconic behavior fr fr π«Ά
β¨ SYNOPSIS β¨
int tty_dev_name_to_number (const char *name , dev_t *number );
no cap, that's the whole signature. look at her go π
π ARGUMENTS π
nameβ the user space name of the device under/dev. you know, the little guy you actually type, not the numbers π¦numberβ pointer to thedev_tthat this function will populate. she fills it in for you, cute right? π
π¦ DESCRIPTION π¦
okay so here's the tea: this function converts device names like ttyS0 or ttyUSB1 into dev_t like (4, 64) or (188, 1). literally a glow-up from name to numbers π
β¨
and if no corresponding driver is registered? bestie, it's not happening β the function returns -ENODEV. sad but honest π
Locking: this acquires tty_mutex to protect the tty_drivers list from being modified while we are traversing it, and makes sure to release it before exiting. she locks, she unlocks, she never leaves you hanging. that's main character energy π₯π
π SEE ALSO π
the whole friend group lives in the kernel file ./drivers/tty/tty_io.c β and honestly, this list ate:
free_tty_struct(9)tty_free_file(9)tty_name(9)get_tty_driver(9)tty_find_polling_driver(9)tty_wakeup(9)tty_release_redirect(9)__tty_hangup(9)tty_hangup(9)tty_vhangup(9)tty_vhangup_self(9)tty_vhangup_session(9)tty_hung_up_p(9)stop_tty(9)start_tty(9)tty_read(9)tty_write(9)tty_send_xchar(9)pty_line_name(9)tty_line_name(9)tty_driver_lookup_tty(9)tty_init_termios(9)tty_standard_install(9)tty_driver_install_tty(9)tty_driver_remove_tty(9)tty_reopen(9)tty_init_dev(9)tty_save_termios(9)tty_flush_works(9)release_one_tty(9)tty_kref_put(9)release_tty(9)tty_release_checks(9)tty_kclose(9)tty_release_struct(9)tty_release(9)tty_open_current_tty(9)tty_lookup_driver(9)tty_kopen_exclusive(9)tty_kopen_shared(9)tty_open_by_driver(9)tty_open(9)tty_poll(9)tiocsti(9)tiocgwinsz(9)tty_do_resize(9)tiocswinsz(9)tioccons(9)tiocsetd(9)tiocgetd(9)send_break(9)tty_get_tiocm(9)tty_tiocmget(9)tty_tiocmset(9)tty_get_icount(9)alloc_tty_struct(9)tty_put_char(9)tty_register_device(9)tty_register_device_attr(9)tty_unregister_device(9)__tty_alloc_driver(9)tty_driver_kref_put(9)tty_register_driver(9)tty_unregister_driver(9)
iykyk π§π
quick vibe check: that source line says ./drivers/tty, and you'll catch her in October 2026 β so basically bookmark it. mwah π
okay bestie that's the whole page, go forth and convert those names to numbers, periodt π βππΈπ
π¦ 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