diff options
author | Andrew Walbran <qwandor@google.com> | 2023-12-07 12:16:46 +0000 |
---|---|---|
committer | Andrew Walbran <qwandor@google.com> | 2023-12-07 12:59:43 +0000 |
commit | c7abcf1bf01b3e41fa768b73859368828daee178 (patch) | |
tree | 5eac0e2b3f209892c8ebbbdb3c3bf5dea9c8b696 | |
parent | 61f371d4fb41c0eed0ac801f0f4575d976ed6d50 (diff) | |
download | nix-c7abcf1bf01b3e41fa768b73859368828daee178.tar.gz |
Use from_bits_retain for all Termios wrapper fields.
In case there are any unrecognised bits, they should be kept when
setting fields of the underlying libc termios struct in
get_libc_termios, rather than being dropped. This ensures that termios
can be roundtripped even with unrecognised bits set.
Test: Treehugger
Change-Id: I478b660042edac07b82dedf5fe997e5deac14777
-rw-r--r-- | src/sys/termios.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/sys/termios.rs b/src/sys/termios.rs index ecaa3ea..74c5fc5 100644 --- a/src/sys/termios.rs +++ b/src/sys/termios.rs @@ -307,10 +307,10 @@ impl Termios { /// Updates the wrapper values from the internal `libc::termios` data structure. pub(crate) fn update_wrapper(&mut self) { let termios = *self.inner.borrow_mut(); - self.input_flags = InputFlags::from_bits_truncate(termios.c_iflag); - self.output_flags = OutputFlags::from_bits_truncate(termios.c_oflag); + self.input_flags = InputFlags::from_bits_retain(termios.c_iflag); + self.output_flags = OutputFlags::from_bits_retain(termios.c_oflag); self.control_flags = ControlFlags::from_bits_retain(termios.c_cflag); - self.local_flags = LocalFlags::from_bits_truncate(termios.c_lflag); + self.local_flags = LocalFlags::from_bits_retain(termios.c_lflag); self.control_chars = termios.c_cc; #[cfg(any( target_os = "linux", @@ -327,10 +327,10 @@ impl From<libc::termios> for Termios { fn from(termios: libc::termios) -> Self { Termios { inner: RefCell::new(termios), - input_flags: InputFlags::from_bits_truncate(termios.c_iflag), - output_flags: OutputFlags::from_bits_truncate(termios.c_oflag), - control_flags: ControlFlags::from_bits_truncate(termios.c_cflag), - local_flags: LocalFlags::from_bits_truncate(termios.c_lflag), + input_flags: InputFlags::from_bits_retain(termios.c_iflag), + output_flags: OutputFlags::from_bits_retain(termios.c_oflag), + control_flags: ControlFlags::from_bits_retain(termios.c_cflag), + local_flags: LocalFlags::from_bits_retain(termios.c_lflag), control_chars: termios.c_cc, #[cfg(any( target_os = "linux", |