ioctl

OS/161 Reference Manual

Name

ioctl - miscellaneous device I/O operations

Library

Standard C Library (libc, -lc)

Synopsis

#include <sys/ioctl.h>

int
ioctl(int fd, int code, void *data);

Description

ioctl performs an object-specific operation code on the object referred to by the file handle fd. The data argument may point to supplemental data required or returned by the operation. The size of buffer required, if any, and other such matters are operation-specific.

Traditionally, ioctl is a catchall function for performing operations that don't fit neatly into any other model.

The ioctl codes are defined in <kern/ioctl.h>, which should be included via <sys/ioctl.h> by user-level code. As of this writing, the base OS/161 system defines no ioctls. However, it may prove useful to implement some, particularly in connection with some less conventional possible projects.

Return Values

On success, ioctl returns 0. On error, -1 is returned, and errno is set according to the error encountered.

Errors

The following error codes should be returned under the conditions given. Other error codes may be returned for other errors not mentioned here.
  
EBADF fd was not a valid file handle.
EIOCTL code was an invalid ioctl for the object referenced.
EFAULT data was required by the operation requested, but was an invalid pointer.