⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ioctl.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<dt>I_NREAD<dd>Counts the number of data bytes in the data part of the first message on theSTREAM head read queue and places this value in the<b>int</b>pointed to by<i>arg</i>.  The return value for the command is the number of messages on theSTREAM head read queue.  For example, if 0 is returned in <i>arg</i>, butthe<i>ioctl()</i>return value is greater than 0, this indicates that a zero-length messageis next on the queue.<p><dt>I_FDINSERT<dd>Creates a message from specified buffer(s), adds information about anotherSTREAM, and sends the message downstream.  The message contains a control partand an optional data part.  The data and control parts to be sent aredistinguished by placement in separate buffers, as described below.  The<i>arg</i> argument points to a <b>strfdinsert</b> structure.<p>The <b>len</b> member in the <b>ctlbuf strbuf</b> structure must be set to thesize of a<b>t_uscalar_t</b>plus the number of bytes of control information to be sentwith the message.  The <b>fildes</b> member specifies the file descriptor ofthe other STREAM, and the <b>offset</b> member,which must be suitably aligned for use as a<b>t_uscalar_t</b>,specifies the offset from the start of the control buffer whereI_FDINSERT will store a<b>t_uscalar_t</b>whose interpretation is specific to the STREAMend.  The <b>len</b> member in the <b>databuf strbuf</b> structure must be setto the number of bytes of data information to be sent with the message, or to0 if no data part is to be sent.<p>The <b>flags</b> member specifies the type of message to be created.  A normalmessage is created if <b>flags</b> is set to 0, and a high-priority message iscreated if <b>flags</b> is set to RS_HIPRI.  For non-priority messages,I_FDINSERT will block if the STREAM write queue is full due to internal flowcontrol conditions.  For priority messages, I_FDINSERT does not block on thiscondition.  For non-priority messages, I_FDINSERT does not block when thewrite queue is full and O_NONBLOCK is set.  Instead, it fails and sets<i>errno</i> to [EAGAIN].<p>I_FDINSERT also blocks, unless prevented by lack of internal resources,waiting for the availability of message blocks in the STREAM, regardless ofpriority or whether O_NONBLOCK has been specified.  No partial message issent.<p>The<i>ioctl()</i>function with the I_FDINSERT command will fail if:<dl compact><dt>[EAGAIN]<dd>A non-priority message is specified, the O_NONBLOCK flag is set, and theSTREAM write queue is full due to internal flow control conditions.<dt>[EAGAIN] or [ENOSR]<dd>Buffers can not be allocated for the message that is to be created.<dt>[EINVAL]<dd>One of the following:<ul><li>The <i>fildes</i> member of the <b>strfdinsert</b> structureis not a valid, open STREAM file descriptor.<li>The size of a<b>t_uscalar_t</b>plus <i>offset</i> is greater than the <i>len</i> memberfor the buffer specified through <i>ctlbuf</i>.<li>The <i>offset</i> member does not specify a properly-alignedlocation in the data buffer.<li>An undefined value is stored in <b>flags</b>.</ul><dt>[ENXIO]<dd>Hangup received on the STREAM identified by either the<i>fildes</i>argument or the <i>fildes</i> member of the <b>strfdinsert</b> structure.<dt>[ERANGE]<dd>The <i>len</i> member for the buffer specified through <i>databuf</i> doesnot fall within the range specified by the maximum and minimum packetsizes of the topmost STREAM module or the <i>len</i> member forthe buffer specified through <i>databuf</i> is larger than the maximumconfigured size of the data part of a message; or the <i>len</i> memberfor the buffer specified through <i>ctlbuf</i> is larger than themaximum configured size of the control part of a message.</dl><p><dt>I_STR<dd>Constructs an internal STREAMS<i>ioctl()</i>message from the data pointed to by <i>arg</i>, and sends that messagedownstream.<p>This mechanism is provided to send<i>ioctl()</i>requests to downstream modules and drivers.  It allows information to be sentwith<i>ioctl()</i>,and returns to the process any information sent upstream by the downstreamrecipient.  I_STR blocks until the system responds with either a positive ornegative acknowledgement message, or until the request "times out" after someperiod of time.  If the request times out, it fails with <i>errno</i> set to[ETIME].<p>At most, one I_STR can be active on a STREAM.  Further I_STR calls will blockuntil the active I_STR completes at the STREAM head.  The default timeoutinterval for these requests is 15 seconds.  The O_NONBLOCKflag has no effect on this call.<p>To send requests downstream, <i>arg</i> must point to a <b>strioctl</b>structure.<p>The <b>ic_cmd</b> member is the internal<i>ioctl()</i>command intended for a downstreammodule or driver and <b>ic_timout</b> is the number of seconds (-1 =infinite, 0 = use implementation-dependent timeoutinterval, &gt;0 = as specified) an I_STRrequest will wait for acknowledgement before timing out.<b>ic_len</b> is the number of bytes in the data argument, and<b>ic_dp</b> is a pointer to the data argument.The <b>ic_len</b> member has two uses:  on input, it contains the length of thedata argument passed in, and on return from the command, it contains thenumber of bytes being returned to the process (the buffer pointed to by<b>ic_dp</b> should be large enough to contain the maximum amount of data thatany module or the driver in the STREAM can return).<p>The STREAM head will convert the information pointed to by the<b>strioctl</b> structure to an internal<i>ioctl()</i>command message and send it downstream.<p>The<i>ioctl()</i>function with the I_STR command will fail if:<dl compact><dt>[EAGAIN] or [ENOSR]<dd>Unable to allocate buffers for the<i>ioctl()</i>message.<dt>[EINVAL]<dd>The <i>ic_len</i> memberis less than 0 or larger than the maximum configured size of thedata part of a message, or <i>ic_timout</i> is less than -1.<dt>[ENXIO]<dd>Hangup received on <i>fildes</i>.<dt>[ETIME]<dd>A downstream<i>ioctl()</i>timed out before acknowledgement was received.</dl><p>An I_STR can also fail while waiting for an acknowledgement if a messageindicating an error or a hangup is received at the STREAM head.  In addition,an error code can be returned in the positive or negative acknowledgementmessage, in the event the<i>ioctl()</i>command sent downstream fails.  For these cases, I_STR fails with <i>errno</i>set to the value in the message.<p><dt>I_SWROPT<dd>Sets the write mode using the value of the argument <i>arg</i>.Valid bit settings for <i>arg</i> are:<dl compact><dt>SNDZERO<dd>Send a zero-length message downstream when a<i><a href="write.html">write()</a></i>of 0 bytes occurs.  To not send a zero-length message when a<i><a href="write.html">write()</a></i>of 0 bytes occurs, this bit must not be set in <i>arg</i>(for example, <i>arg</i> would be set to 0).</dl><p>The<i>ioctl()</i>function with the I_SWROPT command will fail if:<dl compact><dt>[EINVAL]<dd><i>arg</i> is not the above value.</dl><p><dt>I_GWROPT<dd>Returns the current write mode setting, as described above, in the <b>int</b>that is pointed to by the argument <i>arg</i>.<p><dt>I_SENDFD<dd>I_SENDFD creates a new reference to the open file description associated withthe file descriptor<i>arg,</i>and writes a message on the STREAMS-based pipe<i>fildes</i>containing this reference, together with the user ID and group ID of thecalling process.<p>The<i>ioctl()</i>function with the I_SENDFD command will fail if:<dl compact><dt>[EAGAIN]<dd>The sending STREAM is unable to allocate a message block to contain the filepointer; or the read queue of the receiving STREAM head is full andcannot accept the message sent by I_SENDFD.<dt>[EBADF]<dd>The <i>arg</i> argument is not a valid, open file descriptor.<dt>[EINVAL]<dd>The <i>fildes</i> argument is not connected to a STREAM pipe.<dt>[ENXIO]<dd>Hangup received on <i>fildes</i>.</dl><p><dt>I_RECVFD<dd>Retrieves the reference to an open file description from a message written toa STREAMS-based pipe using the I_SENDFD command, and allocates a new filedescriptor in the calling process that refers to this open file description.The <i>arg</i> argument is a pointer toan <b>strrecvfd</b> data structure as defined in<i><a href="stropts.h.html">&lt;stropts.h&gt;</a></i>.<p>The <b>fd</b> member is a file descriptor.  The <b>uid</b> and <b>gid</b> membersare the effective user ID and effective group ID, respectively, of the sendingprocess.<p>If O_NONBLOCK is not set I_RECVFD blocks until a message is present at theSTREAM head.  If O_NONBLOCK is set, I_RECVFD fails with <i>errno</i> set to[EAGAIN] if no message is present at the STREAM head.<p>If the message at the STREAM head is a message sent by an I_SENDFD, a new filedescriptor is allocated for the open file descriptor referenced in themessage.  The new file descriptor is placed in the <b>fd</b> member of the<b>strrecvfd</b> structure pointed to by <i>arg</i>.<p>The<i>ioctl()</i>function with the I_RECVFD command will fail if:<dl compact><dt>[EAGAIN]<dd>A message is not present at the STREAM head read queue and the O_NONBLOCK flagis set.<dt>[EBADMSG]<dd>The message at the STREAM head read queue is nota message containing a passed file descriptor.<dt>[EMFILE]<dd>The process has the maximum number of file descriptors currently open thatit is allowed.<dt>[ENXIO]<dd>Hangup received on <i>fildes</i>.</dl><p><dt>I_LIST<dd>This request allows the process to list all the module names on the STREAM, upto and including the topmost driver name.  If <i>arg</i> is a null pointer, thereturn value is the number of modules, including the driver, that are on theSTREAM pointed to by <i>fildes</i>.  This lets the process allocate enoughspace for the module names.  Otherwise, it should point to an <b>str_list</b>structure.<p>The <b>sl_nmods</b> member indicates the number of entries the process hasallocated in the array.  Upon return, the <b>sl_modlist</b> member of the<b>str_list</b> structure contains the list of module names, and the number ofentries that have been filled into the <b>sl_modlist</b> array is found in the<b>sl_nmods</b> member (the number includes the number of modules including thedriver).  The return value from<i>ioctl()</i>is 0.  The entries are filled in starting at the top of the STREAM andcontinuing downstream until either the end of the STREAM is reached, orthe number of requested modules (<b>sl_nmods</b>) is satisfied.<p>The<i>ioctl()</i>function with the I_LIST command will fail if:<dl compact><dt>[EINVAL]<dd>The <b>sl_nmods</b> member is less than 1.<dt>[EAGAIN] or [ENOSR]<dd>Unable to allocate buffers.</dl><p><dt>I_ATMARK<dd>This request allows the process to see if the message at the head of the STREAMhead read queue is marked by some module downstream.  The <i>arg</i>argument determines how the checking is done when there may be multiple markedmessages on the STREAM head read queue.  It may take on the following values:<dl compact><dt>ANYMARK<dd>Check if the message is marked.<dt>LASTMARK<dd>Check if the message is the last one marked on the queue.</dl><p>The bitwise inclusive OR of the flags ANYMARK and LASTMARK is permitted.<p>The return value is 1 if the mark condition is satisfied and 0 otherwise.<p>The<i>ioctl()</i>function with the I_ATMARK command will fail if:<dl compact><dt>[EINVAL]<dd>Invalid <i>arg</i> value.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -