Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/fs/doorfs/door_vnops.c
+++ new/usr/src/uts/common/fs/doorfs/door_vnops.c
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
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
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 2007 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 -#pragma ident "%Z%%M% %I% %E% SMI"
27 -
28 26 #include <sys/types.h>
29 27 #include <sys/vnode.h>
30 28 #include <sys/vfs_opreg.h>
31 29 #include <sys/door.h>
32 30 #include <sys/proc.h>
33 31 #include <sys/kmem.h>
34 32 #include <sys/debug.h>
35 33 #include <sys/cmn_err.h>
36 34 #include <fs/fs_subr.h>
37 35 #include <sys/zone.h>
38 36 #include <sys/tsol/label.h>
39 37
40 38 kmutex_t door_knob;
41 39 static int door_open(struct vnode **vpp, int flag, struct cred *cr,
42 40 caller_context_t *ct);
43 41 static int door_close(struct vnode *vp, int flag, int count,
44 42 offset_t offset, struct cred *cr, caller_context_t *ct);
45 43 static int door_getattr(struct vnode *vp, struct vattr *vap,
46 44 int flags, struct cred *cr, caller_context_t *ct);
47 45 static void door_inactive(struct vnode *vp, struct cred *cr,
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
48 46 caller_context_t *ct);
49 47 static int door_access(struct vnode *vp, int mode, int flags,
50 48 struct cred *cr, caller_context_t *ct);
51 49 static int door_realvp(vnode_t *vp, vnode_t **vpp, caller_context_t *ct);
52 50
53 51 struct vfs door_vfs;
54 52
55 53 struct vnodeops *door_vnodeops;
56 54
57 55 const fs_operation_def_t door_vnodeops_template[] = {
58 - VOPNAME_OPEN, { .vop_open = door_open },
59 - VOPNAME_CLOSE, { .vop_close = door_close },
60 - VOPNAME_GETATTR, { .vop_getattr = door_getattr },
61 - VOPNAME_ACCESS, { .vop_access = door_access },
62 - VOPNAME_INACTIVE, { .vop_inactive = door_inactive },
63 - VOPNAME_FRLOCK, { .error = fs_error },
64 - VOPNAME_REALVP, { .vop_realvp = door_realvp },
65 - VOPNAME_POLL, { .error = fs_error },
66 - VOPNAME_PATHCONF, { .error = fs_error },
67 - VOPNAME_DISPOSE, { .error = fs_error },
68 - VOPNAME_GETSECATTR, { .error = fs_error },
69 - VOPNAME_SHRLOCK, { .error = fs_error },
70 - NULL, NULL
56 + { VOPNAME_OPEN, { .vop_open = door_open } },
57 + { VOPNAME_CLOSE, { .vop_close = door_close } },
58 + { VOPNAME_GETATTR, { .vop_getattr = door_getattr } },
59 + { VOPNAME_ACCESS, { .vop_access = door_access } },
60 + { VOPNAME_INACTIVE, { .vop_inactive = door_inactive } },
61 + { VOPNAME_FRLOCK, { .error = fs_error } },
62 + { VOPNAME_REALVP, { .vop_realvp = door_realvp } },
63 + { VOPNAME_POLL, { .error = fs_error } },
64 + { VOPNAME_PATHCONF, { .error = fs_error } },
65 + { VOPNAME_DISPOSE, { .error = fs_error } },
66 + { VOPNAME_GETSECATTR, { .error = fs_error } },
67 + { VOPNAME_SHRLOCK, { .error = fs_error } },
68 + { NULL, { NULL } }
71 69 };
72 70
73 71 /* ARGSUSED */
74 72 static int
75 73 door_open(struct vnode **vpp, int flag, struct cred *cr, caller_context_t *ct)
76 74 {
77 75 /*
78 76 * MAC policy for doors. Restrict cross-zone open()s so that only
79 77 * door servers in the global zone can have clients from other zones.
80 78 * For other zones, client must be within the same zone as server.
81 79 */
82 80 if (is_system_labeled()) {
83 81 zone_t *server_zone, *client_zone;
84 82 door_node_t *dp = VTOD((*vpp));
85 83
86 84 mutex_enter(&door_knob);
87 85 if (DOOR_INVALID(dp)) {
88 86 mutex_exit(&door_knob);
89 87 return (0);
90 88 }
91 89 client_zone = curproc->p_zone;
92 90 server_zone = dp->door_target->p_zone;
93 91 mutex_exit(&door_knob);
94 92 if (server_zone != global_zone &&
95 93 server_zone != client_zone)
96 94 return (EACCES);
97 95 }
98 96 return (0);
99 97 }
100 98
101 99 /* ARGSUSED */
102 100 static int
103 101 door_close(
104 102 struct vnode *vp,
105 103 int flag,
106 104 int count,
107 105 offset_t offset,
108 106 struct cred *cr,
109 107 caller_context_t *ct
110 108 )
111 109 {
112 110 door_node_t *dp = VTOD(vp);
113 111
114 112 /*
115 113 * If this is being called from closeall on exit, any doors created
116 114 * by this process should have been revoked already in door_exit.
117 115 */
118 116 ASSERT(dp->door_target != curproc ||
119 117 ((curthread->t_proc_flag & TP_LWPEXIT) == 0));
120 118
121 119 /*
122 120 * Deliver an unref if needed.
123 121 *
124 122 * If the count is equal to 2, it means that I'm doing a VOP_CLOSE
125 123 * on the next to last reference for *this* file struct. There may
126 124 * be multiple files pointing to this vnode in which case the v_count
127 125 * will be > 1.
128 126 *
129 127 * The door_active count is bumped during each invocation.
130 128 */
131 129 if (count == 2 && vp->v_count == 1 &&
132 130 (dp->door_flags & (DOOR_UNREF | DOOR_UNREF_MULTI))) {
133 131 mutex_enter(&door_knob);
134 132 if (dp->door_active == 0) {
135 133 /* o.k. to deliver unref now */
136 134 door_deliver_unref(dp);
137 135 } else {
138 136 /* do the unref later */
139 137 dp->door_flags |= DOOR_DELAY;
140 138 }
141 139 mutex_exit(&door_knob);
142 140 }
143 141 return (0);
144 142 }
145 143
146 144 /* ARGSUSED */
147 145 static int
148 146 door_getattr(struct vnode *vp, struct vattr *vap, int flags, struct cred *cr,
149 147 caller_context_t *ct)
150 148 {
151 149 static timestruc_t tzero = {0, 0};
152 150 extern dev_t doordev;
153 151
154 152 vap->va_mask = 0; /* bit-mask of attributes */
155 153 vap->va_type = vp->v_type; /* vnode type (for create) */
156 154 vap->va_mode = 0777; /* file access mode */
157 155 vap->va_uid = 0; /* owner user id */
158 156 vap->va_gid = 0; /* owner group id */
159 157 vap->va_fsid = doordev; /* file system id (dev for now) */
160 158 vap->va_nodeid = (ino64_t)0; /* node id */
161 159 vap->va_nlink = vp->v_count; /* number of references to file */
162 160 vap->va_size = (u_offset_t)0; /* file size in bytes */
163 161 vap->va_atime = tzero; /* time of last access */
164 162 vap->va_mtime = tzero; /* time of last modification */
165 163 vap->va_ctime = tzero; /* time file ``created'' */
166 164 vap->va_rdev = doordev; /* device the file represents */
167 165 vap->va_blksize = 0; /* fundamental block size */
168 166 vap->va_nblocks = (fsblkcnt64_t)0; /* # of blocks allocated */
169 167 vap->va_seq = 0; /* sequence number */
170 168
171 169 return (0);
172 170 }
173 171
174 172 /* ARGSUSED */
175 173 static void
176 174 door_inactive(struct vnode *vp, struct cred *cr, caller_context_t *ct)
177 175 {
178 176 door_node_t *dp = VTOD(vp);
179 177
180 178 mutex_enter(&vp->v_lock);
181 179 /*
182 180 * Once the door_node is unreferenced, it stays unreferenced,
183 181 * so we can simply return if there are active thread bindings;
184 182 * the final door_unbind_thread() will re-invoke us.
185 183 */
186 184 ASSERT(vp->v_count == 1);
187 185 if (dp->door_bound_threads > 0) {
188 186 vp->v_count--;
189 187 mutex_exit(&vp->v_lock);
190 188 return;
191 189 }
192 190 mutex_exit(&vp->v_lock);
193 191
194 192 /* if not revoked, remove door from per-process list */
195 193 if (dp->door_target) {
196 194 mutex_enter(&door_knob);
197 195 if (dp->door_target) /* recheck door_target under lock */
198 196 door_list_delete(dp);
199 197 mutex_exit(&door_knob);
200 198 }
201 199 vn_invalid(vp);
202 200 vn_free(vp);
203 201 kmem_free(dp, sizeof (door_node_t));
204 202 }
205 203
206 204 /*
207 205 * To avoid having bound threads interfere with unref processing, we
208 206 * don't use VN_HOLD/VN_RELE to track threads bound to our private
209 207 * pool. Instead, we keep a separate counter, also under v_lock.
210 208 */
211 209 void
212 210 door_bind_thread(door_node_t *dp)
213 211 {
214 212 vnode_t *vp = DTOV(dp);
215 213
216 214 mutex_enter(&vp->v_lock);
217 215 dp->door_bound_threads++;
218 216 ASSERT(dp->door_bound_threads > 0 && vp->v_count > 0);
219 217 mutex_exit(&vp->v_lock);
220 218 }
221 219
222 220 void
223 221 door_unbind_thread(door_node_t *dp)
224 222 {
225 223 vnode_t *vp = DTOV(dp);
226 224 int do_inactive = 0;
227 225
228 226 mutex_enter(&vp->v_lock);
229 227 ASSERT(dp->door_bound_threads > 0);
230 228 if (--dp->door_bound_threads == 0 && vp->v_count == 0) {
231 229 /* set up for inactive handling */
232 230 vp->v_count++;
233 231 do_inactive = 1;
234 232 }
235 233 mutex_exit(&vp->v_lock);
236 234
237 235 if (do_inactive)
238 236 door_inactive(vp, NULL, NULL);
239 237 }
240 238
241 239 /* ARGSUSED */
242 240 static int
243 241 door_access(struct vnode *vp, int mode, int flags, struct cred *cr,
244 242 caller_context_t *ct)
245 243 {
246 244 return (0);
247 245 }
248 246
249 247 /* ARGSUSED */
250 248 static int
251 249 door_realvp(vnode_t *vp, vnode_t **vpp, caller_context_t *ct)
252 250 {
253 251 *vpp = vp;
254 252 return (0);
255 253 }
↓ open down ↓ |
175 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX