Solved

userspace to kernel interraction

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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