Solved

open file in kernel space????

Posted on 2002-05-03
4
422 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
Comment Utility
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
Comment Utility
Have also a look at khttpd, it's in /usr/src/linux/net/khttpd.
0
 
LVL 20

Expert Comment

by:jmcg
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

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 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 discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

10 Experts available now in Live!

Get 1:1 Help Now