Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What are some user space examples of using inb, inl, and inw to access kernel space in Linux?

share|improve this question

inb, outb and friends aren't meant for kernel ↔ userspace communication, they are used to read from and write to platform-specific IO ports.

Typical usage for these features would be direct interactions with the serial or parallel ports (and thus devices attached), without going all the way and creating specific kernel device drivers.
X servers can also use these for low-level communication with the video (or possibly input device) hardware.

To use these calls from userspace, two things are required:

  • The calling process must have CAP_SYS_RAWIO capability (this usually means it needs to be run as root).
  • The calling process must request permission to use the ports it wants, with the ioperm or iopl system calls.

Linux I/O port programming mini-HOWTO will walk you through the essentials, and there's a simple example program at the end*.
Do note that programs that use this communicate directly with whatever hardware (or firmware) is behind those ports. The kernel doesn't validate or otherwise interfere with these calls. So mis-using them could cause serious problems. Handle with care.

*You'll need to #include <stdlib.h> and replace <asm/io.h> with <sys/io.h> to get it to compile.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.