ng_tty.c (131130) | ng_tty.c (132163) |
---|---|
1 2/* 3 * ng_tty.c 4 * 5 * Copyright (c) 1996-1999 Whistle Communications, Inc. 6 * All rights reserved. 7 * 8 * Subject to the following obligations and disclaimer of warranty, use and --- 22 unchanged lines hidden (view full) --- 31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 35 * OF SUCH DAMAGE. 36 * 37 * Author: Archie Cobbs <archie@freebsd.org> 38 * | 1 2/* 3 * ng_tty.c 4 * 5 * Copyright (c) 1996-1999 Whistle Communications, Inc. 6 * All rights reserved. 7 * 8 * Subject to the following obligations and disclaimer of warranty, use and --- 22 unchanged lines hidden (view full) --- 31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 35 * OF SUCH DAMAGE. 36 * 37 * Author: Archie Cobbs <archie@freebsd.org> 38 * |
39 * $FreeBSD: head/sys/netgraph/ng_tty.c 131130 2004-06-26 08:44:04Z phk $ | 39 * $FreeBSD: head/sys/netgraph/ng_tty.c 132163 2004-07-14 20:31:05Z rwatson $ |
40 * $Whistle: ng_tty.c,v 1.21 1999/11/01 09:24:52 julian Exp $ 41 */ 42 43/* 44 * This file implements a terminal line discipline that is also a 45 * netgraph node. Installing this line discipline on a terminal device 46 * instantiates a new netgraph node of this type, which allows access 47 * to the device via the "hook" hook of the node. --- 113 unchanged lines hidden (view full) --- 161 .shutdown = ngt_shutdown, 162 .newhook = ngt_newhook, 163 .connect = ngt_connect, 164 .rcvdata = ngt_rcvdata, 165 .disconnect = ngt_disconnect, 166}; 167NETGRAPH_INIT(tty, &typestruct); 168 | 40 * $Whistle: ng_tty.c,v 1.21 1999/11/01 09:24:52 julian Exp $ 41 */ 42 43/* 44 * This file implements a terminal line discipline that is also a 45 * netgraph node. Installing this line discipline on a terminal device 46 * instantiates a new netgraph node of this type, which allows access 47 * to the device via the "hook" hook of the node. --- 113 unchanged lines hidden (view full) --- 161 .shutdown = ngt_shutdown, 162 .newhook = ngt_newhook, 163 .connect = ngt_connect, 164 .rcvdata = ngt_rcvdata, 165 .disconnect = ngt_disconnect, 166}; 167NETGRAPH_INIT(tty, &typestruct); 168 |
169/* 170 * XXXRW: ngt_unit is protected by ng_tty_mtx. ngt_ldisc is constant once 171 * ng_tty is initialized. ngt_nodeop_ok is untouched, and might want to be a 172 * sleep lock in the future? 173 */ |
|
169static int ngt_unit; 170static int ngt_nodeop_ok; /* OK to create/remove node */ 171static int ngt_ldisc; 172 | 174static int ngt_unit; 175static int ngt_nodeop_ok; /* OK to create/remove node */ 176static int ngt_ldisc; 177 |
178static struct mtx ng_tty_mtx; 179MTX_SYSINIT(ng_tty, &ng_tty_mtx, "ng_tty", MTX_DEF); 180 |
|
173/****************************************************************** 174 LINE DISCIPLINE METHODS 175******************************************************************/ 176 177/* 178 * Set our line discipline on the tty. 179 * Called from device open routine or ttioctl() at >= splsofttty() 180 */ --- 28 unchanged lines hidden (view full) --- 209 /* Setup netgraph node */ 210 ngt_nodeop_ok = 1; 211 error = ng_make_node_common(&typestruct, &sc->node); 212 ngt_nodeop_ok = 0; 213 if (error) { 214 FREE(sc, M_NETGRAPH); 215 goto done; 216 } | 181/****************************************************************** 182 LINE DISCIPLINE METHODS 183******************************************************************/ 184 185/* 186 * Set our line discipline on the tty. 187 * Called from device open routine or ttioctl() at >= splsofttty() 188 */ --- 28 unchanged lines hidden (view full) --- 217 /* Setup netgraph node */ 218 ngt_nodeop_ok = 1; 219 error = ng_make_node_common(&typestruct, &sc->node); 220 ngt_nodeop_ok = 0; 221 if (error) { 222 FREE(sc, M_NETGRAPH); 223 goto done; 224 } |
225 mtx_lock(&ng_tty_mtx); |
|
217 snprintf(name, sizeof(name), "%s%d", typestruct.name, ngt_unit++); | 226 snprintf(name, sizeof(name), "%s%d", typestruct.name, ngt_unit++); |
227 mtx_unlock(&ng_tty_mtx); |
|
218 219 /* Assign node its name */ 220 if ((error = ng_name_node(sc->node, name))) { 221 log(LOG_ERR, "%s: node name exists?\n", name); 222 ngt_nodeop_ok = 1; 223 NG_NODE_UNREF(sc->node); 224 ngt_nodeop_ok = 0; 225 goto done; --- 453 unchanged lines hidden --- | 228 229 /* Assign node its name */ 230 if ((error = ng_name_node(sc->node, name))) { 231 log(LOG_ERR, "%s: node name exists?\n", name); 232 ngt_nodeop_ok = 1; 233 NG_NODE_UNREF(sc->node); 234 ngt_nodeop_ok = 0; 235 goto done; --- 453 unchanged lines hidden --- |