STREAMS-UX Programmer's Guide (February 2007)

Message Types
High Priority Messages
Appendix C
246
High Priority Messages
M_CLOSE
This message is generated by the stream head to notify driver of a close (2) when the driver specifies
C_ALLCLOSES in the d_flags field of drv_ops_t structure. When the C_ALLCLOSES flag is set, STREAMS
sends an M_CLOSE message downstream when a close is issued on the driver. It then waits for a reply from the
driver. The stream will be dismantled if the reply (M_CLOSE_REPL message) for the M_CLOSE message has
MSGLASTCLOSE set in the b_flag field. If the M_CLOSE_REPL message does not have MSGLASTCLOSE set in the
b_flag field, STREAMS will return without dismantling the stream.
M_CLOSE_REPL
This message is generated by the driver, in response to the M_CLOSE message sent to it by the stream head.
When the flag C_ALLCLOSES is set in the d_flags field of the drv_ops_t structure, it is the responsibility of
the driver to keep track of the information about the number of opens/closes for this device. Accordingly, for
the last close on the device, the driver should set the MSGLASTCLOSE flag in the b_flag field of the
M_CLOSE_REPL message, if it wants the stream associated with device to be dismantled.
M_COPYIN
The M_COPYIN message is generated by modules or drivers to request a copyin() to be performed on their
behalf by stream head. This message is valid only after the M_IOCTL message is received by a module or driver
and before an M_IOCACK or M_IOCNAK message is sent upstream by the module or driver. The format of a
M_COPYIN message is one message block of type M_COPYIN, whose data buffer contains a copyreq structure
defined in <sys/stream.h> and is shown here:
int cq_cmd; /* command type == ioc_cmd */
cred_t * cq_cr; /* pointer to full credentials */
uint cq_id; /* ioctl id == ioc_id */
int cq_flag; /* reserved */
mblk_t * cq_private; /* module’s private state info */
ioc_pad cq_ad; /* address to copy data to/from */
uint cq_size; /* number of bytes to copy */
The first four fields of the copyreq structure correspond to those of the iocblk structure in the M_IOCTL
message. This allows the same message block to be reused for M_COPYIN and M_IOCTL structures. The stream
head guarantees that the message block allocated for M_IOCTL is large enough to contain a copyreq structure.
The cq_ad refers to the address of the data buffer from which data needs to be copied for an M_COPYIN
message. The cq_size specifies the number of bytes to be copied. Both cq_ad and cq_size values need to be
set by the modules. The cq_flag field is reserved for future use and should be set to zero. cq_private can be
set by the modules and drivers to get their state information pertaining to this IOCTL. The stream head will
copy the contents of cq_private field to the M_IOCDATA response message so that the module can resume the
associated state. If an M_COPYIN or M_COPYOUT message is freed, STREAMS will not free any message block
pointed to by cq_private. It is then the modules responsibility to free any associated data in cq_private.
This message should not be queued by a module or driver unless it intends to process the data for the IOCTL.