STREAMS Programming Guide

M_COPYIN

The M_COPYIN message is generated by a module or driver and sent upstream to request that the stream head perform a copyin(9F) on behalf of the module or driver. It is valid only after receiving an M_IOCTL message and before an M_IOCACK or M_IOCNAK.

The message format is one M_COPYIN message block containing a copyreq(9S) structure, defined in <sys/stream.h>. Different structures are defined for 64–bit and 32–bit architectures.


#if defined(_LP64)
struct copyreq {
	int      cq_cmd;                /* ioctl command (from ioc_cmd) */
	cred_t   *cq_cr;                /* full credentials (from ioc_cmd) */
	uint     cq_id;                 /* ioctl id (from ioc_id) */
	uint     cq_flag;               /* see below */
	mblk_t   *cq_private;           /* private state information */
	caddr_t  cq_addr;               /* address to copy data to/from */
	size_t   cq_size;               /* number of bytes to copy */
};
#else
struct copyreq {
	int      cq_cmd;                /* ioctl command (from ioc_cmd) */
	cred_t   *cq_cr;                /* full credentials */
	uint     cq_id;                 /* ioctl id (from ioc_id) */
	caddr_t  cq_addr;               /* address to copy data to/from */
	size_t   cq_size;               /* number of bytes to copy */
	uint     cq_flag;               /* see below */
	mblk_t   *cq_private;           /* private state information */
	int      cq_filler[4];          /* reserved for future use */
};
#endif   /* _LP64 */

The first four members of the structure correspond to those of the iocblk(9S) structure in the M_IOCTL message that allows the same message block to be reused for both structures. The stream head guarantees that the message block allocated for the M_IOCTL message is large enough to contain a copyreq(9S). The cq_addr field contains the user space address from which the data is to be copied. The cq_size field is the number of bytes to copy from user space. The cq_flag field is reserved for future use and should be set to zero.

This message should not be queued by a module or driver unless it intends to process the data for the ioctl(2).