ioperm(2)

๐Ÿ’– ioperm(2) โ€” set I/O port permissions ๐Ÿ’–

okay bestie, welcome to the ioperm page from the System Calls Manual ๐ŸŽ€ this one's short and sweet, let's get into it ๐Ÿ’…


๐Ÿ“š LIBRARY

Standard C library (libc, -lc) ๐Ÿซถ


โœจ SYNOPSIS

#include <sys/io.h>

int ioperm(unsigned long from, unsigned long num, int turn_on);

๐ŸŒธ DESCRIPTION

so basically, ioperm() sets the calling thread's access permission for num ports, starting from port address from ๐Ÿฆ‹

if turn_on is nonzero, permission for those ports gets turned on; otherwise it gets turned off. and here's the tea: if turn_on is nonzero, the calling thread must be privileged โ€” like, it needs CAP_SYS_RAWIO ๐Ÿ‘‘

okay now the lore: before Linux 2.6.8, only the first 0x3ff I/O ports could be specified this way. wanted more? you had to use the iopl(2) system call instead, with a level argument of 3 ๐Ÿ˜ญ since Linux 2.6.8, 65,536 I/O ports can be specified. we love growth ๐Ÿ’–

permissions are inherited by the child created by fork(2) โ€” but peek at HISTORY for the plot twist ๐Ÿ™ˆ permissions are preserved across execve(2), which is lowkey the whole point: it's useful for giving port access permissions to unprivileged programs โœจ

this call is mostly for the i386 architecture. on many other architectures it does not exist, or it will always return an error ๐Ÿ’€


๐Ÿ”ฅ RETURN VALUE

win? you get zero ๐ŸŽ‰ lose? you get -1 back, and errno is set to tell you what went wrong ๐Ÿ’…


๐Ÿ’€ ERRORS

  • EINVAL โ€” invalid values for from or num ๐Ÿ™ˆ
  • EIO โ€” (on PowerPC) this call is not supported, sorry bestie ๐Ÿ˜ญ
  • ENOMEM โ€” out of memory ๐Ÿ˜ต
  • EPERM โ€” the calling thread has insufficient privilege ๐Ÿ‘‘๐Ÿšซ

โญ VERSIONS

glibc has an ioperm() prototype in both <sys/io.h> and <sys/perm.h>. avoid the latter โ€” it is available on i386 only ๐Ÿšฉ


๐ŸŒˆ STANDARDS

Linux โœจ


๐Ÿ•ฐ๏ธ HISTORY

before Linux 2.4, permissions were not inherited by a child created by fork(2). wild, right? ๐Ÿ˜ณ


๐Ÿงš NOTES

the /proc/ioports file shows the I/O ports that are currently allocated on the system ๐Ÿ‘€ handy!!


๐Ÿ‘€ SEE ALSO

iopl(2), outb(2), capabilities(7)


and that's the whole page, no cap ๐Ÿ’– go forth and permission responsibly bestie ๐Ÿซถ

okay love u bye โ€” this was pulled from Linux man-pages 6.20, dated 2026-10-11 ๐ŸŽ€๐Ÿ’œโœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: GPL-2.0-or-later
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms