http://www.qnx.com/developers/docs/6.5.0/index.jsp?topic=%2Fcom.qnx.doc.neutrino_lib_ref%2Fi%2Fioctl.html

目录

Synopsis:

Arguments:

Library:

Description:

How ioctl() commands map to other commands

Commands with special handling in ioctl_socket()

Returns:

Errors:

Classification:

Caveats:

See also:


Control a device

Synopsis:

#include <sys/ioctl.h> int ioctl( int fd, int request, ... );int ioctl_socket( int fd, int request, ... );

Arguments:

fd

An open file descriptor for the file or device that you want to manipulate.

request

What you want to do to the file or device; see below for a summary. The macros and definitions that you use in specifying a request are located in the file <sys/ioctl.h>.

Additional arguments

As required by the request.

Library:

Function Library Linking option to qcc
ioctl() libc -l c (This library is usually included automatically.)
ioctl_socket() libsocket -l socket

Description:

The ioctl() function manipulates the underlying parameters of files. In particular, it can be used to control many of the operating attributes of files (such as the attributes of terminals).

The ioctl_socket() function is an optimized version of ioctl() that provides special handling for commands that use embedded pointers (see “Commands with special handling in ioctl_socket(),” below). It uses ioctl() for commands that don't require special handling. The fd argument must be a socket for ioctl_socket().


Note: If you're using QNX Neutrino 6.4.1 or earlier, use ioctl_socket() instead of ioctl() in network applications such as packet filters.

In QNX Neutrino 6.5.0 and later, ioctl() handles embedded pointers, so you don't have to use ioctl_socket() instead.


The request argument determines whether the subsequent arguments are an “in” or “out” parameter; it also specifies the size of the arguments in bytes.

How ioctl() commands map to other commands

Some ioctl() commands map to calls to fcntl()tcgetattr()tcsetattr(), and tcsetsid(). Other commands are transformed into a different devctl() command, and the rest are simply passed to devctl(). Here's a summary:

