unix

package
v0.0.0-...-b9252dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2024 License: Apache-2.0, MIT Imports: 24 Imported by: 14

Documentation

Overview

Package unix provides an implementation of the socket.Socket interface for the AF_UNIX protocol family.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddressAndFamily

func AddressAndFamily(addr []byte) (transport.Address, uint16, *syserr.Error)

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.

func NewSockfsFile

func NewSockfsFile(t *kernel.Task, ep transport.Endpoint, stype linux.SockType) (*vfs.FileDescription, *syserr.Error)

NewSockfsFile creates a new socket file in the global sockfs mount and returns a corresponding file description.

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) Bind

func (s *Socket) Bind(t *kernel.Task, sockaddr []byte) *syserr.Error

Bind implements the linux syscall bind(2) for unix sockets.

func (*Socket) Connect

func (s *Socket) Connect(t *kernel.Task, sockaddr []byte, blocking bool) *syserr.Error

Connect implements the linux syscall connect(2) for unix sockets.

func (*Socket) ConnectedPasscred

func (s *Socket) ConnectedPasscred() bool

ConnectedPasscred implements transport.Credentialer.ConnectedPasscred.

func (*Socket) DecRef

func (s *Socket) DecRef(ctx context.Context)

DecRef implements RefCounter.DecRef.

func (*Socket) Endpoint

func (s *Socket) Endpoint() transport.Endpoint

Endpoint extracts the transport.Endpoint.

func (*Socket) Epollable

func (s *Socket) Epollable() bool

Epollable implements FileDescriptionImpl.Epollable.

func (*Socket) EventRegister

func (s *Socket) EventRegister(e *waiter.Entry) error

EventRegister implements waiter.Waitable.EventRegister.

func (*Socket) EventUnregister

func (s *Socket) EventUnregister(e *waiter.Entry)

EventUnregister implements waiter.Waitable.EventUnregister.

func (*Socket) GetPeerName

func (s *Socket) GetPeerName(t *kernel.Task) (linux.SockAddr, uint32, *syserr.Error)

GetPeerName implements the linux syscall getpeername(2) for sockets backed by a transport.Endpoint.

func (*Socket) GetSockName

func (s *Socket) GetSockName(t *kernel.Task) (linux.SockAddr, uint32, *syserr.Error)

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) Ioctl

func (s *Socket) Ioctl(ctx context.Context, uio usermem.IO, sysno uintptr, args arch.SyscallArguments) (uintptr, error)

Ioctl implements vfs.FileDescriptionImpl.

func (*Socket) Listen

func (s *Socket) Listen(t *kernel.Task, backlog int) *syserr.Error

Listen implements the linux syscall listen(2) for sockets backed by a transport.Endpoint.

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) Passcred

func (s *Socket) Passcred() bool

Passcred implements transport.Credentialer.Passcred.

func (*Socket) Read

func (s *Socket) Read(ctx context.Context, dst usermem.IOSequence, opts vfs.ReadOptions) (int64, error)

Read implements vfs.FileDescriptionImpl.

func (*Socket) Readiness

func (s *Socket) Readiness(mask waiter.EventMask) waiter.EventMask

Readiness implements waiter.Waitable.Readiness.

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) Release

func (s *Socket) Release(ctx context.Context)

Release implements vfs.FileDescriptionImpl.Release.

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

func (s *Socket) SetSockOpt(t *kernel.Task, level int, name int, optVal []byte) *syserr.Error

SetSockOpt implements the linux syscall setsockopt(2) for sockets backed by a transport.Endpoint.

func (*Socket) Shutdown

func (s *Socket) Shutdown(t *kernel.Task, how int) *syserr.Error

Shutdown implements the linux syscall shutdown(2) for sockets backed by a transport.Endpoint.

func (*Socket) State

func (s *Socket) State() uint32

State implements socket.Socket.State.

func (*Socket) Type

func (s *Socket) Type() (family int, skType linux.SockType, protocol int)

Type implements socket.Socket.Type.

func (*Socket) Write

func (s *Socket) Write(ctx context.Context, src usermem.IOSequence, opts vfs.WriteOptions) (int64, error)

Write implements vfs.FileDescriptionImpl.

Directories

Path Synopsis
Package transport contains the implementation of Unix endpoints.
Package transport contains the implementation of Unix endpoints.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL