reading a file which is in user space from kernel space - Linux

This is a discussion on reading a file which is in user space from kernel space - Linux ; HI, Can we read a file which is in user space from kernel space. Idea is : This file is a configuration file which contains info which is needed by the file system. so while mounting i want to read ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: reading a file which is in user space from kernel space

  1. reading a file which is in user space from kernel space

    HI,

    Can we read a file which is in user space from kernel space.
    Idea is : This file is a configuration file which contains info which
    is needed by the file system. so while mounting i want to read this
    file and keep it in memory.

    Regards
    Gururaja

  2. Re: reading a file which is in user space from kernel space

    On May 7, 9:31*am, guru wrote:
    > HI,
    >
    > Can we read a file which is in user space from kernel space.
    > Idea is : This file is a configuration file which contains info which
    > is needed by the file system. so while mounting i want to read this
    > file and keep it in memory.
    >
    > Regards
    > Gururaja


    Hi!

    for starters read , http://www.linuxjournal.com/article/8110 , article
    at Linux journal about reading , and writnig files from the linux
    kernel.

    First of all , this is not recommended , secondly you have to check
    whether the symbols , sys_open , sys_read , sys_write are exported in
    your kernel. A simple way to do is :

    # more /proc/ksyms|egrep sys_open , for sys_open and similarly for
    others. If it shows nothing , then these symbols have been unexported
    in your kernel version.

    Then later maybe you have to manually apply some patches and recompile
    the kernel

    thanks



  3. Re: reading a file which is in user space from kernel space

    On May 7, 9:31 am, guru wrote:
    > HI,
    >
    > Can we read a file which is in user space from kernel space.
    > Idea is : This file is a configuration file which contains info which
    > is needed by the file system. so while mounting i want to read this
    > file and keep it in memory.
    >
    > Regards
    > Gururaja


    Hi,
    Try using set_fs() and get_fs(), this would surely solve your problem.
    But surely its a very bad programming to do it inside the kernel.
    First try your best to avoid such situation and then if still you feel
    that this is the way out, you may proceed.

    Thanks & Regards,
    Sandeep.

  4. Re: reading a file which is in user space from kernel space

    On May 7, 7:40 pm, kartik saxena wrote:
    > On May 7, 9:31 am, guru wrote:
    >
    > > HI,

    >
    > > Can we read a file which is in user space from kernel space.
    > > Idea is : This file is a configuration file which contains info which
    > > is needed by the file system. so while mounting i want to read this
    > > file and keep it in memory.

    >
    > > Regards
    > > Gururaja

    >
    > Hi!
    >
    > for starters read ,http://www.linuxjournal.com/article/8110, article
    > at Linux journal about reading , and writnig files from the linux
    > kernel.
    >
    > First of all , this is not recommended , secondly you have to check
    > whether the symbols , sys_open , sys_read , sys_write are exported in
    > your kernel. A simple way to do is :
    >
    > # more /proc/ksyms|egrep sys_open , for sys_open and similarly for
    > others. If it shows nothing , then these symbols have been unexported
    > in your kernel version.
    >
    > Then later maybe you have to manually apply some patches and recompile
    > the kernel
    >
    > thanks


    HI
    Thanks for the valuable article.

    Regards
    Gururaja

+ Reply to Thread