Msgrcv implements msgrcv(2).
(t *kernel.Task, sysno uintptr, args arch.SyscallArguments)
| 78 | |
| 79 | // Msgrcv implements msgrcv(2). |
| 80 | func Msgrcv(t *kernel.Task, sysno uintptr, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) { |
| 81 | id := ipc.ID(args[0].Int()) |
| 82 | msgAddr := args[1].Pointer() |
| 83 | size := args[2].Uint64() |
| 84 | mType := args[3].Int64() |
| 85 | flags := args[4].Int() |
| 86 | |
| 87 | msg, err := receive(t, id, mType, size, flags) |
| 88 | if err != nil { |
| 89 | return 0, nil, err |
| 90 | } |
| 91 | |
| 92 | buf := linux.MsgBuf{ |
| 93 | Type: primitive.Int64(msg.Type), |
| 94 | Text: msg.Text, |
| 95 | } |
| 96 | if uint64(len(buf.Text)) > size { |
| 97 | buf.Text = buf.Text[:size] |
| 98 | } |
| 99 | if _, err := buf.CopyOut(t, msgAddr); err != nil { |
| 100 | return 0, nil, err |
| 101 | } |
| 102 | return uintptr(len(buf.Text)), nil, nil |
| 103 | } |
| 104 | |
| 105 | // receive returns a message from the queue with the given ID. If msgCopy is |
| 106 | // true, a message is copied from the queue without being removed. Otherwise, |
nothing calls this directly
no test coverage detected
searching dependent graphs…