sentry: Adds canonical mode support.

PiperOrigin-RevId: 196331627
Change-Id: Ifef4485f8202c52481af317cedd52d2ef48cea6a
This commit is contained in:
Kevin Krakauer
2018-05-11 17:19:46 -07:00
committed by Shentubot
parent 987f7841a6
commit 08879266fe
4 changed files with 300 additions and 92 deletions
+28
View File
@@ -14,9 +14,16 @@
package linux
import (
"unicode/utf8"
)
const (
// NumControlCharacters is the number of control characters in Termios.
NumControlCharacters = 19
// disabledChar is used to indicate that a control character is
// disabled.
disabledChar = 0
)
// Termios is struct termios, defined in uapi/asm-generic/termbits.h.
@@ -86,6 +93,27 @@ func (t *KernelTermios) FromTermios(term Termios) {
t.ControlCharacters = term.ControlCharacters
}
// IsTerminating returns whether c is a line terminating character.
func (t *KernelTermios) IsTerminating(c rune) bool {
if t.IsEOF(c) {
return true
}
switch byte(c) {
case disabledChar:
return false
case '\n', t.ControlCharacters[VEOL]:
return true
case t.ControlCharacters[VEOL2]:
return t.LEnabled(IEXTEN)
}
return false
}
// IsEOF returns whether c is the EOF character.
func (t *KernelTermios) IsEOF(c rune) bool {
return utf8.RuneLen(c) == 1 && byte(c) == t.ControlCharacters[VEOF] && t.ControlCharacters[VEOF] != disabledChar
}
// Input flags.
const (
IGNBRK = 0000001
File diff suppressed because it is too large Load Diff
+3
View File
@@ -148,6 +148,9 @@ func (mf *masterFileOperations) Write(ctx context.Context, _ *fs.File, src userm
// Ioctl implements fs.FileOperations.Ioctl.
func (mf *masterFileOperations) Ioctl(ctx context.Context, io usermem.IO, args arch.SyscallArguments) (uintptr, error) {
switch args[1].Uint() {
case linux.FIONREAD: // linux.FIONREAD == linux.TIOCINQ
// Get the number of bytes in the output queue read buffer.
return 0, mf.t.ld.outputQueueReadSize(ctx, io, args)
case linux.TCGETS:
// N.B. TCGETS on the master actually returns the configuration
// of the slave end.
+3
View File
@@ -133,6 +133,9 @@ func (sf *slaveFileOperations) Write(ctx context.Context, _ *fs.File, src userme
// Ioctl implements fs.FileOperations.Ioctl.
func (sf *slaveFileOperations) Ioctl(ctx context.Context, io usermem.IO, args arch.SyscallArguments) (uintptr, error) {
switch args[1].Uint() {
case linux.FIONREAD: // linux.FIONREAD == linux.TIOCINQ
// Get the number of bytes in the input queue read buffer.
return 0, sf.si.t.ld.inputQueueReadSize(ctx, io, args)
case linux.TCGETS:
return sf.si.t.ld.getTermios(ctx, io, args)
case linux.TCSETS: