Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / libafscp / afscp_acl.c
blob09b7df000fad5741423dd3abf851a9b1ca70579b
1 /* AUTORIGHTS
2 Copyright (C) 2003 - 2010 Chaskiel Grundman
3 All rights reserved
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
9 1. Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include <afsconfig.h>
28 #include <afs/param.h>
30 #include <afs/vlserver.h>
31 #include <afs/vldbint.h>
32 #include <afs/dir.h>
33 #include "afscp.h"
34 #include "afscp_internal.h"
36 int
37 afscp_FetchACL(const struct afscp_venusfid *dir, struct AFSOpaque *acl)
39 int code, i, j;
40 struct AFSFid df = dir->fid;
41 struct afscp_volume *vol;
42 struct AFSFetchStatus dfst;
43 struct AFSVolSync vs;
44 struct afscp_server *server;
46 vol = afscp_VolumeById(dir->cell, dir->fid.Volume);
47 if (vol == NULL) {
48 afscp_errno = ENOENT;
49 return -1;
51 code = ENOENT;
52 for (i = 0; i < vol->nservers; i++) {
53 server = afscp_ServerByIndex(vol->servers[i]);
54 if (server && server->naddrs > 0) {
55 for (j = 0; j < server->naddrs; j++) {
56 code = RXAFS_FetchACL(server->conns[j], &df, acl, &dfst, &vs);
57 if (code >= 0)
58 break;
61 if (code >= 0)
62 break;
64 if (code != 0) {
65 _StatInvalidate(dir);
66 afscp_errno = code;
67 return -1;
69 _StatStuff(dir, &dfst);
70 return 0;
74 int
75 afscp_StoreACL(const struct afscp_venusfid *dir, struct AFSOpaque *acl)
77 int code, i, j;
78 struct AFSFid df = dir->fid;
79 struct afscp_volume *vol;
80 struct AFSFetchStatus dfst;
81 struct AFSVolSync vs;
82 struct afscp_server *server;
84 vol = afscp_VolumeById(dir->cell, dir->fid.Volume);
85 if (vol == NULL) {
86 afscp_errno = ENOENT;
87 return -1;
89 code = ENOENT;
90 for (i = 0; i < vol->nservers; i++) {
91 server = afscp_ServerByIndex(vol->servers[i]);
92 if (server && server->naddrs > 0) {
93 for (j = 0; j < server->naddrs; j++) {
94 code = RXAFS_StoreACL(server->conns[j], &df, acl, &dfst, &vs);
95 if (code >= 0)
96 break;
99 if (code >= 0)
100 break;
102 if (code != 0) {
103 _StatInvalidate(dir);
104 afscp_errno = code;
105 return -1;
107 _StatStuff(dir, &dfst);
108 return 0;