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