etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libsys / sys_getinfo.c
blobfad4da4f254290b1b1eec71d53e014c85e59ba27
2 #include <string.h>
3 #include <sys/param.h>
4 #include "syslib.h"
6 /*===========================================================================*
7 * sys_getinfo *
8 *===========================================================================*/
9 int sys_getinfo(request, ptr, len, ptr2, len2)
10 int request; /* system info requested */
11 void *ptr; /* pointer where to store it */
12 int len; /* max length of value to get */
13 void *ptr2; /* second pointer */
14 int len2; /* length or process nr */
16 message m;
18 m.m_lsys_krn_sys_getinfo.request = request;
19 m.m_lsys_krn_sys_getinfo.endpt = SELF; /* always store values at caller */
20 m.m_lsys_krn_sys_getinfo.val_ptr = (vir_bytes)ptr;
21 m.m_lsys_krn_sys_getinfo.val_len = len;
22 m.m_lsys_krn_sys_getinfo.val_ptr2 = (vir_bytes)ptr2;
23 m.m_lsys_krn_sys_getinfo.val_len2_e = len2;
25 return(_kernel_call(SYS_GETINFO, &m));
28 /*===========================================================================*
29 * sys_whoami *
30 *===========================================================================*/
31 int sys_whoami(endpoint_t *who_ep, char *who_name, int len,
32 int *priv_flags, int *init_flags)
34 message m;
35 int r;
36 int lenmin;
38 m.m_lsys_krn_sys_getinfo.request = GET_WHOAMI;
40 if(len < 2)
41 return EINVAL;
43 if((r = _kernel_call(SYS_GETINFO, &m)) != OK)
44 return r;
46 lenmin = MIN((size_t) len, sizeof(m.m_krn_lsys_sys_getwhoami.name)) - 1;
48 strncpy(who_name, m.m_krn_lsys_sys_getwhoami.name, lenmin);
49 who_name[lenmin] = '\0';
50 *who_ep = m.m_krn_lsys_sys_getwhoami.endpt;
51 *priv_flags = m.m_krn_lsys_sys_getwhoami.privflags;
52 *init_flags = m.m_krn_lsys_sys_getwhoami.initflags;
54 return OK;