2010-01-14 16:24:16 +01:00
|
|
|
|
|
|
|
#include "syslib.h"
|
|
|
|
|
|
|
|
#include <minix/safecopies.h>
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* sys_safemap *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int sys_safemap(endpoint_t grantor, cp_grant_id_t grant,
|
2010-01-14 16:24:16 +01:00
|
|
|
vir_bytes grant_offset, vir_bytes my_address,
|
|
|
|
size_t bytes, int my_seg, int writable)
|
|
|
|
{
|
|
|
|
/* Map a block of data for which the other process has previously
|
|
|
|
* granted permission.
|
|
|
|
*/
|
|
|
|
|
|
|
|
message copy_mess;
|
|
|
|
|
|
|
|
copy_mess.SMAP_EP = grantor;
|
|
|
|
copy_mess.SMAP_GID = grant;
|
|
|
|
copy_mess.SMAP_OFFSET = grant_offset;
|
|
|
|
copy_mess.SMAP_SEG = (void*) my_seg;
|
|
|
|
copy_mess.SMAP_ADDRESS = my_address;
|
|
|
|
copy_mess.SMAP_BYTES = bytes;
|
|
|
|
copy_mess.SMAP_FLAG = writable;
|
|
|
|
|
2010-02-09 16:20:09 +01:00
|
|
|
return(_kernel_call(SYS_SAFEMAP, ©_mess));
|
2010-01-14 16:24:16 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* sys_saferevmap_gid *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int sys_saferevmap_gid(cp_grant_id_t grant)
|
2010-01-14 16:24:16 +01:00
|
|
|
{
|
|
|
|
/* Grantor revokes safemap by grant id. */
|
|
|
|
message copy_mess;
|
|
|
|
|
|
|
|
copy_mess.SMAP_FLAG = 1;
|
|
|
|
copy_mess.SMAP_GID = grant;
|
|
|
|
|
2010-02-09 16:20:09 +01:00
|
|
|
return(_kernel_call(SYS_SAFEREVMAP, ©_mess));
|
2010-01-14 16:24:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* sys_saferevmap_addr *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int sys_saferevmap_addr(vir_bytes addr)
|
2010-01-14 16:24:16 +01:00
|
|
|
{
|
|
|
|
/* Grantor revokes safemap by address. */
|
|
|
|
message copy_mess;
|
|
|
|
|
|
|
|
copy_mess.SMAP_FLAG = 0;
|
|
|
|
copy_mess.SMAP_GID = addr;
|
|
|
|
|
2010-02-09 16:20:09 +01:00
|
|
|
return(_kernel_call(SYS_SAFEREVMAP, ©_mess));
|
2010-01-14 16:24:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* sys_safeunmap *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int sys_safeunmap(int my_seg, vir_bytes my_address)
|
2010-01-14 16:24:16 +01:00
|
|
|
{
|
|
|
|
/* Requestor unmaps safemap. */
|
|
|
|
message copy_mess;
|
|
|
|
|
|
|
|
copy_mess.SMAP_SEG = (void*) my_seg;
|
|
|
|
copy_mess.SMAP_ADDRESS = my_address;
|
|
|
|
|
2010-02-09 16:20:09 +01:00
|
|
|
return(_kernel_call(SYS_SAFEUNMAP, ©_mess));
|
2010-01-14 16:24:16 +01:00
|
|
|
}
|
|
|
|
|