MINIX3. SystemCall passing char *pointer,any help... - Minix
This is a discussion on MINIX3. SystemCall passing char *pointer,any help... - Minix ; Hello.
I want to design a system call in MINIX 3 that should take as argument
a string.
I use the message m stuct.
When i do that for an integer,all work fine.But no using a char
*pointer.
i would ...
-
MINIX3. SystemCall passing char *pointer,any help...
Hello.
I want to design a system call in MINIX 3 that should take as argument
a string.
I use the message m stuct.
When i do that for an integer,all work fine.But no using a char
*pointer.
i would like to mention that i dont want somebody to do my homework(!)
but the only i want is any ideas,because i have been working with that
3days and i havent managed to find a solution.
In: /usr/src/lib/posix i have the file _my.c :
/*...*/
PUBLIC int my(arg)
_CONST char *arg;
{
message m;
m.m1_p1= (char *) arg;
return(_syscall(FS,70,&m));
}
And in /usr/src/servers/fs i have modified the misc.c adding the
follow lines:
PUBLIC int do_my()
{
char *arg;
arg=m_in.m1_p1;
printf("%s",arg);
return(OK);
}
After recompiling the kernel and libraries, i use a simple c program
to test that.such as:
void main(void)
{
char *f="hello All";
my(f);
}
when i run the executable i take the following message:
FS, bad process, who = %d, call_nr = %d, endpt1 = %d
Please any help..
-
Re: MINIX3. SystemCall passing char *pointer,any help...
mhyp_power@hotmail.com wrote:
> Hello.
> I want to design a system call in MINIX 3 that should take as argument
> a string.
> I use the message m stuct.
> When i do that for an integer,all work fine.But no using a char
> *pointer.
> i would like to mention that i dont want somebody to do my homework(!)
> but the only i want is any ideas,because i have been working with that
> 3days and i havent managed to find a solution.
Hi,
In my opinion, if this is indeed a homework assignment and you are stuck
like this, you should be able to ask support from a supervisor or fellow
student with these kinds of problems. Nevertheless, I'll try to help you
along.
Minix has, like most modern operating systems, a form of memory management
using the MMU (memory management unit) found in most CPUs. Minix uses this
to give each process its own memory map, starting at address zero. This
means that a _pointer_ in one process is not valid (or at least does not
point to the same memory) in another process. Because system calls cross
process boundaries, passing pointers to transfer strings (character
arrays actually) between processes will not work. The pointer that gets
passed is actually the same (you can check this by using printf("%p"); in
both processes), it's just that they don't mean the same in both
processes.
Good luck!
Jens
--
Jens de Smit
Student Computer Science | Vrije Universiteit Amsterdam
jfdsmit@few.vu.nl | http://www.few.vu.nl/~jfdsmit
"[In the end, people] get furious at IT that the goddamn magic isn't working"
-- Stewart Dean