ioctl() command Description Maps to:
FIOASYNC Set or clear asynchronous I/O fcntl(): F_GETFL (which becomes a devctl() DCMD_ALL_GETFLAGS), followed by fcntl(): F_SETFL (which becomes a devctl() DCMD_ALL_SETFLAGS), setting or clearing O_ASYNC
FIOCLEX Set “close on exec” on a file descriptor fcntl(): F_SETFD with FD_CLOEXEC
FIOGETOWN Get the owner fcntl(): F_GETOWN
FIONBIO Set or clear non-blocking I/O fcntl(): F_GETFL (which becomes a devctl() DCMD_ALL_GETFLAGS), followed by fcntl(): F_SETFL (which becomes a devctl() DCMD_ALL_SETFLAGS), setting or clearing O_NONBLOCK
FIONCLEX Remove “close on exec” fcntl(): F_SETFD with ~FD_CLOEXEC
FIONREAD Get the number of bytes to read devctl(): DCMD_CHR_ISCHARS
FIOSETOWN Set the owner fcntl(): F_SETOWN
NOSIOCGIFCONF Get ifnet list Passed to devctl()
OSIOCGIFADDR Get ifnet address Passed to devctl()
OSIOCGIFBRDADDR Get broadcast address Passed to devctl()
OSIOCGIFCONF Get ifnet list Passed to devctl()
OSIOCGIFDSTADDR Get point-to-point address Passed to devctl()
OSIOCGIFNETMASK Get net address mask Passed to devctl()
SIOCADDMULTI Add multicast address Passed to devctl()
SIOCADDRT Add route Passed to devctl()
SIOCAIFADDR Add or change an interface alias Passed to devctl()
SIOCALIFADDR Add interface address Passed to devctl()
SIOCATMARK At out-of-band mark? Passed to devctl()
SIOCDARP Delete ARP entry Passed to devctl()
SIOCDELMULTI Delete multicast address Passed to devctl()
SIOCDELRT Delete route Passed to devctl()
SIOCDIFADDR Delete interface address Passed to devctl()
SIOCDIFPHYADDR Delete gif addresses Passed to devctl()
SIOCDLIFADDR Delete interface address Passed to devctl()
SIOCGARP Get ARP entry Passed to devctl()
SIOCGDRVSPEC Get driver-specific parameters Passed to devctl()
SIOCGETSGCNT Get the source group packet count Passed to devctl()
SIOCGETVIFCNT Get the packet count for a virtual interface Passed to devctl()
SIOCGHIWAT Get high watermark Passed to devctl()
SIOCGIFADDR Get the interface address Passed to devctl()
SIOCGIFALIAS Get interface alias Passed to devctl()
SIOCGIFASYNCMAP Get ppp asyncmap Passed to devctl()
SIOCGIFBRDADDR Get broadcast address Passed to devctl()
SIOCGIFCAP Get capabilities Passed to devctl()
SIOCGIFCONF Return a list of interface (transport layer) addresses Passed to devctl()
SIOCGIFDLT Get data link type Passed to devctl()
SIOCGIFDSTADDR Get point-to-point address Passed to devctl()
SIOCGIFFLAGS Get ifnet flags Passed to devctl()
SIOCGIFGENERIC Generic interface get op Passed to devctl()
SIOCGIFMEDIA Get net media; ioctl_socket() provides special handling for this command. Passed to devctl()
SIOCGIFMETRIC Get interface metric Passed to devctl()
SIOCGIFMTU Get ifnet MTU Passed to devctl()
SIOCGIFNETMASK Get net address mask Passed to devctl()
SIOCGIFPDSTADDR Get gif pdst address Passed to devctl()
SIOCGIFPSRCADDR Get gif psrc address Passed to devctl()
SIOCGLIFADDR Get interface address Passed to devctl()
SIOCGLIFPHYADDR Get gif addresses Passed to devctl()
SIOCGLOWAT Get low watermark Passed to devctl()
SIOCGPGRP Get process group fcntl(): F_GETOWN
SIOCIFCREATE Create clone interface Passed to devctl()
SIOCIFDESTROY Destroy clone interface Passed to devctl()
SIOCIFGCLONERS Get cloners; ioctl_socket() provides special handling for this command. Passed to devctl()
SIOCSARP Set ARP entry Passed to devctl()
SIOCSDRVSPEC Set driver-specific parameters Passed to devctl()
SIOCSHIWAT Set high watermark Passed to devctl()
SIOCSIFADDR Set ifnet address Passed to devctl()
SIOCSIFASYNCMAP Set ppp asyncmap Passed to devctl()
SIOCSIFBRDADDR Set broadcast address Passed to devctl()
SIOCSIFCAP Set capabilities Passed to devctl()
SIOCSIFDSTADDR Set point-to-point address Passed to devctl()
SIOCSIFFLAGS Set ifnet flags Passed to devctl()
SIOCSIFGENERIC Generic interface set op Passed to devctl()
SIOCSIFMEDIA Set net media Passed to devctl()
SIOCSIFMETRIC Set interface metric Passed to devctl()
SIOCSIFMTU Set ifnet MTU Passed to devctl()
SIOCSIFNETMASK Set net address mask Passed to devctl()
SIOCSIFPHYADDR Set gif address Passed to devctl()
SIOCSLIFPHYADDR Set gif addresses Passed to devctl()
SIOCSLOWAT Set low watermark Passed to devctl()
SIOCSPGRP Set process group fcntl(): F_SETOWN
TCFLSH Flush buffers Passed to devctl()
TCGETA Get the terminal's properties in a termio structure tcgetattr()
TCGETS Get the terminal's properties in a termios structure tcgetattr()
TCSBRK Send a break for a period of time devctl() : DCMD_CHR_SERCTL
TCSETA Set the terminal's properties tcsetattr()
TCSETAF Set the terminal's properties, waiting until all currently written data has been transmitted, and discarding any received but unread data tcsetattr()
TCSETAW Set the terminal's properties, waiting until all currently written data has been transmitted tcsetattr()
TCSETS Set the terminal's properties from a termios structure devctl() : DCMD_CHR_TCSETATTR
TCSETSF Drain the output, flush the input, and set Passed to devctl()
TCSETSW Drain output, set Passed to devctl()
TCXONC Perform a flow-control operation on a data stream devctl(): DCMD_CHR_TCFLOW
TIOCCBRK Clear the break bit tcsetattr()
TIOCCDTR Clear the Data Terminal Ready line devctl() : DCMD_CHR_LINESTATUS, followed by DCMD_CHR_SERCTL
TIOCDRAIN Wait until output has drained devctl(): DCMD_CHR_TCDRAIN
TIOCEXCL Set exclusive use of tty fcntl(): F_SETLK
TIOCFLUSH Flush buffers devctl(): DCMD_CHR_TCFLUSH
TIOCGETA Get the terminal's properties in a termios structure devctl() : DCMD_CHR_TCGETATTR
TIOCGETC Get special characters tcgetattr()
TIOCGETP Get the terminal's parameters in a sgttyb structure tcgetattr()
TIOCGETPGRP Get the process group of the tty (POSIX) Passed to devctl()
TIOCGLTC Get local special characters tcgetattr()
TIOCGPGRP Get the process group of the tty devctl(): DCMD_CHR_TCGETPGRP
TIOCGSIZE Get window size devctl(): DCMD_CHR_GETSIZE
TIOCGWINSZ Get window size devctl(): DCMD_CHR_GETSIZE
TIOCHPCL Hang up on last close tcsetattr()
TIOCLGET Get local modes tcgetattr()
TIOCLSET Set entire local mode word tcsetattr()
TIOCMBIC Clear modem port B interrupt devctl() : DCMD_CHR_LINESTATUS, followed by DCMD_CHR_SERCTL
TIOCMBIS Set modem port B interrupt devctl() : DCMD_CHR_LINESTATUS, followed by DCMD_CHR_SERCTL
TIOCMGET Set the state of the modem lines devctl() : DCMD_CHR_SERCTL
TIOCMSET Set all modem bits Passed to devctl()
TIOCNOTTY Make this terminal not be the controlling terminal for the process tcsetsid()
TIOCNXCL Reset exclusive use of tty fcntl(): F_SETLK
TIOCOUTQ Output queue size devctl(): DCMD_CHR_OSCHARS
TIOCPKT Pty: set/clear packet mode Passed to devctl()
TIOCSBRK Set break bit Passed to devctl()
TIOCSCTTY Make the terminal become the controlling tty tcsetsid()
TIOCSDTR Set the Data Terminal Ready line devctl() : DCMD_CHR_LINESTATUS, followed by DCMD_CHR_SERCTL
TIOCSETA Set the terminal's properties from a termios structure devctl() : DCMD_CHR_TCSETATTR
TIOCSETAF Drain the output, flush the input, and set devctl(): DCMD_CHR_TCSETATTRF
TIOCSETAW Drain output, set devctl(): DCMD_CHR_TCSETATTRD
TIOCSETC Set special characters tcsetattr()
TIOCSETN Similar to TIOCSETP, but the changes are made immediately without discarding any data. tcsetattr()
TIOCSETP Set the terminal's parameters in a sgttyb structure. No change is made until all currently written data has been transmitted, at which point any received but unread data is discarded. tcsetattr()
TIOCSETPGRP Set the process group of the tty (POSIX) Passed to devctl()
TIOCSINUSE Set exclusive use of tty fcntl(): F_SETLK
TIOCSLTC Set local special characters tcsetattr()
TIOCSPGRP Set the process group of the tty devctl(): DCMD_CHR_TCSETPGRP
TIOCSSIZE Set the window size devctl(): DCMD_CHR_SETSIZE
TIOCSTART Start output, like Ctrl-Q Passed to devctl()
TIOCSTI Simulate terminal input devctl(): DCMD_CHR_TCINJECTC
TIOCSTOP Stop output, like Ctrl-S Passed to devctl()
TIOCSWINSZ Set window size devctl(): DCMD_CHR_SETSIZE
UIOCCMD User control operator n Passed to devctl()

