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