Print this page
Bring back LX zones.
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/ptms.h
+++ new/usr/src/uts/common/sys/ptms.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
↓ open down ↓ |
20 lines elided |
↑ open up ↑ |
21 21 /*
22 22 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 */
24 24 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
25 25 /* All Rights Reserved */
26 26
27 27
28 28 #ifndef _SYS_PTMS_H
29 29 #define _SYS_PTMS_H
30 30
31 +#pragma ident "%Z%%M% %I% %E% SMI"
32 +
31 33 #ifdef __cplusplus
32 34 extern "C" {
33 35 #endif
34 36
35 37 #ifdef _KERNEL
36 38
37 39 /*
38 40 * Structures and definitions supporting the pseudo terminal
39 41 * drivers. This structure is private and should not be used by any
40 42 * applications.
41 43 */
42 44 struct pt_ttys {
43 45 queue_t *ptm_rdq; /* master's read queue pointer */
44 46 queue_t *pts_rdq; /* slave's read queue pointer */
45 47 mblk_t *pt_nullmsg; /* 0-bytes message block for pts close */
46 48 pid_t pt_pid; /* process id (for debugging) */
47 49 minor_t pt_minor; /* Minor number of this pty */
48 50 int pt_refcnt; /* reference count for ptm_rdq/pts_rdq uses */
49 51 ushort_t pt_state; /* state of master/slave pair */
50 52 kcondvar_t pt_cv; /* condition variable for exclusive access */
51 53 kmutex_t pt_lock; /* Per-element lock */
52 54 zoneid_t pt_zoneid; /* Zone membership for this pty */
53 55 uid_t pt_ruid; /* Real owner of pty */
54 56 gid_t pt_rgid; /* Real group owner of pty */
55 57 };
56 58
57 59 /*
58 60 * pt_state values
59 61 */
60 62 #define PTLOCK 0x01 /* master/slave pair is locked */
61 63 #define PTMOPEN 0x02 /* master side is open */
62 64 #define PTSOPEN 0x04 /* slave side is open */
63 65 #define PTSTTY 0x08 /* slave side is tty */
64 66
65 67 /*
66 68 * Multi-threading primitives.
67 69 * Values of pt_refcnt: -1 if a writer is accessing the struct
68 70 * 0 if no one is reading or writing
69 71 * > 0 equals to the number of readers accessing the struct
70 72 */
71 73 #define PT_ENTER_READ(p) { \
72 74 mutex_enter(&(p)->pt_lock); \
73 75 while ((p)->pt_refcnt < 0) \
74 76 cv_wait(&((p)->pt_cv), &(p)->pt_lock); \
75 77 (p)->pt_refcnt++; \
76 78 mutex_exit(&(p)->pt_lock); \
77 79 }
78 80
79 81 #define PT_ENTER_WRITE(p) { \
80 82 mutex_enter(&(p)->pt_lock); \
81 83 while ((p)->pt_refcnt != 0) \
82 84 cv_wait(&((p)->pt_cv), &(p)->pt_lock); \
83 85 (p)->pt_refcnt = -1; \
84 86 mutex_exit(&(p)->pt_lock); \
85 87 }
86 88
87 89 #define PT_EXIT_READ(p) { \
88 90 mutex_enter(&(p)->pt_lock); \
89 91 ASSERT((p)->pt_refcnt > 0); \
90 92 if ((--((p)->pt_refcnt)) == 0) \
91 93 cv_broadcast(&(p)->pt_cv); \
92 94 mutex_exit(&(p)->pt_lock); \
93 95 }
94 96
95 97 #define PT_EXIT_WRITE(p) { \
96 98 mutex_enter(&(p)->pt_lock); \
97 99 ASSERT((p)->pt_refcnt == -1); \
98 100 (p)->pt_refcnt = 0; \
99 101 cv_broadcast(&(p)->pt_cv); \
100 102 mutex_exit(&(p)->pt_lock); \
101 103 }
102 104
103 105 /*
104 106 * ptms_lock and pt_cnt are defined in ptms_conf.c
105 107 */
106 108 extern kmutex_t ptms_lock;
107 109 extern dev_info_t *pts_dip; /* private copy of devinfo ptr */
108 110
109 111 extern void ptms_init(void);
110 112 extern struct pt_ttys *pt_ttys_alloc(void);
111 113 extern void ptms_close(struct pt_ttys *, uint_t);
112 114 extern struct pt_ttys *ptms_minor2ptty(minor_t);
113 115 extern int ptms_attach_slave(void);
114 116 extern int ptms_minor_valid(minor_t ptmin, uid_t *uid, gid_t *gid);
115 117 extern int ptms_minor_exists(minor_t ptmin);
116 118 extern void ptms_set_owner(minor_t ptmin, uid_t uid, gid_t gid);
117 119 extern major_t ptms_slave_attached(void);
118 120
↓ open down ↓ |
78 lines elided |
↑ open up ↑ |
119 121 #ifdef DEBUG
120 122 extern void ptms_log(char *, uint_t);
121 123 extern void ptms_logp(char *, uintptr_t);
122 124 #define DDBG(a, b) ptms_log(a, b)
123 125 #define DDBGP(a, b) ptms_logp(a, b)
124 126 #else
125 127 #define DDBG(a, b)
126 128 #define DDBGP(a, b)
127 129 #endif
128 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 +
129 137 #endif /* _KERNEL */
130 138
131 139 typedef struct pt_own {
132 140 uid_t pto_ruid;
133 141 gid_t pto_rgid;
134 142 } pt_own_t;
135 143
136 144 /*
137 145 * ioctl commands
138 146 *
139 147 * ISPTM: Determines whether the file descriptor is that of an open master
140 148 * device. Return code of zero indicates that the file descriptor
141 149 * represents master device.
142 150 *
143 151 * UNLKPT: Unlocks the master and slave devices. It returns 0 on success. On
144 152 * failure, the errno is set to EINVAL indicating that the master
145 153 * device is not open.
146 154 *
147 155 * ZONEPT: Sets the zoneid of the pair of master and slave devices. It
148 156 * returns 0 upon success. Used to force a pty 'into' a zone upon
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
149 157 * zone entry.
150 158 *
151 159 * PT_OWNER: Sets uid and gid for slave device. It returns 0 on success.
152 160 *
153 161 */
154 162 #define ISPTM (('P'<<8)|1) /* query for master */
155 163 #define UNLKPT (('P'<<8)|2) /* unlock master/slave pair */
156 164 #define PTSSTTY (('P'<<8)|3) /* set tty flag */
157 165 #define ZONEPT (('P'<<8)|4) /* set zone of master/slave pair */
158 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 */
159 180
160 181 #ifdef __cplusplus
161 182 }
162 183 #endif
163 184
164 185 #endif /* _SYS_PTMS_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX