File: | xlators/system/posix-acl/src/posix-acl.c |
Location: | line 632, column 17 |
Description: | Use of memory after it is freed |
1 | /* | |||
2 | Copyright (c) 2011-2012 Red Hat, Inc. <http://www.redhat.com> | |||
3 | This file is part of GlusterFS. | |||
4 | ||||
5 | This file is licensed to you under your choice of the GNU Lesser | |||
6 | General Public License, version 3 or any later version (LGPLv3 or | |||
7 | later), or the GNU General Public License, version 2 (GPLv2), in all | |||
8 | cases as published by the Free Software Foundation. | |||
9 | */ | |||
10 | ||||
11 | #include <errno(*__errno_location ()).h> | |||
12 | ||||
13 | #include "xlator.h" | |||
14 | #include "glusterfs.h" | |||
15 | ||||
16 | #include "posix-acl.h" | |||
17 | #include "posix-acl-xattr.h" | |||
18 | ||||
19 | ||||
20 | #define UINT64(ptr)((uint64_t)((long)(ptr))) ((uint64_t)((long)(ptr))) | |||
21 | #define PTR(num)((void *)((long)(num))) ((void *)((long)(num))) | |||
22 | ||||
23 | ||||
24 | static uid_t | |||
25 | r00t () | |||
26 | { | |||
27 | struct posix_acl_conf *conf = NULL((void*)0); | |||
28 | ||||
29 | conf = THIS(*__glusterfs_this_location())->private; | |||
30 | ||||
31 | return conf->super_uid; | |||
32 | } | |||
33 | ||||
34 | ||||
35 | int | |||
36 | whitelisted_xattr (const char *key) | |||
37 | { | |||
38 | if (!key) | |||
39 | return 0; | |||
40 | ||||
41 | if (strcmp (POSIX_ACL_ACCESS_XATTR"system.posix_acl_access", key) == 0) | |||
42 | return 1; | |||
43 | if (strcmp (POSIX_ACL_DEFAULT_XATTR"system.posix_acl_default", key) == 0) | |||
44 | return 1; | |||
45 | return 0; | |||
46 | } | |||
47 | ||||
48 | ||||
49 | int | |||
50 | frame_is_user (call_frame_t *frame, uid_t uid) | |||
51 | { | |||
52 | return (frame->root->uid == uid); | |||
53 | } | |||
54 | ||||
55 | ||||
56 | int | |||
57 | frame_is_super_user (call_frame_t *frame) | |||
58 | { | |||
59 | int ret; | |||
60 | ||||
61 | ret = frame_is_user (frame, r00t()); | |||
62 | if (!ret) | |||
63 | ret = frame_is_user (frame, 0); | |||
64 | ||||
65 | return ret; | |||
66 | } | |||
67 | ||||
68 | ||||
69 | int | |||
70 | frame_in_group (call_frame_t *frame, gid_t gid) | |||
71 | { | |||
72 | int i = 0; | |||
73 | ||||
74 | if (frame->root->gid == gid) | |||
75 | return 1; | |||
76 | ||||
77 | for (i = 0; i < frame->root->ngrps; i++) | |||
78 | if (frame->root->groups[i] == gid) | |||
79 | return 1; | |||
80 | return 0; | |||
81 | } | |||
82 | ||||
83 | ||||
84 | mode_t | |||
85 | posix_acl_access_set_mode (struct posix_acl *acl, struct posix_acl_ctx *ctx) | |||
86 | { | |||
87 | struct posix_ace *ace = NULL((void*)0); | |||
88 | struct posix_ace *group_ce = NULL((void*)0); | |||
89 | struct posix_ace *mask_ce = NULL((void*)0); | |||
90 | int count = 0; | |||
91 | int i = 0; | |||
92 | mode_t mode = 0; | |||
93 | int mask = 0; | |||
94 | ||||
95 | count = acl->count; | |||
96 | ||||
97 | ace = acl->entries; | |||
98 | for (i = 0; i < count; i++) { | |||
99 | switch (ace->tag) { | |||
100 | case POSIX_ACL_USER_OBJ(0x01): | |||
101 | mask |= S_IRWXU(0400|0200|0100); | |||
102 | mode |= (ace->perm << 6); | |||
103 | break; | |||
104 | case POSIX_ACL_GROUP_OBJ(0x04): | |||
105 | group_ce = ace; | |||
106 | break; | |||
107 | case POSIX_ACL_MASK(0x10): | |||
108 | mask_ce = ace; | |||
109 | break; | |||
110 | case POSIX_ACL_OTHER(0x20): | |||
111 | mask |= S_IRWXO(((0400|0200|0100) >> 3) >> 3); | |||
112 | mode |= (ace->perm); | |||
113 | break; | |||
114 | } | |||
115 | ace++; | |||
116 | } | |||
117 | ||||
118 | if (mask_ce) { | |||
119 | mask |= S_IRWXG((0400|0200|0100) >> 3); | |||
120 | mode |= (mask_ce->perm << 3); | |||
121 | } else { | |||
122 | if (!group_ce) | |||
123 | goto out; | |||
124 | mask |= S_IRWXG((0400|0200|0100) >> 3); | |||
125 | mode |= (group_ce->perm << 3); | |||
126 | } | |||
127 | ||||
128 | out: | |||
129 | ctx->perm = (ctx->perm & ~mask) | mode; | |||
130 | ||||
131 | return mode; | |||
132 | } | |||
133 | ||||
134 | ||||
135 | static int | |||
136 | sticky_permits (call_frame_t *frame, inode_t *parent, inode_t *inode) | |||
137 | { | |||
138 | struct posix_acl_ctx *par = NULL((void*)0); | |||
139 | struct posix_acl_ctx *ctx = NULL((void*)0); | |||
140 | ||||
141 | par = posix_acl_ctx_get (parent, frame->this); | |||
142 | ctx = posix_acl_ctx_get (inode, frame->this); | |||
143 | ||||
144 | if (frame_is_super_user (frame)) | |||
145 | return 1; | |||
146 | ||||
147 | if (!(par->perm & S_ISVTX01000)) | |||
148 | return 1; | |||
149 | ||||
150 | if (frame_is_user (frame, par->uid)) | |||
151 | return 1; | |||
152 | ||||
153 | if (frame_is_user (frame, ctx->uid)) | |||
154 | return 1; | |||
155 | ||||
156 | return 0; | |||
157 | } | |||
158 | ||||
159 | ||||
160 | static int | |||
161 | acl_permits (call_frame_t *frame, inode_t *inode, int want) | |||
162 | { | |||
163 | int verdict = 0; | |||
164 | struct posix_acl *acl = NULL((void*)0); | |||
165 | struct posix_ace *ace = NULL((void*)0); | |||
166 | struct posix_acl_ctx *ctx = NULL((void*)0); | |||
167 | struct posix_acl_conf *conf = NULL((void*)0); | |||
168 | int i = 0; | |||
169 | int perm = 0; | |||
170 | int found = 0; | |||
171 | int acl_present = 0; | |||
172 | ||||
173 | conf = frame->this->private; | |||
174 | ||||
175 | ctx = posix_acl_ctx_get (inode, frame->this); | |||
176 | if (!ctx) | |||
177 | goto red; | |||
178 | ||||
179 | if (frame_is_super_user (frame)) | |||
180 | goto green; | |||
181 | ||||
182 | posix_acl_get (inode, frame->this, &acl, NULL((void*)0)); | |||
183 | if (!acl) { | |||
184 | acl = posix_acl_ref (frame->this, conf->minimal_acl); | |||
185 | } | |||
186 | ||||
187 | ace = acl->entries; | |||
188 | ||||
189 | if (acl->count > 3) | |||
190 | acl_present = 1; | |||
191 | ||||
192 | for (i = 0; i < acl->count; i++) { | |||
193 | switch (ace->tag) { | |||
194 | case POSIX_ACL_USER_OBJ(0x01): | |||
195 | perm = ((ctx->perm & S_IRWXU(0400|0200|0100)) >> 6); | |||
196 | if (frame_is_user (frame, ctx->uid)) | |||
197 | goto perm_check; | |||
198 | break; | |||
199 | case POSIX_ACL_USER(0x02): | |||
200 | perm = ace->perm; | |||
201 | if (frame_is_user (frame, ace->id)) | |||
202 | goto mask_check; | |||
203 | break; | |||
204 | case POSIX_ACL_GROUP_OBJ(0x04): | |||
205 | if (acl_present) | |||
206 | perm = ace->perm; | |||
207 | else | |||
208 | perm = ((ctx->perm & S_IRWXG((0400|0200|0100) >> 3)) >> 3); | |||
209 | if (frame_in_group (frame, ctx->gid)) { | |||
210 | found = 1; | |||
211 | if ((perm & want) == want) | |||
212 | goto mask_check; | |||
213 | } | |||
214 | break; | |||
215 | case POSIX_ACL_GROUP(0x08): | |||
216 | perm = ace->perm; | |||
217 | if (frame_in_group (frame, ace->id)) { | |||
218 | found = 1; | |||
219 | if ((perm & want) == want) | |||
220 | goto mask_check; | |||
221 | } | |||
222 | break; | |||
223 | case POSIX_ACL_MASK(0x10): | |||
224 | break; | |||
225 | case POSIX_ACL_OTHER(0x20): | |||
226 | perm = (ctx->perm & S_IRWXO(((0400|0200|0100) >> 3) >> 3)); | |||
227 | if (!found) | |||
228 | goto perm_check; | |||
229 | /* fall through */ | |||
230 | default: | |||
231 | goto red; | |||
232 | } | |||
233 | ||||
234 | ace++; | |||
235 | } | |||
236 | ||||
237 | mask_check: | |||
238 | ace = acl->entries; | |||
239 | ||||
240 | for (i = 0; i < acl->count; i++, ace++) { | |||
241 | if (ace->tag != POSIX_ACL_MASK(0x10)) | |||
242 | continue; | |||
243 | if ((ace->perm & perm & want) == want) { | |||
244 | goto green; | |||
245 | } | |||
246 | goto red; | |||
247 | } | |||
248 | ||||
249 | perm_check: | |||
250 | if ((perm & want) == want) { | |||
251 | goto green; | |||
252 | } else { | |||
253 | goto red; | |||
254 | } | |||
255 | ||||
256 | green: | |||
257 | verdict = 1; | |||
258 | goto out; | |||
259 | red: | |||
260 | verdict = 0; | |||
261 | out: | |||
262 | if (acl) | |||
263 | posix_acl_unref (frame->this, acl); | |||
264 | ||||
265 | return verdict; | |||
266 | } | |||
267 | ||||
268 | ||||
269 | struct posix_acl_ctx * | |||
270 | posix_acl_ctx_get (inode_t *inode, xlator_t *this) | |||
271 | { | |||
272 | struct posix_acl_ctx *ctx = NULL((void*)0); | |||
273 | uint64_t int_ctx = 0; | |||
274 | int ret = 0; | |||
275 | ||||
276 | ret = inode_ctx_get (inode, this, &int_ctx)inode_ctx_get2(inode,this,&int_ctx,0); | |||
277 | if ((ret == 0) && (int_ctx)) | |||
278 | return PTR(int_ctx)((void *)((long)(int_ctx))); | |||
279 | ||||
280 | ctx = CALLOC (1, sizeof (*ctx))__gf_default_calloc(1,sizeof (*ctx)); | |||
281 | if (!ctx) | |||
282 | return NULL((void*)0); | |||
283 | ||||
284 | ret = inode_ctx_put (inode, this, UINT64 (ctx)((uint64_t)((long)(ctx)))); | |||
285 | ||||
286 | return ctx; | |||
287 | } | |||
288 | ||||
289 | ||||
290 | int | |||
291 | __posix_acl_set (inode_t *inode, xlator_t *this, struct posix_acl *acl_access, | |||
292 | struct posix_acl *acl_default) | |||
293 | { | |||
294 | int ret = 0; | |||
295 | struct posix_acl_ctx *ctx = NULL((void*)0); | |||
296 | ||||
297 | ctx = posix_acl_ctx_get (inode, this); | |||
298 | if (!ctx) | |||
299 | goto out; | |||
300 | ||||
301 | ctx->acl_access = acl_access; | |||
302 | ctx->acl_default = acl_default; | |||
303 | ||||
304 | out: | |||
305 | return ret; | |||
306 | } | |||
307 | ||||
308 | ||||
309 | int | |||
310 | __posix_acl_get (inode_t *inode, xlator_t *this, struct posix_acl **acl_access_p, | |||
311 | struct posix_acl **acl_default_p) | |||
312 | { | |||
313 | int ret = 0; | |||
314 | struct posix_acl_ctx *ctx = NULL((void*)0); | |||
315 | ||||
316 | ctx = posix_acl_ctx_get (inode, this); | |||
317 | if (!ctx) | |||
318 | goto out; | |||
319 | ||||
320 | if (acl_access_p) | |||
321 | *acl_access_p = ctx->acl_access; | |||
322 | if (acl_default_p) | |||
323 | *acl_default_p = ctx->acl_default; | |||
324 | ||||
325 | out: | |||
326 | return ret; | |||
327 | } | |||
328 | ||||
329 | ||||
330 | struct posix_acl * | |||
331 | posix_acl_new (xlator_t *this, int entrycnt) | |||
332 | { | |||
333 | struct posix_acl *acl = NULL((void*)0); | |||
334 | struct posix_ace *ace = NULL((void*)0); | |||
335 | ||||
336 | acl = CALLOC (1, sizeof (*acl) + (entrycnt * sizeof (*ace)))__gf_default_calloc(1,sizeof (*acl) + (entrycnt * sizeof (*ace ))); | |||
337 | if (!acl) | |||
338 | return NULL((void*)0); | |||
339 | ||||
340 | acl->count = entrycnt; | |||
341 | ||||
342 | posix_acl_ref (this, acl); | |||
343 | ||||
344 | return acl; | |||
345 | } | |||
346 | ||||
347 | ||||
348 | void | |||
349 | posix_acl_destroy (xlator_t *this, struct posix_acl *acl) | |||
350 | { | |||
351 | FREE (acl)if (acl != ((void*)0)) { free ((void *)acl); acl = (void *)0xeeeeeeee ; }; | |||
352 | ||||
353 | return; | |||
354 | } | |||
355 | ||||
356 | ||||
357 | struct posix_acl * | |||
358 | posix_acl_ref (xlator_t *this, struct posix_acl *acl) | |||
359 | { | |||
360 | struct posix_acl_conf *conf = NULL((void*)0); | |||
361 | ||||
362 | conf = this->private; | |||
363 | ||||
364 | LOCK(&conf->acl_lock)pthread_spin_lock (&conf->acl_lock); | |||
365 | { | |||
366 | acl->refcnt++; | |||
367 | } | |||
368 | UNLOCK(&conf->acl_lock)pthread_spin_unlock (&conf->acl_lock); | |||
369 | ||||
370 | return acl; | |||
371 | } | |||
372 | ||||
373 | ||||
374 | struct posix_acl * | |||
375 | posix_acl_dup (xlator_t *this, struct posix_acl *acl) | |||
376 | { | |||
377 | struct posix_acl *dup = NULL((void*)0); | |||
378 | ||||
379 | dup = posix_acl_new (this, acl->count); | |||
380 | if (!dup) | |||
381 | return NULL((void*)0); | |||
382 | ||||
383 | memcpy (dup->entries, acl->entries, | |||
384 | sizeof (struct posix_ace) * acl->count); | |||
385 | ||||
386 | return dup; | |||
387 | } | |||
388 | ||||
389 | ||||
390 | void | |||
391 | posix_acl_unref (xlator_t *this, struct posix_acl *acl) | |||
392 | { | |||
393 | struct posix_acl_conf *conf = NULL((void*)0); | |||
394 | int refcnt = 0; | |||
395 | ||||
396 | conf = this->private; | |||
397 | ||||
398 | LOCK(&conf->acl_lock)pthread_spin_lock (&conf->acl_lock); | |||
399 | { | |||
400 | refcnt = --acl->refcnt; | |||
401 | } | |||
402 | UNLOCK(&conf->acl_lock)pthread_spin_unlock (&conf->acl_lock); | |||
403 | ||||
404 | if (!refcnt) | |||
405 | posix_acl_destroy (this, acl); | |||
406 | } | |||
407 | ||||
408 | ||||
409 | int | |||
410 | posix_acl_set (inode_t *inode, xlator_t *this, struct posix_acl *acl_access, | |||
411 | struct posix_acl *acl_default) | |||
412 | { | |||
413 | int ret = 0; | |||
414 | int oldret = 0; | |||
415 | struct posix_acl *old_access = NULL((void*)0); | |||
416 | struct posix_acl *old_default = NULL((void*)0); | |||
417 | struct posix_acl_conf *conf = NULL((void*)0); | |||
418 | ||||
419 | conf = this->private; | |||
420 | ||||
421 | LOCK(&conf->acl_lock)pthread_spin_lock (&conf->acl_lock); | |||
422 | { | |||
423 | oldret = __posix_acl_get (inode, this, &old_access, | |||
424 | &old_default); | |||
425 | if (acl_access) | |||
426 | acl_access->refcnt++; | |||
427 | if (acl_default) | |||
428 | acl_default->refcnt++; | |||
429 | ||||
430 | ret = __posix_acl_set (inode, this, acl_access, acl_default); | |||
431 | } | |||
432 | UNLOCK(&conf->acl_lock)pthread_spin_unlock (&conf->acl_lock); | |||
433 | ||||
434 | if (oldret == 0) { | |||
435 | if (old_access) | |||
436 | posix_acl_unref (this, old_access); | |||
437 | if (old_default) | |||
438 | posix_acl_unref (this, old_default); | |||
439 | } | |||
440 | ||||
441 | return ret; | |||
442 | } | |||
443 | ||||
444 | ||||
445 | int | |||
446 | posix_acl_get (inode_t *inode, xlator_t *this, struct posix_acl **acl_access_p, | |||
447 | struct posix_acl **acl_default_p) | |||
448 | { | |||
449 | struct posix_acl_conf *conf = NULL((void*)0); | |||
450 | struct posix_acl *acl_access = NULL((void*)0); | |||
451 | struct posix_acl *acl_default = NULL((void*)0); | |||
452 | int ret = 0; | |||
453 | ||||
454 | conf = this->private; | |||
455 | ||||
456 | LOCK(&conf->acl_lock)pthread_spin_lock (&conf->acl_lock); | |||
457 | { | |||
458 | ret = __posix_acl_get (inode, this, &acl_access, &acl_default); | |||
459 | ||||
460 | if (ret != 0) | |||
461 | goto unlock; | |||
462 | ||||
463 | if (acl_access && acl_access_p) | |||
464 | acl_access->refcnt++; | |||
465 | if (acl_default && acl_default_p) | |||
466 | acl_default->refcnt++; | |||
467 | } | |||
468 | unlock: | |||
469 | UNLOCK(&conf->acl_lock)pthread_spin_unlock (&conf->acl_lock); | |||
470 | ||||
471 | if (acl_access_p) | |||
472 | *acl_access_p = acl_access; | |||
473 | if (acl_default_p) | |||
474 | *acl_default_p = acl_default; | |||
475 | ||||
476 | return ret; | |||
477 | } | |||
478 | ||||
479 | ||||
480 | mode_t | |||
481 | posix_acl_inherit_mode (struct posix_acl *acl, mode_t modein) | |||
482 | { | |||
483 | struct posix_ace *ace = NULL((void*)0); | |||
484 | int count = 0; | |||
485 | int i = 0; | |||
486 | mode_t newmode = 0; | |||
487 | mode_t mode = 0; | |||
488 | struct posix_ace *mask_ce = NULL((void*)0); | |||
489 | struct posix_ace *group_ce = NULL((void*)0); | |||
490 | ||||
491 | newmode = mode = modein; | |||
492 | ||||
493 | count = acl->count; | |||
494 | ||||
495 | ace = acl->entries; | |||
496 | for (i = 0; i < count; i++) { | |||
497 | switch (ace->tag) { | |||
498 | case POSIX_ACL_USER_OBJ(0x01): | |||
499 | ace->perm &= (mode >> 6) | ~S_IRWXO(((0400|0200|0100) >> 3) >> 3); | |||
500 | mode &= (ace->perm << 6) | ~S_IRWXU(0400|0200|0100); | |||
501 | break; | |||
502 | case POSIX_ACL_GROUP_OBJ(0x04): | |||
503 | group_ce = ace; | |||
504 | break; | |||
505 | case POSIX_ACL_MASK(0x10): | |||
506 | mask_ce = ace; | |||
507 | break; | |||
508 | case POSIX_ACL_OTHER(0x20): | |||
509 | ace->perm &= (mode) | ~S_IRWXO(((0400|0200|0100) >> 3) >> 3); | |||
510 | mode &= (ace->perm) | ~S_IRWXO(((0400|0200|0100) >> 3) >> 3); | |||
511 | break; | |||
512 | } | |||
513 | ace++; | |||
514 | } | |||
515 | ||||
516 | if (mask_ce) { | |||
517 | mask_ce->perm &= (mode >> 3) | ~S_IRWXO(((0400|0200|0100) >> 3) >> 3); | |||
518 | mode &= (mask_ce->perm << 3) | ~S_IRWXG((0400|0200|0100) >> 3); | |||
519 | } else if (group_ce) { | |||
520 | group_ce->perm &= (mode >> 3) | ~S_IRWXO(((0400|0200|0100) >> 3) >> 3); | |||
521 | mode &= (group_ce->perm << 3) | ~S_IRWXG((0400|0200|0100) >> 3); | |||
522 | } | |||
523 | ||||
524 | newmode = ((modein & (S_IFMT0170000 | S_ISUID04000 | S_ISGID02000 | S_ISVTX01000)) | | |||
525 | (mode & (S_IRWXU(0400|0200|0100)|S_IRWXG((0400|0200|0100) >> 3)|S_IRWXO(((0400|0200|0100) >> 3) >> 3)))); | |||
526 | ||||
527 | return newmode; | |||
528 | } | |||
529 | ||||
530 | ||||
531 | mode_t | |||
532 | posix_acl_inherit (xlator_t *this, loc_t *loc, dict_t *params, mode_t mode, | |||
533 | int32_t umask, int is_dir) | |||
534 | { | |||
535 | int ret = 0; | |||
536 | struct posix_acl *par_default = NULL((void*)0); | |||
537 | struct posix_acl *acl_default = NULL((void*)0); | |||
538 | struct posix_acl *acl_access = NULL((void*)0); | |||
539 | struct posix_acl_ctx *ctx = NULL((void*)0); | |||
540 | char *xattr_default = NULL((void*)0); | |||
541 | char *xattr_access = NULL((void*)0); | |||
542 | int size_default = 0; | |||
543 | int size_access = 0; | |||
544 | mode_t retmode = 0; | |||
545 | int16_t tmp_mode = 0; | |||
546 | mode_t client_umask = 0; | |||
547 | ||||
548 | retmode = mode; | |||
549 | client_umask = umask; | |||
550 | ret = dict_get_int16 (params, "umask", &tmp_mode); | |||
551 | if (ret == 0) { | |||
| ||||
552 | client_umask = (mode_t)tmp_mode; | |||
553 | dict_del (params, "umask"); | |||
554 | ret = dict_get_int16 (params, "mode", &tmp_mode); | |||
555 | if (ret == 0) { | |||
556 | retmode = (mode_t)tmp_mode; | |||
557 | dict_del (params, "mode"); | |||
558 | } else { | |||
559 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("client sent umask, but not the original mode" ); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__ , 560, GF_LOG_ERROR, "client sent umask, but not the original mode" ); } while (0) | |||
560 | "client sent umask, but not the original mode")do { do { if (0) printf ("client sent umask, but not the original mode" ); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__ , 560, GF_LOG_ERROR, "client sent umask, but not the original mode" ); } while (0); | |||
561 | } | |||
562 | } | |||
563 | ||||
564 | ret = posix_acl_get (loc->parent, this, NULL((void*)0), &par_default); | |||
565 | ||||
566 | if (!par_default) | |||
567 | goto out; | |||
568 | ||||
569 | ctx = posix_acl_ctx_get (loc->inode, this); | |||
570 | ||||
571 | acl_access = posix_acl_dup (this, par_default); | |||
572 | if (!acl_access) | |||
573 | goto out; | |||
574 | ||||
575 | client_umask = 0; // No umask if we inherit an ACL | |||
576 | retmode = posix_acl_inherit_mode (acl_access, retmode); | |||
577 | ctx->perm = retmode; | |||
578 | ||||
579 | size_access = posix_acl_to_xattr (this, acl_access, NULL((void*)0), 0); | |||
580 | xattr_access = CALLOC (1, size_access)__gf_default_calloc(1,size_access); | |||
581 | if (!xattr_access) { | |||
582 | gf_log (this->name, GF_LOG_ERROR, "out of memory")do { do { if (0) printf ("out of memory"); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__, 582, GF_LOG_ERROR , "out of memory"); } while (0); | |||
583 | ret = -1; | |||
584 | goto out; | |||
585 | } | |||
586 | posix_acl_to_xattr (this, acl_access, xattr_access, size_access); | |||
587 | ||||
588 | ret = dict_set_bin (params, POSIX_ACL_ACCESS_XATTR"system.posix_acl_access", xattr_access, | |||
589 | size_access); | |||
590 | if (ret) { | |||
591 | gf_log (this->name, GF_LOG_ERROR, "out of memory")do { do { if (0) printf ("out of memory"); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__, 591, GF_LOG_ERROR , "out of memory"); } while (0); | |||
592 | ret = -1; | |||
593 | goto out; | |||
594 | } | |||
595 | ||||
596 | if (!is_dir) | |||
597 | goto set; | |||
598 | ||||
599 | ||||
600 | acl_default = posix_acl_ref (this, par_default); | |||
601 | ||||
602 | size_default = posix_acl_to_xattr (this, acl_default, NULL((void*)0), 0); | |||
603 | xattr_default = CALLOC (1, size_default)__gf_default_calloc(1,size_default); | |||
604 | if (!xattr_default) { | |||
605 | gf_log (this->name, GF_LOG_ERROR, "out of memory")do { do { if (0) printf ("out of memory"); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__, 605, GF_LOG_ERROR , "out of memory"); } while (0); | |||
606 | ret = -1; | |||
607 | goto out; | |||
608 | } | |||
609 | posix_acl_to_xattr (this, acl_default, xattr_default, size_default); | |||
610 | ||||
611 | ret = dict_set_bin (params, POSIX_ACL_DEFAULT_XATTR"system.posix_acl_default", xattr_default, | |||
612 | size_default); | |||
613 | if (ret) { | |||
614 | gf_log (this->name, GF_LOG_ERROR, "out of memory")do { do { if (0) printf ("out of memory"); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__, 614, GF_LOG_ERROR , "out of memory"); } while (0); | |||
615 | ret = -1; | |||
616 | goto out; | |||
617 | } | |||
618 | ||||
619 | set: | |||
620 | ret = posix_acl_set (loc->inode, this, acl_access, acl_default); | |||
621 | if (ret != 0) | |||
622 | goto out; | |||
623 | ||||
624 | out: | |||
625 | retmode &= ~client_umask; | |||
626 | ||||
627 | if (par_default) | |||
628 | posix_acl_unref (this, par_default); | |||
629 | if (acl_access) | |||
630 | posix_acl_unref (this, acl_access); | |||
631 | if (acl_default) | |||
632 | posix_acl_unref (this, acl_default); | |||
| ||||
633 | ||||
634 | return retmode; | |||
635 | } | |||
636 | ||||
637 | ||||
638 | mode_t | |||
639 | posix_acl_inherit_dir (xlator_t *this, loc_t *loc, dict_t *params, mode_t mode, | |||
640 | int32_t umask) | |||
641 | { | |||
642 | mode_t retmode = 0; | |||
643 | ||||
644 | retmode = posix_acl_inherit (this, loc, params, mode, umask, 1); | |||
645 | ||||
646 | return retmode; | |||
647 | } | |||
648 | ||||
649 | ||||
650 | mode_t | |||
651 | posix_acl_inherit_file (xlator_t *this, loc_t *loc, dict_t *params, mode_t mode, | |||
652 | int32_t umask) | |||
653 | { | |||
654 | mode_t retmode = 0; | |||
655 | ||||
656 | retmode = posix_acl_inherit (this, loc, params, mode, umask, 0); | |||
657 | ||||
658 | return retmode; | |||
659 | } | |||
660 | ||||
661 | ||||
662 | int | |||
663 | posix_acl_ctx_update (inode_t *inode, xlator_t *this, struct iatt *buf) | |||
664 | { | |||
665 | struct posix_acl_ctx *ctx = NULL((void*)0); | |||
666 | int ret = 0; | |||
667 | ||||
668 | ctx = posix_acl_ctx_get (inode, this); | |||
669 | if (!ctx) { | |||
670 | ret = -1; | |||
671 | goto out; | |||
672 | } | |||
673 | ||||
674 | LOCK(&inode->lock)pthread_spin_lock (&inode->lock); | |||
675 | { | |||
676 | ctx->uid = buf->ia_uid; | |||
677 | ctx->gid = buf->ia_gid; | |||
678 | ctx->perm = st_mode_from_ia (buf->ia_prot, buf->ia_type); | |||
679 | } | |||
680 | UNLOCK(&inode->lock)pthread_spin_unlock (&inode->lock); | |||
681 | out: | |||
682 | return ret; | |||
683 | } | |||
684 | ||||
685 | ||||
686 | int | |||
687 | posix_acl_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
688 | int op_ret, int op_errno, inode_t *inode, | |||
689 | struct iatt *buf, dict_t *xattr, struct iatt *postparent) | |||
690 | { | |||
691 | struct posix_acl *acl_access = NULL((void*)0); | |||
692 | struct posix_acl *acl_default = NULL((void*)0); | |||
693 | struct posix_acl *old_access = NULL((void*)0); | |||
694 | struct posix_acl *old_default = NULL((void*)0); | |||
695 | data_t *data = NULL((void*)0); | |||
696 | int ret = 0; | |||
697 | dict_t *my_xattr = NULL((void*)0); | |||
698 | ||||
699 | if (op_ret != 0) | |||
700 | goto unwind; | |||
701 | ||||
702 | ret = posix_acl_get (inode, this, &old_access, &old_default); | |||
703 | ||||
704 | data = dict_get (xattr, POSIX_ACL_ACCESS_XATTR"system.posix_acl_access"); | |||
705 | if (!data) | |||
706 | goto acl_default; | |||
707 | ||||
708 | if (old_access && | |||
709 | posix_acl_matches_xattr (this, old_access, data->data, | |||
710 | data->len)) { | |||
711 | acl_access = posix_acl_ref (this, old_access); | |||
712 | } else { | |||
713 | acl_access = posix_acl_from_xattr (this, data->data, | |||
714 | data->len); | |||
715 | } | |||
716 | ||||
717 | acl_default: | |||
718 | data = dict_get (xattr, POSIX_ACL_DEFAULT_XATTR"system.posix_acl_default"); | |||
719 | if (!data) | |||
720 | goto acl_set; | |||
721 | ||||
722 | if (old_default && | |||
723 | posix_acl_matches_xattr (this, old_default, data->data, | |||
724 | data->len)) { | |||
725 | acl_default = posix_acl_ref (this, old_default); | |||
726 | } else { | |||
727 | acl_default = posix_acl_from_xattr (this, data->data, | |||
728 | data->len); | |||
729 | } | |||
730 | ||||
731 | acl_set: | |||
732 | posix_acl_ctx_update (inode, this, buf); | |||
733 | ||||
734 | ret = posix_acl_set (inode, this, acl_access, acl_default); | |||
735 | if (ret) | |||
736 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set ACL in context"); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__, 737 , GF_LOG_WARNING, "failed to set ACL in context"); } while (0 ) | |||
737 | "failed to set ACL in context")do { do { if (0) printf ("failed to set ACL in context"); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__, 737 , GF_LOG_WARNING, "failed to set ACL in context"); } while (0 ); | |||
738 | unwind: | |||
739 | my_xattr = frame->local; | |||
740 | frame->local = NULL((void*)0); | |||
741 | STACK_UNWIND_STRICT (lookup, frame, op_ret, op_errno, inode, buf, xattr,do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 742, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, xattr, postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
742 | postparent)do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 742, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, xattr, postparent); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
743 | ||||
744 | if (acl_access) | |||
745 | posix_acl_unref (this, acl_access); | |||
746 | if (acl_default) | |||
747 | posix_acl_unref (this, acl_default); | |||
748 | if (old_access) | |||
749 | posix_acl_unref (this, old_access); | |||
750 | if (old_default) | |||
751 | posix_acl_unref (this, old_default); | |||
752 | if (my_xattr) | |||
753 | dict_unref (my_xattr); | |||
754 | ||||
755 | return 0; | |||
756 | } | |||
757 | ||||
758 | ||||
759 | int | |||
760 | posix_acl_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, | |||
761 | dict_t *xattr) | |||
762 | { | |||
763 | int ret = 0; | |||
764 | dict_t *my_xattr = NULL((void*)0); | |||
765 | ||||
766 | if (!loc->parent) | |||
767 | /* lookup of / is always permitted */ | |||
768 | goto green; | |||
769 | ||||
770 | if (acl_permits (frame, loc->parent, POSIX_ACL_EXECUTE(0x01))) | |||
771 | goto green; | |||
772 | else | |||
773 | goto red; | |||
774 | ||||
775 | green: | |||
776 | if (xattr) { | |||
777 | my_xattr = dict_ref (xattr); | |||
778 | } else { | |||
779 | my_xattr = dict_new (); | |||
780 | } | |||
781 | ||||
782 | ret = dict_set_int8 (my_xattr, POSIX_ACL_ACCESS_XATTR"system.posix_acl_access", 0); | |||
783 | if (ret) | |||
784 | gf_log (this->name, GF_LOG_WARNING, "failed to set key %s",do { do { if (0) printf ("failed to set key %s", "system.posix_acl_access" ); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__ , 785, GF_LOG_WARNING, "failed to set key %s", "system.posix_acl_access" ); } while (0) | |||
785 | POSIX_ACL_ACCESS_XATTR)do { do { if (0) printf ("failed to set key %s", "system.posix_acl_access" ); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__ , 785, GF_LOG_WARNING, "failed to set key %s", "system.posix_acl_access" ); } while (0); | |||
786 | ||||
787 | ret = dict_set_int8 (my_xattr, POSIX_ACL_DEFAULT_XATTR"system.posix_acl_default", 0); | |||
788 | if (ret) | |||
789 | gf_log (this->name, GF_LOG_WARNING, "failed to set key %s",do { do { if (0) printf ("failed to set key %s", "system.posix_acl_default" ); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__ , 790, GF_LOG_WARNING, "failed to set key %s", "system.posix_acl_default" ); } while (0) | |||
790 | POSIX_ACL_DEFAULT_XATTR)do { do { if (0) printf ("failed to set key %s", "system.posix_acl_default" ); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__ , 790, GF_LOG_WARNING, "failed to set key %s", "system.posix_acl_default" ); } while (0); | |||
791 | ||||
792 | frame->local = my_xattr; | |||
793 | STACK_WIND (frame, posix_acl_lookup_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 795, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->lookup_cbk) tmp_cbk = posix_acl_lookup_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->lookup" ; _new->unwind_to = "posix_acl_lookup_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->lookup); (this->children->xlator )->fops->lookup (_new, (this->children->xlator), loc , my_xattr); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
794 | FIRST_CHILD (this), FIRST_CHILD (this)->fops->lookup,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 795, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->lookup_cbk) tmp_cbk = posix_acl_lookup_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->lookup" ; _new->unwind_to = "posix_acl_lookup_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->lookup); (this->children->xlator )->fops->lookup (_new, (this->children->xlator), loc , my_xattr); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
795 | loc, my_xattr)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 795, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->lookup_cbk) tmp_cbk = posix_acl_lookup_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD (this)->fops->lookup" ; _new->unwind_to = "posix_acl_lookup_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->lookup); (this->children->xlator )->fops->lookup (_new, (this->children->xlator), loc , my_xattr); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
796 | return 0; | |||
797 | red: | |||
798 | STACK_UNWIND_STRICT (lookup, frame, -1, EACCES, NULL, NULL, NULL,do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 799, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
799 | NULL)do { fop_lookup_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 799, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_lookup_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
800 | ||||
801 | return 0; | |||
802 | } | |||
803 | ||||
804 | ||||
805 | int | |||
806 | posix_acl_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int mask, | |||
807 | dict_t *xdata) | |||
808 | { | |||
809 | int op_ret = 0; | |||
810 | int op_errno = 0; | |||
811 | int perm = 0; | |||
812 | int mode = 0; | |||
813 | int is_fuse_call = 0; | |||
814 | ||||
815 | is_fuse_call = __is_fuse_call (frame); | |||
816 | ||||
817 | if (mask & R_OK4) | |||
818 | perm |= POSIX_ACL_READ(0x04); | |||
819 | if (mask & W_OK2) | |||
820 | perm |= POSIX_ACL_WRITE(0x02); | |||
821 | if (mask & X_OK1) | |||
822 | perm |= POSIX_ACL_EXECUTE(0x01); | |||
823 | if (!mask) { | |||
824 | goto unwind; | |||
825 | } | |||
826 | if (!perm) { | |||
827 | op_ret = -1; | |||
828 | op_errno = EINVAL22; | |||
829 | goto unwind; | |||
830 | } | |||
831 | ||||
832 | if (is_fuse_call) { | |||
833 | mode = acl_permits (frame, loc->inode, perm); | |||
834 | if (mode) { | |||
835 | op_ret = 0; | |||
836 | op_errno = 0; | |||
837 | } else { | |||
838 | op_ret = -1; | |||
839 | op_errno = EACCES13; | |||
840 | } | |||
841 | } else { | |||
842 | if (perm & POSIX_ACL_READ(0x04)) { | |||
843 | if (acl_permits (frame, loc->inode, POSIX_ACL_READ(0x04))) | |||
844 | mode |= POSIX_ACL_READ(0x04); | |||
845 | } | |||
846 | ||||
847 | if (perm & POSIX_ACL_WRITE(0x02)) { | |||
848 | if (acl_permits (frame, loc->inode, POSIX_ACL_WRITE(0x02))) | |||
849 | mode |= POSIX_ACL_WRITE(0x02); | |||
850 | } | |||
851 | ||||
852 | if (perm & POSIX_ACL_EXECUTE(0x01)) { | |||
853 | if (acl_permits (frame, loc->inode, POSIX_ACL_EXECUTE(0x01))) | |||
854 | mode |= POSIX_ACL_EXECUTE(0x01); | |||
855 | } | |||
856 | } | |||
857 | ||||
858 | unwind: | |||
859 | if (is_fuse_call) | |||
860 | STACK_UNWIND_STRICT (access, frame, op_ret, op_errno, NULL)do { fop_access_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 860, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_access_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
861 | else | |||
862 | STACK_UNWIND_STRICT (access, frame, 0, mode, NULL)do { fop_access_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 862, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_access_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, 0, mode, ((void*)0)); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
863 | return 0; | |||
864 | } | |||
865 | ||||
866 | ||||
867 | int | |||
868 | posix_acl_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
869 | int op_ret, int op_errno, struct iatt *prebuf, | |||
870 | struct iatt *postbuf, dict_t *xdata) | |||
871 | { | |||
872 | STACK_UNWIND_STRICT (truncate, frame, op_ret, op_errno, prebuf,do { fop_truncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 873, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_truncate_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
873 | postbuf, xdata)do { fop_truncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 873, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_truncate_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
874 | ||||
875 | return 0; | |||
876 | } | |||
877 | ||||
878 | ||||
879 | int | |||
880 | posix_acl_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t off, | |||
881 | dict_t *xdata) | |||
882 | { | |||
883 | if (acl_permits (frame, loc->inode, POSIX_ACL_WRITE(0x02))) | |||
884 | goto green; | |||
885 | else | |||
886 | goto red; | |||
887 | green: | |||
888 | STACK_WIND (frame, posix_acl_truncate_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 890, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->truncate_cbk) tmp_cbk = posix_acl_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->truncate" ; _new->unwind_to = "posix_acl_truncate_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->truncate); (this->children->xlator )->fops->truncate (_new, (this->children->xlator) , loc, off, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
889 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->truncate,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 890, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->truncate_cbk) tmp_cbk = posix_acl_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->truncate" ; _new->unwind_to = "posix_acl_truncate_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->truncate); (this->children->xlator )->fops->truncate (_new, (this->children->xlator) , loc, off, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
890 | loc, off, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 890, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->truncate_cbk) tmp_cbk = posix_acl_truncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->truncate" ; _new->unwind_to = "posix_acl_truncate_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->truncate); (this->children->xlator )->fops->truncate (_new, (this->children->xlator) , loc, off, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
891 | return 0; | |||
892 | red: | |||
893 | STACK_UNWIND_STRICT (truncate, frame, -1, EACCES, NULL, NULL, NULL)do { fop_truncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 893, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_truncate_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), ((void*)0)); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
894 | return 0; | |||
895 | } | |||
896 | ||||
897 | ||||
898 | int | |||
899 | posix_acl_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
900 | int op_ret, int op_errno, fd_t *fd, dict_t *xdata) | |||
901 | { | |||
902 | STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd, xdata)do { fop_open_cbk_t fn = ((void*)0); call_frame_t *_parent = ( (void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 902, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_open_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
903 | ||||
904 | return 0; | |||
905 | } | |||
906 | ||||
907 | ||||
908 | int | |||
909 | posix_acl_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, | |||
910 | fd_t *fd, dict_t *xdata) | |||
911 | { | |||
912 | int perm = 0; | |||
913 | ||||
914 | switch (flags & O_ACCMODE0003) { | |||
915 | case O_RDONLY00: | |||
916 | perm = POSIX_ACL_READ(0x04); | |||
917 | ||||
918 | /* If O_FMODE_EXEC is present, its good enough | |||
919 | to have '--x' perm, and its not covered in | |||
920 | O_ACCMODE bits */ | |||
921 | if (flags & O_FMODE_EXEC040) | |||
922 | perm = POSIX_ACL_EXECUTE(0x01); | |||
923 | ||||
924 | break; | |||
925 | case O_WRONLY01: | |||
926 | case O_APPEND02000: | |||
927 | case O_TRUNC01000: | |||
928 | perm = POSIX_ACL_WRITE(0x02); | |||
929 | break; | |||
930 | case O_RDWR02: | |||
931 | perm = POSIX_ACL_READ(0x04)|POSIX_ACL_WRITE(0x02); | |||
932 | break; | |||
933 | } | |||
934 | ||||
935 | if (acl_permits (frame, loc->inode, perm)) | |||
936 | goto green; | |||
937 | else | |||
938 | goto red; | |||
939 | green: | |||
940 | STACK_WIND (frame, posix_acl_open_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 942, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->open_cbk) tmp_cbk = posix_acl_open_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->open"; _new ->unwind_to = "posix_acl_open_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->open); (this->children->xlator )->fops->open (_new, (this->children->xlator), loc , flags, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
941 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->open,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 942, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->open_cbk) tmp_cbk = posix_acl_open_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->open"; _new ->unwind_to = "posix_acl_open_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->open); (this->children->xlator )->fops->open (_new, (this->children->xlator), loc , flags, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
942 | loc, flags, fd, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 942, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->open_cbk) tmp_cbk = posix_acl_open_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->open"; _new ->unwind_to = "posix_acl_open_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->open); (this->children->xlator )->fops->open (_new, (this->children->xlator), loc , flags, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
943 | return 0; | |||
944 | red: | |||
945 | STACK_UNWIND_STRICT (open, frame, -1, EACCES, NULL, xdata)do { fop_open_cbk_t fn = ((void*)0); call_frame_t *_parent = ( (void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 945, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_open_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
946 | return 0; | |||
947 | } | |||
948 | ||||
949 | ||||
950 | int | |||
951 | posix_acl_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
952 | int op_ret, int op_errno, struct iovec *vector, | |||
953 | int count, struct iatt *stbuf, struct iobref *iobref, | |||
954 | dict_t *xdata) | |||
955 | { | |||
956 | STACK_UNWIND_STRICT (readv, frame, op_ret, op_errno, vector, count,do { fop_readv_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 957, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_readv_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, vector, count, stbuf, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
957 | stbuf, iobref, xdata)do { fop_readv_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 957, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_readv_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, vector, count, stbuf, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
958 | return 0; | |||
959 | } | |||
960 | ||||
961 | ||||
962 | int | |||
963 | posix_acl_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, | |||
964 | size_t size, off_t offset, uint32_t flags, dict_t *xdata) | |||
965 | { | |||
966 | if (__is_fuse_call (frame)) | |||
967 | goto green; | |||
968 | ||||
969 | if (acl_permits (frame, fd->inode, POSIX_ACL_READ(0x04))) | |||
970 | goto green; | |||
971 | else | |||
972 | goto red; | |||
973 | ||||
974 | green: | |||
975 | STACK_WIND (frame, posix_acl_readv_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 977, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readv_cbk) tmp_cbk = posix_acl_readv_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->readv"; _new ->unwind_to = "posix_acl_readv_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readv); (this->children->xlator )->fops->readv (_new, (this->children->xlator), fd , size, offset, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
976 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 977, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readv_cbk) tmp_cbk = posix_acl_readv_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->readv"; _new ->unwind_to = "posix_acl_readv_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readv); (this->children->xlator )->fops->readv (_new, (this->children->xlator), fd , size, offset, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
977 | fd, size, offset, flags, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 977, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readv_cbk) tmp_cbk = posix_acl_readv_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->readv"; _new ->unwind_to = "posix_acl_readv_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readv); (this->children->xlator )->fops->readv (_new, (this->children->xlator), fd , size, offset, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
978 | return 0; | |||
979 | red: | |||
980 | STACK_UNWIND_STRICT (readv, frame, -1, EACCES, NULL, 0, NULL, NULL, xdata)do { fop_readv_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 980, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_readv_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), 0, ((void*)0), ((void*)0), xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
981 | return 0; | |||
982 | } | |||
983 | ||||
984 | ||||
985 | int | |||
986 | posix_acl_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
987 | int op_ret, int op_errno, | |||
988 | struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata) | |||
989 | { | |||
990 | STACK_UNWIND_STRICT (writev, frame, op_ret, op_errno,do { fop_writev_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 991, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_writev_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
991 | prebuf, postbuf, xdata)do { fop_writev_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 991, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_writev_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
992 | return 0; | |||
993 | } | |||
994 | ||||
995 | ||||
996 | int | |||
997 | posix_acl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, | |||
998 | struct iovec *vector, int count, off_t offset, | |||
999 | uint32_t flags, struct iobref *iobref, dict_t *xdata) | |||
1000 | { | |||
1001 | if (__is_fuse_call (frame)) | |||
1002 | goto green; | |||
1003 | ||||
1004 | if (acl_permits (frame, fd->inode, POSIX_ACL_WRITE(0x02))) | |||
1005 | goto green; | |||
1006 | else | |||
1007 | goto red; | |||
1008 | ||||
1009 | green: | |||
1010 | STACK_WIND (frame, posix_acl_writev_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1012, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->writev_cbk) tmp_cbk = posix_acl_writev_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->writev"; _new->unwind_to = "posix_acl_writev_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->writev); (this->children->xlator )->fops->writev (_new, (this->children->xlator), fd , vector, count, offset, flags, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1011 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1012, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->writev_cbk) tmp_cbk = posix_acl_writev_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->writev"; _new->unwind_to = "posix_acl_writev_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->writev); (this->children->xlator )->fops->writev (_new, (this->children->xlator), fd , vector, count, offset, flags, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1012 | fd, vector, count, offset, flags, iobref, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1012, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->writev_cbk) tmp_cbk = posix_acl_writev_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->writev"; _new->unwind_to = "posix_acl_writev_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->writev); (this->children->xlator )->fops->writev (_new, (this->children->xlator), fd , vector, count, offset, flags, iobref, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1013 | return 0; | |||
1014 | red: | |||
1015 | STACK_UNWIND_STRICT (writev, frame, -1, EACCES, NULL, NULL, xdata)do { fop_writev_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1015, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_writev_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1016 | return 0; | |||
1017 | } | |||
1018 | ||||
1019 | ||||
1020 | ||||
1021 | int | |||
1022 | posix_acl_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1023 | int op_ret, int op_errno, struct iatt *prebuf, | |||
1024 | struct iatt *postbuf, dict_t *xdata) | |||
1025 | { | |||
1026 | STACK_UNWIND_STRICT (ftruncate, frame, op_ret, op_errno,do { fop_ftruncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1027, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_ftruncate_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1027 | prebuf, postbuf, xdata)do { fop_ftruncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1027, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_ftruncate_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1028 | return 0; | |||
1029 | } | |||
1030 | ||||
1031 | ||||
1032 | int | |||
1033 | posix_acl_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, | |||
1034 | off_t offset, dict_t *xdata) | |||
1035 | { | |||
1036 | if (__is_fuse_call (frame)) | |||
1037 | goto green; | |||
1038 | ||||
1039 | if (acl_permits (frame, fd->inode, POSIX_ACL_WRITE(0x02))) | |||
1040 | goto green; | |||
1041 | else | |||
1042 | goto red; | |||
1043 | ||||
1044 | green: | |||
1045 | STACK_WIND (frame, posix_acl_ftruncate_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1047, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->ftruncate_cbk) tmp_cbk = posix_acl_ftruncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->ftruncate" ; _new->unwind_to = "posix_acl_ftruncate_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->ftruncate); (this->children-> xlator)->fops->ftruncate (_new, (this->children-> xlator), fd, offset, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1046 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->ftruncate,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1047, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->ftruncate_cbk) tmp_cbk = posix_acl_ftruncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->ftruncate" ; _new->unwind_to = "posix_acl_ftruncate_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->ftruncate); (this->children-> xlator)->fops->ftruncate (_new, (this->children-> xlator), fd, offset, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1047 | fd, offset, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1047, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->ftruncate_cbk) tmp_cbk = posix_acl_ftruncate_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->ftruncate" ; _new->unwind_to = "posix_acl_ftruncate_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->ftruncate); (this->children-> xlator)->fops->ftruncate (_new, (this->children-> xlator), fd, offset, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1048 | return 0; | |||
1049 | red: | |||
1050 | STACK_UNWIND_STRICT (ftruncate, frame, -1, EACCES, NULL, NULL, xdata)do { fop_ftruncate_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1050, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_ftruncate_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1051 | return 0; | |||
1052 | } | |||
1053 | ||||
1054 | ||||
1055 | int | |||
1056 | posix_acl_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1057 | int op_ret, int op_errno, fd_t *fd, dict_t *xdata) | |||
1058 | { | |||
1059 | STACK_UNWIND_STRICT (opendir, frame, op_ret, op_errno, fd, xdata)do { fop_opendir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1059, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_opendir_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1060 | ||||
1061 | return 0; | |||
1062 | } | |||
1063 | ||||
1064 | ||||
1065 | int | |||
1066 | posix_acl_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, dict_t *xdata) | |||
1067 | { | |||
1068 | if (acl_permits (frame, loc->inode, POSIX_ACL_READ(0x04))) | |||
1069 | goto green; | |||
1070 | else | |||
1071 | goto red; | |||
1072 | green: | |||
1073 | STACK_WIND (frame, posix_acl_opendir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1075, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->opendir_cbk) tmp_cbk = posix_acl_opendir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->opendir" ; _new->unwind_to = "posix_acl_opendir_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->opendir); (this->children->xlator )->fops->opendir (_new, (this->children->xlator), loc, fd, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1074 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->opendir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1075, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->opendir_cbk) tmp_cbk = posix_acl_opendir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->opendir" ; _new->unwind_to = "posix_acl_opendir_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->opendir); (this->children->xlator )->fops->opendir (_new, (this->children->xlator), loc, fd, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1075 | loc, fd, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1075, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->opendir_cbk) tmp_cbk = posix_acl_opendir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->opendir" ; _new->unwind_to = "posix_acl_opendir_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->opendir); (this->children->xlator )->fops->opendir (_new, (this->children->xlator), loc, fd, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1076 | return 0; | |||
1077 | red: | |||
1078 | STACK_UNWIND_STRICT (opendir, frame, -1, EACCES, NULL, xdata)do { fop_opendir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1078, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_opendir_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1079 | return 0; | |||
1080 | } | |||
1081 | ||||
1082 | ||||
1083 | int | |||
1084 | posix_acl_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1085 | int op_ret, int op_errno, inode_t *inode, struct iatt *buf, | |||
1086 | struct iatt *preparent, struct iatt *postparent, | |||
1087 | dict_t *xdata) | |||
1088 | { | |||
1089 | if (op_ret != 0) | |||
1090 | goto unwind; | |||
1091 | ||||
1092 | posix_acl_ctx_update (inode, this, buf); | |||
1093 | ||||
1094 | unwind: | |||
1095 | STACK_UNWIND_STRICT (mkdir, frame, op_ret, op_errno, inode, buf,do { fop_mkdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1096, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_mkdir_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, preparent, postparent, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1096 | preparent, postparent, xdata)do { fop_mkdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1096, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_mkdir_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, preparent, postparent, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1097 | return 0; | |||
1098 | } | |||
1099 | ||||
1100 | ||||
1101 | int | |||
1102 | posix_acl_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, | |||
1103 | mode_t umask, dict_t *xdata) | |||
1104 | { | |||
1105 | mode_t newmode = 0; | |||
1106 | ||||
1107 | newmode = mode; | |||
1108 | if (acl_permits (frame, loc->parent, POSIX_ACL_WRITE(0x02)|POSIX_ACL_EXECUTE(0x01))) | |||
1109 | goto green; | |||
1110 | else | |||
1111 | goto red; | |||
1112 | green: | |||
1113 | newmode = posix_acl_inherit_dir (this, loc, xdata, mode, umask); | |||
1114 | ||||
1115 | STACK_WIND (frame, posix_acl_mkdir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1117, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->mkdir_cbk) tmp_cbk = posix_acl_mkdir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->mkdir"; _new ->unwind_to = "posix_acl_mkdir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->mkdir); (this->children->xlator )->fops->mkdir (_new, (this->children->xlator), loc , newmode, umask, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1116 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->mkdir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1117, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->mkdir_cbk) tmp_cbk = posix_acl_mkdir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->mkdir"; _new ->unwind_to = "posix_acl_mkdir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->mkdir); (this->children->xlator )->fops->mkdir (_new, (this->children->xlator), loc , newmode, umask, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1117 | loc, newmode, umask, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1117, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->mkdir_cbk) tmp_cbk = posix_acl_mkdir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->mkdir"; _new ->unwind_to = "posix_acl_mkdir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->mkdir); (this->children->xlator )->fops->mkdir (_new, (this->children->xlator), loc , newmode, umask, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1118 | return 0; | |||
1119 | red: | |||
1120 | STACK_UNWIND_STRICT (mkdir, frame, -1, EACCES, NULL, NULL, NULL, NULL,do { fop_mkdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1121, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_mkdir_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), ((void*)0), ((void*)0), ((void* )0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1121 | NULL)do { fop_mkdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1121, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_mkdir_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), ((void*)0), ((void*)0), ((void* )0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1122 | return 0; | |||
1123 | } | |||
1124 | ||||
1125 | ||||
1126 | int | |||
1127 | posix_acl_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1128 | int op_ret, int op_errno, inode_t *inode, struct iatt *buf, | |||
1129 | struct iatt *preparent, struct iatt *postparent, | |||
1130 | dict_t *xdata) | |||
1131 | { | |||
1132 | if (op_ret != 0) | |||
1133 | goto unwind; | |||
1134 | ||||
1135 | posix_acl_ctx_update (inode, this, buf); | |||
1136 | ||||
1137 | unwind: | |||
1138 | STACK_UNWIND_STRICT (mknod, frame, op_ret, op_errno, inode, buf,do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1139, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_mknod_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, preparent, postparent, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1139 | preparent, postparent, xdata)do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1139, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_mknod_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, preparent, postparent, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1140 | return 0; | |||
1141 | } | |||
1142 | ||||
1143 | ||||
1144 | int | |||
1145 | posix_acl_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, | |||
1146 | dev_t rdev, mode_t umask, dict_t *xdata) | |||
1147 | { | |||
1148 | mode_t newmode = 0; | |||
1149 | ||||
1150 | newmode = mode; | |||
1151 | if (acl_permits (frame, loc->parent, POSIX_ACL_WRITE(0x02)|POSIX_ACL_EXECUTE(0x01))) | |||
1152 | goto green; | |||
1153 | else | |||
1154 | goto red; | |||
1155 | green: | |||
1156 | newmode = posix_acl_inherit_file (this, loc, xdata, mode, umask); | |||
1157 | ||||
1158 | STACK_WIND (frame, posix_acl_mknod_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1160, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->mknod_cbk) tmp_cbk = posix_acl_mknod_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->mknod"; _new ->unwind_to = "posix_acl_mknod_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->mknod); (this->children->xlator )->fops->mknod (_new, (this->children->xlator), loc , newmode, rdev, umask, xdata); (*__glusterfs_this_location() ) = old_THIS; } while (0) | |||
1159 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->mknod,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1160, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->mknod_cbk) tmp_cbk = posix_acl_mknod_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->mknod"; _new ->unwind_to = "posix_acl_mknod_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->mknod); (this->children->xlator )->fops->mknod (_new, (this->children->xlator), loc , newmode, rdev, umask, xdata); (*__glusterfs_this_location() ) = old_THIS; } while (0) | |||
1160 | loc, newmode, rdev, umask, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1160, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->mknod_cbk) tmp_cbk = posix_acl_mknod_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->mknod"; _new ->unwind_to = "posix_acl_mknod_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->mknod); (this->children->xlator )->fops->mknod (_new, (this->children->xlator), loc , newmode, rdev, umask, xdata); (*__glusterfs_this_location() ) = old_THIS; } while (0); | |||
1161 | return 0; | |||
1162 | red: | |||
1163 | STACK_UNWIND_STRICT (mknod, frame, -1, EACCES, NULL, NULL, NULL, NULL,do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1164, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_mknod_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), ((void*)0), ((void*)0), ((void* )0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1164 | NULL)do { fop_mknod_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1164, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_mknod_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), ((void*)0), ((void*)0), ((void* )0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1165 | return 0; | |||
1166 | } | |||
1167 | ||||
1168 | ||||
1169 | int | |||
1170 | posix_acl_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1171 | int op_ret, int op_errno, fd_t *fd, inode_t *inode, | |||
1172 | struct iatt *buf, struct iatt *preparent, | |||
1173 | struct iatt *postparent, dict_t *xdata) | |||
1174 | { | |||
1175 | if (op_ret != 0) | |||
1176 | goto unwind; | |||
1177 | ||||
1178 | posix_acl_ctx_update (inode, this, buf); | |||
1179 | ||||
1180 | unwind: | |||
1181 | STACK_UNWIND_STRICT (create, frame, op_ret, op_errno, fd, inode, buf,do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1182, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_create_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, inode, buf, preparent, postparent, xdata); (* __glusterfs_this_location()) = old_THIS; } while (0) | |||
1182 | preparent, postparent, xdata)do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1182, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_create_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, fd, inode, buf, preparent, postparent, xdata); (* __glusterfs_this_location()) = old_THIS; } while (0); | |||
1183 | return 0; | |||
1184 | } | |||
1185 | ||||
1186 | ||||
1187 | int | |||
1188 | posix_acl_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, | |||
1189 | mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata) | |||
1190 | { | |||
1191 | mode_t newmode = 0; | |||
1192 | ||||
1193 | newmode = mode; | |||
1194 | if (acl_permits (frame, loc->parent, POSIX_ACL_WRITE(0x02)|POSIX_ACL_EXECUTE(0x01))) | |||
1195 | goto green; | |||
1196 | else | |||
1197 | goto red; | |||
1198 | green: | |||
1199 | newmode = posix_acl_inherit_file (this, loc, xdata, mode, umask); | |||
1200 | ||||
1201 | STACK_WIND (frame, posix_acl_create_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1203, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->create_cbk) tmp_cbk = posix_acl_create_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->create"; _new->unwind_to = "posix_acl_create_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->create); (this->children->xlator )->fops->create (_new, (this->children->xlator), loc , flags, newmode, umask, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1202 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->create,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1203, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->create_cbk) tmp_cbk = posix_acl_create_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->create"; _new->unwind_to = "posix_acl_create_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->create); (this->children->xlator )->fops->create (_new, (this->children->xlator), loc , flags, newmode, umask, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1203 | loc, flags, newmode, umask, fd, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1203, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->create_cbk) tmp_cbk = posix_acl_create_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->create"; _new->unwind_to = "posix_acl_create_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->create); (this->children->xlator )->fops->create (_new, (this->children->xlator), loc , flags, newmode, umask, fd, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1204 | return 0; | |||
1205 | red: | |||
1206 | STACK_UNWIND_STRICT (create, frame, -1, EACCES, NULL, NULL, NULL,do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1207, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_create_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), ((void*)0), ((void*)0), ((void* )0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1207 | NULL, NULL, NULL)do { fop_create_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1207, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_create_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), ((void*)0), ((void*)0), ((void* )0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1208 | return 0; | |||
1209 | } | |||
1210 | ||||
1211 | ||||
1212 | int | |||
1213 | posix_acl_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1214 | int op_ret, int op_errno, inode_t *inode, | |||
1215 | struct iatt *buf, struct iatt *preparent, | |||
1216 | struct iatt *postparent, dict_t *xdata) | |||
1217 | { | |||
1218 | if (op_ret != 0) | |||
1219 | goto unwind; | |||
1220 | ||||
1221 | posix_acl_ctx_update (inode, this, buf); | |||
1222 | ||||
1223 | unwind: | |||
1224 | STACK_UNWIND_STRICT (symlink, frame, op_ret, op_errno, inode, buf,do { fop_symlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1225, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_symlink_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, preparent, postparent, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1225 | preparent, postparent, xdata)do { fop_symlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1225, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_symlink_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, preparent, postparent, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1226 | return 0; | |||
1227 | } | |||
1228 | ||||
1229 | ||||
1230 | int | |||
1231 | posix_acl_symlink (call_frame_t *frame, xlator_t *this, const char *linkname, | |||
1232 | loc_t *loc, mode_t umask, dict_t *xdata) | |||
1233 | { | |||
1234 | if (acl_permits (frame, loc->parent, POSIX_ACL_WRITE(0x02)|POSIX_ACL_EXECUTE(0x01))) | |||
1235 | goto green; | |||
1236 | else | |||
1237 | goto red; | |||
1238 | green: | |||
1239 | STACK_WIND (frame, posix_acl_symlink_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1241, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->symlink_cbk) tmp_cbk = posix_acl_symlink_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->symlink" ; _new->unwind_to = "posix_acl_symlink_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->symlink); (this->children->xlator )->fops->symlink (_new, (this->children->xlator), linkname, loc, umask, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1240 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->symlink,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1241, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->symlink_cbk) tmp_cbk = posix_acl_symlink_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->symlink" ; _new->unwind_to = "posix_acl_symlink_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->symlink); (this->children->xlator )->fops->symlink (_new, (this->children->xlator), linkname, loc, umask, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1241 | linkname, loc, umask, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1241, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->symlink_cbk) tmp_cbk = posix_acl_symlink_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->symlink" ; _new->unwind_to = "posix_acl_symlink_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->symlink); (this->children->xlator )->fops->symlink (_new, (this->children->xlator), linkname, loc, umask, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1242 | return 0; | |||
1243 | red: | |||
1244 | STACK_UNWIND_STRICT (symlink, frame, -1, EACCES, NULL, NULL, NULL,do { fop_symlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1245, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_symlink_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), ((void*)0), ((void*)0), xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1245 | NULL, xdata)do { fop_symlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1245, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_symlink_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), ((void*)0), ((void*)0), xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1246 | return 0; | |||
1247 | } | |||
1248 | ||||
1249 | ||||
1250 | int | |||
1251 | posix_acl_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1252 | int op_ret, int op_errno, struct iatt *preparent, | |||
1253 | struct iatt *postparent, dict_t *xdata) | |||
1254 | { | |||
1255 | if (op_ret != 0) | |||
1256 | goto unwind; | |||
1257 | unwind: | |||
1258 | STACK_UNWIND_STRICT (unlink, frame, op_ret, op_errno,do { fop_unlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1259, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_unlink_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, preparent, postparent, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1259 | preparent, postparent, xdata)do { fop_unlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1259, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_unlink_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, preparent, postparent, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1260 | return 0; | |||
1261 | } | |||
1262 | ||||
1263 | ||||
1264 | int | |||
1265 | posix_acl_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, | |||
1266 | dict_t *xdata) | |||
1267 | { | |||
1268 | if (!sticky_permits (frame, loc->parent, loc->inode)) | |||
1269 | goto red; | |||
1270 | ||||
1271 | if (acl_permits (frame, loc->parent, POSIX_ACL_WRITE(0x02)|POSIX_ACL_EXECUTE(0x01))) | |||
1272 | goto green; | |||
1273 | else | |||
1274 | goto red; | |||
1275 | green: | |||
1276 | STACK_WIND (frame, posix_acl_unlink_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1278, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->unlink_cbk) tmp_cbk = posix_acl_unlink_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->unlink"; _new->unwind_to = "posix_acl_unlink_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->unlink); (this->children->xlator )->fops->unlink (_new, (this->children->xlator), loc , xflag, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1277 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->unlink,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1278, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->unlink_cbk) tmp_cbk = posix_acl_unlink_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->unlink"; _new->unwind_to = "posix_acl_unlink_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->unlink); (this->children->xlator )->fops->unlink (_new, (this->children->xlator), loc , xflag, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1278 | loc, xflag, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1278, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->unlink_cbk) tmp_cbk = posix_acl_unlink_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->unlink"; _new->unwind_to = "posix_acl_unlink_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->unlink); (this->children->xlator )->fops->unlink (_new, (this->children->xlator), loc , xflag, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1279 | return 0; | |||
1280 | red: | |||
1281 | STACK_UNWIND_STRICT (unlink, frame, -1, EACCES, NULL, NULL, xdata)do { fop_unlink_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1281, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_unlink_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1282 | return 0; | |||
1283 | } | |||
1284 | ||||
1285 | ||||
1286 | int | |||
1287 | posix_acl_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1288 | int op_ret, int op_errno, | |||
1289 | struct iatt *preparent, struct iatt *postparent, dict_t *xdata) | |||
1290 | { | |||
1291 | if (op_ret != 0) | |||
1292 | goto unwind; | |||
1293 | unwind: | |||
1294 | STACK_UNWIND_STRICT (rmdir, frame, op_ret, op_errno,do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1295, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, preparent, postparent, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1295 | preparent, postparent, xdata)do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1295, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, preparent, postparent, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1296 | return 0; | |||
1297 | } | |||
1298 | ||||
1299 | ||||
1300 | int | |||
1301 | posix_acl_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, dict_t *xdata) | |||
1302 | { | |||
1303 | if (!sticky_permits (frame, loc->parent, loc->inode)) | |||
1304 | goto red; | |||
1305 | ||||
1306 | if (acl_permits (frame, loc->parent, POSIX_ACL_WRITE(0x02)|POSIX_ACL_EXECUTE(0x01))) | |||
1307 | goto green; | |||
1308 | else | |||
1309 | goto red; | |||
1310 | green: | |||
1311 | STACK_WIND (frame, posix_acl_rmdir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1313, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->rmdir_cbk) tmp_cbk = posix_acl_rmdir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->rmdir"; _new ->unwind_to = "posix_acl_rmdir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->rmdir); (this->children->xlator )->fops->rmdir (_new, (this->children->xlator), loc , flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1312 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->rmdir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1313, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->rmdir_cbk) tmp_cbk = posix_acl_rmdir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->rmdir"; _new ->unwind_to = "posix_acl_rmdir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->rmdir); (this->children->xlator )->fops->rmdir (_new, (this->children->xlator), loc , flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1313 | loc, flags, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1313, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->rmdir_cbk) tmp_cbk = posix_acl_rmdir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->rmdir"; _new ->unwind_to = "posix_acl_rmdir_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->rmdir); (this->children->xlator )->fops->rmdir (_new, (this->children->xlator), loc , flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1314 | return 0; | |||
1315 | red: | |||
1316 | STACK_UNWIND_STRICT (rmdir, frame, -1, EACCES, NULL, NULL, xdata)do { fop_rmdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1316, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_rmdir_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1317 | return 0; | |||
1318 | } | |||
1319 | ||||
1320 | ||||
1321 | int | |||
1322 | posix_acl_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1323 | int op_ret, int op_errno, struct iatt *buf, | |||
1324 | struct iatt *preoldparent, struct iatt *postoldparent, | |||
1325 | struct iatt *prenewparent, struct iatt *postnewparent, | |||
1326 | dict_t *xdata) | |||
1327 | { | |||
1328 | if (op_ret != 0) | |||
1329 | goto unwind; | |||
1330 | unwind: | |||
1331 | STACK_UNWIND_STRICT (rename, frame, op_ret, op_errno, buf,do { fop_rename_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1333, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_rename_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, buf, preoldparent, postoldparent, prenewparent, postnewparent , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) | |||
1332 | preoldparent, postoldparent,do { fop_rename_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1333, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_rename_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, buf, preoldparent, postoldparent, prenewparent, postnewparent , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0) | |||
1333 | prenewparent, postnewparent, xdata)do { fop_rename_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1333, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_rename_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, buf, preoldparent, postoldparent, prenewparent, postnewparent , xdata); (*__glusterfs_this_location()) = old_THIS; } while ( 0); | |||
1334 | return 0; | |||
1335 | } | |||
1336 | ||||
1337 | ||||
1338 | int | |||
1339 | posix_acl_rename (call_frame_t *frame, xlator_t *this, loc_t *old, loc_t *new, dict_t *xdata) | |||
1340 | { | |||
1341 | if (!acl_permits (frame, old->parent, POSIX_ACL_WRITE(0x02))) | |||
1342 | goto red; | |||
1343 | ||||
1344 | if (!acl_permits (frame, new->parent, POSIX_ACL_WRITE(0x02))) | |||
1345 | goto red; | |||
1346 | ||||
1347 | if (!sticky_permits (frame, old->parent, old->inode)) | |||
1348 | goto red; | |||
1349 | ||||
1350 | if (new->inode) { | |||
1351 | if (!sticky_permits (frame, new->parent, new->inode)) | |||
1352 | goto red; | |||
1353 | } | |||
1354 | ||||
1355 | STACK_WIND (frame, posix_acl_rename_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1357, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->rename_cbk) tmp_cbk = posix_acl_rename_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->rename"; _new->unwind_to = "posix_acl_rename_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->rename); (this->children->xlator )->fops->rename (_new, (this->children->xlator), old , new, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1356 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->rename,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1357, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->rename_cbk) tmp_cbk = posix_acl_rename_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->rename"; _new->unwind_to = "posix_acl_rename_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->rename); (this->children->xlator )->fops->rename (_new, (this->children->xlator), old , new, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1357 | old, new, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1357, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->rename_cbk) tmp_cbk = posix_acl_rename_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->rename"; _new->unwind_to = "posix_acl_rename_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->rename); (this->children->xlator )->fops->rename (_new, (this->children->xlator), old , new, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1358 | return 0; | |||
1359 | red: | |||
1360 | STACK_UNWIND_STRICT (rename, frame, -1, EACCES, NULL, NULL, NULL, NULL,do { fop_rename_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1361, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_rename_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), ((void*)0), ((void*)0), ((void* )0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1361 | NULL, NULL)do { fop_rename_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1361, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_rename_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), ((void*)0), ((void*)0), ((void* )0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1362 | return 0; | |||
1363 | } | |||
1364 | ||||
1365 | ||||
1366 | int | |||
1367 | posix_acl_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1368 | int op_ret, int op_errno, inode_t *inode, struct iatt *buf, | |||
1369 | struct iatt *preparent, struct iatt *postparent, dict_t *xdata) | |||
1370 | { | |||
1371 | if (op_ret != 0) | |||
1372 | goto unwind; | |||
1373 | unwind: | |||
1374 | STACK_UNWIND_STRICT (link, frame, op_ret, op_errno, inode, buf,do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = ( (void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1375, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, preparent, postparent, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1375 | preparent, postparent, xdata)do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = ( (void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1375, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, inode, buf, preparent, postparent, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1376 | return 0; | |||
1377 | } | |||
1378 | ||||
1379 | ||||
1380 | int | |||
1381 | posix_acl_link (call_frame_t *frame, xlator_t *this, loc_t *old, loc_t *new, dict_t *xdata) | |||
1382 | { | |||
1383 | struct posix_acl_ctx *ctx = NULL((void*)0); | |||
1384 | int op_errno = 0; | |||
1385 | ||||
1386 | ctx = posix_acl_ctx_get (old->inode, this); | |||
1387 | if (!ctx) { | |||
1388 | op_errno = EIO5; | |||
1389 | goto red; | |||
1390 | } | |||
1391 | ||||
1392 | if (!acl_permits (frame, new->parent, POSIX_ACL_WRITE(0x02))) { | |||
1393 | op_errno = EACCES13; | |||
1394 | goto red; | |||
1395 | } | |||
1396 | ||||
1397 | STACK_WIND (frame, posix_acl_link_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1399, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->link_cbk) tmp_cbk = posix_acl_link_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->link"; _new ->unwind_to = "posix_acl_link_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->link); (this->children->xlator )->fops->link (_new, (this->children->xlator), old , new, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1398 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->link,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1399, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->link_cbk) tmp_cbk = posix_acl_link_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->link"; _new ->unwind_to = "posix_acl_link_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->link); (this->children->xlator )->fops->link (_new, (this->children->xlator), old , new, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1399 | old, new, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1399, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->link_cbk) tmp_cbk = posix_acl_link_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->link"; _new ->unwind_to = "posix_acl_link_cbk"; pthread_spin_init (& _new->lock, 0); pthread_spin_lock (&frame->root-> stack_lock); { _new->next = frame->root->frames.next ; _new->prev = &frame->root->frames; if (frame-> root->frames.next) frame->root->frames.next->prev = _new; frame->root->frames.next = _new; frame->ref_count ++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->link); (this->children->xlator )->fops->link (_new, (this->children->xlator), old , new, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1400 | return 0; | |||
1401 | red: | |||
1402 | STACK_UNWIND_STRICT (link, frame, -1, op_errno, NULL, NULL, NULL, NULL, xdata)do { fop_link_cbk_t fn = ((void*)0); call_frame_t *_parent = ( (void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1402, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_link_cbk_t )frame->ret; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0), ((void*)0), ((void*)0), ((void*)0), xdata ); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1403 | ||||
1404 | return 0; | |||
1405 | } | |||
1406 | ||||
1407 | ||||
1408 | int | |||
1409 | posix_acl_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1410 | int op_ret, int op_errno, gf_dirent_t *entries, | |||
1411 | dict_t *xdata) | |||
1412 | { | |||
1413 | if (op_ret != 0) | |||
1414 | goto unwind; | |||
1415 | unwind: | |||
1416 | STACK_UNWIND_STRICT (readdir, frame, op_ret, op_errno, entries, xdata)do { fop_readdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1416, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_readdir_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, entries, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1417 | return 0; | |||
1418 | } | |||
1419 | ||||
1420 | ||||
1421 | int | |||
1422 | posix_acl_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, | |||
1423 | off_t offset, dict_t *xdata) | |||
1424 | { | |||
1425 | if (acl_permits (frame, fd->inode, POSIX_ACL_READ(0x04))) | |||
1426 | goto green; | |||
1427 | else | |||
1428 | goto red; | |||
1429 | green: | |||
1430 | STACK_WIND (frame, posix_acl_readdir_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1432, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readdir_cbk) tmp_cbk = posix_acl_readdir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->readdir" ; _new->unwind_to = "posix_acl_readdir_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readdir); (this->children->xlator )->fops->readdir (_new, (this->children->xlator), fd, size, offset, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1431 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdir,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1432, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readdir_cbk) tmp_cbk = posix_acl_readdir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->readdir" ; _new->unwind_to = "posix_acl_readdir_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readdir); (this->children->xlator )->fops->readdir (_new, (this->children->xlator), fd, size, offset, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1432 | fd, size, offset, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1432, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readdir_cbk) tmp_cbk = posix_acl_readdir_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->readdir" ; _new->unwind_to = "posix_acl_readdir_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readdir); (this->children->xlator )->fops->readdir (_new, (this->children->xlator), fd, size, offset, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1433 | return 0; | |||
1434 | red: | |||
1435 | STACK_UNWIND_STRICT (readdir, frame, -1, EACCES, NULL, xdata)do { fop_readdir_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1435, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_readdir_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1436 | ||||
1437 | return 0; | |||
1438 | } | |||
1439 | ||||
1440 | ||||
1441 | int | |||
1442 | posix_acl_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1443 | int op_ret, int op_errno, gf_dirent_t *entries, | |||
1444 | dict_t *xdata) | |||
1445 | { | |||
1446 | gf_dirent_t *entry = NULL((void*)0); | |||
1447 | struct posix_acl *acl_access = NULL((void*)0); | |||
1448 | struct posix_acl *acl_default = NULL((void*)0); | |||
1449 | data_t *data = NULL((void*)0); | |||
1450 | int ret = 0; | |||
1451 | ||||
1452 | if (op_ret <= 0) | |||
1453 | goto unwind; | |||
1454 | ||||
1455 | list_for_each_entry (entry, &entries->list, list)for (entry = ((typeof(*entry) *)((char *)((&entries->list )->next)-(unsigned long)(&((typeof(*entry) *)0)->list ))); &entry->list != (&entries->list); entry = ( (typeof(*entry) *)((char *)(entry->list.next)-(unsigned long )(&((typeof(*entry) *)0)->list)))) { | |||
1456 | /* Update the inode ctx */ | |||
1457 | if (!entry->dict || !entry->inode) | |||
1458 | continue; | |||
1459 | ||||
1460 | ret = posix_acl_get (entry->inode, this, | |||
1461 | &acl_access, &acl_default); | |||
1462 | ||||
1463 | data = dict_get (entry->dict, POSIX_ACL_ACCESS_XATTR"system.posix_acl_access"); | |||
1464 | if (!data) | |||
1465 | goto acl_default; | |||
1466 | ||||
1467 | if (acl_access && | |||
1468 | posix_acl_matches_xattr (this, acl_access, data->data, | |||
1469 | data->len)) | |||
1470 | goto acl_default; | |||
1471 | ||||
1472 | if (acl_access) | |||
1473 | posix_acl_unref(this, acl_access); | |||
1474 | ||||
1475 | acl_access = posix_acl_from_xattr (this, data->data, | |||
1476 | data->len); | |||
1477 | ||||
1478 | acl_default: | |||
1479 | data = dict_get (entry->dict, POSIX_ACL_DEFAULT_XATTR"system.posix_acl_default"); | |||
1480 | if (!data) | |||
1481 | goto acl_set; | |||
1482 | ||||
1483 | if (acl_default && | |||
1484 | posix_acl_matches_xattr (this, acl_default, data->data, | |||
1485 | data->len)) | |||
1486 | goto acl_set; | |||
1487 | ||||
1488 | if (acl_default) | |||
1489 | posix_acl_unref(this, acl_default); | |||
1490 | ||||
1491 | acl_default = posix_acl_from_xattr (this, data->data, | |||
1492 | data->len); | |||
1493 | ||||
1494 | acl_set: | |||
1495 | posix_acl_ctx_update (entry->inode, this, &entry->d_stat); | |||
1496 | ||||
1497 | ret = posix_acl_set (entry->inode, this, | |||
1498 | acl_access, acl_default); | |||
1499 | if (ret) | |||
1500 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set ACL in context"); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__, 1501 , GF_LOG_WARNING, "failed to set ACL in context"); } while (0 ) | |||
1501 | "failed to set ACL in context")do { do { if (0) printf ("failed to set ACL in context"); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__, 1501 , GF_LOG_WARNING, "failed to set ACL in context"); } while (0 ); | |||
1502 | ||||
1503 | if (acl_access) | |||
1504 | posix_acl_unref(this, acl_access); | |||
1505 | if (acl_default) | |||
1506 | posix_acl_unref(this, acl_default); | |||
1507 | } | |||
1508 | ||||
1509 | unwind: | |||
1510 | STACK_UNWIND_STRICT (readdirp, frame, op_ret, op_errno, entries, xdata)do { fop_readdirp_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1510, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_readdirp_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, entries, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1511 | return 0; | |||
1512 | } | |||
1513 | ||||
1514 | ||||
1515 | int | |||
1516 | posix_acl_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, | |||
1517 | off_t offset, dict_t *dict) | |||
1518 | { | |||
1519 | int ret = 0; | |||
1520 | dict_t *alloc_dict = NULL((void*)0); | |||
1521 | ||||
1522 | if (acl_permits (frame, fd->inode, POSIX_ACL_READ(0x04))) | |||
1523 | goto green; | |||
1524 | else | |||
1525 | goto red; | |||
1526 | green: | |||
1527 | if (!dict) | |||
1528 | dict = alloc_dict = dict_new (); | |||
1529 | ||||
1530 | if (dict) { | |||
1531 | ret = dict_set_int8 (dict, POSIX_ACL_ACCESS_XATTR"system.posix_acl_access", 0); | |||
1532 | if (ret) | |||
1533 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set key %s", "system.posix_acl_access" ); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__ , 1535, GF_LOG_WARNING, "failed to set key %s", "system.posix_acl_access" ); } while (0) | |||
1534 | "failed to set key %s",do { do { if (0) printf ("failed to set key %s", "system.posix_acl_access" ); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__ , 1535, GF_LOG_WARNING, "failed to set key %s", "system.posix_acl_access" ); } while (0) | |||
1535 | POSIX_ACL_ACCESS_XATTR)do { do { if (0) printf ("failed to set key %s", "system.posix_acl_access" ); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__ , 1535, GF_LOG_WARNING, "failed to set key %s", "system.posix_acl_access" ); } while (0); | |||
1536 | ||||
1537 | ret = dict_set_int8 (dict, POSIX_ACL_DEFAULT_XATTR"system.posix_acl_default", 0); | |||
1538 | if (ret) | |||
1539 | gf_log (this->name, GF_LOG_WARNING,do { do { if (0) printf ("failed to set key %s", "system.posix_acl_default" ); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__ , 1541, GF_LOG_WARNING, "failed to set key %s", "system.posix_acl_default" ); } while (0) | |||
1540 | "failed to set key %s",do { do { if (0) printf ("failed to set key %s", "system.posix_acl_default" ); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__ , 1541, GF_LOG_WARNING, "failed to set key %s", "system.posix_acl_default" ); } while (0) | |||
1541 | POSIX_ACL_DEFAULT_XATTR)do { do { if (0) printf ("failed to set key %s", "system.posix_acl_default" ); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__ , 1541, GF_LOG_WARNING, "failed to set key %s", "system.posix_acl_default" ); } while (0); | |||
1542 | } | |||
1543 | ||||
1544 | STACK_WIND (frame, posix_acl_readdirp_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1546, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readdirp_cbk) tmp_cbk = posix_acl_readdirp_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->readdirp" ; _new->unwind_to = "posix_acl_readdirp_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readdirp); (this->children->xlator )->fops->readdirp (_new, (this->children->xlator) , fd, size, offset, dict); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1545 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdirp,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1546, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readdirp_cbk) tmp_cbk = posix_acl_readdirp_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->readdirp" ; _new->unwind_to = "posix_acl_readdirp_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readdirp); (this->children->xlator )->fops->readdirp (_new, (this->children->xlator) , fd, size, offset, dict); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1546 | fd, size, offset, dict)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1546, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->readdirp_cbk) tmp_cbk = posix_acl_readdirp_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->readdirp" ; _new->unwind_to = "posix_acl_readdirp_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->readdirp); (this->children->xlator )->fops->readdirp (_new, (this->children->xlator) , fd, size, offset, dict); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1547 | ||||
1548 | if (alloc_dict) | |||
1549 | dict_unref (alloc_dict); | |||
1550 | return 0; | |||
1551 | red: | |||
1552 | STACK_UNWIND_STRICT (readdirp, frame, -1, EACCES, NULL, NULL)do { fop_readdirp_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1552, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_readdirp_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0)); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1553 | ||||
1554 | return 0; | |||
1555 | } | |||
1556 | ||||
1557 | ||||
1558 | int | |||
1559 | setattr_scrutiny (call_frame_t *frame, inode_t *inode, struct iatt *buf, | |||
1560 | int valid) | |||
1561 | { | |||
1562 | struct posix_acl_ctx *ctx = NULL((void*)0); | |||
1563 | ||||
1564 | if (frame_is_super_user (frame)) | |||
1565 | return 0; | |||
1566 | ||||
1567 | ctx = posix_acl_ctx_get (inode, frame->this); | |||
1568 | if (!ctx) | |||
1569 | return EIO5; | |||
1570 | ||||
1571 | if (valid & GF_SET_ATTR_MODE0x1) { | |||
1572 | /* | |||
1573 | The effective UID of the calling process must match the owner of the | |||
1574 | file, or the process must be privileged | |||
1575 | */ | |||
1576 | if (!frame_is_user (frame, ctx->uid)) | |||
1577 | return EPERM1; | |||
1578 | /* | |||
1579 | If the calling process is not privileged (Linux: does not have the | |||
1580 | CAP_FSETID capability), and the group of the file does not match the | |||
1581 | effective group ID of the process or one of its supplementary group | |||
1582 | IDs, the S_ISGID bit will be turned off, but this will not cause an | |||
1583 | error to be returned. | |||
1584 | ||||
1585 | */ | |||
1586 | if (!frame_in_group (frame, ctx->gid)) | |||
1587 | buf->ia_prot.sgid = 0; | |||
1588 | } | |||
1589 | ||||
1590 | if (valid & (GF_SET_ATTR_ATIME0x10 | GF_SET_ATTR_MTIME0x20)) { | |||
1591 | /* | |||
1592 | Changing timestamps is permitted when: either the process has appropri? | |||
1593 | ate privileges, or the effective user ID equals the user ID of the | |||
1594 | file, or times is NULL and the process has write permission for the | |||
1595 | file. | |||
1596 | */ | |||
1597 | if (!frame_is_user (frame, ctx->uid) && | |||
1598 | !acl_permits (frame, inode, POSIX_ACL_WRITE(0x02))) | |||
1599 | return EACCES13; | |||
1600 | } | |||
1601 | ||||
1602 | if (valid & GF_SET_ATTR_UID0x2) { | |||
1603 | if ((!frame_is_super_user (frame)) && | |||
1604 | (buf->ia_uid != ctx->uid)) | |||
1605 | return EPERM1; | |||
1606 | } | |||
1607 | ||||
1608 | if (valid & GF_SET_ATTR_GID0x4) { | |||
1609 | if (!frame_is_user (frame, ctx->uid)) | |||
1610 | return EPERM1; | |||
1611 | if (!frame_in_group (frame, buf->ia_gid)) | |||
1612 | return EPERM1; | |||
1613 | } | |||
1614 | ||||
1615 | return 0; | |||
1616 | } | |||
1617 | ||||
1618 | ||||
1619 | int | |||
1620 | posix_acl_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1621 | int op_ret, int op_errno, | |||
1622 | struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata) | |||
1623 | { | |||
1624 | inode_t *inode = NULL((void*)0); | |||
1625 | ||||
1626 | inode = frame->local; | |||
1627 | frame->local = NULL((void*)0); | |||
1628 | ||||
1629 | if (op_ret != 0) | |||
1630 | goto unwind; | |||
1631 | ||||
1632 | posix_acl_ctx_update (inode, this, postbuf); | |||
1633 | ||||
1634 | unwind: | |||
1635 | STACK_UNWIND_STRICT (setattr, frame, op_ret, op_errno, prebuf,do { fop_setattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1636, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_setattr_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1636 | postbuf, xdata)do { fop_setattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1636, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_setattr_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1637 | return 0; | |||
1638 | } | |||
1639 | ||||
1640 | ||||
1641 | int | |||
1642 | posix_acl_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, | |||
1643 | struct iatt *buf, int valid, dict_t *xdata) | |||
1644 | { | |||
1645 | int op_errno = 0; | |||
1646 | ||||
1647 | op_errno = setattr_scrutiny (frame, loc->inode, buf, valid); | |||
1648 | ||||
1649 | if (op_errno) | |||
1650 | goto red; | |||
1651 | ||||
1652 | frame->local = loc->inode; | |||
1653 | ||||
1654 | STACK_WIND (frame, posix_acl_setattr_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1656, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->setattr_cbk) tmp_cbk = posix_acl_setattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->setattr" ; _new->unwind_to = "posix_acl_setattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->setattr); (this->children->xlator )->fops->setattr (_new, (this->children->xlator), loc, buf, valid, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1655 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->setattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1656, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->setattr_cbk) tmp_cbk = posix_acl_setattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->setattr" ; _new->unwind_to = "posix_acl_setattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->setattr); (this->children->xlator )->fops->setattr (_new, (this->children->xlator), loc, buf, valid, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1656 | loc, buf, valid, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1656, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->setattr_cbk) tmp_cbk = posix_acl_setattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->setattr" ; _new->unwind_to = "posix_acl_setattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->setattr); (this->children->xlator )->fops->setattr (_new, (this->children->xlator), loc, buf, valid, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1657 | return 0; | |||
1658 | red: | |||
1659 | STACK_UNWIND_STRICT (setattr, frame, -1, op_errno, NULL, NULL, xdata)do { fop_setattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1659, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_setattr_cbk_t )frame->ret ; _parent = frame->parent; pthread_spin_lock (&frame-> root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, ((void*)0), ((void*)0), xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1660 | ||||
1661 | return 0; | |||
1662 | } | |||
1663 | ||||
1664 | ||||
1665 | int | |||
1666 | posix_acl_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1667 | int op_ret, int op_errno, | |||
1668 | struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata) | |||
1669 | { | |||
1670 | inode_t *inode = NULL((void*)0); | |||
1671 | ||||
1672 | inode = frame->local; | |||
1673 | frame->local = NULL((void*)0); | |||
1674 | ||||
1675 | if (op_ret != 0) | |||
1676 | goto unwind; | |||
1677 | ||||
1678 | posix_acl_ctx_update (inode, this, postbuf); | |||
1679 | ||||
1680 | unwind: | |||
1681 | STACK_UNWIND_STRICT (fsetattr, frame, op_ret, op_errno, prebuf,do { fop_fsetattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1682, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_fsetattr_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1682 | postbuf, xdata)do { fop_fsetattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1682, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_fsetattr_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, prebuf, postbuf, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1683 | return 0; | |||
1684 | } | |||
1685 | ||||
1686 | ||||
1687 | int | |||
1688 | posix_acl_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, | |||
1689 | struct iatt *buf, int valid, dict_t *xdata) | |||
1690 | { | |||
1691 | int op_errno = 0; | |||
1692 | ||||
1693 | op_errno = setattr_scrutiny (frame, fd->inode, buf, valid); | |||
1694 | ||||
1695 | if (op_errno) | |||
1696 | goto red; | |||
1697 | ||||
1698 | frame->local = fd->inode; | |||
1699 | ||||
1700 | STACK_WIND (frame, posix_acl_fsetattr_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1702, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fsetattr_cbk) tmp_cbk = posix_acl_fsetattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fsetattr" ; _new->unwind_to = "posix_acl_fsetattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fsetattr); (this->children->xlator )->fops->fsetattr (_new, (this->children->xlator) , fd, buf, valid, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1701 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsetattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1702, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fsetattr_cbk) tmp_cbk = posix_acl_fsetattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fsetattr" ; _new->unwind_to = "posix_acl_fsetattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fsetattr); (this->children->xlator )->fops->fsetattr (_new, (this->children->xlator) , fd, buf, valid, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1702 | fd, buf, valid, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1702, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fsetattr_cbk) tmp_cbk = posix_acl_fsetattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fsetattr" ; _new->unwind_to = "posix_acl_fsetattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fsetattr); (this->children->xlator )->fops->fsetattr (_new, (this->children->xlator) , fd, buf, valid, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1703 | return 0; | |||
1704 | red: | |||
1705 | STACK_UNWIND_STRICT (fsetattr, frame, -1, EACCES, NULL, NULL, xdata)do { fop_fsetattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1705, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_fsetattr_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), ((void*)0), xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1706 | ||||
1707 | return 0; | |||
1708 | } | |||
1709 | ||||
1710 | ||||
1711 | int | |||
1712 | setxattr_scrutiny (call_frame_t *frame, inode_t *inode, dict_t *xattr) | |||
1713 | { | |||
1714 | struct posix_acl_ctx *ctx = NULL((void*)0); | |||
1715 | int found = 0; | |||
1716 | ||||
1717 | if (frame_is_super_user (frame)) | |||
1718 | return 0; | |||
1719 | ||||
1720 | ctx = posix_acl_ctx_get (inode, frame->this); | |||
1721 | if (!ctx) | |||
1722 | return EIO5; | |||
1723 | ||||
1724 | if (dict_get (xattr, POSIX_ACL_ACCESS_XATTR"system.posix_acl_access")) { | |||
1725 | found = 1; | |||
1726 | if (!frame_is_user (frame, ctx->uid)) | |||
1727 | return EPERM1; | |||
1728 | } | |||
1729 | ||||
1730 | if (dict_get (xattr, POSIX_ACL_DEFAULT_XATTR"system.posix_acl_default")) { | |||
1731 | found = 1; | |||
1732 | if (!frame_is_user (frame, ctx->uid)) | |||
1733 | return EPERM1; | |||
1734 | } | |||
1735 | ||||
1736 | if (!found && !acl_permits (frame, inode, POSIX_ACL_WRITE(0x02))) | |||
1737 | return EACCES13; | |||
1738 | ||||
1739 | return 0; | |||
1740 | } | |||
1741 | ||||
1742 | ||||
1743 | struct posix_acl * | |||
1744 | posix_acl_xattr_update (xlator_t *this, inode_t *inode, dict_t *xattr, | |||
1745 | char *name, struct posix_acl *old) | |||
1746 | { | |||
1747 | struct posix_acl *acl = NULL((void*)0); | |||
1748 | data_t *data = NULL((void*)0); | |||
1749 | ||||
1750 | data = dict_get (xattr, name); | |||
1751 | if (data) { | |||
1752 | acl = posix_acl_from_xattr (this, data->data, | |||
1753 | data->len); | |||
1754 | } | |||
1755 | ||||
1756 | if (!acl && old) | |||
1757 | acl = posix_acl_ref (this, old); | |||
1758 | ||||
1759 | return acl; | |||
1760 | } | |||
1761 | ||||
1762 | ||||
1763 | int | |||
1764 | posix_acl_setxattr_update (xlator_t *this, inode_t *inode, dict_t *xattr) | |||
1765 | { | |||
1766 | struct posix_acl *acl_access = NULL((void*)0); | |||
1767 | struct posix_acl *acl_default = NULL((void*)0); | |||
1768 | struct posix_acl *old_access = NULL((void*)0); | |||
1769 | struct posix_acl *old_default = NULL((void*)0); | |||
1770 | struct posix_acl_ctx *ctx = NULL((void*)0); | |||
1771 | int ret = 0; | |||
1772 | ||||
1773 | ctx = posix_acl_ctx_get (inode, this); | |||
1774 | if (!ctx) | |||
1775 | return -1; | |||
1776 | ||||
1777 | ret = posix_acl_get (inode, this, &old_access, &old_default); | |||
1778 | ||||
1779 | acl_access = posix_acl_xattr_update (this, inode, xattr, | |||
1780 | POSIX_ACL_ACCESS_XATTR"system.posix_acl_access", | |||
1781 | old_access); | |||
1782 | ||||
1783 | acl_default = posix_acl_xattr_update (this, inode, xattr, | |||
1784 | POSIX_ACL_DEFAULT_XATTR"system.posix_acl_default", | |||
1785 | old_default); | |||
1786 | ||||
1787 | ret = posix_acl_set (inode, this, acl_access, acl_default); | |||
1788 | ||||
1789 | if (acl_access && acl_access != old_access) { | |||
1790 | posix_acl_access_set_mode (acl_access, ctx); | |||
1791 | } | |||
1792 | ||||
1793 | if (acl_access) | |||
1794 | posix_acl_unref (this, acl_access); | |||
1795 | if (acl_default) | |||
1796 | posix_acl_unref (this, acl_default); | |||
1797 | if (old_access) | |||
1798 | posix_acl_unref (this, old_access); | |||
1799 | if (old_default) | |||
1800 | posix_acl_unref (this, old_default); | |||
1801 | ||||
1802 | return ret; | |||
1803 | } | |||
1804 | ||||
1805 | ||||
1806 | int | |||
1807 | posix_acl_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1808 | int op_ret, int op_errno, dict_t *xdata) | |||
1809 | { | |||
1810 | STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno, xdata)do { fop_setxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1810, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_setxattr_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1811 | ||||
1812 | return 0; | |||
1813 | } | |||
1814 | ||||
1815 | ||||
1816 | int | |||
1817 | posix_acl_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, | |||
1818 | dict_t *xattr, int flags, dict_t *xdata) | |||
1819 | { | |||
1820 | int op_errno = 0; | |||
1821 | ||||
1822 | op_errno = setxattr_scrutiny (frame, loc->inode, xattr); | |||
1823 | ||||
1824 | if (op_errno != 0) | |||
1825 | goto red; | |||
1826 | ||||
1827 | posix_acl_setxattr_update (this, loc->inode, xattr); | |||
1828 | ||||
1829 | STACK_WIND (frame, posix_acl_setxattr_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1831, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->setxattr_cbk) tmp_cbk = posix_acl_setxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr" ; _new->unwind_to = "posix_acl_setxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->setxattr); (this->children->xlator )->fops->setxattr (_new, (this->children->xlator) , loc, xattr, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1830 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->setxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1831, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->setxattr_cbk) tmp_cbk = posix_acl_setxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr" ; _new->unwind_to = "posix_acl_setxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->setxattr); (this->children->xlator )->fops->setxattr (_new, (this->children->xlator) , loc, xattr, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0) | |||
1831 | loc, xattr, flags, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1831, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->setxattr_cbk) tmp_cbk = posix_acl_setxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->setxattr" ; _new->unwind_to = "posix_acl_setxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->setxattr); (this->children->xlator )->fops->setxattr (_new, (this->children->xlator) , loc, xattr, flags, xdata); (*__glusterfs_this_location()) = old_THIS; } while (0); | |||
1832 | return 0; | |||
1833 | red: | |||
1834 | STACK_UNWIND_STRICT (setxattr, frame, -1, op_errno, xdata)do { fop_setxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1834, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_setxattr_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1835 | ||||
1836 | return 0; | |||
1837 | } | |||
1838 | ||||
1839 | ||||
1840 | int | |||
1841 | posix_acl_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1842 | int op_ret, int op_errno, dict_t *xdata) | |||
1843 | { | |||
1844 | STACK_UNWIND_STRICT (fsetxattr, frame, op_ret, op_errno, xdata)do { fop_fsetxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1844, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_fsetxattr_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1845 | ||||
1846 | return 0; | |||
1847 | } | |||
1848 | ||||
1849 | ||||
1850 | int | |||
1851 | posix_acl_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, | |||
1852 | dict_t *xattr, int flags, dict_t *xdata) | |||
1853 | { | |||
1854 | int op_errno = 0; | |||
1855 | ||||
1856 | op_errno = setxattr_scrutiny (frame, fd->inode, xattr); | |||
1857 | ||||
1858 | if (op_errno != 0) | |||
1859 | goto red; | |||
1860 | ||||
1861 | posix_acl_setxattr_update (this, fd->inode, xattr); | |||
1862 | ||||
1863 | STACK_WIND (frame, posix_acl_fsetxattr_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1865, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fsetxattr_cbk) tmp_cbk = posix_acl_fsetxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fsetxattr" ; _new->unwind_to = "posix_acl_fsetxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fsetxattr); (this->children-> xlator)->fops->fsetxattr (_new, (this->children-> xlator), fd, xattr, flags, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1864 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsetxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1865, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fsetxattr_cbk) tmp_cbk = posix_acl_fsetxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fsetxattr" ; _new->unwind_to = "posix_acl_fsetxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fsetxattr); (this->children-> xlator)->fops->fsetxattr (_new, (this->children-> xlator), fd, xattr, flags, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0) | |||
1865 | fd, xattr, flags, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1865, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fsetxattr_cbk) tmp_cbk = posix_acl_fsetxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fsetxattr" ; _new->unwind_to = "posix_acl_fsetxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fsetxattr); (this->children-> xlator)->fops->fsetxattr (_new, (this->children-> xlator), fd, xattr, flags, xdata); (*__glusterfs_this_location ()) = old_THIS; } while (0); | |||
1866 | return 0; | |||
1867 | red: | |||
1868 | STACK_UNWIND_STRICT (fsetxattr, frame, -1, op_errno, xdata)do { fop_fsetxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1868, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_fsetxattr_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1869 | ||||
1870 | return 0; | |||
1871 | } | |||
1872 | ||||
1873 | ||||
1874 | int | |||
1875 | posix_acl_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1876 | int op_ret, int op_errno, dict_t *xattr, dict_t *xdata) | |||
1877 | { | |||
1878 | STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, xattr, xdata)do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1878, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_getxattr_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, xattr, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1879 | ||||
1880 | return 0; | |||
1881 | } | |||
1882 | ||||
1883 | ||||
1884 | int | |||
1885 | posix_acl_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, | |||
1886 | const char *name, dict_t *xdata) | |||
1887 | { | |||
1888 | if (whitelisted_xattr (name)) | |||
1889 | goto green; | |||
1890 | ||||
1891 | if (acl_permits (frame, loc->inode, POSIX_ACL_READ(0x04))) | |||
1892 | goto green; | |||
1893 | else | |||
1894 | goto red; | |||
1895 | green: | |||
1896 | STACK_WIND (frame, posix_acl_getxattr_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1898, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->getxattr_cbk) tmp_cbk = posix_acl_getxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->getxattr" ; _new->unwind_to = "posix_acl_getxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->getxattr); (this->children->xlator )->fops->getxattr (_new, (this->children->xlator) , loc, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1897 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->getxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1898, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->getxattr_cbk) tmp_cbk = posix_acl_getxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->getxattr" ; _new->unwind_to = "posix_acl_getxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->getxattr); (this->children->xlator )->fops->getxattr (_new, (this->children->xlator) , loc, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1898 | loc, name, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1898, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->getxattr_cbk) tmp_cbk = posix_acl_getxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->getxattr" ; _new->unwind_to = "posix_acl_getxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->getxattr); (this->children->xlator )->fops->getxattr (_new, (this->children->xlator) , loc, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1899 | return 0; | |||
1900 | red: | |||
1901 | STACK_UNWIND_STRICT (getxattr, frame, -1, EACCES, NULL, xdata)do { fop_getxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1901, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_getxattr_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1902 | ||||
1903 | return 0; | |||
1904 | } | |||
1905 | ||||
1906 | ||||
1907 | int | |||
1908 | posix_acl_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1909 | int op_ret, int op_errno, dict_t *xattr, dict_t *xdata) | |||
1910 | { | |||
1911 | STACK_UNWIND_STRICT (fgetxattr, frame, op_ret, op_errno, xattr, xdata)do { fop_fgetxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1911, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_fgetxattr_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, xattr, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1912 | ||||
1913 | return 0; | |||
1914 | } | |||
1915 | ||||
1916 | ||||
1917 | int | |||
1918 | posix_acl_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, | |||
1919 | const char *name, dict_t *xdata) | |||
1920 | { | |||
1921 | if (whitelisted_xattr (name)) | |||
1922 | goto green; | |||
1923 | ||||
1924 | if (acl_permits (frame, fd->inode, POSIX_ACL_READ(0x04))) | |||
1925 | goto green; | |||
1926 | else | |||
1927 | goto red; | |||
1928 | green: | |||
1929 | STACK_WIND (frame, posix_acl_fgetxattr_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1931, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fgetxattr_cbk) tmp_cbk = posix_acl_fgetxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fgetxattr" ; _new->unwind_to = "posix_acl_fgetxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fgetxattr); (this->children-> xlator)->fops->fgetxattr (_new, (this->children-> xlator), fd, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1930 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->fgetxattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1931, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fgetxattr_cbk) tmp_cbk = posix_acl_fgetxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fgetxattr" ; _new->unwind_to = "posix_acl_fgetxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fgetxattr); (this->children-> xlator)->fops->fgetxattr (_new, (this->children-> xlator), fd, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1931 | fd, name, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1931, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->fgetxattr_cbk) tmp_cbk = posix_acl_fgetxattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->fgetxattr" ; _new->unwind_to = "posix_acl_fgetxattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->fgetxattr); (this->children-> xlator)->fops->fgetxattr (_new, (this->children-> xlator), fd, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1932 | return 0; | |||
1933 | red: | |||
1934 | STACK_UNWIND_STRICT (fgetxattr, frame, -1, EACCES, NULL, xdata)do { fop_fgetxattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1934, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_fgetxattr_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , 13, ((void*)0), xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1935 | ||||
1936 | return 0; | |||
1937 | } | |||
1938 | ||||
1939 | ||||
1940 | int | |||
1941 | posix_acl_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, | |||
1942 | int op_ret, int op_errno, dict_t *xdata) | |||
1943 | { | |||
1944 | STACK_UNWIND_STRICT (removexattr, frame, op_ret, op_errno, xdata)do { fop_removexattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1944, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_removexattr_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, op_ret , op_errno, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1945 | ||||
1946 | return 0; | |||
1947 | } | |||
1948 | ||||
1949 | ||||
1950 | int | |||
1951 | posix_acl_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc, | |||
1952 | const char *name, dict_t *xdata) | |||
1953 | { | |||
1954 | struct posix_acl_ctx *ctx = NULL((void*)0); | |||
1955 | int op_errno = EACCES13; | |||
1956 | ||||
1957 | if (frame_is_super_user (frame)) | |||
1958 | goto green; | |||
1959 | ||||
1960 | ctx = posix_acl_ctx_get (loc->inode, this); | |||
1961 | if (!ctx) { | |||
1962 | op_errno = EIO5; | |||
1963 | goto red; | |||
1964 | } | |||
1965 | ||||
1966 | if (whitelisted_xattr (name)) { | |||
1967 | if (!frame_is_user (frame, ctx->uid)) { | |||
1968 | op_errno = EPERM1; | |||
1969 | goto red; | |||
1970 | } | |||
1971 | } | |||
1972 | ||||
1973 | if (acl_permits (frame, loc->inode, POSIX_ACL_WRITE(0x02))) | |||
1974 | goto green; | |||
1975 | else | |||
1976 | goto red; | |||
1977 | green: | |||
1978 | STACK_WIND (frame, posix_acl_removexattr_cbk,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1980, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->removexattr_cbk) tmp_cbk = posix_acl_removexattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->removexattr" ; _new->unwind_to = "posix_acl_removexattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->removexattr); (this->children-> xlator)->fops->removexattr (_new, (this->children-> xlator), loc, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1979 | FIRST_CHILD(this), FIRST_CHILD(this)->fops->removexattr,do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1980, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->removexattr_cbk) tmp_cbk = posix_acl_removexattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->removexattr" ; _new->unwind_to = "posix_acl_removexattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->removexattr); (this->children-> xlator)->fops->removexattr (_new, (this->children-> xlator), loc, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0) | |||
1980 | loc, name, xdata)do { call_frame_t *_new = ((void*)0); xlator_t *old_THIS = (( void*)0); _new = mem_get0 (frame->root->pool->frame_mem_pool ); if (!_new) { do { do { if (0) printf ("alloc failed"); } while (0); _gf_log ("stack", "posix-acl.c", __FUNCTION__, 1980, GF_LOG_ERROR , "alloc failed"); } while (0); break; } typeof( (this->children ->xlator)->fops->removexattr_cbk) tmp_cbk = posix_acl_removexattr_cbk ; _new->root = frame->root; _new->this = (this->children ->xlator); _new->ret = (ret_fn_t) tmp_cbk; _new->parent = frame; _new->cookie = _new; _new->wind_from = __FUNCTION__ ; _new->wind_to = "FIRST_CHILD(this)->fops->removexattr" ; _new->unwind_to = "posix_acl_removexattr_cbk"; pthread_spin_init (&_new->lock, 0); pthread_spin_lock (&frame->root ->stack_lock); { _new->next = frame->root->frames .next; _new->prev = &frame->root->frames; if (frame ->root->frames.next) frame->root->frames.next-> prev = _new; frame->root->frames.next = _new; frame-> ref_count++; } pthread_spin_unlock (&frame->root->stack_lock ); old_THIS = (*__glusterfs_this_location()); (*__glusterfs_this_location ()) = (this->children->xlator); if (frame->this-> ctx->measure_latency) gf_latency_begin (_new, (this->children ->xlator)->fops->removexattr); (this->children-> xlator)->fops->removexattr (_new, (this->children-> xlator), loc, name, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1981 | return 0; | |||
1982 | red: | |||
1983 | STACK_UNWIND_STRICT (removexattr, frame, -1, op_errno, xdata)do { fop_removexattr_cbk_t fn = ((void*)0); call_frame_t *_parent = ((void*)0); xlator_t *old_THIS = ((void*)0); if (!frame) { do { do { if (0) printf ("!frame"); } while (0); _gf_log ("stack" , "posix-acl.c", __FUNCTION__, 1983, GF_LOG_CRITICAL, "!frame" ); } while (0); break; } fn = (fop_removexattr_cbk_t )frame-> ret; _parent = frame->parent; pthread_spin_lock (&frame ->root->stack_lock); { _parent->ref_count--; } pthread_spin_unlock (&frame->root->stack_lock); old_THIS = (*__glusterfs_this_location ()); (*__glusterfs_this_location()) = _parent->this; frame ->complete = _gf_true; frame->unwind_from = __FUNCTION__ ; if (frame->this->ctx->measure_latency) gf_latency_end (frame); fn (_parent, frame->cookie, _parent->this, -1 , op_errno, xdata); (*__glusterfs_this_location()) = old_THIS ; } while (0); | |||
1984 | ||||
1985 | return 0; | |||
1986 | } | |||
1987 | ||||
1988 | ||||
1989 | int | |||
1990 | posix_acl_forget (xlator_t *this, inode_t *inode) | |||
1991 | { | |||
1992 | struct posix_acl_ctx *ctx = NULL((void*)0); | |||
1993 | ||||
1994 | ctx = posix_acl_ctx_get (inode, this); | |||
1995 | if (!ctx) | |||
1996 | goto out; | |||
1997 | ||||
1998 | if (ctx->acl_access) | |||
1999 | posix_acl_unref (this, ctx->acl_access); | |||
2000 | ||||
2001 | if (ctx->acl_default) | |||
2002 | posix_acl_unref (this, ctx->acl_default); | |||
2003 | ||||
2004 | FREE (ctx)if (ctx != ((void*)0)) { free ((void *)ctx); ctx = (void *)0xeeeeeeee ; }; | |||
2005 | out: | |||
2006 | return 0; | |||
2007 | } | |||
2008 | ||||
2009 | ||||
2010 | int | |||
2011 | reconfigure (xlator_t *this, dict_t *options) | |||
2012 | { | |||
2013 | struct posix_acl_conf *conf = NULL((void*)0); | |||
2014 | ||||
2015 | conf = this->private; | |||
2016 | ||||
2017 | GF_OPTION_RECONF ("super-uid", conf->super_uid, options, uint32, err)do { int val_ret = 0; val_ret = xlator_option_reconf_uint32 ( (*__glusterfs_this_location()), options, "super-uid", &(conf ->super_uid)); if (val_ret) goto err; } while (0); | |||
2018 | ||||
2019 | return 0; | |||
2020 | err: | |||
2021 | return -1; | |||
2022 | } | |||
2023 | ||||
2024 | ||||
2025 | int | |||
2026 | init (xlator_t *this) | |||
2027 | { | |||
2028 | struct posix_acl_conf *conf = NULL((void*)0); | |||
2029 | struct posix_acl *minacl = NULL((void*)0); | |||
2030 | struct posix_ace *minace = NULL((void*)0); | |||
2031 | ||||
2032 | conf = CALLOC (1, sizeof (*conf))__gf_default_calloc(1,sizeof (*conf)); | |||
2033 | if (!conf) { | |||
2034 | gf_log (this->name, GF_LOG_ERROR,do { do { if (0) printf ("out of memory"); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__, 2035, GF_LOG_ERROR , "out of memory"); } while (0) | |||
2035 | "out of memory")do { do { if (0) printf ("out of memory"); } while (0); _gf_log (this->name, "posix-acl.c", __FUNCTION__, 2035, GF_LOG_ERROR , "out of memory"); } while (0); | |||
2036 | return -1; | |||
2037 | } | |||
2038 | ||||
2039 | LOCK_INIT (&conf->acl_lock)pthread_spin_init (&conf->acl_lock, 0); | |||
2040 | ||||
2041 | this->private = conf; | |||
2042 | ||||
2043 | minacl = posix_acl_new (this, 3); | |||
2044 | if (!minacl) | |||
2045 | return -1; | |||
2046 | ||||
2047 | minace = minacl->entries; | |||
2048 | minace[0].tag = POSIX_ACL_USER_OBJ(0x01); | |||
2049 | minace[1].tag = POSIX_ACL_GROUP_OBJ(0x04); | |||
2050 | minace[2].tag = POSIX_ACL_OTHER(0x20); | |||
2051 | ||||
2052 | conf->minimal_acl = minacl; | |||
2053 | ||||
2054 | GF_OPTION_INIT ("super-uid", conf->super_uid, uint32, err)do { int val_ret = 0; val_ret = xlator_option_init_uint32 ((* __glusterfs_this_location()), (*__glusterfs_this_location())-> options, "super-uid", &(conf->super_uid)); if (val_ret ) goto err; } while (0); | |||
2055 | ||||
2056 | return 0; | |||
2057 | err: | |||
2058 | return -1; | |||
2059 | } | |||
2060 | ||||
2061 | ||||
2062 | int | |||
2063 | fini (xlator_t *this) | |||
2064 | { | |||
2065 | struct posix_acl_conf *conf = NULL((void*)0); | |||
2066 | struct posix_acl *minacl = NULL((void*)0); | |||
2067 | ||||
2068 | conf = this->private; | |||
2069 | if (!conf) | |||
2070 | return 0; | |||
2071 | this->private = NULL((void*)0); | |||
2072 | ||||
2073 | minacl = conf->minimal_acl; | |||
2074 | ||||
2075 | LOCK (&conf->acl_lock)pthread_spin_lock (&conf->acl_lock); | |||
2076 | { | |||
2077 | conf->minimal_acl = NULL((void*)0); | |||
2078 | } | |||
2079 | UNLOCK (&conf->acl_lock)pthread_spin_unlock (&conf->acl_lock); | |||
2080 | ||||
2081 | LOCK_DESTROY (&conf->acl_lock)pthread_spin_destroy (&conf->acl_lock); | |||
2082 | ||||
2083 | GF_FREE (minacl)__gf_free (minacl); | |||
2084 | ||||
2085 | GF_FREE (conf)__gf_free (conf); | |||
2086 | ||||
2087 | return 0; | |||
2088 | } | |||
2089 | ||||
2090 | ||||
2091 | struct xlator_fops fops = { | |||
2092 | .lookup = posix_acl_lookup, | |||
2093 | .open = posix_acl_open, | |||
2094 | #if FD_MODE_CHECK_IS_IMPLEMENTED | |||
2095 | .readv = posix_acl_readv, | |||
2096 | .writev = posix_acl_writev, | |||
2097 | .ftruncate = posix_acl_ftruncate, | |||
2098 | .fsetattr = posix_acl_fsetattr, | |||
2099 | .fsetxattr = posix_acl_fsetxattr, | |||
2100 | .fgetxattr = posix_acl_fgetxattr, | |||
2101 | #endif | |||
2102 | .access = posix_acl_access, | |||
2103 | .truncate = posix_acl_truncate, | |||
2104 | .mkdir = posix_acl_mkdir, | |||
2105 | .mknod = posix_acl_mknod, | |||
2106 | .create = posix_acl_create, | |||
2107 | .symlink = posix_acl_symlink, | |||
2108 | .unlink = posix_acl_unlink, | |||
2109 | .rmdir = posix_acl_rmdir, | |||
2110 | .rename = posix_acl_rename, | |||
2111 | .link = posix_acl_link, | |||
2112 | .opendir = posix_acl_opendir, | |||
2113 | .readdir = posix_acl_readdir, | |||
2114 | .readdirp = posix_acl_readdirp, | |||
2115 | .setattr = posix_acl_setattr, | |||
2116 | .setxattr = posix_acl_setxattr, | |||
2117 | .getxattr = posix_acl_getxattr, | |||
2118 | .removexattr = posix_acl_removexattr, | |||
2119 | }; | |||
2120 | ||||
2121 | ||||
2122 | struct xlator_cbks cbks = { | |||
2123 | .forget = posix_acl_forget | |||
2124 | }; | |||
2125 | ||||
2126 | ||||
2127 | struct volume_options options[] = { | |||
2128 | { .key = {"super-uid"}, | |||
2129 | .type = GF_OPTION_TYPE_INT, | |||
2130 | .default_value = "0", | |||
2131 | .description = "UID to be treated as super user's id instead of 0", | |||
2132 | }, | |||
2133 | { .key = {NULL((void*)0)} }, | |||
2134 | }; |