2008-01-12 08:20:07 +00:00
|
|
|
.\" Copyright (c) 1980, 1991 Regents of the University of California.
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by the University of
|
|
|
|
.\" California, Berkeley and its contributors.
|
|
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" @(#)ioctl.2 6.4 (Berkeley) 3/10/91
|
|
|
|
.\"
|
|
|
|
.\" Modified 1993-07-23 by Rik Faith <faith@cs.unc.edu>
|
|
|
|
.\" Modified 1996-10-22 by Eric S. Raymond <esr@thyrsus.com>
|
|
|
|
.\" Modified 1999-06-25 by Rachael Munns <vashti@dream.org.uk>
|
|
|
|
.\" Modified 2000-09-21 by Andries Brouwer <aeb@cwi.nl>
|
|
|
|
.\"
|
2007-05-18 09:55:10 +00:00
|
|
|
.TH IOCTL 2 2000-09-21 "Linux" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
ioctl \- control device
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B #include <sys/ioctl.h>
|
|
|
|
.sp
|
|
|
|
.BI "int ioctl(int " d ", int " request ", ...);"
|
|
|
|
.SH DESCRIPTION
|
|
|
|
The
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR ioctl ()
|
2007-04-12 22:42:49 +00:00
|
|
|
function manipulates the underlying device parameters of special files.
|
|
|
|
In particular, many operating characteristics of character special files
|
2007-06-08 11:56:22 +00:00
|
|
|
(e.g., terminals) may be controlled with
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR ioctl ()
|
2007-04-12 22:42:49 +00:00
|
|
|
requests.
|
|
|
|
The argument
|
2004-11-03 13:51:07 +00:00
|
|
|
.I d
|
|
|
|
must be an open file descriptor.
|
|
|
|
.PP
|
2007-04-12 22:42:49 +00:00
|
|
|
The second argument is a device-dependent request code.
|
|
|
|
The third argument is an untyped pointer to memory.
|
|
|
|
It's traditionally
|
2004-11-03 13:51:07 +00:00
|
|
|
.BI "char *" argp
|
|
|
|
(from the days before
|
|
|
|
.B "void *"
|
|
|
|
was valid C), and will be so named for this discussion.
|
|
|
|
.PP
|
2007-04-12 22:42:49 +00:00
|
|
|
An
|
2005-10-20 15:11:10 +00:00
|
|
|
.BR ioctl ()
|
2004-11-03 13:51:07 +00:00
|
|
|
.I request
|
|
|
|
has encoded in it whether the argument is an
|
|
|
|
.I in
|
|
|
|
parameter or
|
|
|
|
.I out
|
|
|
|
parameter, and the size of the argument
|
|
|
|
.I argp
|
2007-04-12 22:42:49 +00:00
|
|
|
in bytes.
|
|
|
|
Macros and defines used in specifying an
|
2005-10-20 15:11:10 +00:00
|
|
|
.BR ioctl ()
|
2004-11-03 13:51:07 +00:00
|
|
|
.I request
|
|
|
|
are located in the file
|
|
|
|
.IR <sys/ioctl.h> .
|
|
|
|
.SH "RETURN VALUE"
|
|
|
|
Usually, on success zero is returned.
|
2007-04-12 22:42:49 +00:00
|
|
|
A few
|
2005-10-20 15:11:10 +00:00
|
|
|
.BR ioctl ()
|
|
|
|
requests use the return value as an output parameter
|
_syscall.2, accept.2, epoll_create.2, inotify_add_watch.2, ioctl.2, msgget.2, msgop.2, open.2, prctl.2, sched_setscheduler.2, semctl.2, semget.2, swapon.2, addseverity.3, cacosh.3, csqrt.3, dirfd.3, drand48.3, fputws.3, mq_send.3, posix_openpt.3, puts.3, sched_getcpu.3, shm_open.3, sqrt.3, sysconf.3, tgamma.3, ulimit.3, credentials.7, svipc.7: Global fix: s/non-negative/nonnegative/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:44:48 +00:00
|
|
|
and return a nonnegative value on success.
|
2004-11-03 13:51:07 +00:00
|
|
|
On error, \-1 is returned, and
|
|
|
|
.I errno
|
|
|
|
is set appropriately.
|
|
|
|
.SH ERRORS
|
|
|
|
.TP 0.7i
|
|
|
|
.B EBADF
|
|
|
|
.I d
|
|
|
|
is not a valid descriptor.
|
|
|
|
.TP
|
|
|
|
.B EFAULT
|
|
|
|
.I argp
|
|
|
|
references an inaccessible memory area.
|
|
|
|
.TP
|
|
|
|
.B EINVAL
|
|
|
|
.I Request
|
|
|
|
or
|
|
|
|
.I argp
|
|
|
|
is not valid.
|
|
|
|
.TP
|
|
|
|
.B ENOTTY
|
|
|
|
.I d
|
|
|
|
is not associated with a character special device.
|
|
|
|
.TP
|
|
|
|
.B ENOTTY
|
|
|
|
The specified request does not apply to the kind of object that the
|
|
|
|
descriptor
|
|
|
|
.I d
|
|
|
|
references.
|
2007-05-18 16:06:42 +00:00
|
|
|
.SH CONFORMING TO
|
2007-04-12 22:42:49 +00:00
|
|
|
No single standard.
|
2006-08-03 13:57:17 +00:00
|
|
|
Arguments, returns, and semantics of
|
2007-11-24 10:10:39 +00:00
|
|
|
.BR ioctl ()
|
2004-11-03 13:51:07 +00:00
|
|
|
vary according to the device driver in question (the call is used as a
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
catch-all for operations that don't cleanly fit the UNIX stream I/O
|
2007-04-12 22:42:49 +00:00
|
|
|
model).
|
|
|
|
See
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR ioctl_list (2)
|
2007-04-12 22:42:49 +00:00
|
|
|
for a list of many of the known
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR ioctl ()
|
2007-04-12 22:42:49 +00:00
|
|
|
calls.
|
2006-08-03 13:57:17 +00:00
|
|
|
The
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR ioctl ()
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
function call appeared in Version 7 AT&T UNIX.
|
2007-05-18 16:06:42 +00:00
|
|
|
.SH NOTES
|
|
|
|
In order to use this call, one needs an open file descriptor.
|
|
|
|
Often the
|
|
|
|
.BR open (2)
|
|
|
|
call has unwanted side effects, that can be avoided under Linux
|
2007-06-22 17:16:20 +00:00
|
|
|
by giving it the
|
2007-09-20 16:26:31 +00:00
|
|
|
.B O_NONBLOCK
|
2007-06-22 17:16:20 +00:00
|
|
|
flag.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR execve (2),
|
|
|
|
.BR fcntl (2),
|
|
|
|
.BR ioctl_list (2),
|
|
|
|
.BR open (2),
|
2007-06-01 05:21:06 +00:00
|
|
|
.\" .BR mt (4),
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR sd (4),
|
|
|
|
.BR tty (4)
|