Documentation ¶
Overview ¶
Package unix provides an implementation of the socket.Socket interface for the AF_UNIX protocol family.
Index ¶
- func AddressAndFamily(addr []byte) (transport.Address, uint16, *syserr.Error)
- func NewFileDescription(ep transport.Endpoint, stype linux.SockType, flags uint32, ns *inet.Namespace, ...) (*vfs.FileDescription, error)
- func NewSockfsFile(t *kernel.Task, ep transport.Endpoint, stype linux.SockType) (*vfs.FileDescription, *syserr.Error)
- type EndpointReader
- type EndpointWriter
- type Socket
- func (s *Socket) Accept(t *kernel.Task, peerRequested bool, flags int, blocking bool) (int32, linux.SockAddr, uint32, *syserr.Error)
- func (s *Socket) Bind(t *kernel.Task, sockaddr []byte) *syserr.Error
- func (s *Socket) Connect(t *kernel.Task, sockaddr []byte, blocking bool) *syserr.Error
- func (s *Socket) ConnectedPasscred() bool
- func (s *Socket) DecRef(ctx context.Context)
- func (s *Socket) Endpoint() transport.Endpoint
- func (s *Socket) Epollable() bool
- func (s *Socket) EventRegister(e *waiter.Entry) error
- func (s *Socket) EventUnregister(e *waiter.Entry)
- func (s *Socket) GetPeerName(t *kernel.Task) (linux.SockAddr, uint32, *syserr.Error)
- func (s *Socket) GetSockName(t *kernel.Task) (linux.SockAddr, uint32, *syserr.Error)
- func (s *Socket) GetSockOpt(t *kernel.Task, level, name int, outPtr hostarch.Addr, outLen int) (marshal.Marshallable, *syserr.Error)
- func (r *Socket) IncRef()
- func (r *Socket) InitRefs()
- func (s *Socket) Ioctl(ctx context.Context, uio usermem.IO, sysno uintptr, args arch.SyscallArguments) (uintptr, error)
- func (r *Socket) LeakMessage() string
- func (s *Socket) Listen(t *kernel.Task, backlog int) *syserr.Error
- func (r *Socket) LogRefs() bool
- func (s *Socket) PRead(ctx context.Context, dst usermem.IOSequence, offset int64, ...) (int64, error)
- func (s *Socket) PWrite(ctx context.Context, src usermem.IOSequence, offset int64, ...) (int64, error)
- func (s *Socket) Passcred() bool
- func (s *Socket) Read(ctx context.Context, dst usermem.IOSequence, opts vfs.ReadOptions) (int64, error)
- func (r *Socket) ReadRefs() int64
- func (s *Socket) Readiness(mask waiter.EventMask) waiter.EventMask
- func (s *Socket) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags int, haveDeadline bool, ...) (n int, msgFlags int, senderAddr linux.SockAddr, senderAddrLen uint32, ...)
- func (r *Socket) RefType() string
- func (s *Socket) Release(ctx context.Context)
- func (s *Socket) SendMsg(t *kernel.Task, src usermem.IOSequence, to []byte, flags int, ...) (int, *syserr.Error)
- func (s *Socket) SetSockOpt(t *kernel.Task, level int, name int, optVal []byte) *syserr.Error
- func (s *Socket) Shutdown(t *kernel.Task, how int) *syserr.Error
- func (s *Socket) State() uint32
- func (s *Socket) StateFields() []string
- func (s *Socket) StateLoad(ctx context.Context, stateSourceObject state.Source)
- func (s *Socket) StateSave(stateSinkObject state.Sink)
- func (s *Socket) StateTypeName() string
- func (r *Socket) TryIncRef() bool
- func (s *Socket) Type() (family int, skType linux.SockType, protocol int)
- func (s *Socket) Write(ctx context.Context, src usermem.IOSequence, opts vfs.WriteOptions) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddressAndFamily ¶
AddressAndFamily converts the addr byte slice to a transport.Address and family. It supports only AF_UNIX addresses.
func NewFileDescription ¶
func NewFileDescription(ep transport.Endpoint, stype linux.SockType, flags uint32, ns *inet.Namespace, mnt *vfs.Mount, d *vfs.Dentry, locks *vfs.FileLocks) (*vfs.FileDescription, error)
NewFileDescription creates and returns a socket file description corresponding to the given mount and dentry.
Types ¶
type EndpointReader ¶
type EndpointReader struct { Ctx context.Context // Endpoint is the transport.Endpoint to read from. Endpoint transport.Endpoint // Creds indicates if credential control messages are requested. Creds bool // NumRights is the number of SCM_RIGHTS FDs requested. NumRights int // Peek indicates that the data should not be consumed from the // endpoint. Peek bool // MsgSize is the size of the message that was read from. For stream // sockets, it is the amount read. MsgSize int64 // From will be set with the address read from. From transport.Address // Control contains the received control messages. Control transport.ControlMessages // UnusedRights is a slice of unused RightsControlMessage that must be // Release()d before this EndpointReader is discarded. UnusedRights []transport.RightsControlMessage // ControlTrunc indicates that SCM_RIGHTS FDs were discarded based on // the value of NumRights. ControlTrunc bool // Notify is the ConnectedEndpoint.RecvNotify callback that is set by // ReadToBlocks and should be called without mm.activeMu held (i.e. // after CopyIn completes). Notify func() }
EndpointReader implements safemem.Reader that reads from a transport.Endpoint.
EndpointReader is not thread-safe.
func (*EndpointReader) ReadToBlocks ¶
func (r *EndpointReader) ReadToBlocks(dsts safemem.BlockSeq) (uint64, error)
ReadToBlocks implements safemem.Reader.ReadToBlocks.
func (*EndpointReader) Truncate ¶
func (r *EndpointReader) Truncate() error
Truncate calls RecvMsg on the endpoint without writing to a destination.
type EndpointWriter ¶
type EndpointWriter struct { Ctx context.Context // Endpoint is the transport.Endpoint to write to. Endpoint transport.Endpoint // Control is the control messages to send. Control transport.ControlMessages // To is the endpoint to send to. May be nil. To transport.BoundEndpoint // Notify is the receiver.SendNotify notification callback that is set // by WriteFromBlocks and should be called without mm.activeMu held // (i.e. after CopyOut completes). Notify func() }
EndpointWriter implements safemem.Writer that writes to a transport.Endpoint.
EndpointWriter is not thread-safe.
func (*EndpointWriter) WriteFromBlocks ¶
func (w *EndpointWriter) WriteFromBlocks(srcs safemem.BlockSeq) (uint64, error)
WriteFromBlocks implements safemem.Writer.WriteFromBlocks.
type Socket ¶
type Socket struct { vfs.FileDescriptionDefaultImpl vfs.DentryMetadataFileDescriptionImpl vfs.LockFD socket.SendReceiveTimeout // contains filtered or unexported fields }
Socket implements socket.Socket (and by extension, vfs.FileDescriptionImpl) for Unix sockets.
+stateify savable
func (*Socket) Accept ¶
func (s *Socket) Accept(t *kernel.Task, peerRequested bool, flags int, blocking bool) (int32, linux.SockAddr, uint32, *syserr.Error)
Accept implements the linux syscall accept(2) for sockets backed by a transport.Endpoint.
func (*Socket) ConnectedPasscred ¶
ConnectedPasscred implements transport.Credentialer.ConnectedPasscred.
func (*Socket) EventRegister ¶
EventRegister implements waiter.Waitable.EventRegister.
func (*Socket) EventUnregister ¶
EventUnregister implements waiter.Waitable.EventUnregister.
func (*Socket) GetPeerName ¶
GetPeerName implements the linux syscall getpeername(2) for sockets backed by a transport.Endpoint.
func (*Socket) GetSockName ¶
GetSockName implements the linux syscall getsockname(2) for sockets backed by a transport.Endpoint.
func (*Socket) GetSockOpt ¶
func (s *Socket) GetSockOpt(t *kernel.Task, level, name int, outPtr hostarch.Addr, outLen int) (marshal.Marshallable, *syserr.Error)
GetSockOpt implements the linux syscall getsockopt(2) for sockets backed by a transport.Endpoint.
func (*Socket) InitRefs ¶
func (r *Socket) InitRefs()
InitRefs initializes r with one reference and, if enabled, activates leak checking.
func (*Socket) Ioctl ¶
func (s *Socket) Ioctl(ctx context.Context, uio usermem.IO, sysno uintptr, args arch.SyscallArguments) (uintptr, error)
Ioctl implements vfs.FileDescriptionImpl.
func (*Socket) LeakMessage ¶
func (r *Socket) LeakMessage() string
LeakMessage implements refs.CheckedObject.LeakMessage.
func (*Socket) Listen ¶
Listen implements the linux syscall listen(2) for sockets backed by a transport.Endpoint.
func (*Socket) LogRefs ¶
func (r *Socket) LogRefs() bool
LogRefs implements refs.CheckedObject.LogRefs.
func (*Socket) PRead ¶
func (s *Socket) PRead(ctx context.Context, dst usermem.IOSequence, offset int64, opts vfs.ReadOptions) (int64, error)
PRead implements vfs.FileDescriptionImpl.
func (*Socket) PWrite ¶
func (s *Socket) PWrite(ctx context.Context, src usermem.IOSequence, offset int64, opts vfs.WriteOptions) (int64, error)
PWrite implements vfs.FileDescriptionImpl.
func (*Socket) Read ¶
func (s *Socket) Read(ctx context.Context, dst usermem.IOSequence, opts vfs.ReadOptions) (int64, error)
Read implements vfs.FileDescriptionImpl.
func (*Socket) ReadRefs ¶
func (r *Socket) ReadRefs() int64
ReadRefs returns the current number of references. The returned count is inherently racy and is unsafe to use without external synchronization.
func (*Socket) RecvMsg ¶
func (s *Socket) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags int, haveDeadline bool, deadline ktime.Time, senderRequested bool, controlDataLen uint64) (n int, msgFlags int, senderAddr linux.SockAddr, senderAddrLen uint32, controlMessages socket.ControlMessages, err *syserr.Error)
RecvMsg implements the linux syscall recvmsg(2) for sockets backed by a transport.Endpoint.
func (*Socket) RefType ¶
func (r *Socket) RefType() string
RefType implements refs.CheckedObject.RefType.
func (*Socket) SendMsg ¶
func (s *Socket) SendMsg(t *kernel.Task, src usermem.IOSequence, to []byte, flags int, haveDeadline bool, deadline ktime.Time, controlMessages socket.ControlMessages) (int, *syserr.Error)
SendMsg implements the linux syscall sendmsg(2) for unix sockets backed by a transport.Endpoint.
func (*Socket) SetSockOpt ¶
SetSockOpt implements the linux syscall setsockopt(2) for sockets backed by a transport.Endpoint.
func (*Socket) Shutdown ¶
Shutdown implements the linux syscall shutdown(2) for sockets backed by a transport.Endpoint.
func (*Socket) StateFields ¶
func (*Socket) StateTypeName ¶
func (*Socket) TryIncRef ¶
func (r *Socket) TryIncRef() bool
TryIncRef implements refs.TryRefCounter.TryIncRef.
To do this safely without a loop, a speculative reference is first acquired on the object. This allows multiple concurrent TryIncRef calls to distinguish other TryIncRef calls from genuine references held.