LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-31-2005, 12:28 PM   #1
cyu021
Member
 
Registered: Oct 2004
Posts: 43

Rep: Reputation: 15
How to open /dev/mem in kernl code?


Hi,

I've been trying to open /dev/mem with a kernel function.
I followed this link, and here is how my code looks like:
Code:
voide test(void)
{
    struct file *fp;
    fp = filp_open("/dev/mem", O_RDONLY, 0);
    filp_close(fp, 0);
}
This test() function is put into linux/init/main.c

I can build bzImage without a problem, however, everytime I tried to do
Code:
call test()
in gdb, I get the following error:
Code:
sleeping function called from invalid context at include/asm/semaphore.h:119
in_atomic():1, irqs_disabled():1
[<c01081aa>] dump_stack+0x1e/0x22
[<c0121d64>] __might_slep+0xb2/0xd3
...
kernel BUG at fs/buffer.c:1436!
invalid operand: 0000 [#1]
PREEMPT SMP DEBUG_PAGEALLOC
Did I do anything wrong or missing something?

Any help would be greatly appreciatd,
James
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What would happen if I where to cat /dev/mem > /dev/null Joey.Dale Linux - General 11 07-26-2009 12:46 PM
how do I compile kernl with nothing installed xlioilx Linux - Newbie 4 02-22-2005 05:21 PM
serial to USB, trying to read from /dev/ttyUSB0 in C code newguy21 Programming 1 09-29-2004 01:11 PM
Open Firmware code for booting OS from SATA : sample code available somewhere ? drsparikh Linux - Hardware 0 03-12-2004 11:16 AM
BLFS: XFree86; TDFX(0) Cannot open /dev/mem. And some other related questions SparceMatrix Linux From Scratch 1 06-14-2003 02:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration