libafscp: code cleanup
[openafs.git] / src / libafscp / afscp.h
1 #ifndef AFS_SRC_LIBAFSCP_AFSCP_H
2 #define AFS_SRC_LIBAFSCP_AFSCP_H
3
4 /* AUTORIGHTS */
5 #include <afs/param.h>
6 #include <afs/afsint.h>
7 #include <afs/afs_consts.h>
8 #include <afs/cellconfig.h>
9 #include <afs/dir.h>
10 #include <afs/afsutil.h>
11
12 struct afscp_server {
13     afsUUID id;
14     int index;
15     int cell;
16     int naddrs;
17     afs_uint32 addrs[AFS_MAXHOSTS];
18     struct rx_connection *conns[AFS_MAXHOSTS];
19 };
20
21 struct afscp_cell {
22     int id;
23     char name[MAXCELLCHARS + 1];
24     struct rx_securityClass *security;
25     int scindex;
26     struct ubik_client *vlservers;
27     int nservers;
28     int srvsalloced;
29     struct afscp_server **fsservers;
30     void *volsbyname;
31     void *volsbyid;
32     char *realm;
33 };
34
35 struct afscp_volume {
36     struct afscp_cell *cell;
37     afs_uint32 id;
38     int voltype;
39     int nservers;
40     int servers[AFS_MAXHOSTS];
41     char name[AFSNAMEMAX];
42     void *statcache;
43     void *dircache;
44 };
45
46 struct afscp_venusfid {
47     struct afscp_cell *cell;
48     struct AFSFid fid;
49 };
50
51 struct afscp_dirent {
52     afs_uint32 vnode;
53     afs_uint32 unique;
54     char name[16 + 32 * (EPP - 2)];
55 };
56
57 struct afscp_dirstream {
58     struct afscp_venusfid fid;
59     int buflen;
60     char *dirbuffer;
61     int hashent;
62     int entry;
63     int dv;
64     struct afscp_dirent ret;
65 };
66
67 struct afscp_dircache {
68     struct afscp_venusfid me;
69     int buflen;
70     char *dirbuffer;
71     int dv;
72 };
73
74 struct afscp_statent {
75     struct afscp_venusfid me;
76     struct AFSFetchStatus status;
77 };
78
79 struct afscp_openfile {
80     struct afscp_venusfid fid;
81     off_t offset;
82 };
83
84 struct afscp_callback {
85     int valid;
86     const struct afscp_server *server;
87     struct AFSFid fid;
88     struct AFSCallBack cb;
89     time_t as_of;
90 };
91
92 extern int afscp_errno;
93 int afscp_Init(const char *);
94 void afscp_Finalize(void);
95
96 int afscp_Insecure(void);
97 int afscp_AnonymousAuth(int);
98
99 struct afscp_cell *afscp_DefaultCell(void);
100 struct afscp_cell *afscp_CellByName(const char *, const char *);
101 int afscp_SetDefaultRealm(const char *);
102 int afscp_SetDefaultCell(const char *);
103 struct afscp_cell *afscp_CellById(int);
104 int afscp_CellId(struct afscp_cell *);
105 void afscp_FreeAllCells(void);
106 void afscp_FreeAllServers(void);
107
108 struct afscp_server *afscp_ServerById(struct afscp_cell *, afsUUID *);
109 struct afscp_server *afscp_ServerByAddr(struct afscp_cell *, afs_uint32);
110 struct afscp_server *afscp_AnyServerByAddr(afs_uint32);
111 struct afscp_server *afscp_ServerByIndex(int);
112 struct rx_connection *afscp_ServerConnection(const struct afscp_server *,
113                                              int);
114
115 int afscp_AddCallBack(const struct afscp_server *,
116                       const struct AFSFid *,
117                       const struct AFSFetchStatus *,
118                       const struct AFSCallBack *, const time_t);
119 int afscp_RemoveCallBack(const struct afscp_server *,
120                          const struct afscp_venusfid *);
121 int afscp_ReturnCallBacks(const struct afscp_server *);
122 int afscp_ReturnAllCallBacks(void);
123
124 /* file metastuff */
125 /* frees with free() */
126 struct afscp_venusfid *afscp_MakeFid(struct afscp_cell *, afs_uint32,
127                                      afs_uint32, afs_uint32);
128 struct afscp_venusfid *afscp_DupFid(const struct afscp_venusfid *);
129 void afscp_FreeFid(struct afscp_venusfid *);
130
131 struct stat;
132 int afscp_Stat(const struct afscp_venusfid *, struct stat *);
133
134 ssize_t afscp_PRead(const struct afscp_venusfid *, void *, size_t, off_t);
135 ssize_t afscp_PWrite(const struct afscp_venusfid *, const void *,
136                      size_t, off_t);
137 /*
138  * for future implementation: (?)
139  * struct afscp_openfile *afscp_FidOpen(const struct afscp_venusfid *);
140  * off_t afscp_FSeek(struct afscp_openfile *, off_t, int);
141  * ssize_t afscp_FRead(const struct afscp_openfile *, void *, size_t);
142  */
143
144 /* rpc wrappers */
145 int afscp_GetStatus(const struct afscp_venusfid *, struct AFSFetchStatus *);
146 int afscp_StoreStatus(const struct afscp_venusfid *, struct AFSStoreStatus *);
147 int afscp_CreateFile(const struct afscp_venusfid *, char *,
148                      struct AFSStoreStatus *, struct afscp_venusfid **);
149 int afscp_MakeDir(const struct afscp_venusfid *, char *,
150                   struct AFSStoreStatus *, struct afscp_venusfid **);
151 int afscp_Symlink(const struct afscp_venusfid *, char *,
152                   char *, struct AFSStoreStatus *);
153 int afscp_RemoveFile(const struct afscp_venusfid *, char *);
154 int afscp_RemoveDir(const struct afscp_venusfid *, char *);
155 int afscp_FetchACL(const struct afscp_venusfid *, struct AFSOpaque *);
156 int afscp_StoreACL(const struct afscp_venusfid *, struct AFSOpaque *);
157
158 /* directory parsing stuff*/
159 struct afscp_dirstream *afscp_OpenDir(const struct afscp_venusfid *);
160 struct afscp_dirent *afscp_ReadDir(struct afscp_dirstream *);
161 int afscp_RewindDir(struct afscp_dirstream *);
162 int afscp_CloseDir(struct afscp_dirstream *);
163 struct afscp_venusfid *afscp_DirLookup(struct afscp_dirstream *,
164                                        const char *);
165 struct afscp_venusfid *afscp_ResolveName(const struct afscp_venusfid *,
166                                          const char *);
167 struct afscp_venusfid *afscp_ResolvePath(const char *);
168 struct afscp_venusfid *afscp_ResolvePathFromVol(const struct afscp_volume *,
169                                                 const char *);
170
171 /* vldb stuff */
172 struct afscp_volume *afscp_VolumeByName(struct afscp_cell *,
173                                         const char *, afs_int32);
174 struct afscp_volume *afscp_VolumeById(struct afscp_cell *, afs_uint32);
175
176 #define DIRMODE_CELL    0
177 #define DIRMODE_DYNROOT 1
178 int afscp_SetDirMode(int);
179
180 #endif /* AFS_SRC_LIBAFSCP_AFSCP_H */