Find the answer to your Linux question:
Results 1 to 2 of 2
hi, when i want to open a file in user space i do: int fd; fd = open("myfile", O_RONLY); ... how can i do the same thing inside module? should ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2005
    Posts
    3

    how to open file (similar to what is done is user space) inside kernel module


    hi,
    when i want to open a file in user space i do:

    int fd;
    fd = open("myfile", O_RONLY);
    ...

    how can i do the same thing inside module? should i call sys_open?
    thanks a lot,
    Meirav.

  2. #2
    Just Joined!
    Join Date
    Nov 2005
    Posts
    2
    This should work. I borrowed the code from http://www.kevinboone.com/linux_kernel_file_1.html

    struct file *f = filp_open(name, flags, mode);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •