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

Function Shmget

pkg/sentry/syscalls/linux/sys_shm.go:27–45  ·  view source on GitHub ↗

Shmget implements shmget(2).

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

Source from the content-addressed store, hash-verified

25
26// Shmget implements shmget(2).
27func Shmget(t *kernel.Task, sysno uintptr, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) {
28 key := ipc.Key(args[0].Int())
29 size := uint64(args[1].SizeT())
30 flag := args[2].Int()
31
32 private := key == linux.IPC_PRIVATE
33 create := flag&linux.IPC_CREAT == linux.IPC_CREAT
34 exclusive := flag&linux.IPC_EXCL == linux.IPC_EXCL
35 mode := linux.FileMode(flag & 0777)
36
37 pid := int32(t.ThreadGroup().ID())
38 r := t.IPCNamespace().ShmRegistry()
39 segment, err := r.FindOrCreate(t, pid, key, size, mode, private, create, exclusive)
40 if err != nil {
41 return 0, nil, err
42 }
43 defer segment.DecRef(t)
44 return uintptr(segment.ID()), nil, nil
45}
46
47// findSegment retrieves a shm segment by the given id.
48//

Callers

nothing calls this directly

Calls 10

KeyTypeAlias · 0.92
FileModeTypeAlias · 0.92
SizeTMethod · 0.80
ShmRegistryMethod · 0.80
IPCNamespaceMethod · 0.80
IDMethod · 0.65
DecRefMethod · 0.65
IntMethod · 0.45
ThreadGroupMethod · 0.45
FindOrCreateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…