summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/kernel/ipc_namespace.go
diff options
context:
space:
mode:
authorZyad A. Ali <zyad.ali.me@gmail.com>2021-07-29 17:33:45 +0200
committerZyad A. Ali <zyad.ali.me@gmail.com>2021-09-28 20:43:47 +0200
commit229c01552e2b819c2fa6bf1f5aa017cff366869e (patch)
tree9415551dea5e460433380aabb2fc381b04045ca4 /pkg/sentry/kernel/ipc_namespace.go
parentbcef079ec24d56d37a670c4c4149c638be6fb110 (diff)
Move filesystem creation from GetFilesystem to RegistryImpl.
Move root dentry and filesystem creation from GetFilesystem to NewRegistryImpl, create IPCNamespace.InitPosixQueues to create a new mqueue filesystem for each ipc namespace, and update GetFilesystem to retreive fs and root dentry from IPCNamespace and return them. Updates #136
Diffstat (limited to 'pkg/sentry/kernel/ipc_namespace.go')
-rw-r--r--pkg/sentry/kernel/ipc_namespace.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/pkg/sentry/kernel/ipc_namespace.go b/pkg/sentry/kernel/ipc_namespace.go
index aa9c3fb31..11b4545c6 100644
--- a/pkg/sentry/kernel/ipc_namespace.go
+++ b/pkg/sentry/kernel/ipc_namespace.go
@@ -15,12 +15,16 @@
package kernel
import (
+ "fmt"
+
"gvisor.dev/gvisor/pkg/context"
+ "gvisor.dev/gvisor/pkg/sentry/fsimpl/mqfs"
"gvisor.dev/gvisor/pkg/sentry/kernel/auth"
"gvisor.dev/gvisor/pkg/sentry/kernel/mq"
"gvisor.dev/gvisor/pkg/sentry/kernel/msgqueue"
"gvisor.dev/gvisor/pkg/sentry/kernel/semaphore"
"gvisor.dev/gvisor/pkg/sentry/kernel/shm"
+ "gvisor.dev/gvisor/pkg/sentry/vfs"
)
// IPCNamespace represents an IPC namespace.
@@ -72,12 +76,19 @@ func (i *IPCNamespace) ShmRegistry() *shm.Registry {
return i.shms
}
-// SetPosixQueues sets value of posixQueues if the value is currently nil,
-// otherwise returns without doing anything.
-func (i *IPCNamespace) SetPosixQueues(r *mq.Registry) {
- if i.posixQueues == nil {
- i.posixQueues = r
+// InitPosixQueues creates a new POSIX queue registry, and returns an error if
+// the registry was previously initialized.
+func (i *IPCNamespace) InitPosixQueues(ctx context.Context, vfsObj *vfs.VirtualFilesystem, creds *auth.Credentials) error {
+ if i.posixQueues != nil {
+ return fmt.Errorf("IPCNamespace.InitPosixQueues: already initialized")
+ }
+
+ impl, err := mqfs.NewRegistryImpl(ctx, vfsObj, creds)
+ if err != nil {
+ return err
}
+ i.posixQueues = mq.NewRegistry(impl)
+ return nil
}
// PosixQueues returns the posix message queue registry for this namespace.