• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <sys/sem.h>
2 #include <limits.h>
3 #include <errno.h>
4 #include <unsupported_api.h>
5 
6 #include "syscall.h"
7 #include "ipc.h"
8 
semget(key_t key,int n,int fl)9 int semget(key_t key, int n, int fl)
10 {
11 	/* The kernel uses the wrong type for the sem_nsems member
12 	 * of struct semid_ds, and thus might not check that the
13 	 * n fits in the correct (per POSIX) userspace type, so
14 	 * we have to check here. */
15 	unsupported_api(__FUNCTION__);
16 	if (n > USHRT_MAX) return __syscall_ret(-EINVAL);
17 #ifndef SYS_ipc
18 	return syscall(SYS_semget, key, n, fl);
19 #else
20 	return syscall(SYS_ipc, IPCOP_semget, key, n, fl);
21 #endif
22 }
23