On 3/21/06, Fawad Lateef <fawadlateef@xxxxxxxxx> wrote: > On 3/21/06, George Joseph <george_linuxprogrammer@xxxxxxxxx> wrote: > > > > Hello Guys, > > > > Ooops looks like I did not enumerate the purpose of the driver. Well the > > use is simple - I am going to write a driver which reads some(a whole lot > > still) packet data from a file stored on a file system - just reading > > nothing else. The file per se will be created by another application and > > stored on an ext2FS or FAT32FS . Now, All that I wish to do is access the > > file from kernel space because a high level user land API will be able to > > open/read the file. But, again the data will be present in user space . This > > data has to be moved to kernel space(for my driver) using copy_from_user() > > and considering the fact that the file itself could be 1 GB + in size - I > > believe I might loose a lot of cycles doing this conversion . Please do let > > me know if there is something else we could do for this in the kernel itself > > rather than doing it in user land. > > What you can do is: > > 1) From user application read the file and provide the data to driver > through sysfs, this is secure (I think its fast too) > 2) Directly call the file system functions to access the file (I think > its difficult) > 3) Directly call the user space file accessing functions through doing > system-calls from kernel (its the worst thing to do) Hi Fawad, Can you explain, why the 3rd point is not recommended. whats the harm in doing that, why we say it to be a worst thing to do. I only reason I can find for that is, just because we are using the user applications unused fd for opening our file without letting the user application know about it. Whenever we opena file in kernel, using sys_open() systemcall, we would be using the unused fd of an application in context of which the driver is executing, and the application wont come to know about it. Is there any harm in doing so, if yes, please explain. Gaurav > > See this thread > (http://mail.nl.linux.org/kernelnewbies/2005-11/msg00025.html) and for > point number 3 although its bad see > (http://mail.nl.linux.org/kernelnewbies/2005-10/msg00249.html) > > I hope this helps. > > > > -- > Fawad Lateef > > -- > Kernelnewbies: Help each other learn about the Linux kernel. > Archive: http://mail.nl.linux.org/kernelnewbies/ > FAQ: http://kernelnewbies.org/faq/ > > -- -- -Gaurav Email: gauravd.chd@xxxxxxxxx --------------------------------- Read my blog at: http://lkdp.blogspot.com/ --------------------------------- -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/