Hi all,
Whats wrong with my code?
Since a couple of day's I try to pass a message along to another
server. This should be done as much uninterpreted as possible. (What
I'm really on is a layered filesystem, but this dosn't matter yet.)
But I'm jumping around between all sorts of unrecoverable kernel
faults.
I understand, that I can't pass a message completly uninterpreted
because of the M_READ bit. So I tried to pass a message as follows.
This has been applied to FS_STAT messages only (by now).
/* return 0 on success otherwise a error string */
static char*
passrmsg(struct msg*m, struct file*f)
{
int n;
struct msg om;
om = *m; /* make a rough copy */
om.m_op = m->m_op | M_READ; /* regenerate the M_READ */
/* copy all the buffer, not sure wether it is needed or not */
for(n=0; n<m->m_nseg; ++n) {
void *b;
/* bufmalloc is a garbage collecting malloc. After the reply to
"m", all buffers are free'd. It has proven to be stable .
For tests one may forget about the "m" parameter use malloc
instead and generate some memory leaks of no interest */
b = bufmalloc(m,m->m_seg[n].s_buflen);
if( b == NULL ) return ENOMEM;
bcopy(m->m_seg[n].s_buf,b,m->m_seg[n].s_buflen);
om.m_seg[n].s_buf=b;
}
n = msg_send(f->port,&om); /* send it to the layer below */
if( n < 0 ) {
return strerror();
} else {
return 0;
}
}
The fancy result of this is, that it works for the first time and
break the kernel on the second invocation.
To make things simple I started this server (which handles only M_DUP,
M_CONNECT, M_DISCONNECT in a stable way and FS_STAT mainly by the code
above).
Then I mounted it on /test.
Next I did: stat /test.
This gave me the expected result.
Next step again: stat /test.
Now I got a assertion failed line 170 file ../mach/trap.c.
This is the point where I can only raise my hands.
BTW: I ran into a couple of problems with syslog.
When I pass a FS_STAT message in the way above and I do a syslog just
after the msg_send the result of the msg_send gets overwriten.
There is a second problem, when I do a syslog between the msg_reply
and msg_receive the next msg_send will hand. But this apears to be too
complex to be answered. First I must work out the error condition
exactly.
Thanks for any help.
/Joerg
Received on Tue Dec 20 05:21:08 1994
This archive was generated by hypermail 2.1.8 : Thu Sep 22 2005 - 15:12:11 PDT