So, I need to use the MINIX kernel call sys_vircopy
to copy a filled array (of int
) from a system call I am writing, back to the calling process.
The current setup is as follows, in the calling process (have omitted anything unimportant):
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
So, as I cannot send an array of int
directly over (there is no message type for it), I am trying to send the address of the array in the message.
Then, in my system call:
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?
So here I am trying to use sys_vircopy
to then send the address of my array (*results
), from the current process (SELF
), back to the calling process (who_e
), at the address which points to its array (m_in.m1_i1
).
However, this does not seem to be working. I feel I must be misunderstanding something about messages, and/or sending addresses from one process to another. Unfortunately though, there is not much documented use of this sys_vircopy
function online to help me. Could anyone offer any pointers?
Additionally, I HAVE to use sys_vircopy
here.