📄 streamio.7
字号:
.TP 12.B S_WRBANDcan write out of band message..TP 12.B S_BANDURGmodifier to.BR S_RDBAND ,to generate.B SIGURGinstead of.BR SIGPOLL ..TP 12.B S_ALLall flags..SS I_SRDOPT.PP.PPSets the.BR read (2)options flags for the stream head.These flags alter the behavior of the.BR read (2)call when called for.IR fd ..I argis an integer value containing the read options flags which may be one flagfrom the mode group as follows:.TP 12.B RNORMbyte-stream mode. This is the default read mode..TP 12.B RMSGDmessage discard mode..TP 12.B RMSGNmessage non-discard mode..PPbitwise OR'ed with one flag from the protocol group as follows:.TP 12.B RPROTNORMfail.BR read (2)with.RB [ EBADMSG ]if a message containing a control part is at the front of the stream headread queue..TP 12.B RPROTDATdeliver control part of a message as data..TP 12.B RPROTDISdiscard control part of message, delivering any data part..SS I_STR.PP.PPGenerates an internal STREAMS ioctl message and places it on the stream head'swrite queue for processing by the module or driver and returns the response..I argis a pointer to a.B strioctlstructure formatted as follows:.sp.nf\fC\s-1\struct strioctl { int ic_cmd; int ic_timout; int ic_len; char *ic_dp;};\s+1\fR.fi.PP.I ic_cmdis the command to issue. The command can by any of the commands listed herethat are handled by the module or driver (e.g..BR I_LINK )or any other ioctl command understood by a module or driver on the stream.IR fd ..I ic_timoutis the period of time to wait for an acknowledgement in milliseconds, or-1 indicating that there is no timeout..I ic_lenis the length of the argument data pointed to by.IR ic_dp ..I ic_dpis a pointer to the argument data of length.I ic_lenbytes..PP.B I_STRgenerates an.B M_IOCTLmessage an passes it downstream to the module or driver and blocks until apositive or negative acknowledgement is received, the command times out, anhangup or error message is received by the stream head, or a signal isreceived..PPUpon success,.B I_STRreturns the return value sepcified in the positive or negative acknowledgementmessage.Upon failure,.B I_STRreturns -1 and sets.I errnoto an appropriate error number as follows:.TP 12.RB [ EFAULT ].IR arg " or " ic_dppoint outside the caller's valid address space..TP 12.RB [ EINVAL ].I ic_lenis less than 0..TP 12.RB [ EINVAL ].I ic_lenis greater than the maximum size of the data part of a message..TP 12.RB [ EINVAL ].I ic_timoutis less than -1..TP 12.RB [ ETIME "], [" EAGAIN ]the operation timed out waiting for an acknowledgement..TP 12.RB [ EINTR ]the oepration was interrupted by a signal..TP 12.RB [ ENXIO ].I fdreceived a hangup or is closing..TP 12.RB [ ENOSR ]a buffer for the ioctl message could not be allocated..PPIn addition,.B I_STRcan return any.I errnoplaced in an error message received by the stream head, orplaced in the positive or negative acknowledgement message by the module ordriver..SS I_SWROPT.PP.PPSets the.BR write (2)options flags for the strem head.These flags alter the behavior of the.BR write "(2) and " putmsg (2)calls when called for.IR fd ..I argis an integer value containing the write options flags which may be one ormore flags from the following:.TP 12.B SNDZEROsend a zero-length message downstream when a write of zero bytes occurs..TP 12.B SNDPIPEsend.B SIGPIPEon.BR write (2)and.BR putmsg (2)if the stream head has received a write error.BR "" ( M_ERROR )message..SS I_UNLINK.PP.PPUnlink a stream from under a multiplexing driver that was previously linkedwith.BR I_LINK ..I argis the multiplexor identifier of the linked stream, or,.B MUXID_ALLindicating that all linked streams are requested to be unlinked..PPThis call is passed as an.B I_STRioctl using an.B M_IOCTLdown the stream head write queue to be processed by the multiplexing driver on.IR fd ..B I_UNLINKwill block until an acknowledgement is received from the driver, the calltimes out waiting for an acknowledgement, the call is interrupted whileblocked by a signal, or the receipt of hangup or error message..PPUpon success,.B I_UNLINKreturns zero (0) and unlinks the specified stream(s).Upon failure,.B I_UNLINKreturns -1 and sets.I errnoto an appropriate error number as follows:.TP 12.RB [ ENXIO ].I fdreceived a hangup or is closing..TP 12.RB [ EINVAL ].I argis invalid, or.I fdis a pipe or FIFO..TP 12.RB [ ETIME ]the call timed out waiting for a response from the driver..TP 12.RB [ EINTR ]the call was interrupted by a signal..TP 12.RB [ ENOSR "], [" EAGAIN ]could not allocate the buffer for the ioctl message..PPIn addition, any error received in a error message will be returnedin.IR errno .Also, any error returned by the module or driver in a ioctl positive ornegative acknowledgement message will also be returned in.IR errno ..SH "RETURN VALUE".PP.PPUpon success,.B ioctl()returns zero (0) or a positive integer.Upon failure,.B ioctl()returns -1 and sets.I errnoto an appropriate error number..SH ERRORS.PP.PPWhen.B ioctl()fails, it returns -1 and sets.I errnoto one of the following errors:.TP 12.RB [ ENXIO ].I fdhas received a hangup or is closing..TP 12.RB [ EFAULT ].I argor a member of.IR arg ,points to an address that is outside the caller's valid address space..TP 12.RB [ EINVAL ].IR fd ", " command ", " arg " or a member of " argis invalid..TP 12.RB [ ENOSR ]a buffer could not be allocated for the call..TP 12.RB [ ETIME "], [" EAGAIN ]timed out waiting for an acknowledgment..TP 12.RB [ EINTR ]interrupted by a signal..PPIn addition, any error delivered to the stream head in an error message can bereturned in.IR errno .Where the command is passed to the module or driver, or the command results inthe call to a module or driver open or close procedures, or link or unlinkprocedures, the error number returned by the module or driver can be returnedin.IR errno ..SH CAVEATS.PP.PPSTREAMS.B ioctl()calls are complex and there is much conflicting documentation in specificareas of behavior. Not all bugs are bugs and not all features are features..SH BUGS.PP.SS I_ATMARK.PP.PP.B LiSfails silently (returns success) if there is no queue associated with thestream head..SS I_CANPUT.PP.PP.B LiSuses.BR bcanput (9)to test for flow control once.I argis validated..BR bcanput (9)has the problem that it will return false (0) when an internal error occurs.See the.BR bcanput (9)man page for more information..SS I_CKBAND.PP.B LiSuses.BR strqget (9)to get the.B QCOUNTassociated with the band specified by.IR arg ..BR strqget (9)returns.RB [ EINVAL ]when the specified priority band does not exist. Therefore,.B I_CKBANDwill return.RB [ EINVAL ]when it should return false (0) indicating that there is no message for theband. See.B QCOUNTdescription in the.BR strqget (9)man page for more information..SS I_FDINSERT.PP.PP.B LiSincorrectly returns.RB [ ENODEV ]instead of.RB [ ENXIO ]when.I fdis linked under a multiplexor..PP.B LiSincorrectly returns.RB [ EAGAIN ]when.B RS_HIPRIis set in.IR flags ,and the stream is flow controlled.It should deliver the message in this case..PP.B LiSincorrectly returns.RB [ EINVAL ]when.I fdor.I fildeshas received an error message. It should return the write error of the errormessage in the case of.IR fd ..PP.B LiSincorrectly returns.RB [ ENOSR ]instead of.RB [ ENODEV ]when there is no queue under the stream head..PP.B LiSincorrectly returns.RB [ ENOSTR ]instead of.RB [ EINVAL ]when.I fildesis not a STREAMS character special file..PP.B LiSincorrectly returns.RB [ ENODEV ]instead of.RB [ ENXIO ]when a hangup was received on.I fdor.I fdis closing..PP.B LiSdoes not check whether.I fildeshas received a hangup or is closing. It should return return.RB [ ENXIO ]in that case..SS I_FIND.PP.PP.B LiSverifies read on.I argfor a string sized.BR "(FNNAMESZ + 1)" .If the name string pointed to by.I argis shorter than.B FNAMESZand terminates on a page boundary,.B I_FINDwill fail with error number.RB [ EFAULT ]even though the provided module name is valid and resides completely withinthe caller's address space. A workaround for this is for the caller toalways allocate.B (FNAMESZ + 1)sized buffers to hold the module name. There is no excuse for this bug as.B Linuxprovides one byte look-ahead verify on the kernel function.BR strncpy_from_user ()which is in fact called by.B LiSwhen processing.BR I_FIND ..PP.B LiSallocates memory to hold the passed in string. The maximum size of thisstring is 8 or 16 bytes. This is not too much to place on the stack..B LiSshould not allocate memory for this and should never return.RB [ ENOMEM ]in response to.BR I_FIND ..SS I_FLUSH.PP.PP.B LiSincorrectly returns.RB [ ENOMEM ]when it cannot allocate a message block forthe.B M_FLUSHmessage. The correct error number is.RB [ ENOSR ]..PP.B LiSuses.BR putnext (9)internally to send the.B M_FLUSHmessage..BR putnext (9)can fail silentlyunder a number of conditions detailed in the.BR putnext (9)man page. One ofthose conditions is that.BR qprocsoff (9)has been called on the stream..SS I_FLUSHBAND.PP.PPRather than returning.RB [ EINVAL "], " LiSmasks.I bi_flagwith.B FLUSHRWto force validity. This is a bug. For example,.B I_FLUSHBANDcan be called with.I bi_flag=.B 0xffffffffand.B LiSwould threat this as.BR FLUSHRW ..PPRather than returning.RB [ EINVAL "], " LiSmasks.I bi_priwith.B 0xffto force validity. This is a bug. For example,.B I_FLUSHBANDcan be called with.I bi_pri=.B 257and.B LiSwould flush band.BR 1 ..PP.B LiSincorrectly returns.RB [ ENOMEM ]when it cannot allocate a message block for the.B M_FLUSHmessage. The correct error number is.RB [ ENOSR ]..PP.B LiSusesc .BR putnext (9)to send the.B M_FLUSHmessage..BR putnext (9)can fail silently under a number of con- ditions detailed in the.BR putnext (9)man page. One of those conditions is that.BR qprocsoff (9)has been called on the stream..SS I_GETCLTIME.PP.PPUN*X documentation shows that.I argis a pointer to a.BR long .In.B LiS.I argis a pointer to an.BR int .This has an impact on architectures where a.B longis not the same as an.BR int ..SS I_RECVFD.PP.PP.B LiSdoes not block waiting for a passed file descriptor message to appear on thestream head read queue if the stream indicated by.I fdis set for blocking operation. It should..PP.B LiSwill return.RB [ EAGAIN ]where it should return.RB [ EBADMSG ]..PP.B LiSdoes not check for hangup on the pipe..SS I_SETCLTIME.PP.PPUN*X documentation shows that.I argis a pointer to a.BR long .In.B LiS.I argis a pointer to an.BR int .This has an impact on architectures where a.B longis not the same as an.BR int ..SS I_LINK.PP.PP.B LiSreturns.RB [ ENOMEM ]instead of.RB [ ENOSR "] or [" EAGAIN ]when it cannot allocate a buffer for the call..SS I_LIST.PP.PP.B LiS I_LISTfails silently (returns zero (0)) if there is no queue associatedwith the stream head..SS I_LOOK.PP.PP.B LiSverifies write on.I argfor a string sized.BR (FNAMESZ + 1) .If the name string of the module under the stream head is shorter than.B (FNAMESZ + 1)and.I argterminates on a page boundary,.B I_LOOKwill return with error number.RB [ EFAULT ]even though the provided buffer is valid and resides as far as is necessarycompletely within the caller's address space. A workaround for this is forthe caller to always allocate.B (FNAMESZ + 1)sized buffers to hold the module name. There is no excuse for this bug as.B Linuxprovides one byte look-ahead verify on the kernel function.BR strncpy_to_user ()which is in fact called by.B LiSwhen processing.BR I_LOOK ..SS I_PLINK.PP.PP.B LiSreturns.RB [ ENOMEM ]instead of.RB [ ENOSR "] or [" EAGAIN ]when it cannot allocate a buffer for the call..SS I_PUNLINK.PP.PP.B LiSreturns.RB [ ENOMEM "] instead of [" ENOSR "] or [" EAGAIN ]when it cannot allocate a buffer for the call..SS I_UNLINK.PP.PP.B LiSreturns.RB [ ENOMEM "] instead of [" ENOSR "] or [" EAGAIN ]when it cannot allocate a buffer for the call..SH "SEE ALSO".PP.BR close (2),.BR fcntl (2),.BR getmsg (2),.BR ioctl (2),.BR open (2),.BR open (2s),.BR poll (2),.BR putmsg (2),.BR read (2),.BR signal (2),.BR signal (2),.BR write (2),.BR qopen (9),.BR qclose (9),.BR qattach (9),.BR qdetach (9)..SH VERSIONS.PP.PPThis manpage was written for.B LiS\c..[LiS.].PP.B ioctl()for STREAMS first appeared in SVR 3.0..[svr3.].[$LIST$.].TA
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -