Live data from Hacker News

Linux Kernel Module Programming Guide

sysprog21.github.io

11–20 of 44 posts

Re: Linux Kernel Module Programming Guide

#13
post #12

I’ve always been fascinated by kernel development. Realistically though, what are some examples of useful modules someone could write without several years of practice?

I wrote some low level code to turn an Arduino into a USB audio device and bit banged audio from a couple pins. Basically no experience in hardware stuff. But to be clear, getting good at programming is definitely a year+ kinda thing, of full time focus.

Re: Linux Kernel Module Programming Guide

#14
post #12

I’ve always been fascinated by kernel development. Realistically though, what are some examples of useful modules someone could write without several years of practice?

I wrote some low level code to turn an Arduino into a USB audio device and bit banged audio from a couple pins. Basically no experience in hardware stuff. But to be clear, getting good at programming is definitely a year+ kinda thing, of full time focus.

Expanding on this reply, you can think of Kernel Modules as Windows drivers. Most of the time they are meant to be used as an interface on which you can communicate from the OS with an underlying device more easily .

Re: Linux Kernel Module Programming Guide

#15
post #12

I’ve always been fascinated by kernel development. Realistically though, what are some examples of useful modules someone could write without several years of practice?

Probably nothing that will get added to the upstream source but you could make infinite file system modules for things. Userspace FUSE would probably make more sense but this would be a good way to get started.

The general vibe I got when looking in to this is that the Linux kernel has more than enough contributors right now so they make no effort to make it beginner friendly or offer an easy on ramp. IIRC Linus said they have trouble simply reviewing all the changes they receive and if you want to help out Linux, your time would be better used on the non kernel projects.

Things like Gnome or Libre Office would be more than happy to receive help.

Re: Linux Kernel Module Programming Guide

#16
post #12

I’ve always been fascinated by kernel development. Realistically though, what are some examples of useful modules someone could write without several years of practice?

I wrote some low level code to turn an Arduino into a USB audio device and bit banged audio from a couple pins. Basically no experience in hardware stuff. But to be clear, getting good at programming is definitely a year+ kinda thing, of full time focus.

How did you end up doing USB with the Arduino? Was it bit banged as well (VUSB)? Is this code available anywhere?

Re: Linux Kernel Module Programming Guide

#17

Earlier quoted context omitted.

I wrote some low level code to turn an Arduino into a USB audio device and bit banged audio from a couple pins. Basically no experience in hardware stuff. But to be clear, getting good at programming is definitely a year+ kinda thing, of full time focus.

Expanding on this reply, you can think of Kernel Modules as Windows drivers. Most of the time they are meant to be used as an interface on which you can communicate from the OS with an underlying device more easily .

And usually they are paired with a user space tool for even easier interaction. Ideally the driver should expose literally every function and possible action and then the userspace tool has the job of simplifying that down and not supporting very unusual or complicated setups.

You could think of the userspace side as the gui you get with gpu drivers which interacts with a separate kernel space side

Re: Linux Kernel Module Programming Guide

#18
post #12

I’ve always been fascinated by kernel development. Realistically though, what are some examples of useful modules someone could write without several years of practice?

I've been wanting to write modules to bring more of Plan 9 to Linux by exposing character devices in /dev for TCP (and probably other things, but that's the big one).

Re: Linux Kernel Module Programming Guide

#19
post #12

I’ve always been fascinated by kernel development. Realistically though, what are some examples of useful modules someone could write without several years of practice?

I've been wanting to write modules to bring more of Plan 9 to Linux by exposing character devices in /dev for TCP (and probably other things, but that's the big one).

One of the reasons this probably hasn't already happened is because bash specially handles those so they work already. From the man page for bash:

       Bash handles several filenames specially when they are used in redirections, as described in the following table:

              /dev/fd/fd
                     If fd is a valid integer, file descriptor fd is duplicated.
              /dev/stdin
                     File descriptor 0 is duplicated.
              /dev/stdout
                     File descriptor 1 is duplicated.
              /dev/stderr
                     File descriptor 2 is duplicated.
              /dev/tcp/host/port
                     If host is a valid hostname or Internet address, and port is an integer port number or service name, bash attempts to open
                     a TCP connection to the corresponding socket.
              /dev/udp/host/port
                     If host is a valid hostname or Internet address, and port is an integer port number or service name, bash attempts to open
                     a UDP connection to the corresponding socket.
Edit: Not to imply it's not a good idea. I think it is, so much so that the only reason it wasn't done long ago is because often a "good enough for most people" solution can sap the need for a different solution which has other benefits.

Re: Linux Kernel Module Programming Guide

#20
post #19

Earlier quoted context omitted.

I've been wanting to write modules to bring more of Plan 9 to Linux by exposing character devices in /dev for TCP (and probably other things, but that's the big one).

One of the reasons this probably hasn't already happened is because bash specially handles those so they work already. From the man page for bash: Bash handles several filenames specially when they are used in redirections, as described in the following table: /dev/fd/fd If fd is a valid integer, file descriptor fd is duplicated. /dev/stdin File descriptor 0 is duplicated. /dev/stdout File descriptor 1 is duplicated.…

I'm aware, but I want that functionality outside of BASH.
Post reply on HN