5 * Copy data from the caller into the local address space.
8 fsdriver_copyin(const struct fsdriver_data
* data
, size_t off
, void * ptr
,
12 /* Do nothing for peek requests. */
16 /* The data size field is used only for this integrity check. */
17 if (off
+ len
> data
->size
)
18 panic("fsdriver: copy-in buffer overflow");
20 if (data
->endpt
== SELF
) {
21 memcpy(ptr
, &data
->ptr
[off
], len
);
26 return sys_safecopyfrom(data
->endpt
, data
->grant
, off
, (vir_bytes
)ptr
,
31 * Copy data from the local address space to the caller.
34 fsdriver_copyout(const struct fsdriver_data
* data
, size_t off
,
35 const void * ptr
, size_t len
)
38 /* Do nothing for peek requests. */
42 /* The data size field is used only for this integrity check. */
43 if (off
+ len
> data
->size
)
44 panic("fsdriver: copy-out buffer overflow");
46 if (data
->endpt
== SELF
) {
47 memcpy(&data
->ptr
[off
], ptr
, len
);
52 return sys_safecopyto(data
->endpt
, data
->grant
, off
, (vir_bytes
)ptr
,
57 * Zero out a data region in the caller.
60 fsdriver_zero(const struct fsdriver_data
* data
, size_t off
, size_t len
)
63 /* Do nothing for peek requests. */
67 /* The data size field is used only for this integrity check. */
68 if (off
+ len
> data
->size
)
69 panic("fsdriver: copy-out buffer overflow");
71 if (data
->endpt
== SELF
) {
72 memset(&data
->ptr
[off
], 0, len
);
77 return sys_safememset(data
->endpt
, data
->grant
, off
, 0, len
);
81 * Copy in a null-terminated name, and perform sanity checks.
84 fsdriver_getname(endpoint_t endpt
, cp_grant_id_t grant
, size_t len
,
85 char * name
, size_t size
, int not_empty
)
89 /* The given length includes the null terminator. */
90 if (len
== 0 || (not_empty
&& len
== 1))
95 if ((r
= sys_safecopyfrom(endpt
, grant
, 0, (vir_bytes
)name
,
96 (phys_bytes
)len
)) != OK
)
99 if (name
[len
- 1] != 0) {
100 printf("fsdriver: name not null-terminated\n");