xref: /minix/minix/lib/libsys/sys_safecopy.c (revision 685aa793)
1 
2 #include "syslib.h"
3 
4 #include <minix/safecopies.h>
5 
sys_safecopyfrom(endpoint_t src_e,cp_grant_id_t gr_id,vir_bytes offset,vir_bytes address,size_t bytes)6 int sys_safecopyfrom(endpoint_t src_e,
7 	cp_grant_id_t gr_id, vir_bytes offset,
8 	vir_bytes address, size_t bytes)
9 {
10 /* Transfer a block of data for which the other process has previously
11  * given permission.
12  */
13 
14   message copy_mess;
15 
16   copy_mess.m_lsys_kern_safecopy.from_to = src_e;
17   copy_mess.m_lsys_kern_safecopy.gid = gr_id;
18   copy_mess.m_lsys_kern_safecopy.offset = offset;
19   copy_mess.m_lsys_kern_safecopy.address = (void *)address;
20   copy_mess.m_lsys_kern_safecopy.bytes = bytes;
21 
22   return(_kernel_call(SYS_SAFECOPYFROM, &copy_mess));
23 
24 }
25 
sys_safecopyto(endpoint_t dst_e,cp_grant_id_t gr_id,vir_bytes offset,vir_bytes address,size_t bytes)26 int sys_safecopyto(endpoint_t dst_e,
27 	cp_grant_id_t gr_id, vir_bytes offset,
28 	vir_bytes address, size_t bytes)
29 {
30 /* Transfer a block of data for which the other process has previously
31  * given permission.
32  */
33 
34   message copy_mess;
35 
36   copy_mess.m_lsys_kern_safecopy.from_to = dst_e;
37   copy_mess.m_lsys_kern_safecopy.gid = gr_id;
38   copy_mess.m_lsys_kern_safecopy.offset = offset;
39   copy_mess.m_lsys_kern_safecopy.address = (void *)address;
40   copy_mess.m_lsys_kern_safecopy.bytes = bytes;
41 
42   return(_kernel_call(SYS_SAFECOPYTO, &copy_mess));
43 
44 }
45