Note: If you're writing a resource manager, note that the iofunc_devctl_default() function handles the DCMD_ALL_GETFLAGS and DCMD_ALL_SETFLAGS commands; your resource manager will need to handle all other devctl commands that apply to it.

Commands with special handling in ioctl_socket()

The ioctl_socket() function provides special handling for the commands listed below. Unless otherwise noted, it eventually passes the command to devctl().

These commands are for the Berkeley Packet Filter:

BIOCGDLTLIST

Get an array of the available types of the data link layer underlying the attached interface.

BIOCSETF

Set the BPF filter program.

These commands are for use with cryptography:

CIOCCRYPT

Request a symmetric-key (or unkeyed hash) operation.

CIOCGSESSION

Set up a session for symmetric crypto operations.

CIOCKEY

Perform an asymmetric crypto operation.

CRIOGET

Get a cloned file descriptor of /dev/crypto by calling open(). This isn't necessary in QNX Neutrino, but we've provided it for compatibility and portability.

The following commands are for use with the Packet Filtering interface; for more information, see the entry for pf in the Utilities Reference:

  • DIOCGETSRCNODES
  • DIOCGETSTATES
  • DIOCIGETIFACES
  • DIOCRADDADDRS
  • DIOCRADDTABLES
  • DIOCRCLRASTATS
  • DIOCRCLRTSTATS
  • DIOCRDELADDRS
  • DIOCRDELTABLES
  • DIOCRGETADDRS
  • DIOCRGETASTATS
  • DIOCRGETTABLES
  • DIOCRGETTSTATS
  • DIOCRINADEFINE
  • DIOCRSETADDRS
  • DIOCRSETTFLAGS
  • DIOCRTSTADDRS
  • DIOCXBEGIN
  • DIOCXCOMMIT
  • DIOCXROLLBACK

