Find the answer to your Linux question:
Results 1 to 6 of 6
Hello, Can a kernel module write to a file? If so how can you do this... Thanks Gerard4143...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714

    Writing to a file from a kernel module???


    Hello,

    Can a kernel module write to a file? If so how can you do this...

    Thanks Gerard4143

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,225
    I don't think that's possible. AFAIK the kernel doesn't use the C library, so there are no I/O functions available except for the built-in printk to print kernel messages for klogd.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  3. #3
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714

    Afaik????

    AFAIK...not sure what this means...Gerard4143

  4. #4
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714

    Printk

    Printk also prints to a file /var/log/messages. So the kernel does write to a file in some capacity....Gerard4143

  5. #5
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,225
    Sorry for jargon, Gerard. AFAIK means "as far as I know".

    Actually the kernel does not write to /var/log/messages. That is done by a separate program called klogd which runs in the background of your system (you will sometimes find programs of this sort referred to as daemons).

    klogd and its twin brother syslogd are responsible for routing all system messages: klogd handles messages from the kernel and syslogd messages from other programs. The file /etc/syslog.conf specifies where these messages will go; on most Linux systems they go to /var/log/messages but some may be copied elsewhere. Read the man page on syslog.conf for further details.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  6. #6
    Linux Newbie dilbert's Avatar
    Join Date
    Sep 2006
    Location
    Yorkshire, GB
    Posts
    237
    At least, kernel modules, i.e. drivers, write to the /proc file system. klogd is a kernel module, too, or isn't it?

    There is also a file /etc/mtab or the like where many kernels writes on at start-up what makes it difficult to run those kernels from read-only file systems.

    There are maybe more examples but those have come to my mind.
    Bus Error: Passengers dumped. Hech gap yo'q.

Posting Permissions

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