IO Device Control System Call

Header File

Source: include/sys/ioctl.h

#include <sys/ioctl.h>

Functions

int ioctl(int fd, unsigned long cmd, ...)

Perform generic I/O operation command on special files

Parameters:
  • fd – [in] File descriptor

  • cmd – [in] Command to execute, Argument parameter varies based on command.

Returns:

on success zero is returned, On error, -1 is returned, and errno is set appropriately.

Structures

struct iopeek_t

Peek structure

Public Members

int len

Buffer pointer to store read data

Macros

TIOCOUTQ

Get output queue size (not sent + not acked) This command expects unsigned long

SIOCOUTQ
FIONREAD

Get number of bytes available to read This command expects unsigned long

SIOCINQ
FIONBIO

Set Blocking or non-blocking IO This command expects integer with 1 or 0

FIOASYNC

Set ASYNC IO operation

TODO: Unimplemented

TIOCPEEK

Get Next character in read buffer without removing it. Multiple call to ioctl will result in same character unless read() is called expects int *

TIOCPEEKBUF

Get data from read buffer without removing it. expects struct iopeek_t *