New creates a new endpoint socket.
(t *kernel.Task, family int, skType linux.SockType, protocol int, queue *waiter.Queue, endpoint tcpip.Endpoint)
| 461 | |
| 462 | // New creates a new endpoint socket. |
| 463 | func New(t *kernel.Task, family int, skType linux.SockType, protocol int, queue *waiter.Queue, endpoint tcpip.Endpoint) (*vfs.FileDescription, *syserr.Error) { |
| 464 | if skType == linux.SOCK_STREAM { |
| 465 | endpoint.SocketOptions().SetDelayOption(true) |
| 466 | } |
| 467 | |
| 468 | mnt := t.Kernel().SocketMount() |
| 469 | d := sockfs.NewDentry(t, mnt) |
| 470 | defer d.DecRef(t) |
| 471 | |
| 472 | namespace := t.NetworkNamespace() |
| 473 | s := &sock{ |
| 474 | Queue: queue, |
| 475 | family: family, |
| 476 | Endpoint: endpoint, |
| 477 | skType: skType, |
| 478 | protocol: protocol, |
| 479 | namespace: namespace, |
| 480 | } |
| 481 | s.LockFD.Init(&vfs.FileLocks{}) |
| 482 | vfsfd := &s.vfsfd |
| 483 | if err := vfsfd.Init(s, linux.O_RDWR, t.Credentials(), mnt, d, &vfs.FileDescriptionOptions{ |
| 484 | DenyPRead: true, |
| 485 | DenyPWrite: true, |
| 486 | UseDentryMetadata: true, |
| 487 | }); err != nil { |
| 488 | return nil, syserr.FromError(err) |
| 489 | } |
| 490 | namespace.IncRef() |
| 491 | return vfsfd, nil |
| 492 | } |
| 493 | |
| 494 | // Release implements vfs.FileDescriptionImpl.Release. |
| 495 | func (s *sock) Release(ctx context.Context) { |
no test coverage detected