man-pages/man2/ioperm.2.html
2021-03-31 01:06:50 +01:00

183 lines
4.0 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of IOPERM</TITLE>
</HEAD><BODY>
<H1>IOPERM</H1>
Section: Linux Programmer's Manual (2)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
ioperm - set port input/output permissions
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>#include &lt;<A HREF="file:///usr/include/sys/io.h">sys/io.h</A>&gt;</B>
/* for glibc */
<P>
<B>int ioperm(unsigned long </B><I>from</I><B>, unsigned long </B><I>num</I><B>, int </B><I>turn_on</I><B>);</B>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<B>ioperm</B>()
sets the port access permission bits for the calling thread for
<I>num</I>
bits starting from port address
<I>from</I>.
If
<I>turn_on</I>
is nonzero, then permission for the specified bits is enabled;
otherwise it is disabled.
If
<I>turn_on</I>
is nonzero, the calling thread must be privileged
(<B>CAP_SYS_RAWIO</B>).
<P>
Before Linux 2.6.8,
only the first 0x3ff I/O ports could be specified in this manner.
For more ports, the
<B><A HREF="/cgi-bin/man/man2html?2+iopl">iopl</A></B>(2)
system call had to be used (with a
<I>level</I>
argument of 3).
Since Linux 2.6.8, 65,536 I/O ports can be specified.
<P>
Permissions are inherited by the child created by
<B><A HREF="/cgi-bin/man/man2html?2+fork">fork</A></B>(2)
(but see NOTES).
Permissions are preserved across
<B><A HREF="/cgi-bin/man/man2html?2+execve">execve</A></B>(2);
this is useful for giving port access permissions to unprivileged
programs.
<P>
This call is mostly for the i386 architecture.
On many other architectures it does not exist or will always
return an error.
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
On success, zero is returned.
On error, -1 is returned, and
<I>errno</I>
is set appropriately.
<A NAME="lbAF">&nbsp;</A>
<H2>ERRORS</H2>
<DL COMPACT>
<DT id="1"><B>EINVAL</B>
<DD>
Invalid values for
<I>from</I>
or
<I>num</I>.
<DT id="2"><B>EIO</B>
<DD>
(on PowerPC) This call is not supported.
<DT id="3"><B>ENOMEM</B>
<DD>
Out of memory.
<DT id="4"><B>EPERM</B>
<DD>
The calling thread has insufficient privilege.
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>CONFORMING TO</H2>
<B>ioperm</B>()
is Linux-specific and should not be used in programs
intended to be portable.
<A NAME="lbAH">&nbsp;</A>
<H2>NOTES</H2>
The
<I>/proc/ioports</I>
file shows the I/O ports that are currently allocated on the system.
<P>
Before Linux 2.4,
permissions were not inherited by a child created by
<B><A HREF="/cgi-bin/man/man2html?2+fork">fork</A></B>(2).
<P>
Glibc has an
<B>ioperm</B>()
prototype both in
<I>&lt;<A HREF="file:///usr/include/sys/io.h">sys/io.h</A>&gt;</I>
and in
<I>&lt;<A HREF="file:///usr/include/sys/perm.h">sys/perm.h</A>&gt;</I>.
Avoid the latter, it is available on i386 only.
<A NAME="lbAI">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?2+iopl">iopl</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+outb">outb</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?7+capabilities">capabilities</A></B>(7)
<A NAME="lbAJ">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="5"><A HREF="#lbAB">NAME</A><DD>
<DT id="6"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="7"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="8"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="9"><A HREF="#lbAF">ERRORS</A><DD>
<DT id="10"><A HREF="#lbAG">CONFORMING TO</A><DD>
<DT id="11"><A HREF="#lbAH">NOTES</A><DD>
<DT id="12"><A HREF="#lbAI">SEE ALSO</A><DD>
<DT id="13"><A HREF="#lbAJ">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:33 GMT, March 31, 2021
</BODY>
</HTML>