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

Re: Yet, another question about writing a module.....



>So, is there any function that I can use to read the content of a file?
>Any tip will be useful.....

try this

struct file *filp;
mm_segment_t old_fs;
filp = filp_open(name,flags,mode);
old_fs= getfs();
set_fs(KERNEL_DS);
filp->f_op->read(filp,buffer,count,&filp->f_pos);



But you should keep one thing in mind that before this code is executed you
have the filesystem on this this particular file exists has been already
mounted otherwise you risk the crashing of kernel.

Regards,
Anil


-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.surriel.com/kernelnewbies.shtml