mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2026-09-08 23:57:59 +08:00
TCSETS and the legacy TCSETA family discard flag bits that are not named in the kernel bitflags definitions. This differs from Linux 6.6, which copies the raw flag words and preserves the upper 16 bits when merging legacy termio settings. Preserve all four raw flag words at both ABI conversion boundaries while leaving hardware normalization to the existing driver callbacks. Keep legacy control-character merging and baud-rate extraction unchanged. Use bitflags difference() when restoring old hardware settings after an unsupported driver callback. Unlike the bitflags complement operator, it preserves unnamed bits outside the software-controlled mask, matching tty_termios_copy_hw(). Extend the existing dunitest suite to cover all six set commands, raw flag preservation, legacy control-character tails, input flush behavior, EFAULT without state changes, the 18-byte page-boundary termio ABI and zeroed padding, and console stdin settings. Validation: - Reproduced raw flag loss before the fix: 25 of 26 tty_termios tests passed, with only the new flag-preservation case failing. - After the fix, QEMU x86_64 passed tty_termios (26), tty_tcflush (6), tty_pty_hangup (36), and the existing C termios smoke test. - Verified TCSAFLUSH and legacy settings on ttyS0 stdin, plus a successful apt install of a local test package without the TCSAFLUSH error. - All five added tests passed on host Linux with a PTY. - Kernel build, Rust formatting and whitespace checks passed. Signed-off-by: longjin <longjin@dragonos.org>