MCPcopy
hub / github.com/google/gvisor / newTestConnection

Function newTestConnection

pkg/sentry/fsimpl/fuse/utils_test.go:51–76  ·  view source on GitHub ↗

newTestConnection creates a fuse connection that the sentry can communicate with and the FD for the server to communicate with.

(system *testutil.System, maxActiveRequests uint64)

Source from the content-addressed store, hash-verified

49// newTestConnection creates a fuse connection that the sentry can communicate with
50// and the FD for the server to communicate with.
51func newTestConnection(system *testutil.System, maxActiveRequests uint64) (*connection, *vfs.FileDescription, error) {
52 fuseDev := &DeviceFD{}
53
54 vd := system.VFS.NewAnonVirtualDentry("fuse")
55 defer vd.DecRef(system.Ctx)
56 if err := fuseDev.vfsfd.Init(fuseDev, linux.O_RDWR, auth.CredentialsFromContext(system.Ctx), vd.Mount(), vd.Dentry(), &vfs.FileDescriptionOptions{}); err != nil {
57 return nil, nil, err
58 }
59
60 fsopts := filesystemOptions{
61 maxActiveRequests: maxActiveRequests,
62 }
63 fuseDev.mu.Lock()
64 conn, err := newFUSEConnection(system.Ctx, fuseDev, &fsopts)
65 if err != nil {
66 return nil, nil, err
67 }
68 fuseDev.conn = conn
69 fuseDev.mu.Unlock()
70
71 // Fake the connection being properly initialized for testing purposes.
72 conn.mu.Lock()
73 conn.connInitSuccess = true
74 conn.mu.Unlock()
75 return conn, &fuseDev.vfsfd, nil
76}
77
78// newTestFilesystem creates a filesystem that the sentry can communicate with
79// and the FD for the server to communicate with.

Callers 5

TestFUSEXattrFunction · 0.70
TestConnectionInitBlockFunction · 0.70
TestConnectionAbortFunction · 0.70
TestFUSECommunicationFunction · 0.70
TestReuseFdFunction · 0.70

Calls 9

CredentialsFromContextFunction · 0.92
newFUSEConnectionFunction · 0.85
NewAnonVirtualDentryMethod · 0.80
DecRefMethod · 0.65
InitMethod · 0.65
MountMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65
DentryMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…