Where to start with Linux Kernel Modules?

寵の児 提交于 2019-12-05 00:22:05

问题


A little background, I'm a CMPE Student currently in an Operating Systems class. I have some basic knowledge of C coding but am more comfortable with C++ (taken about 3 semesters of that). Other than that, never had any other formal training in coding. Also, I've got a basic understanding of the linux environment.

I am working on a project that requires me and my team to code a linux kernel module that can do the following:

  • echoes data passed from user-level processes by printing the data received to the kernel log
  • is able to pass data from one user process to another.
  • must be possible to use the kernel module as an inter-process communication abstraction. module should provide for situations where a sender posts data to it but no receiver is waiting.module must cover the situation where a receiver asks for data but there is no data available.
  • module must cover the situation where a receiver asks for data but there is no data available.
  • must be a limit in the buffer capacity in your module.

Now I don't know how difficult this seems to those with a background in programming, but this seems like an impossibly complicated task for someone in my position.

Here's what I've done so far:

  1. Coded, Compiled, Inserted, and Removed the basic "hello world" linux kernel module successfully
  2. Read through about the first 4 or 5 chapters of The Linux Kernel Module Programming Guide
  3. Read through a few stackoverflow posts, none of which seem to be able to direct me to where I need to go.

So finally here's my question: Can someone please point me in the direction that I need to go with this? I don't even know where to being to find commands to use for reading in user-level process data and I need somewhere to start me off. TLPD was great for insight on the topic but isn't helping me get to the point where I will have a workable project to turn in. In the past, I would learn off of reading source code and reverse engineering, is there anywhere I can find something like that? Any and all help is appreciated.

-Will


回答1:


I've found that the Linux Kernel Module Programming Guide is a pretty good resource. From the sounds of it, something like a character device might work best for your purposes, but I'm not sure if you have other constraints.

Another direction I might consider (though this could be a bad path) is to look at examples in the Linux kernel for a kernel module that has similar functionality. I don't have a good example offhand, but perhaps look through /drivers/char/.




回答2:


What you describe is pretty much the same as a pipe.

Read chapter three of Linux Device Drivers. (But don't just copy the scull pipe example …)



来源:https://stackoverflow.com/questions/19667624/where-to-start-with-linux-kernel-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!