These commands are for use with sockets:

SIOCG80211

Get configuration or status information.

SIOCG80211NWID

Get the network ID.

SIOCG80211NWKEY

Get the values of the WEP keys.

SIOCG80211STATS, SIOCG80211ZSTATS

Get IEEE 80211 statistics.

SIOCGETVLAN

Get the vlan tag and parent for a given vlan interface.

SIOCGIFMEDIA

Get net media.

SIOCIFGCLONERS

Get cloners.

SIOCS80211

Set configuration or status information.

SIOCS80211NWID

Set the network ID.

SIOCS80211NWKEY

Set the WEP key.

SIOCSETVLAN

Set the vlan tag and parent for a given vlan interface.

Returns:

A value based on the request, or -1 if an error occurs (errno is set).

Errors:

EBADF

Invalid descriptor fd.

EINVAL

The request or optional variables aren't valid.

ENOBUFS

There wasn't enough memory available to allocate for data referred to by embedded pointers.

ENOTTY

The fd argument isn't associated with a character-special device; the specified request doesn't apply to the kind of object that the descriptor fd references.

Classification:

POSIX 1003.1 XSR

Safety:  
Cancellation point No
Interrupt handler No
Signal handler No
Thread No

Caveats:

The ioctl() function is a Unix function that varies greatly from platform to platform.

See also:

devctl()fcntl()tcgetattr()tcsetattr()tcsetsid().

