Solved

Writing into a file from device driver

Posted on 2006-11-22
4
242 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
Comment Utility
AFAIK you have to use printk() for that
0
 
LVL 27

Accepted Solution

by:
Nopius earned 25 total points
Comment Utility
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
Comment Utility
Thanks Nopius! U saved a lot of my time and effort :)
0
 
LVL 27

Expert Comment

by:Nopius
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now