Re: writing to a file in LKM

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

 



how else will one keep account of something without using a file, be it 
from a kernel module or not??? or do u mean to say we shd somehow go 
into user space for such stuff - if so, then how? please enlighten me.

prad

On Tue, 30 Sep 2003, Greg KH wrote:

> 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/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux