Solved

Writing into a file from device driver

Posted on 2006-11-22
4
246 Views
Last Modified: 2012-05-05
Hello experts!

I am writing a simple character device driver in C. I wanted to know if there is a way that I can open a text file and then read/write into it from within the driver.

To summarize, I want to:
1. open a text file from within device driver
2. write some debug data into the file
3. close the text file

I am new to linux kernel programming. Please let me know if there is a way to achieve the above tasks.

Regards,
Vikram
0
Comment
Question by:Vikram_B
  • 2
4 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 17996763
AFAIK you have to use printk() for that
0
 
LVL 27

Accepted Solution

by:
Nopius earned 25 total points
ID: 18000510
Short answer: NO WAY.
Long answer: probably possible but is _very_ difficult and highly unrecommended.

Read here an answer: http://uwsg.iu.edu/hypermail/linux/kernel/0005.3/0061.html
0
 

Author Comment

by:Vikram_B
ID: 18001086
Thanks Nopius! U saved a lot of my time and effort :)
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18001298
Vikram_B: that was all about files. But as ahoffman say, printk() may help to debug driver. Using this function you can generate kernel log messages, that you may log via syslog or read with 'dmesg' command.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question