TheMeaningfulEngineer
TheMeaningfulEngineer

Reputation: 16339

How do userspace programs interact with kernel moduels?

The motivation for this question is my try to figure out with which kernel module is the command aplay sound.wav communicating to play the actual audio file. If it uses the library functions for it, trace it to the library function".

My current understanding is that the kernel modules provide an interface to the user space through device files in /dev. So I would expect to identify somewhere in the source code a stream form the sound.wav being sent to a /dev/something.

Is this an oversimplification of the real situation?

Upvotes: 0

Views: 272

Answers (2)

LubosD
LubosD

Reputation: 840

ALSA's device nodes are located in /dev/snd. The logic to open individual device nodes is within libasound and follows (optionally) the rules set in /etc/asoundrc or ~/.asoundrc.

I'm not sure if this helps you to find the specific kernel module. I'd use aplay -L to identify the hardware used and then lsmod to see which module it is.

Upvotes: 1

Andreas Bombe
Andreas Bombe

Reputation: 2470

The ways user space can interact with the kernel are mainly the device files you mention and system calls. There are others like netlink, files in /sys and more.

Playing audio would be accomplished through a device file, yes. However, the device file may not be opened in the application directly, it may use a library to do that. In that case the program does open the /dev file, but you won't find that in the source code.

Another possibility is that it uses a sound server. It doesn't open a /dev file at all in that case, it just connects to a sound server to let it do that work.

Upvotes: 0

Related Questions