I_PUSH
| ’Pushes’ the module whose name is pointed to by arg into the beginning of the current stream, directly below the stream head. If the stream is a pipe, the module will be pushed between the stream heads of both ends of the pipe. This command then calls the open() function of the newly pushed-in module. ioctl() with the I_PUSH command will fail if:
|
| EINVAL
| Invalid module name. |
| EFAULT
| arg references a point outside the reserved address space. |
| ENXIO
| The open() function of the new module failed. |
| ENXIO
| Hang-up signal received for fildes. |
I_POP
| ’Pops’ the module directly below the stream head out of the stream referenced by fildes. If a module is to be popped out of a pipe, it must be popped out from the side from which it was pushed in. In this case, arg should equal 0. In the event of an error, errno assumes one of the following values: ioctl() with the I_POP command will fail if:
|
| EINVAL
| No module stream exists. |
| ENXIO
| Hang-up signal received for fildes. |
I_LOOK
| Determines the name of the module directly below the stream head in the stream specified by fildes, and stores it in a null-terminated string pointed to by arg. The buffer to which arg points should be at least FMNAMESZ+1 bytes long. FMNAMESZ is defined in stropts.h . ioctl() with the I_LOOK command will fail if:
|
| EINVAL
| There is no module in the stream. |
| EFAULT
| arg references a point outside the reserved address space. |
I_FLUSH
| Flushes all read and/or write queues, depending on the value of arg. arg can have any of the following values: |
| FLUSHR
| Flush read queues. |
| FLUSHW
| Flush write queues. |
| FLUSHRW
| Flush read and write queues. |
| ioctl() with the I_FLUSH command will fail if:
|
| EINVAL
| Invalid value for arg. |
| EAGAIN or ENOSR
|
|
| No buffer could be reserved for the flush message, because not enough STREAMS storage space was available. |
| ENXIO
| Hang-up signal received for fildes. |
I_FLUSHBAND
|
| Flushes a particular band of messages. arg points to a bandinfo structure that has the following components: unsigned char bi_pri ;int bi_flag ;
The bi_flag component can equal FLUSHR , FLUSHW or FLUSHRW (see above). The bi_pri component determines the priority band. |
I_SETSIG
| Informs the stream head that the user wants the system kernel to issue the SIGPOLL signal (see signal() ) if a particular event occurs for the stream assigned to fildes. I_SETSIG supports the capability of asynchronous processing under STREAMS . The value of arg is a bit mask which specifies the events for which the signal is to be issued. It is the bit-wise OR of any combination of the following constants. |
| S_RDNORM
| There is a message with normal priority (priority band = 0) at the head of the read queue of the stream head. A signal is issued even if the message has the length 0. |
| S_RDBAND
| There is a message in the priority band > 0 at the head of the read queue of the stream head. A signal is issued even if the message has the length 0. |
| S_INPUT
| A message not equal to M_PCPROTO (high priority) has arrived in the read queue of the stream head. This event is still supported for reasons of compatibility with earlier versions of UNIX System V. A signal is issued even if the message has the length 0. |
| S_HIPRI
| There is a message with high priority (M_PCPROTO ) at the head of the read queue of the stream head. A signal is issued even if the message has the length 0. |
| S_OUTPUT
| A write queue for regular data (priority band = 0) directly below the stream head is no longer full (without flow control). This informs the user that there is room in the queue to write or send normal data downstream. |
| S_WRNORM
| Exactly like S_OUTPUT . |
| S_WRBAND
| A write queue for data in the priority band != 0) just below the stream head is no longer full. This informs the user that there is room in the queue to write or send priority data downstream. |
| S_MSG
| An M_SIG or M_PCSIG message containing the SIGPOLL signal has reached the head of the read queue of the stream head. |
| S_ERROR
| An M_ERROR message has reached the stream head. |
| S_HANGUP
| An M_HANGUP message has reached the stream head. |
| S_BANDURG
| If this event is used together with S_RDBAND , then SIGURG is generated instead of SIGPOLL if a high-priority message reaches the head of the read queue of the stream head. |
| If arg is 0, the calling process logs off again and does not receive any further SIGPOLL signals. A user process can decide to only receive a signal in the event of messages with high priority, by setting the arg bit mask to the value S_HIPRI . Processes which want to receive the SIGPOLL signal must sign on explicitly for its receipt by using I_SETSIG . If several processes sign on for this signal requesting the same event for the same stream, then every process receives the signal when the event occurs. ioctl() with the I_SETSIG command will fail if:
|
| EINVAL
| The value of arg is invalid or arg is 0 and the process does not sign on for receipt of the SIGPOLL signal. |
| EAGAIN
| The reservation of a data structure for the signal request failed. |
I_GETSIG
| Returns the events for which the calling process has currently signed on to receive a SIGPOLL signal. The events are returned in the bit mask pointed to by arg, where the events are the ones specified in the description of I_SETSIG (see above). ioctl() with the I_GETSIG command will fail if:
|
| EINVAL
| The process is not signed on for receipt of the SIGPOLL signal. |
| EFAULT
| arg references a point outside the reserved address space. |
I_FIND
| Compares the names of all modules currently located in the stream with the name pointed to by arg. It returns the value 1 if the specified module is present in the stream. It returns the value 0 if the specified module is not popped in. ioctl() with the I_FIND command will fail if:
|
| EINVAL
| arg does not contain a valid module name. |
| EFAULT
| arg references a point outside the reserved address space. |
I_PEEK
| Allows a user to read the information in the first message in the read queue of the stream head without removing the message from the queue. I_PEEK works in the same way as getmsg() , except that it does not remove the message from the queue. arg points to an strpeek structure containing the following components: struct strbuf ctlbuf ; struct strbuf databuf ; long flags ;
The maxlen component in the strbuf structures ctlbuf and databuf (see getmsg() ) must be set to the number of bytes to be read as control and/or data information. flags can be set to RS_HIPRI or to 0. If RS_HIPRI is set, I_PEEK searches for a message with high priority in the read queue of the stream head. Otherwise, I_PEEK searches for the first message in the read queue of the stream head. I_PEEK returns the value 1 if a message was found, and 0 if no message was found in the read queue of the stream head or if flags was set to RS_HIPRI and no message with a high priority was found. This command does not wait for a message to arrive. After the return, ctlbuf supplies the information from the control section, databuf the information from the data section, and flags contains the value RS_HIPRI or 0.
ioctl() with the I_PEEK command will fail if:
|
| EFAULT
| arg references a point outside the reserved address space, or the buffer area specified in ctlbuf or databuf is located outside the reserved address space. |
| EBADMSG
| The message to be read is invalid for I_PEEK . |
| EINVAL
| flags has an invalid value. |
I_SRDOPT
| Sets the setting for the reading (see read() ) to the value of the arg argument. arg can take the following values: |
| RNORM
| Byte-stream mode (default). |
| RMSGD
| Message-discard mode. |
| RMSGN
| Message-nondiscard mode. |
| If the value for arg is the result of bit-wise inclusive OR of RMSGD and RMSGN , this produces the error EINVAL . Bit-wise inclusive OR of RNORM with RMSGD produces RMSGN ; bit-wise inclusive OR of RNORM with RMSGN produces RMSGD . In addition, the handling of control messages by the stream head can be changed via the following identifiers for arg: RPROTNORM
read() will fail with EBADMSG if there is a control message at the beginning of the read queue of the stream head. This is the default behavior.
RPROTDAT
Returns the control section of a message as data if a user calls read(). RPROTDIS
Discards the control section of a message and delivers an existing data section if a user calls read() . ioctl() with the I_SRDOPT command will fail if:
|
| EINVAL
| arg does not have any of the valid values listed above. |
I_GRDOPT
| Supplies the currently valid setting for the reading in the int variable pointed to by arg. The settings for the reading are described under read() . ioctl() with the I_GRDOPT command will fail if:
|
| EFAULT
| arg references a point outside the reserved address space. |
I_NREAD
| Counts the number of data bytes in the data blocks of the first message in the read queue of the stream head and stores this number in the variable pointed to by arg. The result for this command is the number of messages in the read queue of the stream head. If, for example, the value 0 is returned in arg, but the ioctl call returns a result greater than 0, this indicates that the next message in the queue has the length 0. ioctl() with the I_NREAD command will fail if:
|
| EFAULT
| arg references a point outside the reserved address space. |
I_FDINSERT
|
| Generates a message from user-defined buffers, adds information about a different stream and sends the message downstream. The message contains a control section and an optional data section. The data and control sections to be sent are stored in separate buffers (see below). arg points to an strfdinsert structure that has the following components: struct strbuf ctlbuf ; struct strbuf databuf ; long flags ; Int fildes ; int offset ;
The len component in the strbuf structure ctlbuf (see putmsg() ) must be the same as the size of a pointer plus the number of bytes for the control information of this message. fildes in the strfdinsert structure specifies the file descriptor of the other stream. offset must be aligned with a word boundary and specifies the number of bytes after which I_FDINSERT stores a pointer after the start of the control buffer. This pointer is the address of the read queue structure of the driver for the stream that corresponds to fildes in the strfdinsert structure. The len component in the strbuf structure databuf must be set to the same as the number of bytes to be sent as data information with the message, or 0 if no data section is to be sent. flags indicates what type of message is to be generated. A normal message is generated if flags is 0, and a high-priority message is generated if flags is RS_HIPRI . With normal messages, I_FDINSERT blocks if the write queue of the stream is full because of the internal flow control. With high-priority messages, I_FDINSERT does not block in this case. With normal messages, I_FDINSERT does not block if the write queue is full but O_NDELAY or O_NONBLOCK is set. Instead, the call fails and errno is then EAGAIN . I_FDINSERT also blocks if the call is waiting for the availability of message blocks and is not prevented from doing this because internal resources are missing. Here it is irrelevant which priority is set and whether O_NDELAY or O_NONBLOCK were specified. No partial message is sent.
ioctl() with the I_FDINSERT command will fail if:
|
| EAGAIN
| A message without priority was specified, O_NDELAY or O_NONBLOCK is set and the write queue of the stream is full because of the internal flow control. |
| EAGAIN or ENOSR
|
|
| No buffers could be reserved for the message to be generated, because there was too little storage space available under STREAMS. |
| EINVAL
| One of the following applies: fildes in the strfdinsert structure is not a valid open file descriptor for a stream. The size of a pointer plus offset is greater than the len component of the buffer specified by ctlptr. offset does not specify a correctly aligned location in the data buffer. flags has an undefined value.
|
| ENXIO
| A hang-up signal was received for fildes in the ioctl call or for fildes in the strfdinsert structure. |
| ERANGE
| The len component for the buffer specified by databuf is not in the range defined by the values for the maximum and minimum packet size of the highest module in the stream. Or the len component for the buffer specified by databuf is greater than the configured maximum size of the data section of a message. Or the len component for the buffer specified by ctlbuf is greater than the configured maximum size of the control section of a message. |
| EFAULT
| arg references a point outside the reserved address space, or the buffer area specified in ctlbuf or databuf is outside the reserved address space. |
| I_FDINSERT can also fail if an error message by the head of the stream is received which belongs to fildes in the strfdinsert structure. In this case, errno has the value in the message.
|
I_STR
| Generates an internal ioctl message from the data to which arg points and sends this message downstream. This mechanism is provided for sending user-defined ioctl() requests downstream to modules and drivers. It allows information to be sent with ioctl() and returns to the user all information that is sent upstream from the downstream recipient. I_STR blocks until the system responds with a positive or negative confirmation, or until a timeout occurs after a certain length of time. If a timeout occurs, the call fails with errno set to ETIME . There can never be more than one active I_STR call in a stream. Other I_STR calls will block until the active I_STR call terminates at the stream head. The default value for a timeout with these requests is 15 seconds. O_NDELAY and O_NONBLOCK (see open() ) do not affect this call. For requests to be sent downstream, arg must point to an strioctl structure containing the following components: int ic_cmd ; int ic_timout ; int ic_len ; char * ic_dp ;
ic_cmd is the internal ioctl() command that is to be sent to a module located downstream or a driver, and ic_timout is the number of seconds for a timeout(-1 = infinite, 0 = default, > 0 = as specified). ic_len is the number of bytes in the data argument and ic_dp is a pointer to the data argument. The ic_len component has two uses: at input it contains the length of the transferred data argument, and on return from the command it contains the number of bytes returned to the user (the buffer pointed to by ic_dp should be large enough to hold the maximum length of the data to be returned from a module or driver). The stream head converts the information in the strioctl structure into an internal ioctl() message and sends it downstream. ioctl() with the I_STR command will fail if:
|
| EAGAIN or ENOSR
|
|
| Due to insufficient storage space, no buffer could be reserved for the ioctl() message. |
| EINVAL
| ic_len is less than 0, or ic_len is greater than the configured maximum size of the data section of a message, or ic_timout is less than -1. |
| ENXIO
| Hang-up signal received for fildes. |
| ETIME
| A downstream ioctl() call received a timeout before a confirmation was received. |
| EFAULT
| arg references a point outside the reserved address space, or the buffer area that was specified by ic_dp and ic_len (separate for sent and received data) is outside the reserved address space. |
| An I_STR call can also fail if an error message or hang-up signal message is received by the head of the stream while it is waiting for confirmation. In addition, an error ID can be returned in the positive or negative message if the ioctl command fails further downstream. In this case, errno has the value from the message. |
I_SWROPT
| Defines the settings for the writing, where the value of the arg argument is used. arg can have the following values: |
| SNDZERO
| Sends a message of length 0 downstream if a write() call with 0 bytes occurs. If in this case no message of length 0 is to be sent, then this bit must not be set in arg. |
| ioctl() with the I_SWROPT command will fail if:
|
| EINVAL
| arg does not contain the value specified above. |
I_GWROPT
| Returns the currently valid setting for the writing in the int variable pointed to by arg (see under I_SWROPT ). |
I_SENDFD
| Requests the stream assigned to fildes to send a message containing a file pointer to the stream head at the other end of the pipe. The file pointer corresponds to the arg argument, which must be an open file descriptor. I_SENDFD converts arg into the corresponding file pointer. The command reserves a message block and inserts the file pointer in this block. The user ID and group ID of the sending process are also inserted. This message is entered directly in the read queue of the stream head at the other end of the pipe.
ioctl() with the I_SENDFD command will fail if:
|
| EAGAIN
| The sending stream is not in a position to reserve a message block that can include the file pointer, or the read queue of the receiving stream head is full and cannot take the message sent by I_SENDFD . |
| EBADF
| arg is not a valid open file descriptor. |
| EINVAL
| fildes is not linked with a pipe. |
| ENXIO
| Hang-up signal received for fildes. |
I_RECVFD
| Determines the assignment to an open file description of a message that was sent with the I_SENDFD command for ioctl() via a pipe and reserves a new file descriptor in the calling process which refers to this open file description. arg is a pointer to a data buffer large enough to take an strrecvfd data structure. The strrecvfd structure is defined in stropts.h and contains the following components: int fd;
uid_t
uid ; gid_t gid ; char fill[8] ;
fd is a file descriptor. uid and gid are the user ID and group ID of the sending stream. If O_NDELAY and O_NONBLOCK are not set (see open() ), then I_RECVFD blocks until there is a message at the stream head. If O_NDELAY or O_NONBLOCK is set, I_RECVFD will fail, with errno equaling EAGAIN , if there is no message at the stream head. If the message at the stream head is a message that was sent by I_SENDFD , a new user file descriptor is reserved for the file pointer contained in the message. The new file descriptor is stored in the fd component of the strrecvfd structure. The structure is copied into the data buffer of the user to which arg points. ioctl() with the I_RECVFD command will fail if:
|
| EAGAIN
| There is no message in the read queue of the stream head and O_NDELAY or O_NONBLOCK is set. |
| EBADMSG
| The message in the read queue of the stream head does not contain a transferred file descriptor. |
| EMFILE
| NOFILES file descriptors are already open.
|
| ENXIO
| Hang-up signal received for fildes. |
| EOVERFLOW
|
|
| uid or gid is too big to be stored in the structure pointed to by arg. |
| EFAULT
| arg references a point outside the reserved address space. |
I_LIST
| Allows a user to output all module names in the stream, including the highest driver. If arg is zero, the result of the call is the number of modules (including drivers) in the stream referenced by fildes. This allows the user to reserve enough space for the module names. If arg is not zero, this argument should point to an str_list structure which has the following components: int sl_nmods; struct str_mlist *sl_modlist; The str_mlist structure has the following components: char l_name[FMNAMESZ+1]; sl_nmods specifies the number of entries reserved by the user in the array. After the return, sl_modlist contains the list of module names and sl_nmods contains the number of entries in the sl_modlist array; this is the number of all modules including the driver. The return value of ioctl() is 0. When the entries are written, they start at the top of the stream and continue downstream until either the end of the stream or the number of desired modules (sl_nmods) is reached. ioctl() with the I_LIST command will fail if:
|
| EINVAL
| The sl_nmods component is less than 1. |
| EAGAIN or ENOSR
|
|
| Buffer could not be reserved. |
I_ATMARK
| Enables the user to check whether the current message in the read queue of the stream head was “marked” by a module further downstream. arg defines how the check is carried out if there can be more than one “marked” message in the read queue of the stream head. It can take the following values: ANYMARK
| Check whether the message is marked. | LASTMARK
| Check whether the message is the last one marked in the queue. |
The result is 1 if the relevant marking condition is fulfilled. Otherwise it is 0. In the event of an error, errno can have the following value: ioctl() with the I_ATMARK command will fail if:
|
| EINVAL
| The value of arg is invalid. |
I_CKBAND
| Checks whether a message exists in a given priority band in the read queue of the stream head. The result is 1 if such a message exists, or -1 in the event of an error. arg should be an integer containing the value of the priority band to be checked. ioctl() with the I_CKBAND command will fail if:
|
| EINVAL
| The value of arg is invalid. |
I_GETBAND
|
| Returns the priority band of the first message in the read queue of the stream head in the integer value pointed to by arg. ioctl() with the I_GETBAND command will fail if:
|
| ENODATA
| There is no message in the read queue of the stream head. |
I_CANPUT
|
| Checks whether a band can be written to. arg is the same as the priority band to be checked. The result is 0 if the priority band arg is subject to flow control, 1 if the band can be written to, or -1 for an error. ioctl() with the I_CANPUT command will fail if:
|
| EINVAL
| The value of arg is invalid. |
I_SETCLTIME
|
| Enables a user to define how long the stream head is to wait if a stream is closed while there is still data in the write queue. Before it closes every module and every driver, the stream head waits the specified length of time so that the data can still be transferred. If there is still data in the queue after the wait time, this data is discarded. arg is a pointer to the number of milliseconds to be waited, always rounded up to the next highest valid value in the system. The default value is 15 seconds. ioctl() with the I_SETCLTIME command will fail if:
|
| EINVAL
| The value of arg is invalid. |
I_GETCLTIME
|
| Returns the wait time when closing in the long variable pointed to by arg. |