mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
@@ -35,7 +35,6 @@ go_library(
|
||||
"//pkg/sentry/kernel/ipc",
|
||||
"//pkg/sentry/kernel/mq",
|
||||
"//pkg/sentry/vfs",
|
||||
"//pkg/sync",
|
||||
"//pkg/usermem",
|
||||
"//pkg/waiter",
|
||||
],
|
||||
|
||||
@@ -23,18 +23,17 @@ import (
|
||||
"gvisor.dev/gvisor/pkg/sentry/kernel/auth"
|
||||
"gvisor.dev/gvisor/pkg/sentry/kernel/mq"
|
||||
"gvisor.dev/gvisor/pkg/sentry/vfs"
|
||||
"gvisor.dev/gvisor/pkg/sync"
|
||||
)
|
||||
|
||||
// RegistryImpl implements mq.RegistryImpl. It implements the interface using
|
||||
// the message queue filesystem, and is provided to mq.Registry at
|
||||
// initialization.
|
||||
//
|
||||
// RegistryImpl is not thread-safe, so it is the responsibility of the user
|
||||
// (the containing mq.Registry) to protect using a lock.
|
||||
//
|
||||
// +stateify savable
|
||||
type RegistryImpl struct {
|
||||
// mu protects all fields below.
|
||||
mu sync.Mutex
|
||||
|
||||
// root is the root dentry of the mq filesystem. Its main usage is to
|
||||
// retreive the root inode, which we use to add, remove, and lookup message
|
||||
// queues.
|
||||
@@ -82,9 +81,6 @@ func NewRegistryImpl(ctx context.Context, vfsObj *vfs.VirtualFilesystem, creds *
|
||||
|
||||
// Get implements mq.RegistryImpl.Get.
|
||||
func (r *RegistryImpl) Get(ctx context.Context, name string, access mq.AccessType, block bool, flags uint32) (*vfs.FileDescription, bool, error) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
inode, err := r.lookup(ctx, name)
|
||||
if err != nil {
|
||||
return nil, false, nil
|
||||
@@ -106,9 +102,6 @@ func (r *RegistryImpl) Get(ctx context.Context, name string, access mq.AccessTyp
|
||||
|
||||
// New implements mq.RegistryImpl.New.
|
||||
func (r *RegistryImpl) New(ctx context.Context, name string, q *mq.Queue, access mq.AccessType, block bool, perm linux.FileMode, flags uint32) (*vfs.FileDescription, error) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
root := r.root.Inode().(*rootInode)
|
||||
qInode := r.fs.newQueueInode(ctx, auth.CredentialsFromContext(ctx), q, perm).(*queueInode)
|
||||
err := root.Insert(name, qInode)
|
||||
@@ -120,9 +113,6 @@ func (r *RegistryImpl) New(ctx context.Context, name string, q *mq.Queue, access
|
||||
|
||||
// Unlink implements mq.RegistryImpl.Unlink.
|
||||
func (r *RegistryImpl) Unlink(ctx context.Context, name string) error {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
creds := auth.CredentialsFromContext(ctx)
|
||||
if err := r.root.Inode().CheckPermissions(ctx, creds, vfs.MayWrite|vfs.MayExec); err != nil {
|
||||
return err
|
||||
@@ -142,8 +132,6 @@ func (r *RegistryImpl) Destroy(ctx context.Context) {
|
||||
}
|
||||
|
||||
// lookup retreives a kernfs.Inode using a name.
|
||||
//
|
||||
// Precondition: r.mu must be held.
|
||||
func (r *RegistryImpl) lookup(ctx context.Context, name string) (kernfs.Inode, error) {
|
||||
inode := r.root.Inode().(*rootInode)
|
||||
lookup, err := inode.Lookup(ctx, name)
|
||||
|
||||
Reference in New Issue
Block a user