430 ptmp->pt_nullmsg = NULL;
431 /*
432 * qenable slave side write queue so that it can flush
433 * its messages as master's read queue is going away
434 */
435 if (ptmp->pts_rdq)
436 qenable(WR(ptmp->pts_rdq));
437 PT_EXIT_WRITE(ptmp);
438
439 qprocsoff(rqp);
440
441 /* Finish the close */
442 rqp->q_ptr = NULL;
443 WR(rqp)->q_ptr = NULL;
444
445 ptms_close(ptmp, PTMOPEN | PTLOCK);
446
447 return (0);
448 }
449
450 /*
451 * The wput procedure will only handle ioctl and flush messages.
452 */
453 static void
454 ptmwput(queue_t *qp, mblk_t *mp)
455 {
456 struct pt_ttys *ptmp;
457 struct iocblk *iocp;
458
459 DBG(("entering ptmwput\n"));
460 ASSERT(qp->q_ptr);
461
462 ptmp = (struct pt_ttys *)qp->q_ptr;
463 PT_ENTER_READ(ptmp);
464
465 switch (mp->b_datap->db_type) {
466 /*
467 * if write queue request, flush master's write
468 * queue and send FLUSHR up slave side. If read
469 * queue request, convert to FLUSHW and putnext().
555 if ((error = miocpullup(mp, sizeof (pt_own_t))) != 0) {
556 miocnak(qp, mp, 0, error);
557 break;
558 }
559
560 zone = zone_find_by_id(ptmp->pt_zoneid);
561 ptop = (pt_own_t *)mp->b_cont->b_rptr;
562
563 if (!VALID_UID(ptop->pto_ruid, zone) ||
564 !VALID_GID(ptop->pto_rgid, zone)) {
565 zone_rele(zone);
566 miocnak(qp, mp, 0, EINVAL);
567 break;
568 }
569 zone_rele(zone);
570 mutex_enter(&ptmp->pt_lock);
571 ptmp->pt_ruid = ptop->pto_ruid;
572 ptmp->pt_rgid = ptop->pto_rgid;
573 mutex_exit(&ptmp->pt_lock);
574 miocack(qp, mp, 0, 0);
575 break;
576 }
577 }
578 break;
579
580 case M_READ:
581 /* Caused by ldterm - can not pass to slave */
582 freemsg(mp);
583 break;
584
585 /*
586 * send other messages to slave
587 */
588 default:
589 if ((ptmp->pt_state & PTLOCK) || (ptmp->pts_rdq == NULL)) {
590 DBG(("got msg. but no slave\n"));
591 mp = mexchange(NULL, mp, 2, M_ERROR, -1);
592 if (mp != NULL) {
593 mp->b_rptr[0] = NOERROR;
594 mp->b_rptr[1] = EINVAL;
|
430 ptmp->pt_nullmsg = NULL;
431 /*
432 * qenable slave side write queue so that it can flush
433 * its messages as master's read queue is going away
434 */
435 if (ptmp->pts_rdq)
436 qenable(WR(ptmp->pts_rdq));
437 PT_EXIT_WRITE(ptmp);
438
439 qprocsoff(rqp);
440
441 /* Finish the close */
442 rqp->q_ptr = NULL;
443 WR(rqp)->q_ptr = NULL;
444
445 ptms_close(ptmp, PTMOPEN | PTLOCK);
446
447 return (0);
448 }
449
450 static boolean_t
451 ptmptsopencb(ptmptsopencb_arg_t arg)
452 {
453 struct pt_ttys *ptmp = (struct pt_ttys *)arg;
454 boolean_t rval;
455
456 PT_ENTER_READ(ptmp);
457 rval = (ptmp->pt_nullmsg != NULL);
458 PT_EXIT_READ(ptmp);
459 return (rval);
460 }
461
462 /*
463 * The wput procedure will only handle ioctl and flush messages.
464 */
465 static void
466 ptmwput(queue_t *qp, mblk_t *mp)
467 {
468 struct pt_ttys *ptmp;
469 struct iocblk *iocp;
470
471 DBG(("entering ptmwput\n"));
472 ASSERT(qp->q_ptr);
473
474 ptmp = (struct pt_ttys *)qp->q_ptr;
475 PT_ENTER_READ(ptmp);
476
477 switch (mp->b_datap->db_type) {
478 /*
479 * if write queue request, flush master's write
480 * queue and send FLUSHR up slave side. If read
481 * queue request, convert to FLUSHW and putnext().
567 if ((error = miocpullup(mp, sizeof (pt_own_t))) != 0) {
568 miocnak(qp, mp, 0, error);
569 break;
570 }
571
572 zone = zone_find_by_id(ptmp->pt_zoneid);
573 ptop = (pt_own_t *)mp->b_cont->b_rptr;
574
575 if (!VALID_UID(ptop->pto_ruid, zone) ||
576 !VALID_GID(ptop->pto_rgid, zone)) {
577 zone_rele(zone);
578 miocnak(qp, mp, 0, EINVAL);
579 break;
580 }
581 zone_rele(zone);
582 mutex_enter(&ptmp->pt_lock);
583 ptmp->pt_ruid = ptop->pto_ruid;
584 ptmp->pt_rgid = ptop->pto_rgid;
585 mutex_exit(&ptmp->pt_lock);
586 miocack(qp, mp, 0, 0);
587 break;
588 }
589 case PTMPTSOPENCB:
590 {
591 mblk_t *dp; /* ioctl reply data */
592 ptmptsopencb_t *ppocb;
593
594 /* only allow the kernel to invoke this ioctl */
595 if (iocp->ioc_cr != kcred) {
596 miocnak(qp, mp, 0, EINVAL);
597 break;
598 }
599
600 /* we don't support transparent ioctls */
601 ASSERT(iocp->ioc_count != TRANSPARENT);
602 if (iocp->ioc_count == TRANSPARENT) {
603 miocnak(qp, mp, 0, EINVAL);
604 break;
605 }
606
607 /* allocate a response message */
608 dp = allocb(sizeof (ptmptsopencb_t), BPRI_MED);
609 if (dp == NULL) {
610 miocnak(qp, mp, 0, EAGAIN);
611 break;
612 }
613
614 /* initialize the ioctl results */
615 ppocb = (ptmptsopencb_t *)dp->b_rptr;
616 ppocb->ppocb_func = ptmptsopencb;
617 ppocb->ppocb_arg = (ptmptsopencb_arg_t)ptmp;
618
619 /* send the reply data */
620 mioc2ack(mp, dp, sizeof (ptmptsopencb_t), 0);
621 qreply(qp, mp);
622 break;
623 }
624 }
625 break;
626
627 case M_READ:
628 /* Caused by ldterm - can not pass to slave */
629 freemsg(mp);
630 break;
631
632 /*
633 * send other messages to slave
634 */
635 default:
636 if ((ptmp->pt_state & PTLOCK) || (ptmp->pts_rdq == NULL)) {
637 DBG(("got msg. but no slave\n"));
638 mp = mexchange(NULL, mp, 2, M_ERROR, -1);
639 if (mp != NULL) {
640 mp->b_rptr[0] = NOERROR;
641 mp->b_rptr[1] = EINVAL;
|