unix: Fix Termios type definition
- types_linux.go: Use the kernel-defined termios structure, *not* the
LIBC-defined one. The LIBC termios structure cannot be safely used
to do tty-related ioctls on all architectures (e.g. ppc64,
ppc64le). The kernel termios structure, and the associated
macros/constants, are defined in: "asm/termbits.h" which is included
by "linux/termios.h". The LIBC termios structure is defined in
"bits/termios.h" which is included by "termios.h". These structures
are *not* the same.
For systems that have both "struct termios" and "struct termios2"
use the latter to define the Termios type. This is ok, since the
"struct termios2" memory layout is compatible with "struct termios"
(with a couple of fields added at the end). This way, type Termios
can be used with both: the "old-style" TCSETS[FW], TCGETS ioctls,
*and* with the new TCSETS[FW]2, TCGETS2 ioctls. The new ioctls allow
configuring arbitrary baudrates.
The new Termios definitions (kernel-compatible) have the same fields
as the old ones (LIBC-derived) so there should be no user-code
compatibility issues.
Change-Id: I3c1484c60f45b28e13404765c01616c33063afd5
Reviewed-on: https://go-review.googlesource.com/17185
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/unix/ztypes_linux_ppc64le.go b/unix/ztypes_linux_ppc64le.go
index d4a689f..22c96a2 100644
--- a/unix/ztypes_linux_ppc64le.go
+++ b/unix/ztypes_linux_ppc64le.go
@@ -1,8 +1,7 @@
+// +build ppc64le,linux
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs types_linux.go
-// +build ppc64le,linux
-
package unix
const (
@@ -595,13 +594,12 @@
)
type Termios struct {
- Iflag uint32
- Oflag uint32
- Cflag uint32
- Lflag uint32
- Line uint8
- Cc [32]uint8
- Pad_cgo_0 [3]byte
- Ispeed uint32
- Ospeed uint32
+ Iflag uint32
+ Oflag uint32
+ Cflag uint32
+ Lflag uint32
+ Cc [19]uint8
+ Line uint8
+ Ispeed uint32
+ Ospeed uint32
}