Minix - 将系统调用地址中的数据复制回调用进程

时间:2016-12-08 11:32:10

标签: c arrays system-calls minix

因此,我需要使用MINIX内核调用sys_vircopy将填充的数组(int)从我正在编写的系统调用中复制回调用进程。

当前设置如下,在调用过程中(省略了任何不重要的内容):

int *results = malloc(...); // allocate required mem
message m;

m.m1_i1 = *results; 
// is this the correct way to send the address of the array via a message?

_syscall(..., MYSYSCALL, &m); // syscall to relevant server

因此,由于我无法直接发送int数组(没有消息类型),我试图在消息中发送数组的地址。

然后,在我的系统调用中:

int nelements;
int *results = &m_in.m1_i1;
// is this the correct way to receive the array at the address in the message?

// Some code here filling the array

sys_vircopy(SELF, *results, who_e, m_in.m1_i1, sizeof(int) * nelements);
// is this the correct way to send the address of the filled array...
// ...back to the address holding the array in the calling process?

所以在这里我尝试使用sys_vircopy然后将我的数组地址(*results)从当前进程(SELF)发送回调用进程({ {1}}),在指向其数组的地址(who_e)。

但是,这似乎不起作用。我觉得我必须误解一些关于消息的信息,和/或将地址从一个进程发送到另一个进程。不幸的是,虽然没有太多记录在线使用此m_in.m1_i1功能来帮助我。任何人都可以提供任何指示吗?

此外,我必须在这里使用sys_vircopy

1 个答案:

答案 0 :(得分:0)

没有旧D | T | S段的痕迹,所以我猜这是MINIX 3.2或更新版本。您可能需要使用memory grants(a.k.a safecopies)来处理保护问题,而不是尝试使用较低级别的vircopy

相关问题