4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * Redirection STREAMS module.
32 * This module is intended for use in conjunction with instantiations of the
33 * redirection driver. Its purpose in life is to detect when the stream that
34 * it's pushed on is closed, thereupon calling back into the redirection
35 * driver so that the driver can cancel redirection to the stream.
36 * It passes all messages on unchanged, in both directions.
39 #include <sys/types.h>
40 #include <sys/param.h>
41 #include <sys/errno.h>
42 #include <sys/stream.h>
43 #include <sys/stropts.h>
44 #include <sys/debug.h>
45 #include <sys/strredir.h>
46 #include <sys/strsubr.h>
47 #include <sys/strsun.h>
50 #include <sys/sunddi.h>
51 #include <sys/modctl.h>
54 * Forward declarations for private routines.
56 static int wcmopen(queue_t
*, dev_t
*, int, int, cred_t
*);
57 static int wcmclose(queue_t
*, int, cred_t
*);
58 static int wcmrput(queue_t
*, mblk_t
*);
60 static struct module_info wcminfo
= {
69 static struct qinit wcmrinit
= {
79 static struct qinit wcmwinit
= {
80 (int (*)())putnext
, /* put */
89 static struct streamtab redirminfo
= {
96 static struct fmodsw fsw
= {
102 static struct modlstrmod modlstrmod
= {
104 "redirection module",
108 static struct modlinkage modlinkage
= {
109 MODREV_1
, &modlstrmod
, NULL
115 return (mod_install(&modlinkage
));
125 _info(struct modinfo
*modinfop
)
127 return (mod_info(&modlinkage
, modinfop
));
132 wcmopen(queue_t
*q
, dev_t
*dev
, int flag
, int sflag
, cred_t
*cred
)
134 if (sflag
!= MODOPEN
)
142 wcmclose(queue_t
*q
, int flag
, cred_t
*cred
)
145 srpop(q
->q_stream
->sd_vnode
, B_TRUE
);
150 * Upstream messages are passed unchanged.
151 * If a hangup occurs the target is no longer usable, so deprecate it.
154 wcmrput(queue_t
*q
, mblk_t
*mp
)
156 if (DB_TYPE(mp
) == M_HANGUP
)
157 /* Don't block waiting for outstanding operations to complete */
158 srpop(q
->q_stream
->sd_vnode
, B_FALSE
);