@@ -2,6 +2,20 @@ use crate::fd::AsFd;
2
2
use crate :: process:: Pid ;
3
3
use crate :: { backend, io} ;
4
4
5
+ #[ cfg( all(
6
+ any( target_os = "android" , target_os = "linux" ) ,
7
+ any(
8
+ target_arch = "x86" ,
9
+ target_arch = "x86_64" ,
10
+ target_arch = "x32" ,
11
+ target_arch = "riscv64" ,
12
+ target_arch = "aarch64" ,
13
+ target_arch = "arm" ,
14
+ target_arch = "mips" ,
15
+ target_arch = "mips64" ,
16
+ )
17
+ ) ) ]
18
+ pub use backend:: termios:: types:: Termios2 ;
5
19
pub use backend:: termios:: types:: {
6
20
Action , OptionalActions , QueueSelector , Speed , Tcflag , Termios , Winsize ,
7
21
} ;
@@ -25,6 +39,37 @@ pub fn tcgetattr<Fd: AsFd>(fd: Fd) -> io::Result<Termios> {
25
39
backend:: termios:: syscalls:: tcgetattr ( fd. as_fd ( ) )
26
40
}
27
41
42
+ /// `tcgetattr2(fd)`—Get terminal attributes.
43
+ ///
44
+ /// Also known as the `TCGETS2` operation with `ioctl`.
45
+ ///
46
+ /// # References
47
+ /// - [POSIX `tcgetattr`]
48
+ /// - [Linux `ioctl_tty`]
49
+ /// - [Linux `termios`]
50
+ ///
51
+ /// [POSIX `tcgetattr`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcgetattr.html
52
+ /// [Linux `ioctl_tty`]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html
53
+ /// [Linux `termios`]: https://man7.org/linux/man-pages/man3/termios.3.html
54
+ #[ inline]
55
+ #[ doc( alias = "TCGETS2" ) ]
56
+ #[ cfg( all(
57
+ any( target_os = "android" , target_os = "linux" ) ,
58
+ any(
59
+ target_arch = "x86" ,
60
+ target_arch = "x86_64" ,
61
+ target_arch = "x32" ,
62
+ target_arch = "riscv64" ,
63
+ target_arch = "aarch64" ,
64
+ target_arch = "arm" ,
65
+ target_arch = "mips" ,
66
+ target_arch = "mips64" ,
67
+ )
68
+ ) ) ]
69
+ pub fn tcgetattr2 < Fd : AsFd > ( fd : Fd ) -> io:: Result < Termios2 > {
70
+ backend:: termios:: syscalls:: tcgetattr2 ( fd. as_fd ( ) )
71
+ }
72
+
28
73
/// `tcgetwinsize(fd)`—Get the current terminal window size.
29
74
///
30
75
/// Also known as the `TIOCGWINSZ` operation with `ioctl`.
@@ -96,6 +141,41 @@ pub fn tcsetattr<Fd: AsFd>(
96
141
backend:: termios:: syscalls:: tcsetattr ( fd. as_fd ( ) , optional_actions, termios)
97
142
}
98
143
144
+ /// `tcsetattr2(fd)`—Set terminal attributes.
145
+ ///
146
+ /// Also known as the `TCSETS2` operation with `ioctl`.
147
+ ///
148
+ /// # References
149
+ /// - [POSIX `tcsetattr`]
150
+ /// - [Linux `ioctl_tty`]
151
+ /// - [Linux `termios`]
152
+ ///
153
+ /// [POSIX `tcsetattr`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcsetattr.html
154
+ /// [Linux `ioctl_tty`]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html
155
+ /// [Linux `termios`]: https://man7.org/linux/man-pages/man3/termios.3.html
156
+ #[ inline]
157
+ #[ doc( alias = "TCSETS2" ) ]
158
+ #[ cfg( all(
159
+ any( target_os = "android" , target_os = "linux" ) ,
160
+ any(
161
+ target_arch = "x86" ,
162
+ target_arch = "x86_64" ,
163
+ target_arch = "x32" ,
164
+ target_arch = "riscv64" ,
165
+ target_arch = "aarch64" ,
166
+ target_arch = "arm" ,
167
+ target_arch = "mips" ,
168
+ target_arch = "mips64" ,
169
+ )
170
+ ) ) ]
171
+ pub fn tcsetattr2 < Fd : AsFd > (
172
+ fd : Fd ,
173
+ optional_actions : OptionalActions ,
174
+ termios : & Termios2 ,
175
+ ) -> io:: Result < ( ) > {
176
+ backend:: termios:: syscalls:: tcsetattr2 ( fd. as_fd ( ) , optional_actions, termios)
177
+ }
178
+
99
179
/// `tcsendbreak(fd, 0)`—Transmit zero-valued bits.
100
180
///
101
181
/// Also known as the `TCSBRK` operation with `ioctl`, with a duration of 0.
0 commit comments