MCPcopy
hub / github.com/google/gvisor / Msgsnd

Function Msgsnd

pkg/sentry/syscalls/linux/sys_msgqueue.go:47–77  ·  view source on GitHub ↗

Msgsnd implements msgsnd(2).

(t *kernel.Task, sysno uintptr, args arch.SyscallArguments)

Source from the content-addressed store, hash-verified

45
46// Msgsnd implements msgsnd(2).
47func Msgsnd(t *kernel.Task, sysno uintptr, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) {
48 id := ipc.ID(args[0].Int())
49 msgAddr := args[1].Pointer()
50 size := args[2].Int64()
51 flag := args[3].Int()
52
53 if size < 0 || size > linux.MSGMAX {
54 return 0, nil, linuxerr.EINVAL
55 }
56
57 wait := flag&linux.IPC_NOWAIT != linux.IPC_NOWAIT
58 pid := int32(t.ThreadGroup().ID())
59
60 buf := linux.MsgBuf{
61 Text: make([]byte, size),
62 }
63 if _, err := buf.CopyIn(t, msgAddr); err != nil {
64 return 0, nil, err
65 }
66
67 queue, err := t.IPCNamespace().MsgqueueRegistry().FindByID(id)
68 if err != nil {
69 return 0, nil, err
70 }
71
72 msg := msgqueue.Message{
73 Type: int64(buf.Type),
74 Text: buf.Text,
75 }
76 return 0, nil, queue.Send(t, msg, wait, pid)
77}
78
79// Msgrcv implements msgrcv(2).
80func Msgrcv(t *kernel.Task, sysno uintptr, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) {

Callers

nothing calls this directly

Calls 11

IDTypeAlias · 0.92
MsgqueueRegistryMethod · 0.80
IPCNamespaceMethod · 0.80
IDMethod · 0.65
CopyInMethod · 0.65
SendMethod · 0.65
IntMethod · 0.45
PointerMethod · 0.45
Int64Method · 0.45
ThreadGroupMethod · 0.45
FindByIDMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…