Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

userspace to kernel interraction

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

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

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 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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

840 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