9348 mii: duplicate 'const' declaration specifier
[unleashed.git] / usr / src / uts / common / io / pipemod.c
blob3491b9eadc05ef82749c1d78f34eb7a334a68726
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright (c) 1997, by Sun Microsystems, Inc.
24 * All rights reserved.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI"
34 * This module switches the read and write flush bits for each
35 * M_FLUSH control message it receives. It's intended usage is to
36 * properly flush a STREAMS-based pipe.
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <sys/errno.h>
41 #include <sys/stream.h>
42 #include <sys/stropts.h>
44 #include <sys/conf.h>
45 #include <sys/modctl.h>
47 /*ARGSUSED*/
48 static int
49 pipeopen(queue_t *rqp, dev_t *devp, int flag, int sflag, cred_t *crp)
51 qprocson(rqp);
52 return (0);
55 /*ARGSUSED*/
56 static int
57 pipeclose(queue_t *q, int cflag, cred_t *crp)
59 qprocsoff(q);
60 return (0);
64 * Use same put procedure for write and read queues.
65 * If mp is an M_FLUSH message, switch the FLUSHW to FLUSHR and
66 * the FLUSHR to FLUSHW and send the message on. If mp is not an
67 * M_FLUSH message, send it on with out processing.
69 static int
70 pipeput(queue_t *qp, mblk_t *mp)
72 switch (mp->b_datap->db_type) {
73 case M_FLUSH:
74 if (!(*mp->b_rptr & FLUSHR && *mp->b_rptr & FLUSHW)) {
75 if (*mp->b_rptr & FLUSHW) {
76 *mp->b_rptr |= FLUSHR;
77 *mp->b_rptr &= ~FLUSHW;
78 } else {
79 *mp->b_rptr |= FLUSHW;
80 *mp->b_rptr &= ~FLUSHR;
83 break;
85 default:
86 break;
88 putnext(qp, mp);
89 return (0);
92 static struct module_info pipe_info = {
93 1003, "pipemod", 0, INFPSZ, STRHIGH, STRLOW
96 static struct qinit piperinit = {
97 pipeput, NULL, pipeopen, pipeclose, NULL, &pipe_info, NULL
100 static struct qinit pipewinit = {
101 pipeput, NULL, NULL, NULL, NULL, &pipe_info, NULL
104 static struct streamtab pipeinfo = { &piperinit, &pipewinit, NULL, NULL };
106 static struct fmodsw fsw = {
107 "pipemod",
108 &pipeinfo,
109 D_NEW | D_MP
112 static struct modlstrmod modlstrmod = {
113 &mod_strmodops, "pipe flushing module", &fsw
116 static struct modlinkage modlinkage = {
117 MODREV_1, &modlstrmod, NULL
121 _init(void)
123 return (mod_install(&modlinkage));
127 _fini(void)
129 return (mod_remove(&modlinkage));
133 _info(struct modinfo *modinfop)
135 return (mod_info(&modlinkage, modinfop));