Skip to contentSkip to conversation

What's wrong with this really simple function?

DISCUSSION Robert Hancock 1 participant 1 message Nov 28, 2005 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 8 lines · Mohamed El Dawy

Hi,
I have created this 5-liner system call, which basically opens a
file, write "Hello World" to it, and then returns. That's all.

Now, when I actually call it, it creates the file successfully but writes nothing to it. The file is created and is only zero bytes. So, either write didn't write, or close didn't close. Any help would be greatly appreciated.

Well, the main thing wrong is that you are writing to a file from inside the kernel, that is just wrong.. However likely the reason why the write didn't work is that it expects an address inside userspace memory and you've given it a character literal which is inside the kernel address space.

Signature · 3 lines
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]
Home Page: http://www.roberthancock.com/