STREAMS Programming Guide

M_IOCDATA

The M_IOCDATA message is generated by the stream head and sent downstream as a response to an M_COPYIN or M_COPYOUT message. The message format is one M_IOCDATA message block followed by zero or more M_DATA blocks. The M_IOCDATA message block contains a copyresp(9S), defined in sys/stream.h.


#if     defined(_LP64)
struct copyresp {
	int      cp_cmd;          /* ioctl command (from ioc_cmd) */
	cred_t   *cp_cr;          /* full credentials (from ioc_cmd) */
	uint     cp_id;           /* ioctl id (from ioc_id) */
	uint     cp_flag;         /* see above */
	mblk_t   *cp_private;     /* private state information */
	caddr_t  cp_rval;         /* status of request: 0 -> success */
                           /*   non-zero -> failure */
};
#else
struct copyresp {
	int      cp_cmd;          /* ioctl command (from ioc_cmd) */
	cred_t   *cp_cr;          /* full credentials */
	uint     cp_id;           /* ioctl id (from ioc_id) */
	caddr_t  cp_rval          /* status of request: 0 -> success */
                           /*   non-zero -> failure */
	size_t   cp_pad1;
	uint     cp_pad2;
	mblk_t   *cp_private;     /* private state information */
	uint     cp_flag;         /* see above */
	int      cp_filler[3];
};
#endif  /* _LP64 */

The first three members of the structure correspond to those of the iocblk(9S) in the M_IOCTL message that allows the same message blocks to be reused for all of the related transparent messages (M_COPYIN, M_COPYOUT, M_IOCACK, M_IOCNAK). The cp_rval field contains the result of the request at the stream head. Zero indicates success and non-zero indicates failure. If failure is indicated, the module should not generate an M_IOCNAK message. It must abort all ioctl(2) processing, clean up its data structures, and return.

The cp_private field is copied from the cq_private field in the associated M_COPYIN or M_COPYOUT message. It is included in the M_IOCDATA message so the message can be self-describing. This is intended to simplify ioctl(2) processing by modules and drivers.

If the message is in response to an M_COPYIN message and success is indicated, the M_IOCDATA block is followed by M_DATA blocks containing the data copied in.

If an M_IOCDATA block is reused, any unused fields defined for the resultant message block should be cleared (particularly in an M_IOCACK or M_IOCNAK).

This message should not be queued by a module or driver unless it processes the data for the ioctl in some way.