xref: /minix3/minix/lib/libsys/sys_getinfo.c (revision 76bf77a21f01f3eb5a218cc711a04895ded2676d)
1433d6423SLionel Sambuc 
2433d6423SLionel Sambuc #include <string.h>
3433d6423SLionel Sambuc #include <sys/param.h>
4433d6423SLionel Sambuc #include "syslib.h"
5433d6423SLionel Sambuc 
6433d6423SLionel Sambuc /*===========================================================================*
7433d6423SLionel Sambuc  *                                sys_getinfo				     *
8433d6423SLionel Sambuc  *===========================================================================*/
sys_getinfo(request,ptr,len,ptr2,len2)9433d6423SLionel Sambuc int sys_getinfo(request, ptr, len, ptr2, len2)
10433d6423SLionel Sambuc int request; 				/* system info requested */
11433d6423SLionel Sambuc void *ptr;				/* pointer where to store it */
12433d6423SLionel Sambuc int len;				/* max length of value to get */
13433d6423SLionel Sambuc void *ptr2;				/* second pointer */
14433d6423SLionel Sambuc int len2;				/* length or process nr */
15433d6423SLionel Sambuc {
16433d6423SLionel Sambuc     message m;
17433d6423SLionel Sambuc 
18433d6423SLionel Sambuc     m.m_lsys_krn_sys_getinfo.request = request;
19433d6423SLionel Sambuc     m.m_lsys_krn_sys_getinfo.endpt = SELF;	/* always store values at caller */
20685aa793SDavid van Moolenbroek     m.m_lsys_krn_sys_getinfo.val_ptr = (vir_bytes)ptr;
21433d6423SLionel Sambuc     m.m_lsys_krn_sys_getinfo.val_len = len;
22685aa793SDavid van Moolenbroek     m.m_lsys_krn_sys_getinfo.val_ptr2 = (vir_bytes)ptr2;
23433d6423SLionel Sambuc     m.m_lsys_krn_sys_getinfo.val_len2_e = len2;
24433d6423SLionel Sambuc 
25433d6423SLionel Sambuc     return(_kernel_call(SYS_GETINFO, &m));
26433d6423SLionel Sambuc }
27433d6423SLionel Sambuc 
28433d6423SLionel Sambuc /*===========================================================================*
29433d6423SLionel Sambuc  *                                sys_whoami				     *
30433d6423SLionel Sambuc  *===========================================================================*/
sys_whoami(endpoint_t * who_ep,char * who_name,int len,int * priv_flags,int * init_flags)31433d6423SLionel Sambuc int sys_whoami(endpoint_t *who_ep, char *who_name, int len,
32*76bf77a2SCristiano Giuffrida 	int *priv_flags, int *init_flags)
33433d6423SLionel Sambuc {
34433d6423SLionel Sambuc 	message m;
35433d6423SLionel Sambuc 	int r;
36433d6423SLionel Sambuc 	int lenmin;
37433d6423SLionel Sambuc 
38433d6423SLionel Sambuc 	m.m_lsys_krn_sys_getinfo.request = GET_WHOAMI;
39433d6423SLionel Sambuc 
40433d6423SLionel Sambuc 	if(len < 2)
41433d6423SLionel Sambuc 		return EINVAL;
42433d6423SLionel Sambuc 
43433d6423SLionel Sambuc 	if((r = _kernel_call(SYS_GETINFO, &m)) != OK)
44433d6423SLionel Sambuc 		return r;
45433d6423SLionel Sambuc 
46433d6423SLionel Sambuc 	lenmin = MIN((size_t) len, sizeof(m.m_krn_lsys_sys_getwhoami.name)) - 1;
47433d6423SLionel Sambuc 
48433d6423SLionel Sambuc 	strncpy(who_name, m.m_krn_lsys_sys_getwhoami.name, lenmin);
49433d6423SLionel Sambuc 	who_name[lenmin] = '\0';
50433d6423SLionel Sambuc 	*who_ep = m.m_krn_lsys_sys_getwhoami.endpt;
51433d6423SLionel Sambuc 	*priv_flags = m.m_krn_lsys_sys_getwhoami.privflags;
52*76bf77a2SCristiano Giuffrida 	*init_flags = m.m_krn_lsys_sys_getwhoami.initflags;
53433d6423SLionel Sambuc 
54433d6423SLionel Sambuc 	return OK;
55433d6423SLionel Sambuc }
56433d6423SLionel Sambuc 
57