Solved

open file in kernel space????

Posted on 2002-05-03
4
430 Views
Last Modified: 2008-01-09
Please help me! Can i open file or create socket in kernel space????
0
Comment
Question by:minhtuanq7
4 Comments
 
LVL 5

Accepted Solution

by:
bryanh earned 100 total points
ID: 6990680
Yes.  This is a common enough question that I keep an example of it in ftp://giraffe-data.com/pub/filewrite.c .

The example is C source code for a loadable kernel module that writes stuff into a regular file when you attempt to load it.  The load always fails.

It's usually bad design to have the kernel access a regular file, and in fact in Linux the only place I have ever seen it is in the NFS server, and that's pretty much an acknowledged performance hack (i.e. it was meant to be in user space).  But it works.

The key to understanding it is that you can't issue a system call (e.g. write()) from inside the kernel, but you can call the same subroutine that the system call handler does when a user program issues the system call.

Creating sockets is a whole separate question, but the overall strategy is similar.
0
 
LVL 3

Expert Comment

by:superschlonz
ID: 7020299
Have also a look at khttpd, it's in /usr/src/linux/net/khttpd.
0
 
LVL 20

Expert Comment

by:jmcg
ID: 9915669
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: bryanh {http:#6990680}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
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

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 Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

803 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