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 #ifndef _SYS_PTMS_H
29 #define _SYS_PTMS_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #ifdef _KERNEL
36
37 /*
38 * Structures and definitions supporting the pseudo terminal
39 * drivers. This structure is private and should not be used by any
40 * applications.
41 */
42 struct pt_ttys {
43 queue_t *ptm_rdq; /* master's read queue pointer */
44 queue_t *pts_rdq; /* slave's read queue pointer */
45 mblk_t *pt_nullmsg; /* 0-bytes message block for pts close */
46 pid_t pt_pid; /* process id (for debugging) */
47 minor_t pt_minor; /* Minor number of this pty */
48 int pt_refcnt; /* reference count for ptm_rdq/pts_rdq uses */
49 ushort_t pt_state; /* state of master/slave pair */
50 kcondvar_t pt_cv; /* condition variable for exclusive access */
109 extern void ptms_init(void);
110 extern struct pt_ttys *pt_ttys_alloc(void);
111 extern void ptms_close(struct pt_ttys *, uint_t);
112 extern struct pt_ttys *ptms_minor2ptty(minor_t);
113 extern int ptms_attach_slave(void);
114 extern int ptms_minor_valid(minor_t ptmin, uid_t *uid, gid_t *gid);
115 extern int ptms_minor_exists(minor_t ptmin);
116 extern void ptms_set_owner(minor_t ptmin, uid_t uid, gid_t gid);
117 extern major_t ptms_slave_attached(void);
118
119 #ifdef DEBUG
120 extern void ptms_log(char *, uint_t);
121 extern void ptms_logp(char *, uintptr_t);
122 #define DDBG(a, b) ptms_log(a, b)
123 #define DDBGP(a, b) ptms_logp(a, b)
124 #else
125 #define DDBG(a, b)
126 #define DDBGP(a, b)
127 #endif
128
129 #endif /* _KERNEL */
130
131 typedef struct pt_own {
132 uid_t pto_ruid;
133 gid_t pto_rgid;
134 } pt_own_t;
135
136 /*
137 * ioctl commands
138 *
139 * ISPTM: Determines whether the file descriptor is that of an open master
140 * device. Return code of zero indicates that the file descriptor
141 * represents master device.
142 *
143 * UNLKPT: Unlocks the master and slave devices. It returns 0 on success. On
144 * failure, the errno is set to EINVAL indicating that the master
145 * device is not open.
146 *
147 * ZONEPT: Sets the zoneid of the pair of master and slave devices. It
148 * returns 0 upon success. Used to force a pty 'into' a zone upon
149 * zone entry.
150 *
151 * PT_OWNER: Sets uid and gid for slave device. It returns 0 on success.
152 *
153 */
154 #define ISPTM (('P'<<8)|1) /* query for master */
155 #define UNLKPT (('P'<<8)|2) /* unlock master/slave pair */
156 #define PTSSTTY (('P'<<8)|3) /* set tty flag */
157 #define ZONEPT (('P'<<8)|4) /* set zone of master/slave pair */
158 #define OWNERPT (('P'<<8)|5) /* set owner/group for slave device */
159
160 #ifdef __cplusplus
161 }
162 #endif
163
164 #endif /* _SYS_PTMS_H */
|
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 #ifndef _SYS_PTMS_H
29 #define _SYS_PTMS_H
30
31 #pragma ident "%Z%%M% %I% %E% SMI"
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #ifdef _KERNEL
38
39 /*
40 * Structures and definitions supporting the pseudo terminal
41 * drivers. This structure is private and should not be used by any
42 * applications.
43 */
44 struct pt_ttys {
45 queue_t *ptm_rdq; /* master's read queue pointer */
46 queue_t *pts_rdq; /* slave's read queue pointer */
47 mblk_t *pt_nullmsg; /* 0-bytes message block for pts close */
48 pid_t pt_pid; /* process id (for debugging) */
49 minor_t pt_minor; /* Minor number of this pty */
50 int pt_refcnt; /* reference count for ptm_rdq/pts_rdq uses */
51 ushort_t pt_state; /* state of master/slave pair */
52 kcondvar_t pt_cv; /* condition variable for exclusive access */
111 extern void ptms_init(void);
112 extern struct pt_ttys *pt_ttys_alloc(void);
113 extern void ptms_close(struct pt_ttys *, uint_t);
114 extern struct pt_ttys *ptms_minor2ptty(minor_t);
115 extern int ptms_attach_slave(void);
116 extern int ptms_minor_valid(minor_t ptmin, uid_t *uid, gid_t *gid);
117 extern int ptms_minor_exists(minor_t ptmin);
118 extern void ptms_set_owner(minor_t ptmin, uid_t uid, gid_t gid);
119 extern major_t ptms_slave_attached(void);
120
121 #ifdef DEBUG
122 extern void ptms_log(char *, uint_t);
123 extern void ptms_logp(char *, uintptr_t);
124 #define DDBG(a, b) ptms_log(a, b)
125 #define DDBGP(a, b) ptms_logp(a, b)
126 #else
127 #define DDBG(a, b)
128 #define DDBGP(a, b)
129 #endif
130
131 typedef struct __ptmptsopencb_arg *ptmptsopencb_arg_t;
132 typedef struct ptmptsopencb {
133 boolean_t (*ppocb_func)(ptmptsopencb_arg_t);
134 ptmptsopencb_arg_t ppocb_arg;
135 } ptmptsopencb_t;
136
137 #endif /* _KERNEL */
138
139 typedef struct pt_own {
140 uid_t pto_ruid;
141 gid_t pto_rgid;
142 } pt_own_t;
143
144 /*
145 * ioctl commands
146 *
147 * ISPTM: Determines whether the file descriptor is that of an open master
148 * device. Return code of zero indicates that the file descriptor
149 * represents master device.
150 *
151 * UNLKPT: Unlocks the master and slave devices. It returns 0 on success. On
152 * failure, the errno is set to EINVAL indicating that the master
153 * device is not open.
154 *
155 * ZONEPT: Sets the zoneid of the pair of master and slave devices. It
156 * returns 0 upon success. Used to force a pty 'into' a zone upon
157 * zone entry.
158 *
159 * PT_OWNER: Sets uid and gid for slave device. It returns 0 on success.
160 *
161 */
162 #define ISPTM (('P'<<8)|1) /* query for master */
163 #define UNLKPT (('P'<<8)|2) /* unlock master/slave pair */
164 #define PTSSTTY (('P'<<8)|3) /* set tty flag */
165 #define ZONEPT (('P'<<8)|4) /* set zone of master/slave pair */
166 #define OWNERPT (('P'<<8)|5) /* set owner/group for slave device */
167
168 #ifdef _KERNEL
169 /*
170 * kernel ioctl commands
171 *
172 * PTMPTSOPENCB: Returns a callback function pointer and opaque argument.
173 * The return value of the callback function when it's invoked
174 * with the opaque argument passed to it will indicate if the
175 * pts slave device is currently open.
176 */
177 #define PTMPTSOPENCB (('P'<<8)|6) /* check if the slave is open */
178
179 #endif /* _KERNEL */
180
181 #ifdef __cplusplus
182 }
183 #endif
184
185 #endif /* _SYS_PTMS_H */
|