简体   繁体   中英

Where to start with Linux Kernel Modules?

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

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/ .

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 …)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM