Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2086027
  • 博文数量: 414
  • 博客积分: 10312
  • 博客等级: 上将
  • 技术积分: 4921
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-31 01:49
文章分类

全部博文(414)

文章存档

2011年(1)

2010年(29)

2009年(82)

2008年(301)

2007年(1)

分类: C/C++

2008-03-12 13:16:25

ioctl()

perform device-specific control functions 

Function


#include

int ioctl(int fildes, int request, ...);


The ioctl() function performs a variety of device-specific control functions on device special files. This function is supported for the following special file types:

  • Sockets
  • Console devices
  • Communication port devices

Refer to the device-specific reference page listed in the section for specific information on the ioctl() requests supported for each device.

The following generic requests are supported as well:

FIOCLEX 

The call ioctl(fildes, FIOCLEX, NULL) is equivalent to:

fcntl(fildes, F_SETFD, FD_CLOEXEC)
FIONCLEX 

The call ioctl(fildes, FIONCLEX, NULL) is equivalent to:

fcntl(fildes, F_SETFD, 0)


fildes 

Specifies an open file descriptor that refers to a device.

request 

Specifies the control function to be performed based upon the device being addressed.

... 

An optional third parameter (arg) for request-specific information. The data type depends upon the particular control request, but it is either an int or a pointer to a device-specific data structure.


If successful, ioctl() returns a nonnegative integer value based on the device control function. On failure, it returns -1 and sets errno to one of the following values, or to another value described for the particular request.

EBADF 

The fildes parameter is not a valid open file descriptor.

EFAULT 

The request parameter requires a data transfer to or from a buffer that arg points to, but this pointer is invalid.

EINTR 

A signal interrupted the call.

EINVAL 

request or arg is not valid for this device.

EIO 

Some physical I/O error has occurred.

ENOTTY 

fildes is not associated with a device driver that accepts control functions.

ENXIO 

The request and arg parameters are valid for this device driver, but the service requested cannot be performed on this particular subdevice.


UNIX 98, with exceptions.


MT-Safe.


ioctl() is inherently non-portable. the NuTCRACKER Platform supports only the documented ioctl() requests, only on the specified devices. Code that attempts to use any other requests, or on any other devices, must be revised.


MKS Toolkit for Professional Developers
MKS Toolkit for Enterprise Developers
MKS Toolkit for Enterprise Developers 64-Bit Edition


Functions:

Miscellaneous:
/dev/com, /dev/console,


MKS Toolkit 9.1 Documentation Build 7.


阅读(2076) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~