2008-11-19 13:26:10 +01:00
|
|
|
|
|
|
|
#include <string.h>
|
2010-08-21 15:10:41 +02:00
|
|
|
#include <sys/param.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include "syslib.h"
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* sys_getinfo *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int sys_getinfo(request, ptr, len, ptr2, len2)
|
2005-04-21 16:53:53 +02:00
|
|
|
int request; /* system info requested */
|
2005-07-19 14:24:51 +02:00
|
|
|
void *ptr; /* pointer where to store it */
|
|
|
|
int len; /* max length of value to get */
|
|
|
|
void *ptr2; /* second pointer */
|
|
|
|
int len2; /* length or process nr */
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
message m;
|
|
|
|
|
2014-05-22 10:46:02 +02:00
|
|
|
m.m_lsys_krn_sys_getinfo.request = request;
|
|
|
|
m.m_lsys_krn_sys_getinfo.endpt = SELF; /* always store values at caller */
|
|
|
|
m.m_lsys_krn_sys_getinfo.val_ptr = ptr;
|
|
|
|
m.m_lsys_krn_sys_getinfo.val_len = len;
|
|
|
|
m.m_lsys_krn_sys_getinfo.val_ptr2 = ptr2;
|
|
|
|
m.m_lsys_krn_sys_getinfo.val_len2_e = len2;
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2010-02-09 16:20:09 +01:00
|
|
|
return(_kernel_call(SYS_GETINFO, &m));
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
2008-11-19 13:26:10 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* sys_whoami *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int sys_whoami(endpoint_t *who_ep, char *who_name, int len,
|
2010-07-07 00:05:21 +02:00
|
|
|
int *priv_flags)
|
2008-11-19 13:26:10 +01:00
|
|
|
{
|
|
|
|
message m;
|
|
|
|
int r;
|
|
|
|
int lenmin;
|
|
|
|
|
2014-05-22 10:46:02 +02:00
|
|
|
m.m_lsys_krn_sys_getinfo.request = GET_WHOAMI;
|
2008-11-19 13:26:10 +01:00
|
|
|
|
|
|
|
if(len < 2)
|
|
|
|
return EINVAL;
|
|
|
|
|
2010-02-09 16:20:09 +01:00
|
|
|
if((r = _kernel_call(SYS_GETINFO, &m)) != OK)
|
2008-11-19 13:26:10 +01:00
|
|
|
return r;
|
|
|
|
|
2014-05-22 10:46:02 +02:00
|
|
|
lenmin = MIN((size_t) len, sizeof(m.m_krn_lsys_sys_getwhoami.name)) - 1;
|
2008-11-19 13:26:10 +01:00
|
|
|
|
2014-05-22 10:46:02 +02:00
|
|
|
strncpy(who_name, m.m_krn_lsys_sys_getwhoami.name, lenmin);
|
2008-11-19 13:26:10 +01:00
|
|
|
who_name[lenmin] = '\0';
|
2014-05-22 10:46:02 +02:00
|
|
|
*who_ep = m.m_krn_lsys_sys_getwhoami.endpt;
|
|
|
|
*priv_flags = m.m_krn_lsys_sys_getwhoami.privflags;
|
2008-11-19 13:26:10 +01:00
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
|