MCPcopy Index your code
hub / github.com/google/gvisor / newSocket

Function newSocket

pkg/sentry/socket/plugin/stack/socket.go:73–108  ·  view source on GitHub ↗
(t *kernel.Task, family int, skType linux.SockType, protocol int, notifier *Notifier, fd int, flags uint32)

Source from the content-addressed store, hash-verified

71)
72
73func newSocket(t *kernel.Task, family int, skType linux.SockType, protocol int, notifier *Notifier, fd int, flags uint32) (*vfs.FileDescription, *syserr.Error) {
74 mnt := t.Kernel().SocketMount()
75 d := sockfs.NewDentry(t, mnt)
76 defer d.DecRef(t)
77
78 switch skType {
79 case syscall.SOCK_STREAM:
80 case syscall.SOCK_DGRAM:
81 default:
82 return nil, syserr.ErrSocketNotSupported
83 }
84
85 wq := &waiter.Queue{}
86 sop := &socketOperations{
87 family: family,
88 fd: uint32(fd),
89 protocol: protocol,
90 skType: skType,
91 eventInfo: plugin.EventInfo{Wq: wq},
92 }
93
94 sop.LockFD.Init(&vfs.FileLocks{})
95
96 vfsfd := &sop.vfsfd
97 if err := vfsfd.Init(sop, linux.O_RDWR|(flags&linux.O_NONBLOCK), t.Credentials(), mnt, d, &vfs.FileDescriptionOptions{
98 DenyPRead: true,
99 DenyPWrite: true,
100 UseDentryMetadata: true,
101 }); err != nil {
102 return nil, syserr.FromError(err)
103 }
104
105 notifier.AddFD(uint32(fd), &sop.eventInfo)
106
107 return vfsfd, nil
108}
109
110// Bind implements socket.Socket.Bind.
111func (s *socketOperations) Bind(t *kernel.Task, sockaddr []byte) *syserr.Error {

Callers 2

SocketMethod · 0.70
AcceptMethod · 0.70

Calls 8

DecRefMethod · 0.95
NewDentryFunction · 0.92
FromErrorFunction · 0.92
SocketMountMethod · 0.80
KernelMethod · 0.80
InitMethod · 0.65
CredentialsMethod · 0.65
AddFDMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…