Solved

userspace to kernel interraction

Posted on 2004-03-30
5
204 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

13 Experts available now in Live!

Get 1:1 Help Now