Re: Write to file & Change Directory
- From: Ben Gras <beng@xxxxxxxxx>
- Date: 20 Jun 2006 08:03:40 GMT
All,
I hope you realize what you're doing is very naughty :). You can get it
working, of course, but the do_*() functions operate in context of the
calling process, and operate on the sent message directly. If you're in
a system call, your creat etc. calls will operate in the context of
that process, which is actually what you want, but is very messy, and
you have to realize what's happening if you're ever going to get it to
work.
buffer is a general type pointer (pointer to void).
Actually it belongs to the struct of type message, and is declared as:
#define buffer m.m1_p1
So, before initializing, I have to declare what type of pointer it will
be.
If I just type strcpy(buffer,"text"); then on the file I am supposed to
write, the only thing written are spaces! If I type
strcpy((char)buffer,"text"); garbage characters are written!
The problem is that do_write() will interpret buffer as a pointer in
the virtual address space of the caller. It's not a pointer in FS
address space. So you're strcpy()ing to more or less random places in
FS. Casting it to (char) just makes matters different, but not
better :).
A neater solution is for the user process that does your new system
call to creat() the file for you, and pass the fd it gets to your new
system call, as well as a buffer in his own address space. Then you can
copy whatever you want to write to the file into that buffer, and call
do_write(). It's not an oil painting, but prettier than what you're
trying above ;-).
=Ben
.
- References:
- Write to file & Change Directory
- From: already.late@xxxxxxxxx
- Re: Write to file & Change Directory
- From: Bill Marcum
- Re: Write to file & Change Directory
- From: already.late@xxxxxxxxx
- Re: Write to file & Change Directory
- From: M E Leypold
- Re: Write to file & Change Directory
- From: already.late@xxxxxxxxx
- Re: Write to file & Change Directory
- From: Chris Double
- Re: Write to file & Change Directory
- From: M E Leypold
- Re: Write to file & Change Directory
- From: already.late@xxxxxxxxx
- Re: Write to file & Change Directory
- From: Chris Double
- Re: Write to file & Change Directory
- From: already.late@xxxxxxxxx
- Write to file & Change Directory
- Prev by Date: Re: Minix uses 4GB HD at most?
- Next by Date: the XDM command of minix3 doesn't work
- Previous by thread: Re: Write to file & Change Directory
- Next by thread: Minix 3 on Thinkpad 755CE: done
- Index(es):
Relevant Pages
|