etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libc / sys / shmctl.c
blob9612e65a57d0c9cd28fad14a7998c470a4bc2415
1 #define _SYSTEM 1
2 #define _MINIX_SYSTEM 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>
15 #include <string.h>
17 static int get_ipc_endpt(endpoint_t *pt)
19 return minix_rs_lookup("ipc", pt);
22 /* Shared memory control operation. */
23 int shmctl(int shmid, int cmd, struct shmid_ds *buf)
25 message m;
26 endpoint_t ipc_pt;
27 int r;
29 if (get_ipc_endpt(&ipc_pt) != OK) {
30 errno = ENOSYS;
31 return -1;
34 memset(&m, 0, sizeof(m));
35 m.m_lc_ipc_shmctl.id = shmid;
36 m.m_lc_ipc_shmctl.cmd = cmd;
37 m.m_lc_ipc_shmctl.buf = buf;
39 r = _syscall(ipc_pt, IPC_SHMCTL, &m);
40 if ((cmd == IPC_INFO || cmd == SHM_INFO || cmd == SHM_STAT)
41 && (r == OK))
42 return m.m_lc_ipc_shmctl.ret;
43 return r;
46 #if defined(__minix) && defined(__weak_alias)
47 __weak_alias(shmctl, __shmctl50)
48 #endif