STREAMS-UX Programmer's Guide (February 2007)

Appendix A
139
A STREAMS IOCTL Commands
Overview
This appendix discusses the various STREAMS ioctl(s) commands.
ioctl(2) Commands
The STREAMS ioctl () commands are a subset of the ioctl (2) commands supported by HP-UX. They enable
the user process to perform a variety of control functions on a stream.
Synopsis
The general syntax of an ioctl() directive is shown:
#include <sys/types.h>
#include <stropts.h>
int ioctl(int fildes, int command, ... /* arg */);
fildes An open file descriptor that refers to a stream.
command Determines the control function to be performed as described.
arg Represents additional information that is needed by this command. The type of arg depends
upon the command, but it is generally an integer or a pointer to a command-specific data
structure.
The command and arg are interpreted by the stream head. Certain combinations of these arguments may be
passed to a module or driver in the stream.
Since these STREAMS commands are a subset of IOCTL, they are subject to the errors described there. In
addition to those errors, the call will fail with errno set to EINVAL, without processing a control function, if
the stream referenced by fildes is linked below a multiplexor, or if command is not a valid value for a
stream.
Also, as described in IOCTL, STREAMS modules and drivers can detect errors. In this case, the module or
driver sends an error message to the stream head containing an error value. This causes subsequent system
calls to fail with errno set to this value.
The following IOCTL commands, with error values indicated, are applicable to all STREAMS files.
I_ATMARK
This command allows the user to see if the current message on the stream head read queue is “marked” by
some module downstream. The arg parameter determines how the checking is done when there are multiple
marked messages on the stream head read queue. It may take the following values:
ANYMARK Checks if the message is marked.
LASTMARK Checks if the message is the last one that is marked on the queue.
If both ANYMARK and LASTMARK are set, ANYMARK supersedes LASTMARK.
The return value is 1 if the mark condition is satisfied and 0 otherwise. On failure, errno may be set to the
following value:
[EINVAL] The arg has an illegal value.