summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/syscalls/linux/sys_sem.go
diff options
context:
space:
mode:
authorJing Chen <chjing@google.com>2020-11-02 23:56:29 -0800
committergVisor bot <gvisor-bot@google.com>2020-11-02 23:58:45 -0800
commit1a3f417f4a329339d89fcf89262bd08c18c1f27e (patch)
tree54d28b81f22b29ac979308b3cf7e642145916d2e /pkg/sentry/syscalls/linux/sys_sem.go
parent1321f837bd9f082e3c1b0a37831453b3637202c3 (diff)
Implement command GETZCNT for semctl.
PiperOrigin-RevId: 340389884
Diffstat (limited to 'pkg/sentry/syscalls/linux/sys_sem.go')
-rw-r--r--pkg/sentry/syscalls/linux/sys_sem.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/pkg/sentry/syscalls/linux/sys_sem.go b/pkg/sentry/syscalls/linux/sys_sem.go
index c2d4bf805..067f6be6d 100644
--- a/pkg/sentry/syscalls/linux/sys_sem.go
+++ b/pkg/sentry/syscalls/linux/sys_sem.go
@@ -138,12 +138,15 @@ func Semctl(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Syscal
return 0, nil, err
+ case linux.GETZCNT:
+ v, err := getSemzcnt(t, id, num)
+ return uintptr(v), nil, err
+
case linux.IPC_INFO,
linux.SEM_INFO,
linux.SEM_STAT,
linux.SEM_STAT_ANY,
- linux.GETNCNT,
- linux.GETZCNT:
+ linux.GETNCNT:
t.Kernel().EmitUnimplementedEvent(t)
fallthrough
@@ -258,3 +261,13 @@ func getPID(t *kernel.Task, id int32, num int32) (int32, error) {
}
return int32(tg.ID()), nil
}
+
+func getSemzcnt(t *kernel.Task, id int32, num int32) (uint16, error) {
+ r := t.IPCNamespace().SemaphoreRegistry()
+ set := r.FindByID(id)
+ if set == nil {
+ return 0, syserror.EINVAL
+ }
+ creds := auth.CredentialsFromContext(t)
+ return set.GetZeroWaiters(num, creds)
+}