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 <afs/param.h>
28 #include <afs/afsint.h>
29 #include <afs/vlserver.h>
30 #include <afs/vldbint.h>
37 #include "afscp_internal.h"
40 int afs_CreateFile(const struct afs_venusfid *dir, char *name,
41 struct AFSStoreStatus *sst,
42 struct afs_venusfid **ret) {
44 struct AFSFid df = dir->fid;
45 struct afs_volume *vol;
46 struct AFSFetchStatus dfst, fst;
48 struct AFSCallBack cb;
50 struct afs_volume *volume;
51 struct afs_server *server;
54 vol=afs_volumebyid(dir->cell, dir->fid.Volume);
60 for (i=0;i<vol->nservers;i++) {
61 server=afs_serverbyindex(vol->servers[i]);
62 if (server && server->naddrs > 0) {
63 for (j=0;j < server->naddrs;j++) {
64 code=RXAFS_CreateFile(server->conns[j], &df, name, sst, &ff,
65 &fst, &dfst, &cb, &vs);
78 _StatStuff(dir, &dfst);
79 AddCallBack(server, &ff, &fst, &cb);
81 *ret=makefid(vol->cell, ff.Volume, ff.Vnode, ff.Unique);
85 int afs_MakeDir(const struct afs_venusfid *dir, char *name,
86 struct AFSStoreStatus *sst,
87 struct afs_venusfid **ret) {
89 struct AFSFid df = dir->fid;
90 struct afs_volume *vol;
91 struct AFSFetchStatus dfst, fst;
93 struct AFSCallBack cb;
95 struct afs_volume *volume;
96 struct afs_server *server;
98 vol=afs_volumebyid(dir->cell, dir->fid.Volume);
104 for (i=0;i<vol->nservers;i++) {
105 server=afs_serverbyindex(vol->servers[i]);
106 if (server && server->naddrs > 0) {
107 for (j=0;j < server->naddrs;j++) {
108 code=RXAFS_MakeDir(server->conns[j], &df, name, sst, &ff,
109 &fst, &dfst, &cb, &vs);
118 _StatInvalidate(dir);
122 _StatStuff(dir, &dfst);
123 AddCallBack(server, &ff, &fst, &cb);
125 *ret=makefid(vol->cell, ff.Volume, ff.Vnode, ff.Unique);
129 int afs_Symlink(const struct afs_venusfid *dir, char *name,
131 struct AFSStoreStatus *sst) {
133 struct AFSFid df = dir->fid;
134 struct afs_volume *vol;
135 struct AFSFetchStatus dfst, fst;
136 struct AFSVolSync vs;
137 struct AFSCallBack cb;
139 struct afs_volume *volume;
140 struct afs_server *server;
142 vol=afs_volumebyid(dir->cell, dir->fid.Volume);
148 for (i=0;i<vol->nservers;i++) {
149 server=afs_serverbyindex(vol->servers[i]);
150 if (server && server->naddrs > 0) {
151 for (j=0;j < server->naddrs;j++) {
152 code=RXAFS_Symlink(server->conns[j], &df, name, target, sst, &ff,
162 _StatInvalidate(dir);
166 _StatStuff(dir, &dfst);
171 int afs_RemoveFile(const struct afs_venusfid *dir, char *name) {
173 struct AFSFid df = dir->fid;
174 struct afs_volume *vol;
175 struct AFSFetchStatus dfst;
176 struct AFSVolSync vs;
177 struct AFSCallBack cb;
178 struct afs_volume *volume;
179 struct afs_server *server;
181 vol=afs_volumebyid(dir->cell, dir->fid.Volume);
187 for (i=0;i<vol->nservers;i++) {
188 server=afs_serverbyindex(vol->servers[i]);
189 if (server && server->naddrs > 0) {
190 for (j=0;j < server->naddrs;j++) {
191 code=RXAFS_RemoveFile(server->conns[j], &df, name, &dfst, &vs);
200 _StatInvalidate(dir);
204 _StatStuff(dir, &dfst);
208 int afs_RemoveDir(const struct afs_venusfid *dir, char *name) {
210 struct AFSFid df = dir->fid;
211 struct afs_volume *vol;
212 struct AFSFetchStatus dfst;
213 struct AFSVolSync vs;
214 struct AFSCallBack cb;
215 struct afs_volume *volume;
216 struct afs_server *server;
218 vol=afs_volumebyid(dir->cell, dir->fid.Volume);
224 for (i=0;i<vol->nservers;i++) {
225 server=afs_serverbyindex(vol->servers[i]);
226 if (server && server->naddrs > 0) {
227 for (j=0;j < server->naddrs;j++) {
228 code=RXAFS_RemoveDir(server->conns[j], &df, name, &dfst, &vs);
237 _StatInvalidate(dir);
241 _StatStuff(dir, &dfst);