xref: /illumos-gate/usr/src/uts/common/io/ptms_conf.c (revision 0a34963c38fe21eee84ebab010996317731a5171)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * This file contains global data and code shared between master and slave parts
28  * of the pseudo-terminal driver.
29  *
30  * Pseudo terminals (or pt's for short) are allocated dynamically.
31  * pt's are put in the global ptms_slots array indexed by minor numbers.
32  *
33  * The slots array is initially small (of the size NPTY_MIN). When more pt's are
34  * needed than the slot array size, the larger slot array is allocated and all
35  * opened pt's move to the new one.
36  *
37  * Resource allocation:
38  *
39  *	pt_ttys structures are allocated via pt_ttys_alloc, which uses
40  *		kmem_cache_alloc().
41  *	Minor number space is allocated via vmem_alloc() interface.
42  *	ptms_slots arrays are allocated via kmem_alloc().
43  *
44  *   Minors are started from 1 instead of 0 because vmem_alloc returns 0 in case
45  *   of failure. Also, in anticipation of removing clone device interface to
46  *   pseudo-terminal subsystem, minor 0 should not be used. (Potential future
47  *   development).
48  *
49  *   After the table slot size reaches pt_maxdelta, we stop 2^N extension
50  *   algorithm and start extending the slot table size by pt_maxdelta.
51  *
52  *   Device entries /dev/pts directory are created dynamically by the
53  *   /dev filesystem. We no longer call ddi_create_minor_node() on
54  *   behalf of the slave driver. The /dev filesystem creates /dev/pts
55  *   nodes based on the pt_ttys array.
56  *
57  * Synchronization:
58  *
59  *   All global data synchronization between ptm/pts is done via global
60  *   ptms_lock mutex which is implicitly initialized by declaring it global.
61  *
62  *   Individual fields of pt_ttys structure (except ptm_rdq, pts_rdq and
63  *   pt_nullmsg) are protected by pt_ttys.pt_lock mutex.
64  *
65  *   PT_ENTER_READ/PT_ENTER_WRITE are reference counter based read-write locks
66  *   which allow reader locks to be reacquired by the same thread (usual
67  *   reader/writer locks can't be used for that purpose since it is illegal for
68  *   a thread to acquire a lock it already holds, even as a reader). The sole
69  *   purpose of these macros is to guarantee that the peer queue will not
70  *   disappear (due to closing peer) while it is used. It is safe to use
71  *   PT_ENTER_READ/PT_EXIT_READ brackets across calls like putq/putnext (since
72  *   they are not real locks but reference counts).
73  *
74  *   PT_ENTER_WRITE/PT_EXIT_WRITE brackets are used ONLY in master/slave
75  *   open/close paths to modify ptm_rdq and pts_rdq fields. These fields should
76  *   be set to appropriate queues *after* qprocson() is called during open (to
77  *   prevent peer from accessing the queue with incomplete plumbing) and set to
78  *   NULL before qprocsoff() is called during close. Put and service procedures
79  *   use PT_ENTER_READ/PT_EXIT_READ to prevent peer closes.
80  *
81  *   The pt_nullmsg field is only used in open/close routines and is also
82  *   protected by PT_ENTER_WRITE/PT_EXIT_WRITE brackets to avoid extra mutex
83  *   holds.
84  *
85  * Lock Ordering:
86  *
87  *   If both ptms_lock and per-pty lock should be held, ptms_lock should always
88  *   be entered first, followed by per-pty lock.
89  *
90  * Global functions:
91  *
92  * void ptms_init(void);
93  *
94  *	Called by pts/ptm _init entry points. It performes one-time
95  * 	initialization needed for both pts and ptm. This initialization is done
96  * 	here and not in ptms_initspace because all these data structures are not
97  *	needed if pseudo-terminals are not used in the system.
98  *
99  * struct pt_ttys *pt_ttys_alloc(void);
100  *
101  *	Allocate new minor number and pseudo-terminal entry. May sleep.
102  *	New minor number is recorded in pt_minor field of the entry returned.
103  *	This routine also initializes pt_minor and pt_state fields of the new
104  *	pseudo-terminal and puts a pointer to it into ptms_slots array.
105  *
106  * struct pt_ttys *ptms_minor2ptty(minor_t minor)
107  *
108  *	Find pt_ttys structure by minor number.
109  *	Returns NULL when minor is out of range.
110  *
111  * int ptms_minor_valid(minor_t minor, uid_t *ruid, gid_t *rgid)
112  *
113  *	Check if minor refers to an allocated pty in the current zone.
114  *	Returns
115  *		 0 if not allocated or not for this zone.
116  *		 1 if an allocated pty in the current zone.
117  *	Also returns owner of pty.
118  *
119  * int ptms_minor_exists(minor_t minor)
120  *	Check if minor refers to an allocated pty (in any zone)
121  *	Returns
122  *		0 if not an allocated pty
123  *		1 if an allocated pty
124  *
125  * void ptms_set_owner(minor_t minor, uid_t ruid, gid_t rgid)
126  *
127  *	Sets the owner associated with a pty.
128  *
129  * void ptms_close(struct pt_ttys *pt, uint_t flags_to_clear);
130  *
131  *	Clear flags_to_clear in pt and if no one owns it (PTMOPEN/PTSOPEN not
132  * 	set) free pt entry and corresponding slot.
133  *
134  * Tuneables and configuration:
135  *
136  *	pt_cnt: minimum number of pseudo-terminals in the system. The system
137  *		should provide at least this number of ptys (provided sufficient
138  * 		memory is available). It is different from the older semantics
139  *		of pt_cnt meaning maximum number of ptys.
140  *		Set to 0 by default.
141  *
142  *	pt_max_pty: Maximum number of pseudo-terminals in the system. The system
143  *		should not allocate more ptys than pt_max_pty (although, it may
144  * 		impose stricter maximum). Zero value means no user-defined
145  * 		maximum. This is intended to be used as "denial-of-service"
146  *		protection.
147  *		Set to 0 by default.
148  *
149  *         Both pt_cnt and pt_max_pty may be modified during system lifetime
150  *         with their semantics preserved.
151  *
152  *	pt_init_cnt: Initial size of ptms_slots array. Set to NPTY_INITIAL.
153  *
154  *	pt_ptyofmem: Approximate percentage of system memory that may be
155  *		occupied by pty data structures. Initially set to NPTY_PERCENT.
156  *		This variable is used once during initialization to estimate
157  * 		maximum number of ptys in the system. The actual maximum is
158  *		determined as minimum of pt_max_pty and calculated value.
159  *
160  *	pt_maxdelta: Maximum extension chunk of the slot table.
161  */
162 
163 
164 
165 #include <sys/types.h>
166 #include <sys/param.h>
167 #include <sys/termios.h>
168 #include <sys/stream.h>
169 #include <sys/stropts.h>
170 #include <sys/kmem.h>
171 #include <sys/ptms.h>
172 #include <sys/stat.h>
173 #include <sys/sunddi.h>
174 #include <sys/ddi.h>
175 #include <sys/bitmap.h>
176 #include <sys/sysmacros.h>
177 #include <sys/ddi_impldefs.h>
178 #include <sys/zone.h>
179 #ifdef DEBUG
180 #include <sys/strlog.h>
181 #endif
182 
183 
184 /* Initial number of ptms slots */
185 #define	NPTY_INITIAL 16
186 
187 #define	NPTY_PERCENT 5
188 
189 /* Maximum increment of the slot table size */
190 #define	PTY_MAXDELTA 128
191 
192 /*
193  * Tuneable variables.
194  */
195 uint_t	pt_cnt = 0;			/* Minimum number of ptys */
196 size_t 	pt_max_pty = 0;			/* Maximum number of ptys */
197 uint_t	pt_init_cnt = NPTY_INITIAL;	/* Initial number of ptms slots */
198 uint_t	pt_pctofmem = NPTY_PERCENT;	/* Percent of memory to use for ptys */
199 uint_t	pt_maxdelta = PTY_MAXDELTA;	/* Max increment for slot table size */
200 
201 /* Other global variables */
202 
203 kmutex_t ptms_lock;			/* Global data access lock */
204 
205 /*
206  * Slot array and its management variables
207  */
208 static struct pt_ttys **ptms_slots = NULL; /* Slots for actual pt structures */
209 static size_t ptms_nslots = 0;		/* Size of slot array */
210 static size_t ptms_ptymax = 0;		/* Maximum number of ptys */
211 static size_t ptms_inuse = 0;		/* # of ptys currently allocated */
212 
213 dev_info_t 	*pts_dip = NULL;	/* set if slave is attached */
214 
215 static struct kmem_cache *ptms_cache = NULL;	/* pty cache */
216 
217 static vmem_t *ptms_minor_arena = NULL; /* Arena for device minors */
218 
219 static uint_t ptms_roundup(uint_t);
220 static int ptms_constructor(void *, void *, int);
221 static void ptms_destructor(void *, void *);
222 static minor_t ptms_grow(void);
223 
224 /*
225  * Total size occupied by one pty. Each pty master/slave pair consumes one
226  * pointer for ptms_slots array, one pt_ttys structure and one empty message
227  * preallocated for pts close.
228  */
229 
230 #define	PTY_SIZE (sizeof (struct pt_ttys) + \
231     sizeof (struct pt_ttys *) + \
232     sizeof (dblk_t))
233 
234 #ifdef DEBUG
235 int ptms_debug = 0;
236 #define	PTMOD_ID 5
237 #endif
238 
239 /*
240  * Clear all bits of x except the highest bit
241  */
242 #define	truncate(x) 	((x) <= 2 ? (x) : (1 << (highbit(x) - 1)))
243 
244 /*
245  * Roundup the number to the nearest power of 2
246  */
247 static uint_t
248 ptms_roundup(uint_t x)
249 {
250 	uint_t p = truncate(x);	/* x with non-high bits stripped */
251 
252 	/*
253 	 * If x is a power of 2, return x, otherwise roundup.
254 	 */
255 	return (p == x ? p : (p * 2));
256 }
257 
258 /*
259  * Allocate ptms_slots array and kmem cache for pt_ttys. This initialization is
260  * only called once during system lifetime. Called from ptm or pts _init
261  * routine.
262  */
263 void
264 ptms_init(void)
265 {
266 	mutex_enter(&ptms_lock);
267 
268 	if (ptms_slots == NULL) {
269 		ptms_slots = kmem_zalloc(pt_init_cnt *
270 		    sizeof (struct pt_ttys *), KM_SLEEP);
271 
272 		ptms_cache = kmem_cache_create("pty_map",
273 		    sizeof (struct pt_ttys), 0, ptms_constructor,
274 		    ptms_destructor, NULL, NULL, NULL, 0);
275 
276 		ptms_nslots = pt_init_cnt;
277 
278 		/* Allocate integer space for minor numbers */
279 		ptms_minor_arena = vmem_create("ptms_minor", (void *)1,
280 		    ptms_nslots, 1, NULL, NULL, NULL, 0,
281 		    VM_SLEEP | VMC_IDENTIFIER);
282 
283 		/*
284 		 * Calculate available number of ptys - how many ptys can we
285 		 * allocate in pt_pctofmem % of available memory. The value is
286 		 * rounded up to the nearest power of 2.
287 		 */
288 		ptms_ptymax = ptms_roundup((pt_pctofmem * kmem_maxavail()) /
289 		    (100 * PTY_SIZE));
290 	}
291 	mutex_exit(&ptms_lock);
292 }
293 
294 /*
295  * This routine attaches the pts dip.
296  */
297 int
298 ptms_attach_slave(void)
299 {
300 	if (pts_dip == NULL && i_ddi_attach_pseudo_node("pts") == NULL)
301 		return (-1);
302 
303 	ASSERT(pts_dip);
304 	return (0);
305 }
306 
307 /*
308  * Called from /dev fs. Checks if dip is attached,
309  * and if it is, returns its major number.
310  */
311 major_t
312 ptms_slave_attached(void)
313 {
314 	major_t maj = DDI_MAJOR_T_NONE;
315 
316 	mutex_enter(&ptms_lock);
317 	if (pts_dip)
318 		maj = ddi_driver_major(pts_dip);
319 	mutex_exit(&ptms_lock);
320 
321 	return (maj);
322 }
323 
324 /*
325  * Allocate new minor number and pseudo-terminal entry. Returns the new entry or
326  * NULL if no memory or maximum number of entries reached.
327  */
328 struct pt_ttys *
329 pt_ttys_alloc(void)
330 {
331 	minor_t dminor;
332 	struct pt_ttys *pt = NULL;
333 
334 	mutex_enter(&ptms_lock);
335 
336 	/*
337 	 * Always try to allocate new pty when pt_cnt minimum limit is not
338 	 * achieved. If it is achieved, the maximum is determined by either
339 	 * user-specified value (if it is non-zero) or our memory estimations -
340 	 * whatever is less.
341 	 */
342 	if (ptms_inuse >= pt_cnt) {
343 		/*
344 		 * When system achieved required minimum of ptys, check for the
345 		 *   denial of service limits.
346 		 *
347 		 * Since pt_max_pty may be zero, the formula below is used to
348 		 * avoid conditional expression. It will equal to pt_max_pty if
349 		 * it is not zero and ptms_ptymax otherwise.
350 		 */
351 		size_t user_max = (pt_max_pty == 0 ? ptms_ptymax : pt_max_pty);
352 
353 		/* Do not try to allocate more than allowed */
354 		if (ptms_inuse >= min(ptms_ptymax, user_max)) {
355 			mutex_exit(&ptms_lock);
356 			return (NULL);
357 		}
358 	}
359 	ptms_inuse++;
360 
361 	/*
362 	 * Allocate new minor number. If this fails, all slots are busy and
363 	 * we need to grow the hash.
364 	 */
365 	dminor = (minor_t)(uintptr_t)
366 	    vmem_alloc(ptms_minor_arena, 1, VM_NOSLEEP);
367 
368 	if (dminor == 0) {
369 		/* Grow the cache and retry allocation */
370 		dminor = ptms_grow();
371 	}
372 
373 	if (dminor == 0) {
374 		/* Not enough memory now */
375 		ptms_inuse--;
376 		mutex_exit(&ptms_lock);
377 		return (NULL);
378 	}
379 
380 	pt = kmem_cache_alloc(ptms_cache, KM_NOSLEEP);
381 	if (pt == NULL) {
382 		/* Not enough memory - this entry can't be used now. */
383 		vmem_free(ptms_minor_arena, (void *)(uintptr_t)dminor, 1);
384 		ptms_inuse--;
385 	} else {
386 		pt->pt_minor = dminor;
387 		pt->pt_pid = curproc->p_pid;	/* For debugging */
388 		pt->pt_state = (PTMOPEN | PTLOCK);
389 		pt->pt_zoneid = getzoneid();
390 		pt->pt_ruid = 0; /* we don't know uid/gid yet. Report as root */
391 		pt->pt_rgid = 0;
392 		ASSERT(ptms_slots[dminor - 1] == NULL);
393 		ptms_slots[dminor - 1] = pt;
394 	}
395 
396 	mutex_exit(&ptms_lock);
397 	return (pt);
398 }
399 
400 /*
401  * Get pt_ttys structure by minor number.
402  * Returns NULL when minor is out of range.
403  */
404 struct pt_ttys *
405 ptms_minor2ptty(minor_t dminor)
406 {
407 	struct pt_ttys *pt = NULL;
408 
409 	ASSERT(mutex_owned(&ptms_lock));
410 	if ((dminor >= 1) && (dminor <= ptms_nslots) && ptms_slots != NULL)
411 		pt = ptms_slots[dminor - 1];
412 
413 	return (pt);
414 }
415 
416 /*
417  * Invoked in response to chown on /dev/pts nodes to change the
418  * permission on a pty
419  */
420 void
421 ptms_set_owner(minor_t dminor, uid_t ruid, gid_t rgid)
422 {
423 	struct pt_ttys *pt;
424 
425 	if (ruid > MAXUID || rgid > MAXUID)
426 		return;
427 
428 	/*
429 	 * /dev/pts/0 is not used, but some applications may check it. There
430 	 * is no pty backing it - so we have nothing to do.
431 	 */
432 	if (dminor == 0)
433 		return;
434 
435 	mutex_enter(&ptms_lock);
436 	pt = ptms_minor2ptty(dminor);
437 	if (pt != NULL && pt->pt_zoneid == getzoneid()) {
438 		pt->pt_ruid = ruid;
439 		pt->pt_rgid = rgid;
440 	}
441 	mutex_exit(&ptms_lock);
442 }
443 
444 /*
445  * Given a ptm/pts minor number
446  * returns:
447  *	1 if the pty is allocated to the current zone.
448  *	0 otherwise
449  *
450  * If the pty is allocated to the current zone, it also returns the owner.
451  */
452 int
453 ptms_minor_valid(minor_t dminor, uid_t *ruid, gid_t *rgid)
454 {
455 	struct pt_ttys *pt;
456 	int ret;
457 
458 	ASSERT(ruid);
459 	ASSERT(rgid);
460 
461 	*ruid = (uid_t)-1;
462 	*rgid = (gid_t)-1;
463 
464 	/*
465 	 * /dev/pts/0 is not used, but some applications may check it, so create
466 	 * it also. Report the owner as root. It belongs to all zones.
467 	 */
468 	if (dminor == 0) {
469 		*ruid = 0;
470 		*rgid = 0;
471 		return (1);
472 	}
473 
474 	ret = 0;
475 	mutex_enter(&ptms_lock);
476 	pt = ptms_minor2ptty(dminor);
477 	if (pt != NULL) {
478 		ASSERT(pt->pt_ruid <= MAXUID);
479 		ASSERT(pt->pt_rgid <= MAXUID);
480 		if (pt->pt_zoneid == getzoneid()) {
481 			ret = 1;
482 			*ruid = pt->pt_ruid;
483 			*rgid = pt->pt_rgid;
484 		}
485 	}
486 	mutex_exit(&ptms_lock);
487 
488 	return (ret);
489 }
490 
491 /*
492  * Given a ptm/pts minor number
493  * returns:
494  *	0 if the pty is not allocated
495  *	1 if the pty is allocated
496  */
497 int
498 ptms_minor_exists(minor_t dminor)
499 {
500 	int ret;
501 
502 	mutex_enter(&ptms_lock);
503 	ret = ptms_minor2ptty(dminor) ? 1 : 0;
504 	mutex_exit(&ptms_lock);
505 
506 	return (ret);
507 }
508 
509 /*
510  * Close the pt and clear flags_to_clear.
511  * If pt device is not opened by someone else, free it and clear its slot.
512  */
513 void
514 ptms_close(struct pt_ttys *pt, uint_t flags_to_clear)
515 {
516 	uint_t flags;
517 
518 	ASSERT(MUTEX_NOT_HELD(&ptms_lock));
519 	ASSERT(pt != NULL);
520 
521 	mutex_enter(&ptms_lock);
522 
523 	mutex_enter(&pt->pt_lock);
524 	pt->pt_state &= ~flags_to_clear;
525 	flags = pt->pt_state;
526 	mutex_exit(&pt->pt_lock);
527 
528 	if (! (flags & (PTMOPEN | PTSOPEN))) {
529 		/* No one owns the entry - free it */
530 
531 		ASSERT(pt->ptm_rdq == NULL);
532 		ASSERT(pt->pts_rdq == NULL);
533 		ASSERT(pt->pt_nullmsg == NULL);
534 		ASSERT(pt->pt_refcnt == 0);
535 		ASSERT(pt->pt_minor <= ptms_nslots);
536 		ASSERT(ptms_slots[pt->pt_minor - 1] == pt);
537 		ASSERT(ptms_inuse > 0);
538 
539 		ptms_inuse--;
540 
541 		pt->pt_pid = 0;
542 
543 		ptms_slots[pt->pt_minor - 1] = NULL;
544 		/* Return minor number to the pool of minors */
545 		vmem_free(ptms_minor_arena, (void *)(uintptr_t)pt->pt_minor, 1);
546 		/* Return pt to the cache */
547 		kmem_cache_free(ptms_cache, pt);
548 	}
549 	mutex_exit(&ptms_lock);
550 }
551 
552 /*
553  * Allocate another slot table twice as large as the original one (limited to
554  * global maximum). Migrate all pt to the new slot table and free the original
555  * one. Create more /devices entries for new devices.
556  */
557 static minor_t
558 ptms_grow()
559 {
560 	minor_t old_size = ptms_nslots;
561 	minor_t delta = MIN(pt_maxdelta, old_size);
562 	minor_t new_size = old_size + delta;
563 	struct pt_ttys **ptms_old = ptms_slots;
564 	struct pt_ttys **ptms_new;
565 	void  *vaddr;			/* vmem_add return value */
566 
567 	ASSERT(MUTEX_HELD(&ptms_lock));
568 
569 	DDBG("ptmopen(%d): need to grow\n", (int)ptms_inuse);
570 
571 	/* Allocate new ptms array */
572 	ptms_new = kmem_zalloc(new_size * sizeof (struct pt_ttys *),
573 	    KM_NOSLEEP);
574 	if (ptms_new == NULL)
575 		return ((minor_t)0);
576 
577 	/* Increase clone index space */
578 	vaddr = vmem_add(ptms_minor_arena, (void *)(uintptr_t)(old_size + 1),
579 	    new_size - old_size, VM_NOSLEEP);
580 
581 	if (vaddr == NULL) {
582 		kmem_free(ptms_new, new_size * sizeof (struct pt_ttys *));
583 		return ((minor_t)0);
584 	}
585 
586 	/* Migrate pt entries to a new location */
587 	ptms_nslots = new_size;
588 	bcopy(ptms_old, ptms_new, old_size * sizeof (struct pt_ttys *));
589 	ptms_slots = ptms_new;
590 	kmem_free(ptms_old, old_size * sizeof (struct pt_ttys *));
591 
592 	/* Allocate minor number and return it */
593 	return ((minor_t)(uintptr_t)
594 	    vmem_alloc(ptms_minor_arena, 1, VM_NOSLEEP));
595 }
596 
597 /*ARGSUSED*/
598 static int
599 ptms_constructor(void *maddr, void *arg, int kmflags)
600 {
601 	struct pt_ttys *pt = maddr;
602 
603 	pt->pts_rdq = NULL;
604 	pt->ptm_rdq = NULL;
605 	pt->pt_nullmsg = NULL;
606 	pt->pt_pid = 0;
607 	pt->pt_minor = 0;
608 	pt->pt_refcnt = 0;
609 	pt->pt_state = 0;
610 	pt->pt_zoneid = GLOBAL_ZONEID;
611 
612 	cv_init(&pt->pt_cv, NULL, CV_DEFAULT, NULL);
613 	mutex_init(&pt->pt_lock, NULL, MUTEX_DEFAULT, NULL);
614 	return (0);
615 }
616 
617 /*ARGSUSED*/
618 static void
619 ptms_destructor(void *maddr, void *arg)
620 {
621 	struct pt_ttys *pt = maddr;
622 
623 	ASSERT(pt->pt_refcnt == 0);
624 	ASSERT(pt->pt_state == 0);
625 	ASSERT(pt->ptm_rdq == NULL);
626 	ASSERT(pt->pts_rdq == NULL);
627 
628 	mutex_destroy(&pt->pt_lock);
629 	cv_destroy(&pt->pt_cv);
630 }
631 
632 #ifdef DEBUG
633 void
634 ptms_log(char *str, uint_t arg)
635 {
636 	if (ptms_debug) {
637 		if (ptms_debug & 2)
638 			cmn_err(CE_CONT, str, arg);
639 		if (ptms_debug & 4)
640 			(void) strlog(PTMOD_ID, -1, 0, SL_TRACE | SL_ERROR,
641 			    str, arg);
642 		else
643 			(void) strlog(PTMOD_ID, -1, 0, SL_TRACE, str, arg);
644 	}
645 }
646 
647 void
648 ptms_logp(char *str, uintptr_t arg)
649 {
650 	if (ptms_debug) {
651 		if (ptms_debug & 2)
652 			cmn_err(CE_CONT, str, arg);
653 		if (ptms_debug & 4)
654 			(void) strlog(PTMOD_ID, -1, 0, SL_TRACE | SL_ERROR,
655 			    str, arg);
656 		else
657 			(void) strlog(PTMOD_ID, -1, 0, SL_TRACE, str, arg);
658 	}
659 }
660 #endif
661