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 (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
25 /* All Rights Reserved */
26
27
28
29 /*
30 * Pseudo Terminal Master Driver.
31 *
32 * The pseudo-tty subsystem simulates a terminal connection, where the master
33 * side represents the terminal and the slave represents the user process's
34 * special device end point. The master device is set up as a cloned device
35 * where its major device number is the major for the clone device and its minor
36 * device number is the major for the ptm driver. There are no nodes in the file
37 * system for master devices. The master pseudo driver is opened using the
38 * open(2) system call with /dev/ptmx as the device parameter. The clone open
39 * finds the next available minor device for the ptm major device.
40 *
41 * A master device is available only if it and its corresponding slave device
42 * are not already open. When the master device is opened, the corresponding
43 * slave device is automatically locked out. Only one open is allowed on a
44 * master device. Multiple opens are allowed on the slave device. After both
45 * the master and slave have been opened, the user has two file descriptors
46 * which are the end points of a full duplex connection composed of two streams
47 * which are automatically connected at the master and slave drivers. The user
48 * may then push modules onto either side of the stream pair.
504 switch (iocp->ioc_cmd) {
505 default:
506 if ((ptmp->pt_state & PTLOCK) ||
507 (ptmp->pts_rdq == NULL)) {
508 DBG(("got M_IOCTL but no slave\n"));
509 miocnak(qp, mp, 0, EINVAL);
510 PT_EXIT_READ(ptmp);
511 return (0);
512 }
513 (void) putq(qp, mp);
514 break;
515 case UNLKPT:
516 mutex_enter(&ptmp->pt_lock);
517 ptmp->pt_state &= ~PTLOCK;
518 mutex_exit(&ptmp->pt_lock);
519 /*FALLTHROUGH*/
520 case ISPTM:
521 DBG(("ack the UNLKPT/ISPTM\n"));
522 miocack(qp, mp, 0, 0);
523 break;
524 case ZONEPT:
525 {
526 zoneid_t z;
527 int error;
528
529 if ((error = drv_priv(iocp->ioc_cr)) != 0) {
530 miocnak(qp, mp, 0, error);
531 break;
532 }
533 if ((error = miocpullup(mp, sizeof (zoneid_t))) != 0) {
534 miocnak(qp, mp, 0, error);
535 break;
536 }
537 z = *((zoneid_t *)mp->b_cont->b_rptr);
538 if (z < MIN_ZONEID || z > MAX_ZONEID) {
539 miocnak(qp, mp, 0, EINVAL);
540 break;
541 }
542
543 mutex_enter(&ptmp->pt_lock);
|
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 (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
25 /* All Rights Reserved */
26
27 /*
28 * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
29 */
30
31 /*
32 * Pseudo Terminal Master Driver.
33 *
34 * The pseudo-tty subsystem simulates a terminal connection, where the master
35 * side represents the terminal and the slave represents the user process's
36 * special device end point. The master device is set up as a cloned device
37 * where its major device number is the major for the clone device and its minor
38 * device number is the major for the ptm driver. There are no nodes in the file
39 * system for master devices. The master pseudo driver is opened using the
40 * open(2) system call with /dev/ptmx as the device parameter. The clone open
41 * finds the next available minor device for the ptm major device.
42 *
43 * A master device is available only if it and its corresponding slave device
44 * are not already open. When the master device is opened, the corresponding
45 * slave device is automatically locked out. Only one open is allowed on a
46 * master device. Multiple opens are allowed on the slave device. After both
47 * the master and slave have been opened, the user has two file descriptors
48 * which are the end points of a full duplex connection composed of two streams
49 * which are automatically connected at the master and slave drivers. The user
50 * may then push modules onto either side of the stream pair.
506 switch (iocp->ioc_cmd) {
507 default:
508 if ((ptmp->pt_state & PTLOCK) ||
509 (ptmp->pts_rdq == NULL)) {
510 DBG(("got M_IOCTL but no slave\n"));
511 miocnak(qp, mp, 0, EINVAL);
512 PT_EXIT_READ(ptmp);
513 return (0);
514 }
515 (void) putq(qp, mp);
516 break;
517 case UNLKPT:
518 mutex_enter(&ptmp->pt_lock);
519 ptmp->pt_state &= ~PTLOCK;
520 mutex_exit(&ptmp->pt_lock);
521 /*FALLTHROUGH*/
522 case ISPTM:
523 DBG(("ack the UNLKPT/ISPTM\n"));
524 miocack(qp, mp, 0, 0);
525 break;
526 case PTSSTTY:
527 mutex_enter(&ptmp->pt_lock);
528 ptmp->pt_state |= PTSTTY;
529 mutex_exit(&ptmp->pt_lock);
530 DBG(("ack PTSSTTY\n"));
531 miocack(qp, mp, 0, 0);
532 break;
533 case ZONEPT:
534 {
535 zoneid_t z;
536 int error;
537
538 if ((error = drv_priv(iocp->ioc_cr)) != 0) {
539 miocnak(qp, mp, 0, error);
540 break;
541 }
542 if ((error = miocpullup(mp, sizeof (zoneid_t))) != 0) {
543 miocnak(qp, mp, 0, error);
544 break;
545 }
546 z = *((zoneid_t *)mp->b_cont->b_rptr);
547 if (z < MIN_ZONEID || z > MAX_ZONEID) {
548 miocnak(qp, mp, 0, EINVAL);
549 break;
550 }
551
552 mutex_enter(&ptmp->pt_lock);
|