ioctl(), ioctl_socket()相关推荐

  1. 【视频】V4L2之ioctl

    常见的ioctl命令 VIDIOC_QUERYCAP /* 获取设备支持的操作 */ VIDIOC_G_FMT /* 获取设置支持的视频格式 */ VIDIOC_S_FMT /* 设置捕获视频的格式 ...

  2. UNIX网络编程--ioctl操作(十七)

    一.概述 在本书中有两个地方都对这个函数进行了介绍,其实还有很多地方需要这个函数.ioclt函数传统上一直作为纳西而不适合归入其他精细定义类别的特性的系统接口.网络程序(特别是服务器程序)经常在程序启 ...

  3. ioctl kernel 构建注意事项

    cmd 命令码的构建 书中截图 首先在用户层的 ioctl函数原型为 int iocotl(int fd,int cmd,-) 其实这个系统调用和kernel中 创建的字符驱动有关系 struct f ...

  4. Linux设备驱动中的ioctl

    memdev.h #ifndef _MEMDEV_H #define _MEMDEV_H#define MEM_MAGIC 'm' #define MEM_RESTART _IO(MEM_MAGIC, ...

  5. 远程ssh shell 脚本 tcgetattr: Inappropriate ioctl for device错误

    之前在写一个脚本的时候,脚本里面需要批量化远程登陆主机进行操作,认识执行时遇到了tcgetattr: Inappropriate ioctl for device报错 之前用来测试的脚本: #!/bi ...

  6. linux 错误 ttyname failed: Inappropriate ioctl for device 解决方法

    在我使用 git push.hexo deploy 等类似操作时,时常会看到 ttyname failed: Inappropriate ioctl for device 的报错信息.这怎么能行,不是 ...

  7. linux ioctl 设备操作函数 r3到r0 应用层 驱动层 通讯

    一.ioctl的简介: 虽然在文件操作结构体"struct file_operations"中有很多对应的设备操作函数,但是有些命令是实在找不到对应的操作函数.如CD-ROM的驱动 ...

  8. linux 内核 struct file_operations中 ioctl 变为 unlocked_ioctl

    1.消失的确切时间     ioctl的消失到底是从哪个版本开始的?网上给出的时间是2.6.36开始.网上就是这么说,但是自己必须找到代码中的证据.于是我通过git搜索主线内核代码,找到的删除ioct ...

  9. windows 驱动和应用层的三种通信方式 r3到r0 DeviceIoControl 4种ioctl请求

    驱动程序和客户应用程序经常需要进行数据交换,但我们知道驱动程序和客户应用程序可能不在同一个地址空间,因此操作系统必须解决两者之间的数据交换. 驱动层和应用层通信,主要是靠DeviceIoControl ...

最新文章

  1. Yolo模型部署的两种方法
  2. 吴恩达神经网络和深度学习——第二周笔记
  3. Linux中切换用户变成-bash4.1-$的解决方法
  4. Intel汇编语言程序设计学习-第二章 IA-32处理器体系结构-下
  5. 【BLE MIDI】MIDI 文件格式分析 ( FF 58 04 拍号 | 音符开指令 | 音符关指令 | 音轨结束标志 )
  6. Oracle数据库之过滤和排序
  7. ALGO-1 区间k大数查询
  8. pythoncharm安装时出错误_python01:pycharm中安装包时所遇到的问题
  9. layui数据表格(一:基础篇,数据展示、分页组件、表格内嵌表单和图片)
  10. xmind 模板_XMind 教程 | 如何写出让人眼前一亮的年终总结?
  11. 《java程序设计》结对编程-四则运算整体总结
  12. 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jinjazz/archive/2009/04/29/4138000.aspx...
  13. ios开发之 -- 强制横屏
  14. 机器学习为您揭秘雾霾怎么形成
  15. 【游戏开发3D数学笔记】1.有话说在前面
  16. KEGG COMPOUND 数据库
  17. 2021物联网国赛zigbee点对点通讯——G卷
  18. Python-docx 读写 Word 文档:读取正文、表格文本信息、段落格式、字体格式等
  19. MySQL-SQL注入,导入,导出
  20. 如何对列表/元组进行排序(列表/元组)?

热门文章

  1. MySQL高级-MySQL锁
  2. [Ceoi2010]Pin
  3. 用命令创建MySQL数据库
  4. GSAP JS基础教程--动画的控制及事件
  5. 设置远程桌面(一)修改Win7远程桌面端口
  6. 游戏引擎中的通用编程技术
  7. 6-Spring Boot缓存管理
  8. 在Eclipse新建菜单中添加菜单项,其他地方添加菜单项类似
  9. Linux数据库1366错误,ERROR 1366 (HY000): Incorrect string value:’XXX’ for column 'XXX at row 1解决...
  10. 从mysql数据库读取Blob_读取数据库Blob类型的文本数据