1 /* The kernel call implemented in this file:
2 * m_type: SYS_SAFEMEMSET
4 * The parameters for this kernel call are:
7 * SMS_OFFSET offset within grant
8 * SMS_PATTERN memset pattern byte
9 * SMS_BYTES bytes from offset
13 #include <minix/safecopies.h>
15 #include "kernel/system.h"
18 /*===========================================================================*
20 *===========================================================================*/
21 int do_safememset(struct proc
*caller
, message
*m_ptr
) {
22 /* Implementation of the do_safememset() kernel call */
24 /* Extract parameters */
25 endpoint_t dst_endpt
= m_ptr
->SMS_DST
;
26 endpoint_t caller_endpt
= caller
->p_endpoint
;
27 cp_grant_id_t grantid
= m_ptr
->SMS_GID
;
28 vir_bytes g_offset
= m_ptr
->SMS_OFFSET
;
29 int pattern
= m_ptr
->SMS_PATTERN
;
30 size_t len
= (size_t)m_ptr
->SMS_BYTES
;
33 endpoint_t new_granter
;
34 static vir_bytes v_offset
;
37 if (dst_endpt
== NONE
|| caller_endpt
== NONE
)
40 if (!(dst_p
= endpoint_lookup(dst_endpt
)))
43 if (!(priv(dst_p
) && priv(dst_p
)->s_grant_table
)) {
44 printf("safememset: dst %d has no grant table\n", dst_endpt
);
48 /* Verify permission exists, memset always requires CPF_WRITE */
49 r
= verify_grant(dst_endpt
, caller_endpt
, grantid
, len
, CPF_WRITE
,
50 g_offset
, &v_offset
, &new_granter
);
53 printf("safememset: grant %d verify failed %d", grantid
, r
);
57 return vm_memset(caller
, new_granter
, v_offset
, pattern
, len
);