1

I have been running into a very strange problem in minix lately with regards to a system call I wrote. Basically the code runs fine from within a main() function, and the call does what it should. However, if I put the code in a function and call that function from within main(), it fails. Here is an example:

void do_foo()
{
    message m;
    _syscall(FS_PROC_NR, FOO, &m);
}

int main(int argc, char* argv[])
{
    /* works */
    message m;
    _syscall(FS_PROC_NR, FOO, &m);

    /* does not work */
    do_foo();
}

It seems that if you call a function from your code, it should do the same thing as if you just wrote the code in the main function. What am I missing here??

  • Does that particular system call return before the operation is complete? If it does, then `m` is destroyed when `do_foo()` returns and the operation may either overwrite your stack, thinking `m` is still there, or get garbage from it, thinking the same. Or you may be feeding it wrongly sized `m`. – Alexey Frunze Apr 15 '13 at 11:15
  • I thought it might be something like this, but in fact it had to do with my system call being in /usr/src/servers/vfs, and that I was not correctly loading a string pointer in the message with fetch_name, but instead was trying to directly pass the pointer to the string. Still don't know why these two are different, but using fetch_name seems to fix it – user1615148 Apr 17 '13 at 01:03

0 Answers0