(t *kernel.Task, family int, skType linux.SockType, protocol int, notifier *Notifier, fd int, flags uint32)
| 71 | ) |
| 72 | |
| 73 | func 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. |
| 111 | func (s *socketOperations) Bind(t *kernel.Task, sockaddr []byte) *syserr.Error { |
no test coverage detected
searching dependent graphs…