Solved

userspace to kernel interraction

Posted on 2004-03-30
5
208 Views
Last Modified: 2010-04-22
i want to open a file in user space & want to copy its contents to the kernel space module. & i wanto kno the reverse procedure too...

actually my ioctl call wud activate my module & then the module reads the file & does some work... & at last has to write the file back to the user space...

i found out that it canb done by copy_to_user & etc... functions... but have no time for experimentation now..

& how to manage memory in kernel space ... i mean to allocate buffers & manipulate as done in user space with malloc.

cud i get some code that gets this work done... coz im in areal hurry, so if i get some code... i wud b indebted... plz
thx
namus
0
Comment
Question by:namus
5 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 50 total points
ID: 10720993
I do not have any code at hand but exchange between user and kernel space is indeed done using copy_to_user
copy_from_user
get_user
put_user

all of them should be called from user context

memory allocation
kmalloc
kfree

you may also like to read about vmalloc and __get_free_pages ... you should also know about GFP_KERNEL and GFP_ATOMIC flags that are passed to kmalloc ... (there are more but these two are important)

reading about them will take less than 30 minutes and should get you a start
http://wwwos.inf.tu-dresden.de/~ch12/diplom/DocBook/kernel-api/
0
 
LVL 8

Expert Comment

by:manish_regmi
ID: 10722023
0
 
LVL 8

Expert Comment

by:Anthony2000
ID: 10744577
Rubini's book which can be found online has examples that you can build and try out.
http://www.xml.com/ldd/chapter/book/

See chapter 5, it covers the basics with regards to ioctl, Blocking I/O, Asynchronous Notification, etc.

Cheers
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Boot Linux vm into a menu system 2 82
automating commands in linux on start up 2 45
How to trace the cause of Out Of Memory issues 8 68
improve Shell script 5 145
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…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 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

21 Experts available now in Live!

Get 1:1 Help Now