| 1 |
.\" Copyright, the authors of the Linux man-pages project |
| 2 |
.\" |
| 3 |
.\" SPDX-License-Identifier: GPL-2.0-or-later |
| 4 |
.\" |
| 5 |
.TH ioperm 2 2025-05-17 "Linux man-pages 6.18" |
| 6 |
.SH NAME |
| 7 |
ioperm \- set port input/output permissions |
| 8 |
.SH LIBRARY |
| 9 |
Standard C library |
| 10 |
.RI ( libc ,\~ \-lc ) |
| 11 |
.SH SYNOPSIS |
| 12 |
.nf |
| 13 |
.B #include <sys/io.h> |
| 14 |
.P |
| 15 |
.BI "int ioperm(unsigned long " from ", unsigned long " num ", int " turn_on ); |
| 16 |
.fi |
| 17 |
.SH DESCRIPTION |
| 18 |
.BR ioperm () |
| 19 |
sets the port access permission bits for the calling thread for |
| 20 |
.I num |
| 21 |
bits starting from port address |
| 22 |
.IR from . |
| 23 |
If |
| 24 |
.I turn_on |
| 25 |
is nonzero, then permission for the specified bits is enabled; |
| 26 |
otherwise it is disabled. |
| 27 |
If |
| 28 |
.I turn_on |
| 29 |
is nonzero, the calling thread must be privileged |
| 30 |
.RB ( CAP_SYS_RAWIO ). |
| 31 |
.P |
| 32 |
Before Linux 2.6.8, |
| 33 |
only the first 0x3ff I/O ports could be specified in this manner. |
| 34 |
For more ports, the |
| 35 |
.BR iopl (2) |
| 36 |
system call had to be used (with a |
| 37 |
.I level |
| 38 |
argument of 3). |
| 39 |
Since Linux 2.6.8, 65,536 I/O ports can be specified. |
| 40 |
.P |
| 41 |
Permissions are inherited by the child created by |
| 42 |
.BR fork (2) |
| 43 |
(but see HISTORY). |
| 44 |
Permissions are preserved across |
| 45 |
.BR execve (2); |
| 46 |
this is useful for giving port access permissions to unprivileged |
| 47 |
programs. |
| 48 |
.P |
| 49 |
This call is mostly for the i386 architecture. |
| 50 |
On many other architectures it does not exist or will always |
| 51 |
return an error. |
| 52 |
.SH RETURN VALUE |
| 53 |
On success, zero is returned. |
| 54 |
On error, \-1 is returned, and |
| 55 |
.I errno |
| 56 |
is set to indicate the error. |
| 57 |
.SH ERRORS |
| 58 |
.TP |
| 59 |
.B EINVAL |
| 60 |
Invalid values for |
| 61 |
.I from |
| 62 |
or |
| 63 |
.IR num . |
| 64 |
.TP |
| 65 |
.B EIO |
| 66 |
(on PowerPC) This call is not supported. |
| 67 |
.TP |
| 68 |
.B ENOMEM |
| 69 |
.\" Could not allocate I/O bitmap. |
| 70 |
Out of memory. |
| 71 |
.TP |
| 72 |
.B EPERM |
| 73 |
The calling thread has insufficient privilege. |
| 74 |
.SH VERSIONS |
| 75 |
glibc has an |
| 76 |
.BR ioperm () |
| 77 |
prototype both in |
| 78 |
.I <sys/io.h> |
| 79 |
and in |
| 80 |
.IR <sys/perm.h> . |
| 81 |
Avoid the latter, it is available on i386 only. |
| 82 |
.SH STANDARDS |
| 83 |
Linux. |
| 84 |
.SH HISTORY |
| 85 |
Before Linux 2.4, |
| 86 |
permissions were not inherited by a child created by |
| 87 |
.BR fork (2). |
| 88 |
.SH NOTES |
| 89 |
The |
| 90 |
.I /proc/ioports |
| 91 |
file shows the I/O ports that are currently allocated on the system. |
| 92 |
.SH SEE ALSO |
| 93 |
.BR iopl (2), |
| 94 |
.BR outb (2), |
| 95 |
.BR capabilities (7) |