Accessing a file from kernel space

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

 




I know that this should be avoided as much as possibleI know this must have been discussed here many times before, and I know the various ways I can read a file from my module. But I am not very sure what is the best way to do so. Let me list out my approaches ranging from very crude to standard ones which we read in books.

1. Read the file contents in a buffer and send the buffer to kernel space using an ioctl.
2. Use sys_open, sys_read etc directly from kernel space! This might/will fail since these
functions check the validity of the pointer and expect a user space pointer. But this can be
overcome using fs_get and fs_put etc. For functions which are not exported we can play around a
little do that too.

3. Using sysfs.

4. And many other approaches using /proc etc

Approach 3 by far looks best to me but this kind of approach can be used only to read some config files etc. I would like to know your opinions to decide best approach.

Regards,
Pharaoh.

[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