2 Copyright (C) 2003 - 2010 Chaskiel Grundman
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
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>
32 #include <afs/vlserver.h>
33 #include <afs/vldbint.h>
36 #include "afscp_internal.h"
39 afscp_CreateFile(const struct afscp_venusfid *dir, char *name,
40 struct AFSStoreStatus *sst, struct afscp_venusfid **ret)
43 struct AFSFid df = dir->fid;
44 struct afscp_volume *vol;
45 struct AFSFetchStatus dfst, fst;
47 struct AFSCallBack cb;
49 struct afscp_server *server;
50 struct rx_connection *c;
53 if (dir == NULL || name == NULL || sst == NULL) {
55 "afscp_CreateFile called with NULL args, cannot continue\n");
58 vol = afscp_VolumeById(dir->cell, dir->fid.Volume);
64 for (i = 0; i < vol->nservers; i++) {
65 server = afscp_ServerByIndex(vol->servers[i]);
66 if (server && server->naddrs > 0) {
67 for (j = 0; j < server->naddrs; j++) {
68 c = afscp_ServerConnection(server, j);
73 code = RXAFS_CreateFile(c, &df, name, sst, &ff,
74 &fst, &dfst, &cb, &vs);
89 _StatStuff(dir, &dfst);
90 afscp_AddCallBack(server, &ff, &fst, &cb, now);
92 *ret = afscp_MakeFid(vol->cell, ff.Volume, ff.Vnode, ff.Unique);
97 afscp_MakeDir(const struct afscp_venusfid *dir, char *name,
98 struct AFSStoreStatus *sst, struct afscp_venusfid **ret)
101 struct AFSFid df = dir->fid;
102 struct afscp_volume *vol;
103 struct AFSFetchStatus dfst, fst;
104 struct AFSVolSync vs;
105 struct AFSCallBack cb;
107 struct afscp_server *server;
108 struct rx_connection *c;
111 vol = afscp_VolumeById(dir->cell, dir->fid.Volume);
113 afscp_errno = ENOENT;
117 for (i = 0; i < vol->nservers; i++) {
118 server = afscp_ServerByIndex(vol->servers[i]);
119 if (server && server->naddrs > 0) {
120 for (j = 0; j < server->naddrs; j++) {
121 c = afscp_ServerConnection(server, j);
125 code = RXAFS_MakeDir(c, &df, name, sst, &ff,
126 &fst, &dfst, &cb, &vs);
135 _StatInvalidate(dir);
139 _StatStuff(dir, &dfst);
140 afscp_AddCallBack(server, &ff, &fst, &cb, now);
142 *ret = afscp_MakeFid(vol->cell, ff.Volume, ff.Vnode, ff.Unique);
147 afscp_Symlink(const struct afscp_venusfid *dir, char *name,
148 char *target, struct AFSStoreStatus *sst)
151 struct AFSFid df = dir->fid;
152 struct afscp_volume *vol;
153 struct AFSFetchStatus dfst, fst;
154 struct AFSVolSync vs;
156 struct afscp_server *server;
157 struct rx_connection *c;
159 vol = afscp_VolumeById(dir->cell, dir->fid.Volume);
161 afscp_errno = ENOENT;
165 for (i = 0; i < vol->nservers; i++) {
166 server = afscp_ServerByIndex(vol->servers[i]);
167 if (server && server->naddrs > 0) {
168 for (j = 0; j < server->naddrs; j++) {
169 c = afscp_ServerConnection(server, j);
172 code = RXAFS_Symlink(c, &df, name, target, sst,
173 &ff, &fst, &dfst, &vs);
182 _StatInvalidate(dir);
186 _StatStuff(dir, &dfst);
192 afscp_RemoveFile(const struct afscp_venusfid *dir, char *name)
195 struct AFSFid df = dir->fid;
196 struct afscp_volume *vol;
197 struct AFSFetchStatus dfst;
198 struct AFSVolSync vs;
199 struct afscp_server *server;
200 struct rx_connection *c;
202 vol = afscp_VolumeById(dir->cell, dir->fid.Volume);
204 afscp_errno = ENOENT;
208 for (i = 0; i < vol->nservers; i++) {
209 server = afscp_ServerByIndex(vol->servers[i]);
210 if (server && server->naddrs > 0) {
211 for (j = 0; j < server->naddrs; j++) {
212 c = afscp_ServerConnection(server, j);
215 code = RXAFS_RemoveFile(c, &df, name, &dfst, &vs);
224 _StatInvalidate(dir);
228 _StatStuff(dir, &dfst);
233 afscp_RemoveDir(const struct afscp_venusfid *dir, char *name)
236 struct AFSFid df = dir->fid;
237 struct afscp_volume *vol;
238 struct AFSFetchStatus dfst;
239 struct AFSVolSync vs;
240 struct afscp_server *server;
241 struct rx_connection *c;
243 vol = afscp_VolumeById(dir->cell, dir->fid.Volume);
245 afscp_errno = ENOENT;
249 for (i = 0; i < vol->nservers; i++) {
250 server = afscp_ServerByIndex(vol->servers[i]);
251 if (server && server->naddrs > 0) {
252 for (j = 0; j < server->naddrs; j++) {
253 c = afscp_ServerConnection(server, j);
256 code = RXAFS_RemoveDir(c, &df, name, &dfst, &vs);
265 _StatInvalidate(dir);
269 _StatStuff(dir, &dfst);