Skip to content

[feat] Implement missing TTY termios ioctls (TCSETSF, TCSETA*) #1906

Description

@fslongjin

Summary

Complete TTY termios-related ioctl handling so that tcsetattr() and legacy termio paths behave like Linux 6.6.

Observed behavior

During apt install, user space reports:

E: Setting in Start via TCSAFLUSH for stdin failed! - tcsetattr (25: Inappropriate ioctl for device)

This corresponds to tcsetattr(fd, TCSAFLUSH, ...)ioctl(TCSETSF).

Root cause

In kernel/src/driver/tty/tty_core.rs, tty_mode_ioctl() currently handles only:

  • TCGETS
  • TCSETS (TCSANOW)
  • TCSETSW (TCSADRAIN)

The following ioctls are defined but not wired; requests hit the default branch (ENOIOCTLCMD), which surfaces to user space as ENOTTY:

ioctl value typical user API
TCSETSF 0x5404 tcsetattr(..., TCSAFLUSH)
TCSETA 0x5406 tcsetattr (struct termio)
TCSETAW 0x5407 same + drain
TCSETAF 0x5408 same + flush

Expected behavior

Align with Linux 6.6 TTY termios ioctl semantics, including flush-before-set for TCSETSF / TCSETAF and correct handling of struct termio for the TCSETA* family.

Acceptance criteria

  • tcsetattr(0, TCSAFLUSH, &t) succeeds on a serial console (nographic) shell
  • The debconf error above no longer appears during apt install (except when stdin is legitimately not a TTY)
  • TCSETA / TCSETAW / TCSETAF do not return ENOTTY on a valid TTY fd
  • Covered by c_unitest (e.g. extend existing TTY tests such as test_tty_tcflush.c)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions