diff options
author | Bhasker Hariharan <bhaskerh@google.com> | 2021-03-24 12:08:24 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-03-24 12:11:44 -0700 |
commit | e7ca2a51a89a8ff2c9f5adfdfa5b51be1b3faeb3 (patch) | |
tree | 1abf748d2755526978f560abb67f29b6f83496c7 /pkg/sentry/fs | |
parent | 72ff6a1cac6ab35132b4f79b1149590e103e5291 (diff) |
Add POLLRDNORM/POLLWRNORM support.
On Linux these are meant to be equivalent to POLLIN/POLLOUT. Rather
than hack these on in sys_poll etc it felt cleaner to just cleanup
the call sites to notify for both events. This is what linux does
as well.
Fixes #5544
PiperOrigin-RevId: 364859977
Diffstat (limited to 'pkg/sentry/fs')
-rw-r--r-- | pkg/sentry/fs/host/socket.go | 4 | ||||
-rw-r--r-- | pkg/sentry/fs/host/wait_test.go | 4 | ||||
-rw-r--r-- | pkg/sentry/fs/inotify.go | 4 | ||||
-rw-r--r-- | pkg/sentry/fs/timerfd/timerfd.go | 4 | ||||
-rw-r--r-- | pkg/sentry/fs/tty/line_discipline.go | 16 | ||||
-rw-r--r-- | pkg/sentry/fs/tty/queue.go | 4 |
6 files changed, 18 insertions, 18 deletions
diff --git a/pkg/sentry/fs/host/socket.go b/pkg/sentry/fs/host/socket.go index f2d96d1ec..0b3d0617f 100644 --- a/pkg/sentry/fs/host/socket.go +++ b/pkg/sentry/fs/host/socket.go @@ -248,7 +248,7 @@ func (c *ConnectedEndpoint) Writable() bool { c.mu.RLock() defer c.mu.RUnlock() - return fdnotifier.NonBlockingPoll(int32(c.file.FD()), waiter.EventOut)&waiter.EventOut != 0 + return fdnotifier.NonBlockingPoll(int32(c.file.FD()), waiter.WritableEvents)&waiter.WritableEvents != 0 } // Passcred implements transport.ConnectedEndpoint.Passcred. @@ -345,7 +345,7 @@ func (c *ConnectedEndpoint) Readable() bool { c.mu.RLock() defer c.mu.RUnlock() - return fdnotifier.NonBlockingPoll(int32(c.file.FD()), waiter.EventIn)&waiter.EventIn != 0 + return fdnotifier.NonBlockingPoll(int32(c.file.FD()), waiter.ReadableEvents)&waiter.ReadableEvents != 0 } // SendQueuedSize implements transport.Receiver.SendQueuedSize. diff --git a/pkg/sentry/fs/host/wait_test.go b/pkg/sentry/fs/host/wait_test.go index 5925c85ea..bd6188e03 100644 --- a/pkg/sentry/fs/host/wait_test.go +++ b/pkg/sentry/fs/host/wait_test.go @@ -41,13 +41,13 @@ func TestWait(t *testing.T) { defer file.DecRef(ctx) - r := file.Readiness(waiter.EventIn) + r := file.Readiness(waiter.ReadableEvents) if r != 0 { t.Fatalf("File is ready for read when it shouldn't be.") } e, ch := waiter.NewChannelEntry(nil) - file.EventRegister(&e, waiter.EventIn) + file.EventRegister(&e, waiter.ReadableEvents) defer file.EventUnregister(&e) // Check that there are no notifications yet. diff --git a/pkg/sentry/fs/inotify.go b/pkg/sentry/fs/inotify.go index c5c07d564..fb81d903d 100644 --- a/pkg/sentry/fs/inotify.go +++ b/pkg/sentry/fs/inotify.go @@ -107,7 +107,7 @@ func (i *Inotify) Readiness(mask waiter.EventMask) waiter.EventMask { defer i.evMu.Unlock() if !i.events.Empty() { - ready |= waiter.EventIn + ready |= waiter.ReadableEvents } return mask & ready @@ -246,7 +246,7 @@ func (i *Inotify) queueEvent(ev *Event) { // can do. i.evMu.Unlock() - i.Queue.Notify(waiter.EventIn) + i.Queue.Notify(waiter.ReadableEvents) } // newWatchLocked creates and adds a new watch to target. diff --git a/pkg/sentry/fs/timerfd/timerfd.go b/pkg/sentry/fs/timerfd/timerfd.go index f362ca9b6..46511a6ac 100644 --- a/pkg/sentry/fs/timerfd/timerfd.go +++ b/pkg/sentry/fs/timerfd/timerfd.go @@ -101,7 +101,7 @@ func (t *TimerOperations) SetTime(s ktime.Setting) (ktime.Time, ktime.Setting) { func (t *TimerOperations) Readiness(mask waiter.EventMask) waiter.EventMask { var ready waiter.EventMask if atomic.LoadUint64(&t.val) != 0 { - ready |= waiter.EventIn + ready |= waiter.ReadableEvents } return ready } @@ -143,7 +143,7 @@ func (t *TimerOperations) Write(context.Context, *fs.File, usermem.IOSequence, i // Notify implements ktime.TimerListener.Notify. func (t *TimerOperations) Notify(exp uint64, setting ktime.Setting) (ktime.Setting, bool) { atomic.AddUint64(&t.val, exp) - t.events.Notify(waiter.EventIn) + t.events.Notify(waiter.ReadableEvents) return ktime.Setting{}, false } diff --git a/pkg/sentry/fs/tty/line_discipline.go b/pkg/sentry/fs/tty/line_discipline.go index b34f4a0eb..3ba02c218 100644 --- a/pkg/sentry/fs/tty/line_discipline.go +++ b/pkg/sentry/fs/tty/line_discipline.go @@ -143,7 +143,7 @@ func (l *lineDiscipline) setTermios(task *kernel.Task, args arch.SyscallArgument l.inQueue.pushWaitBufLocked(l) l.inQueue.readable = true l.inQueue.mu.Unlock() - l.replicaWaiter.Notify(waiter.EventIn) + l.replicaWaiter.Notify(waiter.ReadableEvents) } return 0, err @@ -187,9 +187,9 @@ func (l *lineDiscipline) inputQueueRead(ctx context.Context, dst usermem.IOSeque return 0, err } if n > 0 { - l.masterWaiter.Notify(waiter.EventOut) + l.masterWaiter.Notify(waiter.WritableEvents) if pushed { - l.replicaWaiter.Notify(waiter.EventIn) + l.replicaWaiter.Notify(waiter.ReadableEvents) } return n, nil } @@ -204,7 +204,7 @@ func (l *lineDiscipline) inputQueueWrite(ctx context.Context, src usermem.IOSequ return 0, err } if n > 0 { - l.replicaWaiter.Notify(waiter.EventIn) + l.replicaWaiter.Notify(waiter.ReadableEvents) return n, nil } return 0, syserror.ErrWouldBlock @@ -222,9 +222,9 @@ func (l *lineDiscipline) outputQueueRead(ctx context.Context, dst usermem.IOSequ return 0, err } if n > 0 { - l.replicaWaiter.Notify(waiter.EventOut) + l.replicaWaiter.Notify(waiter.WritableEvents) if pushed { - l.masterWaiter.Notify(waiter.EventIn) + l.masterWaiter.Notify(waiter.ReadableEvents) } return n, nil } @@ -239,7 +239,7 @@ func (l *lineDiscipline) outputQueueWrite(ctx context.Context, src usermem.IOSeq return 0, err } if n > 0 { - l.masterWaiter.Notify(waiter.EventIn) + l.masterWaiter.Notify(waiter.ReadableEvents) return n, nil } return 0, syserror.ErrWouldBlock @@ -399,7 +399,7 @@ func (*inputQueueTransformer) transform(l *lineDiscipline, q *queue, buf []byte) // Anything written to the readBuf will have to be echoed. if l.termios.LEnabled(linux.ECHO) { l.outQueue.writeBytes(cBytes, l) - l.masterWaiter.Notify(waiter.EventIn) + l.masterWaiter.Notify(waiter.ReadableEvents) } // If we finish a line, make it available for reading. diff --git a/pkg/sentry/fs/tty/queue.go b/pkg/sentry/fs/tty/queue.go index 79975d812..11d6c15d0 100644 --- a/pkg/sentry/fs/tty/queue.go +++ b/pkg/sentry/fs/tty/queue.go @@ -71,7 +71,7 @@ func (q *queue) readReadiness(t *linux.KernelTermios) waiter.EventMask { q.mu.Lock() defer q.mu.Unlock() if len(q.readBuf) > 0 && q.readable { - return waiter.EventIn + return waiter.ReadableEvents } return waiter.EventMask(0) } @@ -81,7 +81,7 @@ func (q *queue) writeReadiness(t *linux.KernelTermios) waiter.EventMask { q.mu.Lock() defer q.mu.Unlock() if q.waitBufLen < waitBufMaxBytes { - return waiter.EventOut + return waiter.WritableEvents } return waiter.EventMask(0) } |