Re: reading a file from a module

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

 




Your module is a part of the kernel.  Your system call always takes a user
space string.  when you supply a kernel space string your sys call will
reject it.

try using

fs = get_fs();   // fs is of type mm_segment_t
set_fs(get_ds())

/* your code here*/

set_fs(fs);


That is, let the sys call consider the kernel space to be a valid source of
input.  Also look at filp_open if you really want to open a file in kernel
space.

Regards,
Mohit Kalra

"It is a capital mistake to theorize before one has data.
Insensibly one begins to twist facts to suit theories, instead of theories
to suit facts."




 I am not using the systemcall open(). I am using the sys_open().

 I create a function pointer of the type sys_open say my_open

 and do

 my_open = syscall[__NR_OPEN];

 and then use it to open the file...

 But when i do this, i am getting an errno of -14
which is I suppose illegal operation. So what more do i need to open the
file from my module.





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