Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ioctl(2) [hpux man page]

ioctl(2)							System Calls Manual							  ioctl(2)

ioctl - control device SYNOPSIS
Remarks The ANSI C "" construct denotes a variable length argument list whose optional [or required] members are given in the associated comment DESCRIPTION
performs a variety of functions on character special files (devices), or regular files and directories on VxFS file systems. The write-ups of various devices in Section(7) discuss how applies to them. The type of arg is dependent on the specific call, as described in Section(7). request is made up of several fields which encode the size and direction of the argument (referenced by arg), as well as the desired com- mand. An enumeration of the request fields are: Argument is read by the driver (meaning that the argument is copied from the application to the driver). Argument is written by the driver (meaning that the argument is copied from the driver to the application). Ignored if an error occurs. Number of bytes in the passed argument. A nonzero size indicates that arg is a pointer to the passed argument. A zero size indicates that arg is the passed argument (if the driver wants to use it), and is not treated as a pointer. The request command itself. When both and are zero, it can be assumed that request is not encoded for size and direction, for compatibility purposes. Requests that do not require any data to be passed and requests that use arg as a value (as opposed to a pointer), have the bit set to one and the field set to zero. The following macros are used to create the request argument. x and y are concatenated to form and shifted into the proper location according to is the type (e.g. of the actual argument that the request references, and its size is taken and shifted into the appropriate place according to Sets and initializes the values at and accordingly. Sets and initializes the values at and accordingly. Sets both and and initializes the values at and Note: any data structure referenced by arg must contain any pointers. RETURN VALUE
If an error has occurred, a value of -1 is returned and is set to indicate the error. fails if one or more of the following are true: IOC_OUT is ignored if an error occurs. [EBADF] fildes is not a valid open file descriptor. [ENOTTY] The request is not appropriate to the selected device. [EINVAL] request or arg is not valid. [EINTR] A signal was caught during the system call. [EPERM] Typically this error indicates that an ioctl request was attempted that is forbidden in some way to the calling process. AUTHOR
was developed by AT&T and HP. SEE ALSO
ioctl(5), privileges(5), arp(7P), socket(7), termio(7). STANDARDS CONFORMANCE

Check Out this Related Man Page

IOCTL(2)						     Linux Programmer's Manual							  IOCTL(2)

ioctl - control device SYNOPSIS
#include <sys/ioctl.h> int ioctl(int d, int request, ...); DESCRIPTION
The ioctl() function manipulates the underlying device parameters of special files. In particular, many operating characteristics of char- acter special files (e.g., terminals) may be controlled with ioctl() requests. The argument d must be an open file descriptor. The second argument is a device-dependent request code. The third argument is an untyped pointer to memory. It's traditionally char *argp (from the days before void * was valid C), and will be so named for this discussion. An ioctl() request has encoded in it whether the argument is an in parameter or out parameter, and the size of the argument argp in bytes. Macros and defines used in specifying an ioctl() request are located in the file <sys/ioctl.h>. RETURN VALUE
Usually, on success zero is returned. A few ioctl() requests use the return value as an output parameter and return a nonnegative value on success. On error, -1 is returned, and errno is set appropriately. ERRORS
EBADF d is not a valid descriptor. EFAULT argp references an inaccessible memory area. EINVAL Request or argp is not valid. ENOTTY d is not associated with a character special device. ENOTTY The specified request does not apply to the kind of object that the descriptor d references. CONFORMING TO
No single standard. Arguments, returns, and semantics of ioctl() 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 ioctl_list(2) for a list of many of the known ioctl() calls. The ioctl() function call appeared in Version 7 AT&T UNIX. NOTES
In order to use this call, one needs an open file descriptor. Often the open(2) call has unwanted side effects, that can be avoided under Linux by giving it the O_NONBLOCK flag. SEE ALSO
execve(2), fcntl(2), ioctl_list(2), open(2), sd(4), tty(4) COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at Linux 2000-09-21 IOCTL(2)

Featured Tech Videos