Re: What's wrong with this really simple function?

From: Robert Hancock
Date: Sun Nov 27 2005 - 20:03:30 EST


Mohamed El Dawy wrote:
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.

--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@xxxxxxxxxxxxx
Home Page: http://www.roberthancock.com/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/