Go to main content

STREAMS Programming Guide

Exit Print View

Updated: November 2020
 
 

Common ioctl Interfaces

Many ioctl operations are common to a class of STREAMS drivers or STREAMS modules. Modules that deal with terminals usually implement a subset of the termio ioctls. Similarly, drivers that deal with audio devices usually implement a subset of the audio interfaces. For more information, see the termio(4I) and audio(4I) man pages.

Because no data structures have changed size as a result of the LP64 data model for either termio or audio, you do no need to use any of the structure macros to decode any of these ioctls.

FIORDCHK ioctl

The FIORDCHK ioctl returns a count of the number of bytes to be read as the return value. Although FIORDCHK should be able to return more than MAXINT bytes, it is constrained to returning an int by the type of the ioctl() function.

FIONREAD ioctl

The FIONREAD ioctl returns the number of data bytes in all data messages queued in the location pointed to by the arg parameter. The ioctl returns a 32-bit quantity for both 32-bit and 64-bit application., Therefore, code that passes the address of a long variable needs to be changed to pass an int variable for 64 bit applications.

I_NREAD ioctl

The I_NREAD ioctl is an informational ioctl that counts the data bytes as well as the number of messages in the stream head read queue. The number of data bytes is returned in the location pointed to by the arg parameter of the ioctl. The number of messages in the stream head read queue is returned as the return value of the ioctl. For more information, see the streamio(4I) man page.

Like FIONREAD, the arg parameter to the I_NREAD ioctl should be a pointer to an int, not a long. And, like FIORDCHK, the return value is constrained to be less than or equal to MAXINT bytes, even if more data is available.