func open(name string) (p *port, err error) { fd, err := poller.Open(name, poller.O_RW) if err != nil { return nil, newErr("open: " + err.Error()) } if err := fd.Lock(); err != nil { return nil, ErrClosed } defer fd.Unlock() // Get attributes var tiosOrig termios.Termios err = tiosOrig.GetFd(fd.Sysfd()) if err != nil { return nil, newErr("tcgetattr: " + err.Error()) } // ?? Set HUPCL ?? // tiosOrig.CFlag().Set(termios.HUPCL) // err = tiosOrig.SetFd(fd.Sysfd(), termios.TCSANOW) // if err != nil { // return nil, newErr("tcsetattr: " + err.Error()) // } noReset := !tiosOrig.CFlag().Any(termios.HUPCL) // Set raw mode tios := tiosOrig tios.MakeRaw() err = tios.SetFd(fd.Sysfd(), termios.TCSANOW) if err != nil { return nil, newErr("tcsetattr: " + err.Error()) } return &port{fd: fd, origTermios: tiosOrig, noReset: noReset}, nil }
func openFifo(t *testing.T, i int, read bool) *poller.FD { name := fifoName(i) flags := poller.O_RO if !read { flags = poller.O_WO } fd, err := poller.Open(name, flags) if err != nil { t.Fatalf("Open %s: %v", name, err) } return fd }
// NewLoggerReader returns a new LoggerReader reading from the log stream // identified by id. If abiExtension is not nil it is used to parse additional fields from // a buffer read from Android's logging facilities. // // Returns an error if accessing the underlying Android log facilities fails. func NewLoggerReader(id LogId, abiExtension LoggerAbiExtension) (*LoggerReader, error) { fn := filepath.Join("/dev", "alog", id.String()) p, err := poller.Open(fn, poller.O_RO) if err != nil { return nil, err } p.Lock() defer p.Unlock() if abiExtension != nil { if err = requestExtendedLoggerAbi(p.Sysfd()); err != nil { return nil, err } } return &LoggerReader{abiExtension: abiExtension, f: p, buf: make([]byte, maxEntrySize, maxEntrySize)}, nil }