Print this page
104 Bring back lx brand
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 */
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 31 #ifdef __cplusplus
32 32 extern "C" {
33 33 #endif
34 34
35 35 #ifdef _KERNEL
36 36
37 37 /*
38 38 * Structures and definitions supporting the pseudo terminal
39 39 * drivers. This structure is private and should not be used by any
40 40 * applications.
41 41 */
42 42 struct pt_ttys {
43 43 queue_t *ptm_rdq; /* master's read queue pointer */
44 44 queue_t *pts_rdq; /* slave's read queue pointer */
45 45 mblk_t *pt_nullmsg; /* 0-bytes message block for pts close */
46 46 pid_t pt_pid; /* process id (for debugging) */
47 47 minor_t pt_minor; /* Minor number of this pty */
48 48 int pt_refcnt; /* reference count for ptm_rdq/pts_rdq uses */
49 49 ushort_t pt_state; /* state of master/slave pair */
50 50 kcondvar_t pt_cv; /* condition variable for exclusive access */
51 51 kmutex_t pt_lock; /* Per-element lock */
52 52 zoneid_t pt_zoneid; /* Zone membership for this pty */
53 53 uid_t pt_ruid; /* Real owner of pty */
54 54 gid_t pt_rgid; /* Real group owner of pty */
55 55 };
56 56
57 57 /*
58 58 * pt_state values
59 59 */
60 60 #define PTLOCK 0x01 /* master/slave pair is locked */
61 61 #define PTMOPEN 0x02 /* master side is open */
62 62 #define PTSOPEN 0x04 /* slave side is open */
63 63 #define PTSTTY 0x08 /* slave side is tty */
64 64
65 65 /*
66 66 * Multi-threading primitives.
67 67 * Values of pt_refcnt: -1 if a writer is accessing the struct
68 68 * 0 if no one is reading or writing
69 69 * > 0 equals to the number of readers accessing the struct
70 70 */
71 71 #define PT_ENTER_READ(p) { \
72 72 mutex_enter(&(p)->pt_lock); \
73 73 while ((p)->pt_refcnt < 0) \
74 74 cv_wait(&((p)->pt_cv), &(p)->pt_lock); \
75 75 (p)->pt_refcnt++; \
76 76 mutex_exit(&(p)->pt_lock); \
77 77 }
78 78
79 79 #define PT_ENTER_WRITE(p) { \
80 80 mutex_enter(&(p)->pt_lock); \
81 81 while ((p)->pt_refcnt != 0) \
82 82 cv_wait(&((p)->pt_cv), &(p)->pt_lock); \
83 83 (p)->pt_refcnt = -1; \
84 84 mutex_exit(&(p)->pt_lock); \
85 85 }
86 86
87 87 #define PT_EXIT_READ(p) { \
88 88 mutex_enter(&(p)->pt_lock); \
89 89 ASSERT((p)->pt_refcnt > 0); \
90 90 if ((--((p)->pt_refcnt)) == 0) \
91 91 cv_broadcast(&(p)->pt_cv); \
92 92 mutex_exit(&(p)->pt_lock); \
93 93 }
94 94
95 95 #define PT_EXIT_WRITE(p) { \
96 96 mutex_enter(&(p)->pt_lock); \
97 97 ASSERT((p)->pt_refcnt == -1); \
98 98 (p)->pt_refcnt = 0; \
99 99 cv_broadcast(&(p)->pt_cv); \
100 100 mutex_exit(&(p)->pt_lock); \
101 101 }
102 102
103 103 /*
104 104 * ptms_lock and pt_cnt are defined in ptms_conf.c
105 105 */
106 106 extern kmutex_t ptms_lock;
107 107 extern dev_info_t *pts_dip; /* private copy of devinfo ptr */
108 108
109 109 extern void ptms_init(void);
110 110 extern struct pt_ttys *pt_ttys_alloc(void);
111 111 extern void ptms_close(struct pt_ttys *, uint_t);
112 112 extern struct pt_ttys *ptms_minor2ptty(minor_t);
113 113 extern int ptms_attach_slave(void);
114 114 extern int ptms_minor_valid(minor_t ptmin, uid_t *uid, gid_t *gid);
115 115 extern int ptms_minor_exists(minor_t ptmin);
116 116 extern void ptms_set_owner(minor_t ptmin, uid_t uid, gid_t gid);
117 117 extern major_t ptms_slave_attached(void);
118 118
↓ open down ↓ |
118 lines elided |
↑ open up ↑ |
119 119 #ifdef DEBUG
120 120 extern void ptms_log(char *, uint_t);
121 121 extern void ptms_logp(char *, uintptr_t);
122 122 #define DDBG(a, b) ptms_log(a, b)
123 123 #define DDBGP(a, b) ptms_logp(a, b)
124 124 #else
125 125 #define DDBG(a, b)
126 126 #define DDBGP(a, b)
127 127 #endif
128 128
129 +typedef struct __ptmptsopencb_arg *ptmptsopencb_arg_t;
130 +typedef struct ptmptsopencb {
131 + boolean_t (*ppocb_func)(ptmptsopencb_arg_t);
132 + ptmptsopencb_arg_t ppocb_arg;
133 +} ptmptsopencb_t;
134 +
129 135 #endif /* _KERNEL */
130 136
131 137 typedef struct pt_own {
132 138 uid_t pto_ruid;
133 139 gid_t pto_rgid;
134 140 } pt_own_t;
135 141
136 142 /*
137 143 * ioctl commands
138 144 *
139 145 * ISPTM: Determines whether the file descriptor is that of an open master
140 146 * device. Return code of zero indicates that the file descriptor
141 147 * represents master device.
142 148 *
143 149 * UNLKPT: Unlocks the master and slave devices. It returns 0 on success. On
144 150 * failure, the errno is set to EINVAL indicating that the master
145 151 * device is not open.
146 152 *
147 153 * ZONEPT: Sets the zoneid of the pair of master and slave devices. It
148 154 * returns 0 upon success. Used to force a pty 'into' a zone upon
149 155 * zone entry.
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
150 156 *
151 157 * PT_OWNER: Sets uid and gid for slave device. It returns 0 on success.
152 158 *
153 159 */
154 160 #define ISPTM (('P'<<8)|1) /* query for master */
155 161 #define UNLKPT (('P'<<8)|2) /* unlock master/slave pair */
156 162 #define PTSSTTY (('P'<<8)|3) /* set tty flag */
157 163 #define ZONEPT (('P'<<8)|4) /* set zone of master/slave pair */
158 164 #define OWNERPT (('P'<<8)|5) /* set owner/group for slave device */
159 165
166 +#ifdef _KERNEL
167 +/*
168 + * kernel ioctl commands
169 + *
170 + * PTMPTSOPENCB: Returns a callback function pointer and opaque argument.
171 + * The return value of the callback function when it's invoked
172 + * with the opaque argument passed to it will indicate if the
173 + * pts slave device is currently open.
174 + */
175 +#define PTMPTSOPENCB (('P'<<8)|6) /* check if the slave is open */
176 +
177 +#endif /* _KERNEL */
178 +
160 179 #ifdef __cplusplus
161 180 }
162 181 #endif
163 182
164 183 #endif /* _SYS_PTMS_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX