230 lines
5.0 KiB
HTML
230 lines
5.0 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of IOCTL</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>IOCTL</H1>
|
|
Section: Linux Programmer's Manual (2)<BR>Updated: 2017-05-03<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
ioctl - control device
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/sys/ioctl.h">sys/ioctl.h</A>></B>
|
|
|
|
<P>
|
|
|
|
<B>int ioctl(int </B><I>fd</I><B>, unsigned long </B><I>request</I><B>, ...);</B>
|
|
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The
|
|
<B>ioctl</B>()
|
|
|
|
system call manipulates the underlying device parameters of special files.
|
|
In particular, many operating characteristics of character special files
|
|
(e.g., terminals) may be controlled with
|
|
<B>ioctl</B>()
|
|
|
|
requests.
|
|
The argument
|
|
<I>fd</I>
|
|
|
|
must be an open file descriptor.
|
|
<P>
|
|
|
|
The second argument is a device-dependent request code.
|
|
The third argument is an untyped pointer to memory.
|
|
It's traditionally
|
|
<B>char *</B><I>argp</I>
|
|
|
|
(from the days before
|
|
<B>void *</B>
|
|
|
|
was valid C), and will be so named for this discussion.
|
|
<P>
|
|
|
|
An
|
|
<B>ioctl</B>()
|
|
|
|
<I>request</I>
|
|
|
|
has encoded in it whether the argument is an
|
|
<I>in</I>
|
|
|
|
parameter or
|
|
<I>out</I>
|
|
|
|
parameter, and the size of the argument
|
|
<I>argp</I>
|
|
|
|
in bytes.
|
|
Macros and defines used in specifying an
|
|
<B>ioctl</B>()
|
|
|
|
<I>request</I>
|
|
|
|
are located in the file
|
|
<I><<A HREF="file:///usr/include/sys/ioctl.h">sys/ioctl.h</A>></I>.
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
Usually, on success zero is returned.
|
|
A few
|
|
<B>ioctl</B>()
|
|
|
|
requests use the return value as an output parameter
|
|
and return a nonnegative value on success.
|
|
On error, -1 is returned, and
|
|
<I>errno</I>
|
|
|
|
is set appropriately.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="1"><B>EBADF</B>
|
|
|
|
<DD>
|
|
<I>fd</I>
|
|
|
|
is not a valid file descriptor.
|
|
<DT id="2"><B>EFAULT</B>
|
|
|
|
<DD>
|
|
<I>argp</I>
|
|
|
|
references an inaccessible memory area.
|
|
<DT id="3"><B>EINVAL</B>
|
|
|
|
<DD>
|
|
<I>request</I>
|
|
|
|
or
|
|
<I>argp</I>
|
|
|
|
is not valid.
|
|
<DT id="4"><B>ENOTTY</B>
|
|
|
|
<DD>
|
|
<I>fd</I>
|
|
|
|
is not associated with a character special device.
|
|
<DT id="5"><B>ENOTTY</B>
|
|
|
|
<DD>
|
|
The specified request does not apply to the kind of object that the
|
|
file descriptor
|
|
<I>fd</I>
|
|
|
|
references.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
No single standard.
|
|
Arguments, returns, and semantics of
|
|
<B>ioctl</B>()
|
|
|
|
vary according to the device driver in question (the call is used as a
|
|
catch-all for operations that don't cleanly fit the UNIX stream I/O
|
|
model).
|
|
See
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_list">ioctl_list</A></B>(2)
|
|
|
|
for a list of many of the known
|
|
<B>ioctl</B>()
|
|
|
|
calls.
|
|
The
|
|
<B>ioctl</B>()
|
|
|
|
system call appeared in Version 7 AT&T UNIX.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
In order to use this call, one needs an open file descriptor.
|
|
Often the
|
|
<B><A HREF="/cgi-bin/man/man2html?2+open">open</A></B>(2)
|
|
|
|
call has unwanted side effects, that can be avoided under Linux
|
|
by giving it the
|
|
<B>O_NONBLOCK</B>
|
|
|
|
flag.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+execve">execve</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+fcntl">fcntl</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_console">ioctl_console</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_fat">ioctl_fat</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_ficlonerange">ioctl_ficlonerange</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_fideduperange">ioctl_fideduperange</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_getfsmap">ioctl_getfsmap</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_iflags">ioctl_iflags</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_list">ioctl_list</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_ns">ioctl_ns</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_tty">ioctl_tty</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+ioctl_userfaultfd">ioctl_userfaultfd</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+open">open</A></B>(2),
|
|
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?4+sd">sd</A></B>(4),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?4+tty">tty</A></B>(4)
|
|
|
|
<A NAME="lbAJ"> </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"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="6"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="7"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="8"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="9"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="10"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="11"><A HREF="#lbAG">CONFORMING TO</A><DD>
|
|
<DT id="12"><A HREF="#lbAH">NOTES</A><DD>
|
|
<DT id="13"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="14"><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>
|