open file in kernel space????

Posted on 2002-05-03
Last Modified: 2008-01-09
Please help me! Can i open file or create socket in kernel space????
Question by:minhtuanq7
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

Accepted Solution

bryanh earned 100 total points
ID: 6990680
Yes.  This is a common enough question that I keep an example of it in .

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.

Expert Comment

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

Expert Comment

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.

EE Cleanup Volunteer

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

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…
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

630 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