17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5facf4a8dSllai * Common Development and Distribution License (the "License").
6facf4a8dSllai * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate /*
22a204de77Scth * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
24*1fa2a664SJoshua M. Clulow * Copyright 2021 Oxide Computer Company
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate /*
28*1fa2a664SJoshua M. Clulow * PSEUDO-TERMINAL COMMON DATA AND ROUTINES (PTM, PTS)
297c478bd9Sstevel@tonic-gate *
30*1fa2a664SJoshua M. Clulow * This file contains global data and code shared between manager and
31*1fa2a664SJoshua M. Clulow * subsidiary parts of the pseudo-terminal driver.
327c478bd9Sstevel@tonic-gate *
33*1fa2a664SJoshua M. Clulow * Pseudo-terminals (or ptys for short) are allocated dynamically.
34*1fa2a664SJoshua M. Clulow * ptys are put in the global ptms_slots array indexed by minor numbers.
35*1fa2a664SJoshua M. Clulow *
36*1fa2a664SJoshua M. Clulow * The slots array is initially small (of the size NPTY_MIN). When more ptys are
377c478bd9Sstevel@tonic-gate * needed than the slot array size, the larger slot array is allocated and all
38*1fa2a664SJoshua M. Clulow * opened ptys move to the new one.
39*1fa2a664SJoshua M. Clulow *
40*1fa2a664SJoshua M. Clulow *
41*1fa2a664SJoshua M. Clulow * RESOURCE ALLOCATION
42*1fa2a664SJoshua M. Clulow *
43*1fa2a664SJoshua M. Clulow * - pt_ttys structures are allocated via pt_ttys_alloc, which uses
44*1fa2a664SJoshua M. Clulow * kmem_cache_alloc().
45*1fa2a664SJoshua M. Clulow * - Minor number space is allocated via vmem_alloc() interface.
46*1fa2a664SJoshua M. Clulow * - ptms_slots arrays are allocated via kmem_alloc().
477c478bd9Sstevel@tonic-gate *
48*1fa2a664SJoshua M. Clulow * Minors start from 1 instead of 0, because vmem_alloc() returns 0 in case of
49*1fa2a664SJoshua M. Clulow * failure. Also, in anticipation of removing the clone device interface to
50*1fa2a664SJoshua M. Clulow * pseudo-terminal subsystem, minor 0 should not be used. (Potential future
51*1fa2a664SJoshua M. Clulow * development).
527c478bd9Sstevel@tonic-gate *
53*1fa2a664SJoshua M. Clulow * After the table slot size reaches pt_maxdelta, we stop 2^N extension
54*1fa2a664SJoshua M. Clulow * algorithm and start extending the slot table size by pt_maxdelta.
557c478bd9Sstevel@tonic-gate *
56*1fa2a664SJoshua M. Clulow * Device entries /dev/pts directory are created dynamically by the /dev
57*1fa2a664SJoshua M. Clulow * filesystem. We no longer call ddi_create_minor_node() on behalf of the
58*1fa2a664SJoshua M. Clulow * subsidiary driver. The /dev filesystem creates /dev/pts nodes based on the
59*1fa2a664SJoshua M. Clulow * pt_ttys array.
607c478bd9Sstevel@tonic-gate *
617c478bd9Sstevel@tonic-gate *
62*1fa2a664SJoshua M. Clulow * SYNCHRONIZATION
63facf4a8dSllai *
64*1fa2a664SJoshua M. Clulow * All global data synchronization between ptm/pts is done via global ptms_lock
65*1fa2a664SJoshua M. Clulow * mutex which is implicitly initialized by declaring it global.
667c478bd9Sstevel@tonic-gate *
67*1fa2a664SJoshua M. Clulow * Individual fields of pt_ttys structure (except ptm_rdq, pts_rdq and
68*1fa2a664SJoshua M. Clulow * pt_nullmsg) are protected by pt_ttys.pt_lock mutex.
697c478bd9Sstevel@tonic-gate *
70*1fa2a664SJoshua M. Clulow * PT_ENTER_READ/PT_ENTER_WRITE are reference counter based read-write locks
71*1fa2a664SJoshua M. Clulow * which allow reader locks to be reacquired by the same thread (usual
72*1fa2a664SJoshua M. Clulow * reader/writer locks can't be used for that purpose since it is illegal for a
73*1fa2a664SJoshua M. Clulow * thread to acquire a lock it already holds, even as a reader). The sole
74*1fa2a664SJoshua M. Clulow * purpose of these macros is to guarantee that the peer queue will not
75*1fa2a664SJoshua M. Clulow * disappear (due to closing peer) while it is used. It is safe to use
76*1fa2a664SJoshua M. Clulow * PT_ENTER_READ/PT_EXIT_READ brackets across calls like putq/putnext (since
77*1fa2a664SJoshua M. Clulow * they are not real locks but reference counts).
787c478bd9Sstevel@tonic-gate *
79*1fa2a664SJoshua M. Clulow * PT_ENTER_WRITE/PT_EXIT_WRITE brackets are used ONLY in manager/subsidiary
80*1fa2a664SJoshua M. Clulow * open/close paths to modify ptm_rdq and pts_rdq fields. These fields should
81*1fa2a664SJoshua M. Clulow * be set to appropriate queues *after* qprocson() is called during open (to
82*1fa2a664SJoshua M. Clulow * prevent peer from accessing the queue with incomplete plumbing) and set to
83*1fa2a664SJoshua M. Clulow * NULL before qprocsoff() is called during close. Put and service procedures
84*1fa2a664SJoshua M. Clulow * use PT_ENTER_READ/PT_EXIT_READ to prevent peer closes.
857c478bd9Sstevel@tonic-gate *
86*1fa2a664SJoshua M. Clulow * The pt_nullmsg field is only used in open/close routines and is also
87*1fa2a664SJoshua M. Clulow * protected by PT_ENTER_WRITE/PT_EXIT_WRITE brackets to avoid extra mutex
88*1fa2a664SJoshua M. Clulow * holds.
897c478bd9Sstevel@tonic-gate *
907c478bd9Sstevel@tonic-gate *
91*1fa2a664SJoshua M. Clulow * LOCK ORDERING
927c478bd9Sstevel@tonic-gate *
93*1fa2a664SJoshua M. Clulow * If both ptms_lock and per-pty lock should be held, ptms_lock should always
94*1fa2a664SJoshua M. Clulow * be entered first, followed by per-pty lock.
957c478bd9Sstevel@tonic-gate *
96*1fa2a664SJoshua M. Clulow *
97*1fa2a664SJoshua M. Clulow * GLOBAL FUNCTIONS
987c478bd9Sstevel@tonic-gate *
997c478bd9Sstevel@tonic-gate * void ptms_init(void);
1007c478bd9Sstevel@tonic-gate *
1017c478bd9Sstevel@tonic-gate * Called by pts/ptm _init entry points. It performes one-time
102*1fa2a664SJoshua M. Clulow * initialization needed for both pts and ptm. This initialization is done
103*1fa2a664SJoshua M. Clulow * here and not in ptms_initspace because all these data structures are not
1047c478bd9Sstevel@tonic-gate * needed if pseudo-terminals are not used in the system.
1057c478bd9Sstevel@tonic-gate *
1067c478bd9Sstevel@tonic-gate * struct pt_ttys *pt_ttys_alloc(void);
1077c478bd9Sstevel@tonic-gate *
1087c478bd9Sstevel@tonic-gate * Allocate new minor number and pseudo-terminal entry. May sleep.
1097c478bd9Sstevel@tonic-gate * New minor number is recorded in pt_minor field of the entry returned.
1107c478bd9Sstevel@tonic-gate * This routine also initializes pt_minor and pt_state fields of the new
1117c478bd9Sstevel@tonic-gate * pseudo-terminal and puts a pointer to it into ptms_slots array.
1127c478bd9Sstevel@tonic-gate *
1137c478bd9Sstevel@tonic-gate * struct pt_ttys *ptms_minor2ptty(minor_t minor)
1147c478bd9Sstevel@tonic-gate *
1157c478bd9Sstevel@tonic-gate * Find pt_ttys structure by minor number.
1167c478bd9Sstevel@tonic-gate * Returns NULL when minor is out of range.
1177c478bd9Sstevel@tonic-gate *
118facf4a8dSllai * int ptms_minor_valid(minor_t minor, uid_t *ruid, gid_t *rgid)
119facf4a8dSllai *
120facf4a8dSllai * Check if minor refers to an allocated pty in the current zone.
121facf4a8dSllai * Returns
122facf4a8dSllai * 0 if not allocated or not for this zone.
123facf4a8dSllai * 1 if an allocated pty in the current zone.
124facf4a8dSllai * Also returns owner of pty.
125facf4a8dSllai *
126facf4a8dSllai * int ptms_minor_exists(minor_t minor)
127*1fa2a664SJoshua M. Clulow *
128facf4a8dSllai * Check if minor refers to an allocated pty (in any zone)
129facf4a8dSllai * Returns
130facf4a8dSllai * 0 if not an allocated pty
131facf4a8dSllai * 1 if an allocated pty
132facf4a8dSllai *
133facf4a8dSllai * void ptms_set_owner(minor_t minor, uid_t ruid, gid_t rgid)
134facf4a8dSllai *
135facf4a8dSllai * Sets the owner associated with a pty.
136facf4a8dSllai *
1377c478bd9Sstevel@tonic-gate * void ptms_close(struct pt_ttys *pt, uint_t flags_to_clear);
1387c478bd9Sstevel@tonic-gate *
1397c478bd9Sstevel@tonic-gate * Clear flags_to_clear in pt and if no one owns it (PTMOPEN/PTSOPEN not
140*1fa2a664SJoshua M. Clulow * set) free pt entry and corresponding slot.
141*1fa2a664SJoshua M. Clulow *
1427c478bd9Sstevel@tonic-gate *
143*1fa2a664SJoshua M. Clulow * TUNEABLES AND CONFIGURATION
1447c478bd9Sstevel@tonic-gate *
1457c478bd9Sstevel@tonic-gate * pt_cnt: minimum number of pseudo-terminals in the system. The system
1467c478bd9Sstevel@tonic-gate * should provide at least this number of ptys (provided sufficient
147*1fa2a664SJoshua M. Clulow * memory is available). It is different from the older semantics
1487c478bd9Sstevel@tonic-gate * of pt_cnt meaning maximum number of ptys.
1497c478bd9Sstevel@tonic-gate * Set to 0 by default.
1507c478bd9Sstevel@tonic-gate *
1517c478bd9Sstevel@tonic-gate * pt_max_pty: Maximum number of pseudo-terminals in the system. The system
1527c478bd9Sstevel@tonic-gate * should not allocate more ptys than pt_max_pty (although, it may
153*1fa2a664SJoshua M. Clulow * impose stricter maximum). Zero value means no user-defined
154*1fa2a664SJoshua M. Clulow * maximum. This is intended to be used as "denial-of-service"
1557c478bd9Sstevel@tonic-gate * protection.
1567c478bd9Sstevel@tonic-gate * Set to 0 by default.
1577c478bd9Sstevel@tonic-gate *
158*1fa2a664SJoshua M. Clulow * Both pt_cnt and pt_max_pty may be modified during system
159*1fa2a664SJoshua M. Clulow * lifetime with their semantics preserved.
1607c478bd9Sstevel@tonic-gate *
1617c478bd9Sstevel@tonic-gate * pt_init_cnt: Initial size of ptms_slots array. Set to NPTY_INITIAL.
1627c478bd9Sstevel@tonic-gate *
1637c478bd9Sstevel@tonic-gate * pt_ptyofmem: Approximate percentage of system memory that may be
1647c478bd9Sstevel@tonic-gate * occupied by pty data structures. Initially set to NPTY_PERCENT.
1657c478bd9Sstevel@tonic-gate * This variable is used once during initialization to estimate
166*1fa2a664SJoshua M. Clulow * maximum number of ptys in the system. The actual maximum is
1677c478bd9Sstevel@tonic-gate * determined as minimum of pt_max_pty and calculated value.
1687c478bd9Sstevel@tonic-gate *
1697c478bd9Sstevel@tonic-gate * pt_maxdelta: Maximum extension chunk of the slot table.
1707c478bd9Sstevel@tonic-gate */
1717c478bd9Sstevel@tonic-gate
1727c478bd9Sstevel@tonic-gate
1737c478bd9Sstevel@tonic-gate
1747c478bd9Sstevel@tonic-gate #include <sys/types.h>
1757c478bd9Sstevel@tonic-gate #include <sys/param.h>
1767c478bd9Sstevel@tonic-gate #include <sys/termios.h>
1777c478bd9Sstevel@tonic-gate #include <sys/stream.h>
1787c478bd9Sstevel@tonic-gate #include <sys/stropts.h>
1797c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
1807c478bd9Sstevel@tonic-gate #include <sys/ptms.h>
1817c478bd9Sstevel@tonic-gate #include <sys/stat.h>
1827c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
1837c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
1847c478bd9Sstevel@tonic-gate #include <sys/bitmap.h>
1857c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
1867c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
1877c478bd9Sstevel@tonic-gate #include <sys/zone.h>
1887c478bd9Sstevel@tonic-gate #ifdef DEBUG
1897c478bd9Sstevel@tonic-gate #include <sys/strlog.h>
1907c478bd9Sstevel@tonic-gate #endif
1917c478bd9Sstevel@tonic-gate
1927c478bd9Sstevel@tonic-gate
1937c478bd9Sstevel@tonic-gate /* Initial number of ptms slots */
1947c478bd9Sstevel@tonic-gate #define NPTY_INITIAL 16
1957c478bd9Sstevel@tonic-gate
1967c478bd9Sstevel@tonic-gate #define NPTY_PERCENT 5
1977c478bd9Sstevel@tonic-gate
1987c478bd9Sstevel@tonic-gate /* Maximum increment of the slot table size */
1997c478bd9Sstevel@tonic-gate #define PTY_MAXDELTA 128
2007c478bd9Sstevel@tonic-gate
2017c478bd9Sstevel@tonic-gate /*
2027c478bd9Sstevel@tonic-gate * Tuneable variables.
2037c478bd9Sstevel@tonic-gate */
2047c478bd9Sstevel@tonic-gate uint_t pt_cnt = 0; /* Minimum number of ptys */
205*1fa2a664SJoshua M. Clulow size_t pt_max_pty = 0; /* Maximum number of ptys */
2067c478bd9Sstevel@tonic-gate uint_t pt_init_cnt = NPTY_INITIAL; /* Initial number of ptms slots */
2077c478bd9Sstevel@tonic-gate uint_t pt_pctofmem = NPTY_PERCENT; /* Percent of memory to use for ptys */
2087c478bd9Sstevel@tonic-gate uint_t pt_maxdelta = PTY_MAXDELTA; /* Max increment for slot table size */
2097c478bd9Sstevel@tonic-gate
2107c478bd9Sstevel@tonic-gate /* Other global variables */
2117c478bd9Sstevel@tonic-gate
2127c478bd9Sstevel@tonic-gate kmutex_t ptms_lock; /* Global data access lock */
2137c478bd9Sstevel@tonic-gate
2147c478bd9Sstevel@tonic-gate /*
2157c478bd9Sstevel@tonic-gate * Slot array and its management variables
2167c478bd9Sstevel@tonic-gate */
2177c478bd9Sstevel@tonic-gate static struct pt_ttys **ptms_slots = NULL; /* Slots for actual pt structures */
2187c478bd9Sstevel@tonic-gate static size_t ptms_nslots = 0; /* Size of slot array */
2197c478bd9Sstevel@tonic-gate static size_t ptms_ptymax = 0; /* Maximum number of ptys */
2207c478bd9Sstevel@tonic-gate static size_t ptms_inuse = 0; /* # of ptys currently allocated */
2217c478bd9Sstevel@tonic-gate
222*1fa2a664SJoshua M. Clulow dev_info_t *pts_dip = NULL; /* Set if subsidiary is attached */
2237c478bd9Sstevel@tonic-gate
2247c478bd9Sstevel@tonic-gate static struct kmem_cache *ptms_cache = NULL; /* pty cache */
2257c478bd9Sstevel@tonic-gate
2267c478bd9Sstevel@tonic-gate static vmem_t *ptms_minor_arena = NULL; /* Arena for device minors */
2277c478bd9Sstevel@tonic-gate
2287c478bd9Sstevel@tonic-gate static uint_t ptms_roundup(uint_t);
2297c478bd9Sstevel@tonic-gate static int ptms_constructor(void *, void *, int);
2307c478bd9Sstevel@tonic-gate static void ptms_destructor(void *, void *);
2317c478bd9Sstevel@tonic-gate static minor_t ptms_grow(void);
2327c478bd9Sstevel@tonic-gate
2337c478bd9Sstevel@tonic-gate /*
234*1fa2a664SJoshua M. Clulow * Total size occupied by one pty. Each pty manager/subsidiary pair consumes
235*1fa2a664SJoshua M. Clulow * one pointer for ptms_slots array, one pt_ttys structure, and one empty
236*1fa2a664SJoshua M. Clulow * message preallocated for pts close.
2377c478bd9Sstevel@tonic-gate */
2387c478bd9Sstevel@tonic-gate
2397c478bd9Sstevel@tonic-gate #define PTY_SIZE (sizeof (struct pt_ttys) + \
2407c478bd9Sstevel@tonic-gate sizeof (struct pt_ttys *) + \
2417c478bd9Sstevel@tonic-gate sizeof (dblk_t))
2427c478bd9Sstevel@tonic-gate
2437c478bd9Sstevel@tonic-gate #ifdef DEBUG
2447c478bd9Sstevel@tonic-gate int ptms_debug = 0;
2457c478bd9Sstevel@tonic-gate #define PTMOD_ID 5
2467c478bd9Sstevel@tonic-gate #endif
2477c478bd9Sstevel@tonic-gate
2487c478bd9Sstevel@tonic-gate /*
2497c478bd9Sstevel@tonic-gate * Clear all bits of x except the highest bit
2507c478bd9Sstevel@tonic-gate */
251*1fa2a664SJoshua M. Clulow #define truncate(x) ((x) <= 2 ? (x) : (1 << (highbit(x) - 1)))
2527c478bd9Sstevel@tonic-gate
2537c478bd9Sstevel@tonic-gate /*
2547c478bd9Sstevel@tonic-gate * Roundup the number to the nearest power of 2
2557c478bd9Sstevel@tonic-gate */
2567c478bd9Sstevel@tonic-gate static uint_t
ptms_roundup(uint_t x)2577c478bd9Sstevel@tonic-gate ptms_roundup(uint_t x)
2587c478bd9Sstevel@tonic-gate {
2597c478bd9Sstevel@tonic-gate uint_t p = truncate(x); /* x with non-high bits stripped */
2607c478bd9Sstevel@tonic-gate
2617c478bd9Sstevel@tonic-gate /*
2627c478bd9Sstevel@tonic-gate * If x is a power of 2, return x, otherwise roundup.
2637c478bd9Sstevel@tonic-gate */
2647c478bd9Sstevel@tonic-gate return (p == x ? p : (p * 2));
2657c478bd9Sstevel@tonic-gate }
2667c478bd9Sstevel@tonic-gate
2677c478bd9Sstevel@tonic-gate /*
2687c478bd9Sstevel@tonic-gate * Allocate ptms_slots array and kmem cache for pt_ttys. This initialization is
2697c478bd9Sstevel@tonic-gate * only called once during system lifetime. Called from ptm or pts _init
2707c478bd9Sstevel@tonic-gate * routine.
2717c478bd9Sstevel@tonic-gate */
2727c478bd9Sstevel@tonic-gate void
ptms_init(void)2737c478bd9Sstevel@tonic-gate ptms_init(void)
2747c478bd9Sstevel@tonic-gate {
2757c478bd9Sstevel@tonic-gate mutex_enter(&ptms_lock);
2767c478bd9Sstevel@tonic-gate
2777c478bd9Sstevel@tonic-gate if (ptms_slots == NULL) {
2787c478bd9Sstevel@tonic-gate ptms_slots = kmem_zalloc(pt_init_cnt *
2797c478bd9Sstevel@tonic-gate sizeof (struct pt_ttys *), KM_SLEEP);
2807c478bd9Sstevel@tonic-gate
2817c478bd9Sstevel@tonic-gate ptms_cache = kmem_cache_create("pty_map",
2827c478bd9Sstevel@tonic-gate sizeof (struct pt_ttys), 0, ptms_constructor,
2837c478bd9Sstevel@tonic-gate ptms_destructor, NULL, NULL, NULL, 0);
2847c478bd9Sstevel@tonic-gate
2857c478bd9Sstevel@tonic-gate ptms_nslots = pt_init_cnt;
2867c478bd9Sstevel@tonic-gate
2877c478bd9Sstevel@tonic-gate /* Allocate integer space for minor numbers */
2887c478bd9Sstevel@tonic-gate ptms_minor_arena = vmem_create("ptms_minor", (void *)1,
2897c478bd9Sstevel@tonic-gate ptms_nslots, 1, NULL, NULL, NULL, 0,
2907c478bd9Sstevel@tonic-gate VM_SLEEP | VMC_IDENTIFIER);
2917c478bd9Sstevel@tonic-gate
2927c478bd9Sstevel@tonic-gate /*
2937c478bd9Sstevel@tonic-gate * Calculate available number of ptys - how many ptys can we
2947c478bd9Sstevel@tonic-gate * allocate in pt_pctofmem % of available memory. The value is
2957c478bd9Sstevel@tonic-gate * rounded up to the nearest power of 2.
2967c478bd9Sstevel@tonic-gate */
2977c478bd9Sstevel@tonic-gate ptms_ptymax = ptms_roundup((pt_pctofmem * kmem_maxavail()) /
2987c478bd9Sstevel@tonic-gate (100 * PTY_SIZE));
2997c478bd9Sstevel@tonic-gate }
3007c478bd9Sstevel@tonic-gate mutex_exit(&ptms_lock);
3017c478bd9Sstevel@tonic-gate }
3027c478bd9Sstevel@tonic-gate
3037c478bd9Sstevel@tonic-gate /*
304facf4a8dSllai * This routine attaches the pts dip.
3057c478bd9Sstevel@tonic-gate */
3067c478bd9Sstevel@tonic-gate int
ptms_attach_subsidiary(void)307*1fa2a664SJoshua M. Clulow ptms_attach_subsidiary(void)
3087c478bd9Sstevel@tonic-gate {
309facf4a8dSllai if (pts_dip == NULL && i_ddi_attach_pseudo_node("pts") == NULL)
310facf4a8dSllai return (-1);
3117c478bd9Sstevel@tonic-gate
312facf4a8dSllai ASSERT(pts_dip);
313facf4a8dSllai return (0);
3147c478bd9Sstevel@tonic-gate }
3157c478bd9Sstevel@tonic-gate
3167c478bd9Sstevel@tonic-gate /*
317facf4a8dSllai * Called from /dev fs. Checks if dip is attached,
318facf4a8dSllai * and if it is, returns its major number.
3197c478bd9Sstevel@tonic-gate */
320facf4a8dSllai major_t
ptms_subsidiary_attached(void)321*1fa2a664SJoshua M. Clulow ptms_subsidiary_attached(void)
3227c478bd9Sstevel@tonic-gate {
323a204de77Scth major_t maj = DDI_MAJOR_T_NONE;
324facf4a8dSllai
3257c478bd9Sstevel@tonic-gate mutex_enter(&ptms_lock);
326facf4a8dSllai if (pts_dip)
327facf4a8dSllai maj = ddi_driver_major(pts_dip);
3287c478bd9Sstevel@tonic-gate mutex_exit(&ptms_lock);
329facf4a8dSllai
330facf4a8dSllai return (maj);
3317c478bd9Sstevel@tonic-gate }
3327c478bd9Sstevel@tonic-gate
3337c478bd9Sstevel@tonic-gate /*
3347c478bd9Sstevel@tonic-gate * Allocate new minor number and pseudo-terminal entry. Returns the new entry or
3357c478bd9Sstevel@tonic-gate * NULL if no memory or maximum number of entries reached.
3367c478bd9Sstevel@tonic-gate */
3377c478bd9Sstevel@tonic-gate struct pt_ttys *
pt_ttys_alloc(void)3387c478bd9Sstevel@tonic-gate pt_ttys_alloc(void)
3397c478bd9Sstevel@tonic-gate {
3407c478bd9Sstevel@tonic-gate minor_t dminor;
3417c478bd9Sstevel@tonic-gate struct pt_ttys *pt = NULL;
3427c478bd9Sstevel@tonic-gate
3437c478bd9Sstevel@tonic-gate mutex_enter(&ptms_lock);
3447c478bd9Sstevel@tonic-gate
3457c478bd9Sstevel@tonic-gate /*
3467c478bd9Sstevel@tonic-gate * Always try to allocate new pty when pt_cnt minimum limit is not
3477c478bd9Sstevel@tonic-gate * achieved. If it is achieved, the maximum is determined by either
3487c478bd9Sstevel@tonic-gate * user-specified value (if it is non-zero) or our memory estimations -
3497c478bd9Sstevel@tonic-gate * whatever is less.
3507c478bd9Sstevel@tonic-gate */
3517c478bd9Sstevel@tonic-gate if (ptms_inuse >= pt_cnt) {
3527c478bd9Sstevel@tonic-gate /*
3537c478bd9Sstevel@tonic-gate * When system achieved required minimum of ptys, check for the
3547c478bd9Sstevel@tonic-gate * denial of service limits.
3557c478bd9Sstevel@tonic-gate *
3567c478bd9Sstevel@tonic-gate * Since pt_max_pty may be zero, the formula below is used to
3577c478bd9Sstevel@tonic-gate * avoid conditional expression. It will equal to pt_max_pty if
3587c478bd9Sstevel@tonic-gate * it is not zero and ptms_ptymax otherwise.
3597c478bd9Sstevel@tonic-gate */
3607c478bd9Sstevel@tonic-gate size_t user_max = (pt_max_pty == 0 ? ptms_ptymax : pt_max_pty);
3617c478bd9Sstevel@tonic-gate
3627c478bd9Sstevel@tonic-gate /* Do not try to allocate more than allowed */
3637c478bd9Sstevel@tonic-gate if (ptms_inuse >= min(ptms_ptymax, user_max)) {
3647c478bd9Sstevel@tonic-gate mutex_exit(&ptms_lock);
3657c478bd9Sstevel@tonic-gate return (NULL);
3667c478bd9Sstevel@tonic-gate }
3677c478bd9Sstevel@tonic-gate }
3687c478bd9Sstevel@tonic-gate ptms_inuse++;
3697c478bd9Sstevel@tonic-gate
3707c478bd9Sstevel@tonic-gate /*
3717c478bd9Sstevel@tonic-gate * Allocate new minor number. If this fails, all slots are busy and
3727c478bd9Sstevel@tonic-gate * we need to grow the hash.
3737c478bd9Sstevel@tonic-gate */
3747c478bd9Sstevel@tonic-gate dminor = (minor_t)(uintptr_t)
3757c478bd9Sstevel@tonic-gate vmem_alloc(ptms_minor_arena, 1, VM_NOSLEEP);
3767c478bd9Sstevel@tonic-gate
3777c478bd9Sstevel@tonic-gate if (dminor == 0) {
3787c478bd9Sstevel@tonic-gate /* Grow the cache and retry allocation */
3797c478bd9Sstevel@tonic-gate dminor = ptms_grow();
3807c478bd9Sstevel@tonic-gate }
3817c478bd9Sstevel@tonic-gate
3827c478bd9Sstevel@tonic-gate if (dminor == 0) {
3837c478bd9Sstevel@tonic-gate /* Not enough memory now */
3847c478bd9Sstevel@tonic-gate ptms_inuse--;
3857c478bd9Sstevel@tonic-gate mutex_exit(&ptms_lock);
3867c478bd9Sstevel@tonic-gate return (NULL);
3877c478bd9Sstevel@tonic-gate }
3887c478bd9Sstevel@tonic-gate
3897c478bd9Sstevel@tonic-gate pt = kmem_cache_alloc(ptms_cache, KM_NOSLEEP);
3907c478bd9Sstevel@tonic-gate if (pt == NULL) {
3917c478bd9Sstevel@tonic-gate /* Not enough memory - this entry can't be used now. */
3927c478bd9Sstevel@tonic-gate vmem_free(ptms_minor_arena, (void *)(uintptr_t)dminor, 1);
3937c478bd9Sstevel@tonic-gate ptms_inuse--;
3947c478bd9Sstevel@tonic-gate } else {
3957c478bd9Sstevel@tonic-gate pt->pt_minor = dminor;
3967c478bd9Sstevel@tonic-gate pt->pt_pid = curproc->p_pid; /* For debugging */
3977c478bd9Sstevel@tonic-gate pt->pt_state = (PTMOPEN | PTLOCK);
3987c478bd9Sstevel@tonic-gate pt->pt_zoneid = getzoneid();
399facf4a8dSllai pt->pt_ruid = 0; /* we don't know uid/gid yet. Report as root */
400facf4a8dSllai pt->pt_rgid = 0;
4017c478bd9Sstevel@tonic-gate ASSERT(ptms_slots[dminor - 1] == NULL);
4027c478bd9Sstevel@tonic-gate ptms_slots[dminor - 1] = pt;
4037c478bd9Sstevel@tonic-gate }
4047c478bd9Sstevel@tonic-gate
4057c478bd9Sstevel@tonic-gate mutex_exit(&ptms_lock);
4067c478bd9Sstevel@tonic-gate return (pt);
4077c478bd9Sstevel@tonic-gate }
4087c478bd9Sstevel@tonic-gate
4097c478bd9Sstevel@tonic-gate /*
4107c478bd9Sstevel@tonic-gate * Get pt_ttys structure by minor number.
4117c478bd9Sstevel@tonic-gate * Returns NULL when minor is out of range.
4127c478bd9Sstevel@tonic-gate */
4137c478bd9Sstevel@tonic-gate struct pt_ttys *
ptms_minor2ptty(minor_t dminor)4147c478bd9Sstevel@tonic-gate ptms_minor2ptty(minor_t dminor)
4157c478bd9Sstevel@tonic-gate {
4167c478bd9Sstevel@tonic-gate struct pt_ttys *pt = NULL;
4177c478bd9Sstevel@tonic-gate
4187c478bd9Sstevel@tonic-gate ASSERT(mutex_owned(&ptms_lock));
4197c478bd9Sstevel@tonic-gate if ((dminor >= 1) && (dminor <= ptms_nslots) && ptms_slots != NULL)
4207c478bd9Sstevel@tonic-gate pt = ptms_slots[dminor - 1];
4217c478bd9Sstevel@tonic-gate
4227c478bd9Sstevel@tonic-gate return (pt);
4237c478bd9Sstevel@tonic-gate }
4247c478bd9Sstevel@tonic-gate
425facf4a8dSllai /*
426facf4a8dSllai * Invoked in response to chown on /dev/pts nodes to change the
427facf4a8dSllai * permission on a pty
428facf4a8dSllai */
429facf4a8dSllai void
ptms_set_owner(minor_t dminor,uid_t ruid,gid_t rgid)430facf4a8dSllai ptms_set_owner(minor_t dminor, uid_t ruid, gid_t rgid)
431facf4a8dSllai {
432facf4a8dSllai struct pt_ttys *pt;
433facf4a8dSllai
4343df2e8b2SRobert Mustacchi if (ruid > MAXUID || rgid > MAXUID)
435facf4a8dSllai return;
436facf4a8dSllai
437facf4a8dSllai /*
438facf4a8dSllai * /dev/pts/0 is not used, but some applications may check it. There
439facf4a8dSllai * is no pty backing it - so we have nothing to do.
440facf4a8dSllai */
441facf4a8dSllai if (dminor == 0)
442facf4a8dSllai return;
443facf4a8dSllai
444facf4a8dSllai mutex_enter(&ptms_lock);
445facf4a8dSllai pt = ptms_minor2ptty(dminor);
446facf4a8dSllai if (pt != NULL && pt->pt_zoneid == getzoneid()) {
447facf4a8dSllai pt->pt_ruid = ruid;
448facf4a8dSllai pt->pt_rgid = rgid;
449facf4a8dSllai }
450facf4a8dSllai mutex_exit(&ptms_lock);
451facf4a8dSllai }
452facf4a8dSllai
453facf4a8dSllai /*
454facf4a8dSllai * Given a ptm/pts minor number
455facf4a8dSllai * returns:
456facf4a8dSllai * 1 if the pty is allocated to the current zone.
457facf4a8dSllai * 0 otherwise
458facf4a8dSllai *
459facf4a8dSllai * If the pty is allocated to the current zone, it also returns the owner.
460facf4a8dSllai */
461facf4a8dSllai int
ptms_minor_valid(minor_t dminor,uid_t * ruid,gid_t * rgid)462facf4a8dSllai ptms_minor_valid(minor_t dminor, uid_t *ruid, gid_t *rgid)
463facf4a8dSllai {
464facf4a8dSllai struct pt_ttys *pt;
465facf4a8dSllai int ret;
466facf4a8dSllai
467facf4a8dSllai ASSERT(ruid);
468facf4a8dSllai ASSERT(rgid);
469facf4a8dSllai
470f48205beScasper *ruid = (uid_t)-1;
471f48205beScasper *rgid = (gid_t)-1;
472facf4a8dSllai
473facf4a8dSllai /*
474facf4a8dSllai * /dev/pts/0 is not used, but some applications may check it, so create
475facf4a8dSllai * it also. Report the owner as root. It belongs to all zones.
476facf4a8dSllai */
477facf4a8dSllai if (dminor == 0) {
478facf4a8dSllai *ruid = 0;
479facf4a8dSllai *rgid = 0;
480facf4a8dSllai return (1);
481facf4a8dSllai }
482facf4a8dSllai
483facf4a8dSllai ret = 0;
484facf4a8dSllai mutex_enter(&ptms_lock);
485facf4a8dSllai pt = ptms_minor2ptty(dminor);
486facf4a8dSllai if (pt != NULL) {
4873df2e8b2SRobert Mustacchi ASSERT(pt->pt_ruid <= MAXUID);
4883df2e8b2SRobert Mustacchi ASSERT(pt->pt_rgid <= MAXUID);
489facf4a8dSllai if (pt->pt_zoneid == getzoneid()) {
490facf4a8dSllai ret = 1;
491facf4a8dSllai *ruid = pt->pt_ruid;
492facf4a8dSllai *rgid = pt->pt_rgid;
493facf4a8dSllai }
494facf4a8dSllai }
495facf4a8dSllai mutex_exit(&ptms_lock);
496facf4a8dSllai
497facf4a8dSllai return (ret);
498facf4a8dSllai }
499facf4a8dSllai
500facf4a8dSllai /*
501facf4a8dSllai * Given a ptm/pts minor number
502facf4a8dSllai * returns:
503facf4a8dSllai * 0 if the pty is not allocated
504facf4a8dSllai * 1 if the pty is allocated
505facf4a8dSllai */
506facf4a8dSllai int
ptms_minor_exists(minor_t dminor)507facf4a8dSllai ptms_minor_exists(minor_t dminor)
508facf4a8dSllai {
509facf4a8dSllai int ret;
510facf4a8dSllai
511facf4a8dSllai mutex_enter(&ptms_lock);
512facf4a8dSllai ret = ptms_minor2ptty(dminor) ? 1 : 0;
513facf4a8dSllai mutex_exit(&ptms_lock);
514facf4a8dSllai
515facf4a8dSllai return (ret);
516facf4a8dSllai }
517facf4a8dSllai
5187c478bd9Sstevel@tonic-gate /*
5197c478bd9Sstevel@tonic-gate * Close the pt and clear flags_to_clear.
5207c478bd9Sstevel@tonic-gate * If pt device is not opened by someone else, free it and clear its slot.
5217c478bd9Sstevel@tonic-gate */
5227c478bd9Sstevel@tonic-gate void
ptms_close(struct pt_ttys * pt,uint_t flags_to_clear)5237c478bd9Sstevel@tonic-gate ptms_close(struct pt_ttys *pt, uint_t flags_to_clear)
5247c478bd9Sstevel@tonic-gate {
5257c478bd9Sstevel@tonic-gate uint_t flags;
5267c478bd9Sstevel@tonic-gate
5277c478bd9Sstevel@tonic-gate ASSERT(MUTEX_NOT_HELD(&ptms_lock));
5287c478bd9Sstevel@tonic-gate ASSERT(pt != NULL);
5297c478bd9Sstevel@tonic-gate
5307c478bd9Sstevel@tonic-gate mutex_enter(&ptms_lock);
5317c478bd9Sstevel@tonic-gate
5327c478bd9Sstevel@tonic-gate mutex_enter(&pt->pt_lock);
5337c478bd9Sstevel@tonic-gate pt->pt_state &= ~flags_to_clear;
5347c478bd9Sstevel@tonic-gate flags = pt->pt_state;
5357c478bd9Sstevel@tonic-gate mutex_exit(&pt->pt_lock);
5367c478bd9Sstevel@tonic-gate
5377c478bd9Sstevel@tonic-gate if (! (flags & (PTMOPEN | PTSOPEN))) {
5387c478bd9Sstevel@tonic-gate /* No one owns the entry - free it */
5397c478bd9Sstevel@tonic-gate
5407c478bd9Sstevel@tonic-gate ASSERT(pt->ptm_rdq == NULL);
5417c478bd9Sstevel@tonic-gate ASSERT(pt->pts_rdq == NULL);
5427c478bd9Sstevel@tonic-gate ASSERT(pt->pt_nullmsg == NULL);
5437c478bd9Sstevel@tonic-gate ASSERT(pt->pt_refcnt == 0);
5447c478bd9Sstevel@tonic-gate ASSERT(pt->pt_minor <= ptms_nslots);
5457c478bd9Sstevel@tonic-gate ASSERT(ptms_slots[pt->pt_minor - 1] == pt);
5467c478bd9Sstevel@tonic-gate ASSERT(ptms_inuse > 0);
5477c478bd9Sstevel@tonic-gate
5487c478bd9Sstevel@tonic-gate ptms_inuse--;
5497c478bd9Sstevel@tonic-gate
5507c478bd9Sstevel@tonic-gate pt->pt_pid = 0;
5517c478bd9Sstevel@tonic-gate
5527c478bd9Sstevel@tonic-gate ptms_slots[pt->pt_minor - 1] = NULL;
5537c478bd9Sstevel@tonic-gate /* Return minor number to the pool of minors */
5547c478bd9Sstevel@tonic-gate vmem_free(ptms_minor_arena, (void *)(uintptr_t)pt->pt_minor, 1);
5557c478bd9Sstevel@tonic-gate /* Return pt to the cache */
5567c478bd9Sstevel@tonic-gate kmem_cache_free(ptms_cache, pt);
5577c478bd9Sstevel@tonic-gate }
5587c478bd9Sstevel@tonic-gate mutex_exit(&ptms_lock);
5597c478bd9Sstevel@tonic-gate }
5607c478bd9Sstevel@tonic-gate
5617c478bd9Sstevel@tonic-gate /*
5627c478bd9Sstevel@tonic-gate * Allocate another slot table twice as large as the original one (limited to
5637c478bd9Sstevel@tonic-gate * global maximum). Migrate all pt to the new slot table and free the original
5647c478bd9Sstevel@tonic-gate * one. Create more /devices entries for new devices.
5657c478bd9Sstevel@tonic-gate */
5667c478bd9Sstevel@tonic-gate static minor_t
ptms_grow()5677c478bd9Sstevel@tonic-gate ptms_grow()
5687c478bd9Sstevel@tonic-gate {
5697c478bd9Sstevel@tonic-gate minor_t old_size = ptms_nslots;
5707c478bd9Sstevel@tonic-gate minor_t delta = MIN(pt_maxdelta, old_size);
5717c478bd9Sstevel@tonic-gate minor_t new_size = old_size + delta;
5727c478bd9Sstevel@tonic-gate struct pt_ttys **ptms_old = ptms_slots;
5737c478bd9Sstevel@tonic-gate struct pt_ttys **ptms_new;
5747c478bd9Sstevel@tonic-gate void *vaddr; /* vmem_add return value */
5757c478bd9Sstevel@tonic-gate
5767c478bd9Sstevel@tonic-gate ASSERT(MUTEX_HELD(&ptms_lock));
5777c478bd9Sstevel@tonic-gate
5787c478bd9Sstevel@tonic-gate DDBG("ptmopen(%d): need to grow\n", (int)ptms_inuse);
5797c478bd9Sstevel@tonic-gate
5807c478bd9Sstevel@tonic-gate /* Allocate new ptms array */
5817c478bd9Sstevel@tonic-gate ptms_new = kmem_zalloc(new_size * sizeof (struct pt_ttys *),
5827c478bd9Sstevel@tonic-gate KM_NOSLEEP);
5837c478bd9Sstevel@tonic-gate if (ptms_new == NULL)
5847c478bd9Sstevel@tonic-gate return ((minor_t)0);
5857c478bd9Sstevel@tonic-gate
5867c478bd9Sstevel@tonic-gate /* Increase clone index space */
5877c478bd9Sstevel@tonic-gate vaddr = vmem_add(ptms_minor_arena, (void *)(uintptr_t)(old_size + 1),
5887c478bd9Sstevel@tonic-gate new_size - old_size, VM_NOSLEEP);
5897c478bd9Sstevel@tonic-gate
5907c478bd9Sstevel@tonic-gate if (vaddr == NULL) {
5917c478bd9Sstevel@tonic-gate kmem_free(ptms_new, new_size * sizeof (struct pt_ttys *));
5927c478bd9Sstevel@tonic-gate return ((minor_t)0);
5937c478bd9Sstevel@tonic-gate }
5947c478bd9Sstevel@tonic-gate
5957c478bd9Sstevel@tonic-gate /* Migrate pt entries to a new location */
5967c478bd9Sstevel@tonic-gate ptms_nslots = new_size;
5977c478bd9Sstevel@tonic-gate bcopy(ptms_old, ptms_new, old_size * sizeof (struct pt_ttys *));
5987c478bd9Sstevel@tonic-gate ptms_slots = ptms_new;
5997c478bd9Sstevel@tonic-gate kmem_free(ptms_old, old_size * sizeof (struct pt_ttys *));
6007c478bd9Sstevel@tonic-gate
6017c478bd9Sstevel@tonic-gate /* Allocate minor number and return it */
6027c478bd9Sstevel@tonic-gate return ((minor_t)(uintptr_t)
6037c478bd9Sstevel@tonic-gate vmem_alloc(ptms_minor_arena, 1, VM_NOSLEEP));
6047c478bd9Sstevel@tonic-gate }
6057c478bd9Sstevel@tonic-gate
6067c478bd9Sstevel@tonic-gate /*ARGSUSED*/
6077c478bd9Sstevel@tonic-gate static int
ptms_constructor(void * maddr,void * arg,int kmflags)6087c478bd9Sstevel@tonic-gate ptms_constructor(void *maddr, void *arg, int kmflags)
6097c478bd9Sstevel@tonic-gate {
6107c478bd9Sstevel@tonic-gate struct pt_ttys *pt = maddr;
6117c478bd9Sstevel@tonic-gate
6127c478bd9Sstevel@tonic-gate pt->pts_rdq = NULL;
6137c478bd9Sstevel@tonic-gate pt->ptm_rdq = NULL;
6147c478bd9Sstevel@tonic-gate pt->pt_nullmsg = NULL;
6157e12ceb3SToomas Soome pt->pt_pid = 0;
6167e12ceb3SToomas Soome pt->pt_minor = 0;
6177c478bd9Sstevel@tonic-gate pt->pt_refcnt = 0;
6187c478bd9Sstevel@tonic-gate pt->pt_state = 0;
6197c478bd9Sstevel@tonic-gate pt->pt_zoneid = GLOBAL_ZONEID;
6207c478bd9Sstevel@tonic-gate
6217c478bd9Sstevel@tonic-gate cv_init(&pt->pt_cv, NULL, CV_DEFAULT, NULL);
6227c478bd9Sstevel@tonic-gate mutex_init(&pt->pt_lock, NULL, MUTEX_DEFAULT, NULL);
6237c478bd9Sstevel@tonic-gate return (0);
6247c478bd9Sstevel@tonic-gate }
6257c478bd9Sstevel@tonic-gate
6267c478bd9Sstevel@tonic-gate /*ARGSUSED*/
6277c478bd9Sstevel@tonic-gate static void
ptms_destructor(void * maddr,void * arg)6287c478bd9Sstevel@tonic-gate ptms_destructor(void *maddr, void *arg)
6297c478bd9Sstevel@tonic-gate {
6307c478bd9Sstevel@tonic-gate struct pt_ttys *pt = maddr;
6317c478bd9Sstevel@tonic-gate
6327c478bd9Sstevel@tonic-gate ASSERT(pt->pt_refcnt == 0);
6337c478bd9Sstevel@tonic-gate ASSERT(pt->pt_state == 0);
6347c478bd9Sstevel@tonic-gate ASSERT(pt->ptm_rdq == NULL);
6357c478bd9Sstevel@tonic-gate ASSERT(pt->pts_rdq == NULL);
6367c478bd9Sstevel@tonic-gate
6377c478bd9Sstevel@tonic-gate mutex_destroy(&pt->pt_lock);
6387c478bd9Sstevel@tonic-gate cv_destroy(&pt->pt_cv);
6397c478bd9Sstevel@tonic-gate }
6407c478bd9Sstevel@tonic-gate
6417c478bd9Sstevel@tonic-gate #ifdef DEBUG
6427c478bd9Sstevel@tonic-gate void
ptms_log(char * str,uint_t arg)6437c478bd9Sstevel@tonic-gate ptms_log(char *str, uint_t arg)
6447c478bd9Sstevel@tonic-gate {
6457c478bd9Sstevel@tonic-gate if (ptms_debug) {
6467c478bd9Sstevel@tonic-gate if (ptms_debug & 2)
6477c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, str, arg);
6487c478bd9Sstevel@tonic-gate if (ptms_debug & 4)
6497c478bd9Sstevel@tonic-gate (void) strlog(PTMOD_ID, -1, 0, SL_TRACE | SL_ERROR,
6507c478bd9Sstevel@tonic-gate str, arg);
6517c478bd9Sstevel@tonic-gate else
6527c478bd9Sstevel@tonic-gate (void) strlog(PTMOD_ID, -1, 0, SL_TRACE, str, arg);
6537c478bd9Sstevel@tonic-gate }
6547c478bd9Sstevel@tonic-gate }
6557c478bd9Sstevel@tonic-gate
6567c478bd9Sstevel@tonic-gate void
ptms_logp(char * str,uintptr_t arg)6577c478bd9Sstevel@tonic-gate ptms_logp(char *str, uintptr_t arg)
6587c478bd9Sstevel@tonic-gate {
6597c478bd9Sstevel@tonic-gate if (ptms_debug) {
6607c478bd9Sstevel@tonic-gate if (ptms_debug & 2)
6617c478bd9Sstevel@tonic-gate cmn_err(CE_CONT, str, arg);
6627c478bd9Sstevel@tonic-gate if (ptms_debug & 4)
6637c478bd9Sstevel@tonic-gate (void) strlog(PTMOD_ID, -1, 0, SL_TRACE | SL_ERROR,
6647c478bd9Sstevel@tonic-gate str, arg);
6657c478bd9Sstevel@tonic-gate else
6667c478bd9Sstevel@tonic-gate (void) strlog(PTMOD_ID, -1, 0, SL_TRACE, str, arg);
6677c478bd9Sstevel@tonic-gate }
6687c478bd9Sstevel@tonic-gate }
6697c478bd9Sstevel@tonic-gate #endif
670