Find the answer to your Linux question:
Results 1 to 2 of 2
Hi all, How to open a file inside a driver. I heard that it is bad idea to open a file inside a kernel module but my driver wants to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2006
    Posts
    24

    how to open a file inside a driver (kernel module)


    Hi all,
    How to open a file inside a driver. I heard that it is bad idea to open a file inside a kernel module but my driver wants to open a file for maintaining device states. Can anyone help me in this.If opening a file is bad idea in a kernel module how the network drivers are maintaining the mac addresses . So please help me how can i proceed .

  2. #2
    Linux User fernape's Avatar
    Join Date
    Dec 2005
    Location
    Holland
    Posts
    301
    Quote Originally Posted by raju82
    I heard that it is bad idea to open a file inside a kernel module
    Yes, it is really a bad idea that has been extensively discussed time ago... in fact, in kernelnewbies, it has been included in the FAQ.

    http://kernelnewbies.org/FAQ/WhyWrit...romKernelIsBad
    Quote Originally Posted by raju82
    my driver wants to open a file for maintaining device states
    I don't know what you mean... if you are attempting to communicate with userland and tell something like: "Device is busy" "Device ready" and so on... you should use one of the pseudo-filesystems provided by the kernel (sysfs, debugfs or procfs, although this last should be used only if your module offers process related information. For general information use the first ones).

    Quote Originally Posted by raju82
    how the network drivers are maintaining the mac addresses
    The NIC data is stored in the net_device structure declared at linux/netdevice.h. See the field:

    Code:
    unsigned char           perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
    Regards

Posting Permissions

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