some coverity fixes.
[minix.git] / lib / libc / sys-minix / shmctl.c
blob9ae6a5c9750f1d1619dc12468fb7a9e13c29892a
1 #define _SYSTEM 1
2 #define _MINIX 1
4 #include <sys/cdefs.h>
5 #include <lib.h>
6 #include "namespace.h"
8 #include <minix/rs.h>
9 #include <lib.h>
10 #include <sys/types.h>
11 #include <sys/ipc.h>
12 #include <sys/shm.h>
13 #include <stdlib.h>
14 #include <errno.h>
16 static int get_ipc_endpt(endpoint_t *pt)
18 return minix_rs_lookup("ipc", pt);
21 /* Shared memory control operation. */
22 int shmctl(int shmid, int cmd, struct shmid_ds *buf)
24 message m;
25 endpoint_t ipc_pt;
26 int r;
28 if (get_ipc_endpt(&ipc_pt) != OK) {
29 errno = ENOSYS;
30 return -1;
33 m.SHMCTL_ID = shmid;
34 m.SHMCTL_CMD = cmd;
35 m.SHMCTL_BUF = (long) buf;
37 r = _syscall(ipc_pt, IPC_SHMCTL, &m);
38 if ((cmd == IPC_INFO || cmd == SHM_INFO || cmd == SHM_STAT)
39 && (r == OK))
40 return m.SHMCTL_RET;
41 return r;