Lines Matching defs:pt

32  * Pseudo terminals (or pt's for short) are allocated dynamically.
33 * pt's are put in the global ptms_slots array indexed by minor numbers.
35 * The slots array is initially small (of the size NPTY_MIN). When more pt's are
37 * opened pt's move to the new one.
131 * void ptms_close(struct pt_ttys *pt, uint_t flags_to_clear);
133 * Clear flags_to_clear in pt and if no one owns it (PTMOPEN/PTSOPEN not
134 * set) free pt entry and corresponding slot.
210 static struct pt_ttys **ptms_slots = NULL; /* Slots for actual pt structures */
334 struct pt_ttys *pt = NULL;
382 pt = kmem_cache_alloc(ptms_cache, KM_NOSLEEP);
383 if (pt == NULL) {
388 pt->pt_minor = dminor;
389 pt->pt_pid = curproc->p_pid; /* For debugging */
390 pt->pt_state = (PTMOPEN | PTLOCK);
391 pt->pt_zoneid = getzoneid();
392 pt->pt_ruid = 0; /* we don't know uid/gid yet. Report as root */
393 pt->pt_rgid = 0;
395 ptms_slots[dminor - 1] = pt;
399 return (pt);
409 struct pt_ttys *pt = NULL;
413 pt = ptms_slots[dminor - 1];
415 return (pt);
425 struct pt_ttys *pt;
441 pt = ptms_minor2ptty(dminor);
442 if (pt != NULL && pt->pt_zoneid == getzoneid()) {
443 pt->pt_ruid = ruid;
444 pt->pt_rgid = rgid;
460 struct pt_ttys *pt;
481 pt = ptms_minor2ptty(dminor);
482 if (pt != NULL) {
483 ASSERT(pt->pt_ruid >= 0);
484 ASSERT(pt->pt_rgid >= 0);
485 if (pt->pt_zoneid == getzoneid()) {
487 *ruid = pt->pt_ruid;
488 *rgid = pt->pt_rgid;
515 * Close the pt and clear flags_to_clear.
516 * If pt device is not opened by someone else, free it and clear its slot.
519 ptms_close(struct pt_ttys *pt, uint_t flags_to_clear)
524 ASSERT(pt != NULL);
528 mutex_enter(&pt->pt_lock);
529 pt->pt_state &= ~flags_to_clear;
530 flags = pt->pt_state;
531 mutex_exit(&pt->pt_lock);
536 ASSERT(pt->ptm_rdq == NULL);
537 ASSERT(pt->pts_rdq == NULL);
538 ASSERT(pt->pt_nullmsg == NULL);
539 ASSERT(pt->pt_refcnt == 0);
540 ASSERT(pt->pt_minor <= ptms_nslots);
541 ASSERT(ptms_slots[pt->pt_minor - 1] == pt);
546 pt->pt_pid = 0;
548 ptms_slots[pt->pt_minor - 1] = NULL;
550 vmem_free(ptms_minor_arena, (void *)(uintptr_t)pt->pt_minor, 1);
551 /* Return pt to the cache */
552 kmem_cache_free(ptms_cache, pt);
559 * global maximum). Migrate all pt to the new slot table and free the original
591 /* Migrate pt entries to a new location */
606 struct pt_ttys *pt = maddr;
608 pt->pts_rdq = NULL;
609 pt->ptm_rdq = NULL;
610 pt->pt_nullmsg = NULL;
611 pt->pt_pid = NULL;
612 pt->pt_minor = NULL;
613 pt->pt_refcnt = 0;
614 pt->pt_state = 0;
615 pt->pt_zoneid = GLOBAL_ZONEID;
617 cv_init(&pt->pt_cv, NULL, CV_DEFAULT, NULL);
618 mutex_init(&pt->pt_lock, NULL, MUTEX_DEFAULT, NULL);
626 struct pt_ttys *pt = maddr;
628 ASSERT(pt->pt_refcnt == 0);
629 ASSERT(pt->pt_state == 0);
630 ASSERT(pt->ptm_rdq == NULL);
631 ASSERT(pt->pts_rdq == NULL);
633 mutex_destroy(&pt->pt_lock);
634 cv_destroy(&pt->pt_cv);