[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: writing to a file in LKM



On Tue, Sep 30, 2003 at 01:02:42PM +0530, Pradheep K E wrote:
> hi,
> i'm getting a strange problem while writing to a file from a LKM.
> could anyone tell me how exactly do we write to a file in the kernel mode.
> this code just created the file but didn't write anything to it.
> 
> struct file* f= filp_open(filename, O_CREAT|O_APPEND, 0600);
> f->f_op->write(f, "foo", 3, &f->fpos);
> filp_close(f, NULL);
> 
> 
> the write function returned -14, and i dont know why it's giving me a 
> problem. is there anything more that i should do before writing to the 
> file?

Other than you should never be doing this from a kernel module?  No.  :)


greg k-h
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/