namespaces.7: ffix
[man-pages.git] / man2 / ioperm.2
blob7d4a4690ad781d1f8269fbed567e56848af90c07
1 .\" Copyright (c) 1993 Michael Haardt
2 .\" (michael@moria.de)
3 .\" Fri Apr  2 11:32:09 MET DST 1993
4 .\"
5 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
6 .\" This is free documentation; you can redistribute it and/or
7 .\" modify it under the terms of the GNU General Public License as
8 .\" published by the Free Software Foundation; either version 2 of
9 .\" the License, or (at your option) any later version.
10 .\"
11 .\" The GNU General Public License's references to "object code"
12 .\" and "executables" are to be interpreted as the output of any
13 .\" document formatting or typesetting system, including
14 .\" intermediate and printed output.
15 .\"
16 .\" This manual is distributed in the hope that it will be useful,
17 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
18 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 .\" GNU General Public License for more details.
20 .\"
21 .\" You should have received a copy of the GNU General Public
22 .\" License along with this manual; if not, see
23 .\" <http://www.gnu.org/licenses/>.
24 .\" %%%LICENSE_END
25 .\"
26 .\" Modified Sat Jul 24 15:12:05 1993 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified Tue Aug  1 16:27    1995 by Jochen Karrer
28 .\"                              <cip307@cip.physik.uni-wuerzburg.de>
29 .\" Modified Tue Oct 22 08:11:14 EDT 1996 by Eric S. Raymond <esr@thyrsus.com>
30 .\" Modified Mon Feb 15 17:28:41 CET 1999 by Andries E. Brouwer <aeb@cwi.nl>
31 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
32 .\"     Added notes on capability requirements
33 .\"
34 .TH IOPERM 2 2021-03-22 "Linux" "Linux Programmer's Manual"
35 .SH NAME
36 ioperm \- set port input/output permissions
37 .SH SYNOPSIS
38 .nf
39 .B #include <sys/io.h>
40 .PP
41 .BI "int ioperm(unsigned long " from ", unsigned long " num ", int " turn_on );
42 .fi
43 .SH DESCRIPTION
44 .BR ioperm ()
45 sets the port access permission bits for the calling thread for
46 .I num
47 bits starting from port address
48 .IR from .
50 .I turn_on
51 is nonzero, then permission for the specified bits is enabled;
52 otherwise it is disabled.
54 .I turn_on
55 is nonzero, the calling thread must be privileged
56 .RB ( CAP_SYS_RAWIO ).
57 .PP
58 Before Linux 2.6.8,
59 only the first 0x3ff I/O ports could be specified in this manner.
60 For more ports, the
61 .BR iopl (2)
62 system call had to be used (with a
63 .I level
64 argument of 3).
65 Since Linux 2.6.8, 65,536 I/O ports can be specified.
66 .PP
67 Permissions are inherited by the child created by
68 .BR fork (2)
69 (but see NOTES).
70 Permissions are preserved across
71 .BR execve (2);
72 this is useful for giving port access permissions to unprivileged
73 programs.
74 .PP
75 This call is mostly for the i386 architecture.
76 On many other architectures it does not exist or will always
77 return an error.
78 .SH RETURN VALUE
79 On success, zero is returned.
80 On error, \-1 is returned, and
81 .I errno
82 is set to indicate the error.
83 .SH ERRORS
84 .TP
85 .B EINVAL
86 Invalid values for
87 .I from
89 .IR num .
90 .TP
91 .B EIO
92 (on PowerPC) This call is not supported.
93 .TP
94 .B ENOMEM
95 .\" Could not allocate I/O bitmap.
96 Out of memory.
97 .TP
98 .B EPERM
99 The calling thread has insufficient privilege.
100 .SH CONFORMING TO
101 .BR ioperm ()
102 is Linux-specific and should not be used in programs
103 intended to be portable.
104 .SH NOTES
106 .I /proc/ioports
107 file shows the I/O ports that are currently allocated on the system.
109 Before Linux 2.4,
110 permissions were not inherited by a child created by
111 .BR fork (2).
113 Glibc has an
114 .BR ioperm ()
115 prototype both in
116 .I <sys/io.h>
117 and in
118 .IR <sys/perm.h> .
119 Avoid the latter, it is available on i386 only.
120 .SH SEE ALSO
121 .BR iopl (2),
122 .BR outb (2),
123 .BR capabilities (7)