.\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
.\" Added notes on capability requirements
.\"
-.TH IOPERM 2 2013-03-12 "Linux" "Linux Programmer's Manual"
+.TH IOPERM 2 2017-09-15 "Linux" "Linux Programmer's Manual"
.SH NAME
ioperm \- set port input/output permissions
.SH SYNOPSIS
-.B #include <unistd.h>
-/* for libc5 */
-.br
.B #include <sys/io.h>
/* for glibc */
-.sp
+.PP
.BI "int ioperm(unsigned long " from ", unsigned long " num ", int " turn_on );
.SH DESCRIPTION
.BR ioperm ()
.I num
bits starting from port address
.IR from .
-If
+If
.I turn_on
is nonzero, then permission for the specified bits is enabled;
otherwise it is disabled.
.I turn_on
is nonzero, the calling thread must be privileged
.RB ( CAP_SYS_RAWIO ).
-
+.PP
Before Linux 2.6.8,
only the first 0x3ff I/O ports could be specified in this manner.
For more ports, the
.BR iopl (2)
-system call had to be used.
+system call had to be used (with a
+.I level
+argument of 3).
Since Linux 2.6.8, 65,536 I/O ports can be specified.
-
-Permissions are not inherited by the child created by
-.BR fork (2);
-following a
+.PP
+Permissions are inherited by the child created by
.BR fork (2)
-the child must turn on those permissions that it needs.
+(but see NOTES).
Permissions are preserved across
.BR execve (2);
this is useful for giving port access permissions to unprivileged
programs.
-
+.PP
This call is mostly for the i386 architecture.
On many other architectures it does not exist or will always
return an error.
is Linux-specific and should not be used in programs
intended to be portable.
.SH NOTES
-Libc5 treats it as a system call and has a prototype in
-.IR <unistd.h> .
-Glibc1 does not have a prototype.
-Glibc2 has a prototype both in
+The
+.I /proc/ioports
+file shows the I/O ports that are currently allocated on the system.
+.PP
+Before Linux 2.4,
+permissions were not inherited by a child created by
+.BR fork (2).
+.PP
+Glibc has an
+.BR ioperm ()
+prototype both in
.I <sys/io.h>
and in
.IR <sys/perm.h> .
Avoid the latter, it is available on i386 only.
.SH SEE ALSO
.BR iopl (2),
+.BR outb (2),
.BR capabilities (7)