summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/fsimpl/mqfs/queue.go4
-rw-r--r--pkg/sentry/kernel/mq/mq.go19
2 files changed, 18 insertions, 5 deletions
diff --git a/pkg/sentry/fsimpl/mqfs/queue.go b/pkg/sentry/fsimpl/mqfs/queue.go
index a8e9bc722..933dbc6ed 100644
--- a/pkg/sentry/fsimpl/mqfs/queue.go
+++ b/pkg/sentry/fsimpl/mqfs/queue.go
@@ -65,8 +65,8 @@ type queueFD struct {
vfsfd vfs.FileDescription
inode kernfs.Inode
- // queue is the queue backing this fd.
- queue *mq.Queue
+ // queue is a view into the queue backing this fd.
+ queue mq.View
}
// Init initializes a queueFD. Mostly copied from DynamicBytesFD.Init, but uses
diff --git a/pkg/sentry/kernel/mq/mq.go b/pkg/sentry/kernel/mq/mq.go
index 739ea2f1c..954883c5f 100644
--- a/pkg/sentry/kernel/mq/mq.go
+++ b/pkg/sentry/kernel/mq/mq.go
@@ -129,6 +129,21 @@ type Queue struct {
byteCount uint64
}
+// View is a view into a message queue. Views should only be used in file
+// descriptions, but not inodes, because we use inodes to retreive the actual
+// queue, and only FDs are responsible for providing user functionality.
+type View interface {
+ // TODO: Add Send and Receive when mq_timedsend(2) and mq_timedreceive(2)
+ // are implemented.
+
+ // Flush checks if the calling process has attached a notification request
+ // to this queue, if yes, then the request is removed, and another process
+ // can attach a request.
+ Flush(ctx context.Context)
+
+ waiter.Waitable
+}
+
// Message holds a message exchanged through a Queue via mq_timedsend(2) and
// mq_timedreceive(2), and additional info relating to the message.
//
@@ -179,9 +194,7 @@ func (q *Queue) Generate(ctx context.Context, buf *bytes.Buffer) error {
return nil
}
-// Flush checks if the calling process has attached a notification request to
-// this queue, if yes, then the request is removed, and another process can
-// attach a request.
+// Flush implements View.Flush.
func (q *Queue) Flush(ctx context.Context) {
q.mu.Lock()
defer q.mu.Unlock()