summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/abi/linux/linux_abi_autogen_unsafe.go4
-rw-r--r--pkg/sentry/kernel/epoll/epoll.go13
-rw-r--r--pkg/sentry/kernel/epoll/epoll_state.go3
-rw-r--r--pkg/waiter/waiter.go18
-rw-r--r--pkg/waiter/waiter_state_autogen.go15
5 files changed, 22 insertions, 31 deletions
diff --git a/pkg/abi/linux/linux_abi_autogen_unsafe.go b/pkg/abi/linux/linux_abi_autogen_unsafe.go
index a4854ebcf..62090b192 100644
--- a/pkg/abi/linux/linux_abi_autogen_unsafe.go
+++ b/pkg/abi/linux/linux_abi_autogen_unsafe.go
@@ -124,7 +124,7 @@ func (s *Statx) UnmarshalBytes(src []byte) {
// Packed implements marshal.Marshallable.Packed.
//go:nosplit
func (s *Statx) Packed() bool {
- return s.Atime.Packed() && s.Btime.Packed() && s.Ctime.Packed() && s.Mtime.Packed()
+ return s.Btime.Packed() && s.Ctime.Packed() && s.Mtime.Packed() && s.Atime.Packed()
}
// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
@@ -204,7 +204,7 @@ func (s *Statx) CopyIn(task marshal.Task, addr usermem.Addr) (int, error) {
// WriteTo implements io.WriterTo.WriteTo.
func (s *Statx) WriteTo(w io.Writer) (int64, error) {
- if !s.Mtime.Packed() && s.Atime.Packed() && s.Btime.Packed() && s.Ctime.Packed() {
+ if !s.Atime.Packed() && s.Btime.Packed() && s.Ctime.Packed() && s.Mtime.Packed() {
// Type Statx doesn't have a packed layout in memory, fall back to MarshalBytes.
buf := make([]byte, s.SizeBytes())
s.MarshalBytes(buf)
diff --git a/pkg/sentry/kernel/epoll/epoll.go b/pkg/sentry/kernel/epoll/epoll.go
index 3d78cd48f..679ab495d 100644
--- a/pkg/sentry/kernel/epoll/epoll.go
+++ b/pkg/sentry/kernel/epoll/epoll.go
@@ -271,11 +271,13 @@ func (e *EventPoll) ReadEvents(max int) []linux.EpollEvent {
// readyCallback is called when one of the files we're polling becomes ready. It
// moves said file to the readyList if it's currently in the waiting list.
-type readyCallback struct{}
+type readyCallback struct {
+ context *pollEntry
+}
// Callback implements waiter.EntryCallback.Callback.
-func (*readyCallback) Callback(w *waiter.Entry) {
- entry := w.Context.(*pollEntry)
+func (r *readyCallback) Callback(*waiter.Entry) {
+ entry := r.context
e := entry.epoll
e.listsMu.Lock()
@@ -310,7 +312,7 @@ func (e *EventPoll) initEntryReadiness(entry *pollEntry) {
// Check if the file happens to already be in a ready state.
ready := f.Readiness(entry.mask) & entry.mask
if ready != 0 {
- (*readyCallback).Callback(nil, &entry.waiter)
+ (&readyCallback{context: entry}).Callback(&entry.waiter)
}
}
@@ -380,10 +382,9 @@ func (e *EventPoll) AddEntry(id FileIdentifier, flags EntryFlags, mask waiter.Ev
userData: data,
epoll: e,
flags: flags,
- waiter: waiter.Entry{Callback: &readyCallback{}},
mask: mask,
}
- entry.waiter.Context = entry
+ entry.waiter.Callback = &readyCallback{context: entry}
e.files[id] = entry
entry.file = refs.NewWeakRef(id.File, entry)
diff --git a/pkg/sentry/kernel/epoll/epoll_state.go b/pkg/sentry/kernel/epoll/epoll_state.go
index 8e9f200d0..02f9aabfa 100644
--- a/pkg/sentry/kernel/epoll/epoll_state.go
+++ b/pkg/sentry/kernel/epoll/epoll_state.go
@@ -21,8 +21,7 @@ import (
// afterLoad is invoked by stateify.
func (p *pollEntry) afterLoad() {
- p.waiter = waiter.Entry{Callback: &readyCallback{}}
- p.waiter.Context = p
+ p.waiter.Callback = &readyCallback{context: p}
p.file = refs.NewWeakRef(p.id.File, p)
p.id.File.EventRegister(&p.waiter, p.mask)
}
diff --git a/pkg/waiter/waiter.go b/pkg/waiter/waiter.go
index 707eb085b..67a950444 100644
--- a/pkg/waiter/waiter.go
+++ b/pkg/waiter/waiter.go
@@ -128,13 +128,6 @@ type EntryCallback interface {
//
// +stateify savable
type Entry struct {
- // Context stores any state the waiter may wish to store in the entry
- // itself, which may be used at wake up time.
- //
- // Note that use of this field is optional and state may alternatively be
- // stored in the callback itself.
- Context interface{}
-
Callback EntryCallback
// The following fields are protected by the queue lock.
@@ -142,13 +135,14 @@ type Entry struct {
waiterEntry
}
-type channelCallback struct{}
+type channelCallback struct {
+ ch chan struct{}
+}
// Callback implements EntryCallback.Callback.
-func (*channelCallback) Callback(e *Entry) {
- ch := e.Context.(chan struct{})
+func (c *channelCallback) Callback(*Entry) {
select {
- case ch <- struct{}{}:
+ case c.ch <- struct{}{}:
default:
}
}
@@ -164,7 +158,7 @@ func NewChannelEntry(c chan struct{}) (Entry, chan struct{}) {
c = make(chan struct{}, 1)
}
- return Entry{Context: c, Callback: &channelCallback{}}, c
+ return Entry{Callback: &channelCallback{ch: c}}, c
}
// Queue represents the wait queue where waiters can be added and
diff --git a/pkg/waiter/waiter_state_autogen.go b/pkg/waiter/waiter_state_autogen.go
index 086f10dbc..2a2321a67 100644
--- a/pkg/waiter/waiter_state_autogen.go
+++ b/pkg/waiter/waiter_state_autogen.go
@@ -12,7 +12,6 @@ func (x *Entry) StateTypeName() string {
func (x *Entry) StateFields() []string {
return []string{
- "Context",
"Callback",
"mask",
"waiterEntry",
@@ -23,19 +22,17 @@ func (x *Entry) beforeSave() {}
func (x *Entry) StateSave(m state.Sink) {
x.beforeSave()
- m.Save(0, &x.Context)
- m.Save(1, &x.Callback)
- m.Save(2, &x.mask)
- m.Save(3, &x.waiterEntry)
+ m.Save(0, &x.Callback)
+ m.Save(1, &x.mask)
+ m.Save(2, &x.waiterEntry)
}
func (x *Entry) afterLoad() {}
func (x *Entry) StateLoad(m state.Source) {
- m.Load(0, &x.Context)
- m.Load(1, &x.Callback)
- m.Load(2, &x.mask)
- m.Load(3, &x.waiterEntry)
+ m.Load(0, &x.Callback)
+ m.Load(1, &x.mask)
+ m.Load(2, &x.waiterEntry)
}
func (x *Queue) StateTypeName() string {