Remove UKERNEL code from files that don't need it
[openafs.git] / src / ubik / ubik.p.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef UBIK_H
11 #define UBIK_H
12
13 #include <stdarg.h>
14
15 #include <ubik_int.h>
16
17 /*! \name ubik_trans types */
18 #define UBIK_READTRANS      0
19 #define UBIK_WRITETRANS     1
20 /*\}*/
21
22 /*! \name ubik_lock types */
23 #define LOCKREAD            1
24 #define LOCKWRITE           2
25 #define LOCKWAIT            3
26 /*\}*/
27
28 /*! \name ubik client flags */
29 #define UPUBIKONLY          1   /*!< only check servers presumed functional */
30 #define UBIK_CALL_NEW       2   /*!< use the semantics of ubik_Call_New */
31 /*\}*/
32
33 /*! \name RX services types */
34 #define VOTE_SERVICE_ID     50
35 #define DISK_SERVICE_ID     51
36 #define USER_SERVICE_ID     52  /*!< Since most applications use same port! */
37 /*\}*/
38
39 #define UBIK_MAGIC      0x354545
40
41 /*! \name global ubik parameters */
42 #define MAXSERVERS          20  /*!< max number of servers */
43 /*\}*/
44
45 /*! version comparison macro */
46 #define vcmp(a,b) ((a).epoch == (b).epoch? ((a).counter - (b).counter) : ((a).epoch - (b).epoch))
47
48 /*! \name ubik_client state bits */
49 #define CFLastFailed        1   /*!< last call failed to this guy (to detect down hosts) */
50 /*\}*/
51
52 #ifdef AFS_PTHREAD_ENV
53 #include <pthread.h>
54 #else
55 #include <lwp.h>
56 #endif
57
58 /*!
59  * \brief per-client structure for ubik
60  */
61 struct ubik_client {
62     short initializationState;  /*!< ubik client init state */
63     short states[MAXSERVERS];   /*!< state bits */
64     struct rx_connection *conns[MAXSERVERS];
65     afs_int32 syncSite;
66 #ifdef AFS_PTHREAD_ENV
67     pthread_mutex_t cm;
68 #endif
69 };
70
71 #ifdef AFS_PTHREAD_ENV
72 #define LOCK_UBIK_CLIENT(client) opr_mutex_enter(&client->cm)
73 #define UNLOCK_UBIK_CLIENT(client) opr_mutex_exit(&client->cm)
74 #else
75 #define LOCK_UBIK_CLIENT(client)
76 #define UNLOCK_UBIK_CLIENT(client)
77 #endif
78
79 #define ubik_GetRPCConn(astr,aindex)    ((aindex) >= MAXSERVERS? 0 : (astr)->conns[aindex])
80 #define ubik_GetRPCHost(astr,aindex)    ((aindex) >= MAXSERVERS? 0 : (astr)->hosts[aindex])
81
82 /*!
83  * \brief ubik header file structure
84  */
85 struct ubik_hdr {
86     afs_int32 magic;            /*!< magic number */
87     short pad1;                 /*!< some 0-initd padding */
88     short size;                 /*!< header allocation size */
89     struct ubik_version version;        /*!< the version for this file */
90 };
91
92 /*!
93  * \brief representation of a ubik transaction
94  */
95 struct ubik_trans {
96     struct ubik_dbase *dbase;   /*!< corresponding database */
97     struct ubik_trans *next;    /*!< in the list */
98     afs_int32 locktype;         /*!< transaction lock */
99     struct ubik_trunc *activeTruncs;    /*!< queued truncates */
100     struct ubik_tid tid;        /*!< transaction id of this trans (if write trans.) */
101     afs_int32 minCommitTime;    /*!< time before which this trans can't commit */
102     afs_int32 seekFile;         /*!< seek ptr: file number */
103     afs_int32 seekPos;          /*!< seek ptr: offset therein */
104     short flags;                /*!< trans flag bits */
105     char type;                  /*!< type of trans */
106     iovec_wrt iovec_info;
107     iovec_buf iovec_data;
108 };
109
110 /*!
111  * \brief representation of a truncation operation
112  */
113 struct ubik_trunc {
114     struct ubik_trunc *next;
115     afs_int32 file;             /*!< file to truncate */
116     afs_int32 length;           /*!< new size */
117 };
118
119 struct ubik_stat {
120     afs_int32 size;
121     afs_int32 mtime;
122 };
123
124 #include <lock.h>               /* just to make sure we've got this */
125
126 /*!
127  * \brief representation of a ubik database.
128  *
129  * Contains info on low-level disk access routines
130  * for use by disk transaction module.
131  */
132 struct ubik_dbase {
133     char *pathName;             /*!< root name for dbase */
134     struct ubik_trans *activeTrans;     /*!< active transaction list */
135     struct ubik_version version;        /*!< version number */
136 #ifdef AFS_PTHREAD_ENV
137     pthread_mutex_t versionLock;        /*!< lock on version number */
138 #else
139     struct Lock versionLock;    /*!< lock on version number */
140 #endif
141     afs_int32 tidCounter;       /*!< last RW or RO trans tid counter */
142     afs_int32 writeTidCounter;  /*!< last write trans tid counter */
143     afs_int32 flags;            /*!< flags */
144     /* physio procedures */
145     int (*read) (struct ubik_dbase * adbase, afs_int32 afile, void *abuffer,
146                  afs_int32 apos, afs_int32 alength);
147     int (*write) (struct ubik_dbase * adbase, afs_int32 afile, void *abuffer,
148                   afs_int32 apos, afs_int32 alength);
149     int (*truncate) (struct ubik_dbase * adbase, afs_int32 afile,
150                      afs_int32 asize);
151     int (*sync) (struct ubik_dbase * adbase, afs_int32 afile);
152     int (*stat) (struct ubik_dbase * adbase, afs_int32 afid,
153                  struct ubik_stat * astat);
154     void (*open) (struct ubik_dbase * adbase, afs_int32 afid);
155     int (*setlabel) (struct ubik_dbase * adbase, afs_int32 afile, struct ubik_version * aversion);      /*!< set the version label */
156     int (*getlabel) (struct ubik_dbase * adbase, afs_int32 afile, struct ubik_version * aversion);      /*!< retrieve the version label */
157     int (*getnfiles) (struct ubik_dbase * adbase);      /*!< find out number of files */
158     short readers;              /*!< number of current read transactions */
159     struct ubik_version cachedVersion;  /*!< version of caller's cached data */
160     struct Lock cache_lock; /*!< protects cached application data */
161 #ifdef AFS_PTHREAD_ENV
162     pthread_cond_t version_cond;    /*!< condition variable to manage changes to version */
163     pthread_cond_t flags_cond;      /*!< condition variable to manage changes to flags */
164 #endif
165 };
166
167 /**
168  * ubik_CheckCache callback function.
169  *
170  * @param[in] atrans  ubik transaction
171  * @param[in] rock    rock passed to ubik_CheckCache
172  *
173  * @return operation status
174  *   @retval 0        cache was read properly
175  */
176 typedef int (*ubik_updatecache_func) (struct ubik_trans *atrans, void *rock);
177
178 /*! \name procedures for automatically authenticating ubik connections */
179 extern int (*ubik_CRXSecurityProc) (void *, struct rx_securityClass **,
180                                     afs_int32 *);
181 extern void *ubik_CRXSecurityRock;
182 extern int (*ubik_SRXSecurityProc) (void *, struct rx_securityClass **,
183                                     afs_int32 *);
184 extern void *ubik_SRXSecurityRock;
185 extern int (*ubik_CheckRXSecurityProc) (void *, struct rx_call *);
186 extern void *ubik_CheckRXSecurityRock;
187
188 extern void ubik_SetClientSecurityProcs(int (*scproc)(void *,
189                                                       struct rx_securityClass **,
190                                                       afs_int32 *),
191                                         int (*checkproc) (void *),
192                                         void *rock);
193 extern void ubik_SetServerSecurityProcs
194                 (void (*buildproc) (void *,
195                                     struct rx_securityClass ***,
196                                     afs_int32 *),
197                  int (*checkproc) (void *, struct rx_call *),
198                  void *rock);
199
200 /*\}*/
201
202 /*
203  * For applications that make use of ubik_BeginTransReadAnyWrite, writing
204  * processes must not update the application-level cache as they write,
205  * or else readers can read the new cache before the data is committed to
206  * the db. So, when a commit occurs, the cache must be updated right then.
207  * If set, this function will be called during commits of write transactions,
208  * to update the application-level cache after a write. This will be called
209  * immediately after the local disk commit succeeds, and it will be called
210  * with a lock held that prevents other threads from reading from the cache
211  * or the db in general.
212  *
213  * Note that this function MUST be set in order to make use of
214  * ubik_BeginTransReadAnyWrite.
215  */
216 extern int (*ubik_SyncWriterCacheProc) (void);
217
218 /****************INTERNALS BELOW ****************/
219
220 #ifdef UBIK_INTERNALS
221 /*! \name some ubik parameters */
222 #define UBIK_PAGESIZE       1024        /*!< fits in current r packet */
223 #define UBIK_LOGPAGESIZE    10  /*!< base 2 log thereof */
224 #define NBUFFERS            20  /*!< number of 1K buffers */
225 #define HDRSIZE             64  /*!< bytes of header per dbfile */
226 /*\}*/
227
228 /*! \name ubik_dbase flags */
229 #define DBWRITING           1   /*!< are any write trans. in progress */
230 /*\}*/
231
232 /*!\name ubik trans flags */
233 #define TRDONE              1   /*!< commit or abort done */
234 #define TRABORT             2   /*!< if #TRDONE, tells if aborted */
235 #define TRREADANY           4   /*!< read any data available in trans */
236 #define TRCACHELOCKED       32  /*!< this trans has locked dbase->cache_lock
237                                  *   (meaning, this trans has called
238                                  *   ubik_CheckCache at some point */
239 #define TRREADWRITE         64  /*!< read even if there's a conflicting ubik-
240                                  *   level write lock */
241 /*\}*/
242
243 /*! \name ubik_lock flags */
244 #define LWANT               1
245 /*\}*/
246
247 /*! \name ubik system database numbers */
248 #define LOGFILE             (-1)
249 /*\}*/
250
251 /*! \name define log opcodes */
252 #define LOGNEW              100 /*!< start transaction */
253 #define LOGEND              101 /*!< commit (good) end transaction */
254 #define LOGABORT            102 /*!< abort (fail) transaction */
255 #define LOGDATA             103 /*!< data */
256 #define LOGTRUNCATE         104 /*!< truncate operation */
257 /*\}*/
258
259 /*!
260  * \name timer constants
261  * time constant for replication algorithms: the R time period is 20 seconds.  Both
262  * #SMALLTIME and #BIGTIME must be larger than #RPCTIMEOUT+max(#RPCTIMEOUT, #POLLTIME),
263  * so that timeouts do not prevent us from getting through to our servers in time.
264  *
265  * We use multi-R to time out multiple down hosts concurrently.
266  * The only other restrictions:  #BIGTIME > #SMALLTIME and
267  * #BIGTIME-#SMALLTIME > #MAXSKEW (the clock skew).
268  */
269 #define MAXSKEW 10
270 #define POLLTIME 15
271 #define RPCTIMEOUT 20
272 #define BIGTIME 75
273 #define SMALLTIME 60
274 /*\}*/
275
276 /*!
277  * \brief the per-server state, used by the sync site to keep track of its charges
278  */
279 struct ubik_server {
280     struct ubik_server *next;   /*!< next ptr */
281     afs_uint32 addr[UBIK_MAX_INTERFACE_ADDR];   /*!< network order, addr[0] is primary */
282     afs_int32 lastVoteTime;     /*!< last time yes vote received */
283     afs_int32 lastBeaconSent;   /*!< last time beacon attempted */
284     struct ubik_version version;        /*!< version, only used during recovery */
285     struct rx_connection *vote_rxcid;   /*!< cid to use to contact dude for votes */
286     struct rx_connection *disk_rxcid;   /*!< cid to use to contact dude for disk reqs */
287     char lastVote;              /*!< true if last vote was yes */
288     char up;                    /*!< is it up? */
289     char beaconSinceDown;       /*!< did beacon get through since last crash? */
290     char currentDB;             /*!< is dbase up-to-date */
291     char magic;                 /*!< the one whose vote counts twice */
292     char isClone;               /*!< is only a clone, doesn't vote */
293 };
294
295 /*! \name hold and release functions on a database */
296 #ifdef AFS_PTHREAD_ENV
297 # define        DBHOLD(a)       opr_mutex_enter(&((a)->versionLock))
298 # define        DBRELE(a)       opr_mutex_exit(&((a)->versionLock))
299 #else /* !AFS_PTHREAD_ENV */
300 # define        DBHOLD(a)       ObtainWriteLock(&((a)->versionLock))
301 # define        DBRELE(a)       ReleaseWriteLock(&((a)->versionLock))
302 #endif /* !AFS_PTHREAD_ENV */
303 /*\}*/
304
305 /* globals */
306
307 /*!name list of all servers in the system */
308 extern struct ubik_server *ubik_servers;
309 extern char amIClone;
310 /*\}*/
311
312 /*! \name network port info */
313 extern short ubik_callPortal;
314 /*\}*/
315
316 /*! \name urecovery state bits for sync site */
317 #define UBIK_RECSYNCSITE        1       /* am sync site */
318 #define UBIK_RECFOUNDDB         2       /* found acceptable dbase from quorum */
319 #define UBIK_RECHAVEDB          4       /* fetched best dbase */
320 #define UBIK_RECLABELDB         8       /* relabelled dbase */
321 #define UBIK_RECSENTDB          0x10    /* sent best db to *everyone* */
322 #define UBIK_RECSBETTER         UBIK_RECLABELDB /* last state */
323 /*\}*/
324
325 extern afs_int32 ubik_quorum;   /* min hosts in quorum */
326 extern struct ubik_dbase *ubik_dbase;   /* the database handled by this server */
327 extern afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR];   /* this host addr, in net order */
328 extern int ubik_amSyncSite;     /* sleep on this waiting to be sync site */
329 extern struct ubik_stats {      /* random stats */
330     afs_int32 escapes;
331 } ubik_stats;
332 extern afs_int32 urecovery_state;       /* sync site recovery process state */
333 extern struct ubik_trans *ubik_currentTrans;    /* current trans */
334 extern afs_int32 ubik_debugFlag;        /* ubik debug flag */
335 extern int ubikPrimaryAddrOnly; /* use only primary address */
336
337 /*
338  * Lock ordering
339  *
340  * Any of the locks may be acquired singly; when acquiring multiple locks, they
341  * should be acquired in the listed order:
342  *      application cache lock  (dbase->cache_lock)
343  *      database lock           DBHOLD/DBRELE
344  *      beacon lock             UBIK_BEACON_LOCK/UNLOCK
345  *      vote lock               UBIK_VOTE_LOCK/UNLOCK
346  *      version lock            UBIK_VERSION_LOCK/UNLOCK
347  *      server address lock     UBIK_ADDR_LOCK/UNLOCK
348  */
349
350 /*!
351  * \brief Global beacon data.  All values are protected by beacon_lock
352  * This lock also protects some values in the ubik_server structures:
353  *      lastVoteTime
354  *      lastBeaconSent
355  *      lastVote
356  *      up
357  *      beaconSinceDown
358  */
359 struct beacon_data {
360 #ifdef AFS_PTHREAD_ENV
361     pthread_mutex_t beacon_lock;
362 #endif
363     int ubik_amSyncSite;                /*!< flag telling if I'm sync site */
364     afs_int32 syncSiteUntil;            /*!< valid only if amSyncSite */
365 };
366
367 #define UBIK_BEACON_LOCK opr_mutex_enter(&beacon_globals.beacon_lock)
368 #define UBIK_BEACON_UNLOCK opr_mutex_exit(&beacon_globals.beacon_lock)
369
370 /*!
371  * \brief Global vote data.  All values are protected by vote_lock
372  */
373 struct vote_data {
374 #ifdef AFS_PTHREAD_ENV
375     pthread_mutex_t vote_lock;
376 #endif
377     struct ubik_version ubik_dbVersion; /* sync site's dbase version */
378     struct ubik_tid ubik_dbTid;         /* sync site's tid, or 0 if none */
379     /* Used by all sites in nominating new sync sites */
380     afs_int32 ubik_lastYesTime;         /* time we sent the last yes vote */
381     afs_uint32 lastYesHost;             /* host to which we sent yes vote */
382     /* Next is time sync site began this vote: guarantees sync site until this + SMALLTIME */
383     afs_int32 lastYesClaim;
384     int lastYesState;                   /* did last site we voted for claim to be sync site? */
385     /* Used to guarantee that nomination process doesn't loop */
386     afs_int32 lowestTime;
387     afs_uint32 lowestHost;
388     afs_int32 syncTime;
389     afs_int32 syncHost;
390 };
391
392 #define UBIK_VOTE_LOCK opr_mutex_enter(&vote_globals.vote_lock)
393 #define UBIK_VOTE_UNLOCK opr_mutex_exit(&vote_globals.vote_lock)
394
395 /*!
396  * \brief Server address data.  All values are protected by addr_lock
397  *
398  * This lock also protects:
399  *     ubik_server: addr[], vote_rxcid, disk_rxcid
400  *
401  */
402 struct addr_data {
403 #ifdef AFS_PTHREAD_ENV
404     pthread_mutex_t addr_lock;
405 #endif
406     afs_int32 ubikSecIndex;
407     struct rx_securityClass *ubikSecClass;
408 };
409
410 #define UBIK_ADDR_LOCK opr_mutex_enter(&addr_globals.addr_lock)
411 #define UBIK_ADDR_UNLOCK opr_mutex_exit(&addr_globals.addr_lock)
412
413 /*!
414  * \brief The version lock protects the structure member, as well as
415  * the database version, flags, tidCounter, writeTidCounter
416  */
417 struct version_data {
418 #ifdef AFS_PTHREAD_ENV
419     pthread_mutex_t version_lock;
420 #endif
421     afs_int32 ubik_epochTime;   /* time when this site started */
422 };
423
424 #define UBIK_VERSION_LOCK opr_mutex_enter(&version_globals.version_lock)
425 #define UBIK_VERSION_UNLOCK opr_mutex_exit(&version_globals.version_lock)
426
427 /* phys.c */
428 extern int uphys_stat(struct ubik_dbase *adbase, afs_int32 afid,
429                       struct ubik_stat *astat);
430 extern int uphys_read(struct ubik_dbase *adbase, afs_int32 afile,
431                       void *abuffer, afs_int32 apos,
432                       afs_int32 alength);
433 extern int uphys_write(struct ubik_dbase *adbase, afs_int32 afile,
434                        void *abuffer, afs_int32 apos,
435                        afs_int32 alength);
436 extern int uphys_truncate(struct ubik_dbase *adbase, afs_int32 afile,
437                           afs_int32 asize);
438 extern int uphys_getnfiles(struct ubik_dbase *adbase);
439 extern int uphys_getlabel(struct ubik_dbase *adbase, afs_int32 afile,
440                           struct ubik_version *aversion);
441 extern int uphys_setlabel(struct ubik_dbase *adbase, afs_int32 afile,
442                           struct ubik_version *aversion);
443 extern int uphys_sync(struct ubik_dbase *adbase, afs_int32 afile);
444 extern void uphys_invalidate(struct ubik_dbase *adbase,
445                              afs_int32 afid);
446
447 /*! \name recovery.c */
448 extern int urecovery_ResetState(void);
449 extern int urecovery_LostServer(struct ubik_server *server);
450 extern int urecovery_AllBetter(struct ubik_dbase *adbase,
451                                int areadAny);
452 extern int urecovery_AbortAll(struct ubik_dbase *adbase);
453 extern int urecovery_CheckTid(struct ubik_tid *atid, int abortalways);
454 extern int urecovery_Initialize(struct ubik_dbase *adbase);
455 extern void *urecovery_Interact(void *);
456 extern int DoProbe(struct ubik_server *server);
457 /*\}*/
458
459 /*! \name ubik.c */
460 extern afs_int32 ContactQuorum_NoArguments(afs_int32 (*proc)
461                                                        (struct rx_connection *,
462                                                         ubik_tid *),
463                                            struct ubik_trans *atrans,
464                                            int aflags);
465
466 extern afs_int32 ContactQuorum_DISK_Lock(struct ubik_trans *atrans,
467                                          int aflags,
468                                          afs_int32 file, afs_int32 position,
469                                          afs_int32 length, afs_int32 type);
470
471 extern afs_int32 ContactQuorum_DISK_Write(struct ubik_trans *atrans,
472                                           int aflags,
473                                           afs_int32 file, afs_int32 position,
474                                           bulkdata *data);
475
476 extern afs_int32 ContactQuorum_DISK_Truncate(struct ubik_trans *atrans,
477                                              int aflags,
478                                              afs_int32 file, afs_int32 length);
479
480 extern afs_int32 ContactQuorum_DISK_WriteV(struct ubik_trans *atrans,
481                                            int aflags,
482                                            iovec_wrt * io_vector,
483                                            iovec_buf *io_buffer);
484
485 extern afs_int32 ContactQuorum_DISK_SetVersion(struct ubik_trans *atrans,
486                                                int aflags,
487                                                ubik_version *OldVersion,
488                                                ubik_version *NewVersion);
489
490 extern void panic(char *format, ...)
491     AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
492
493 extern afs_uint32 ubikGetPrimaryInterfaceAddr(afs_uint32 addr);
494
495 extern int ubik_CheckAuth(struct rx_call *);
496
497 /*\}*/
498
499 /*! \name beacon.c */
500 struct afsconf_cell;
501 extern void ubeacon_InitSecurityClass(void);
502 extern void ubeacon_ReinitServer(struct ubik_server *ts);
503 extern void ubeacon_Debug(struct ubik_debug *aparm);
504 extern int ubeacon_AmSyncSite(void);
505 extern int ubeacon_InitServerListByInfo(afs_uint32 ame,
506                                         struct afsconf_cell *info,
507                                         char clones[]);
508 extern int ubeacon_InitServerList(afs_uint32 ame, afs_uint32 aservers[]);
509 extern void *ubeacon_Interact(void *);
510 extern int ubeacon_updateUbikNetworkAddress(afs_uint32 ubik_host[]);
511 extern struct beacon_data beacon_globals;
512 extern struct addr_data addr_globals;
513
514 /*\}*/
515
516 /*! \name disk.c */
517 extern int udisk_Init(int nBUffers);
518 extern void udisk_Debug(struct ubik_debug *aparm);
519 extern int udisk_Invalidate(struct ubik_dbase *adbase, afs_int32 afid);
520 extern int udisk_read(struct ubik_trans *atrans, afs_int32 afile,
521                       void *abuffer, afs_int32 apos, afs_int32 alen);
522 extern int udisk_truncate(struct ubik_trans *atrans, afs_int32 afile,
523                           afs_int32 alength);
524 extern int udisk_write(struct ubik_trans *atrans, afs_int32 afile,
525                        void *abuffer, afs_int32 apos, afs_int32 alen);
526 extern int udisk_begin(struct ubik_dbase *adbase, int atype,
527                        struct ubik_trans **atrans);
528 extern int udisk_commit(struct ubik_trans *atrans);
529 extern int udisk_abort(struct ubik_trans *atrans);
530 extern int udisk_end(struct ubik_trans *atrans);
531 /*\}*/
532
533 /*! \name lock.c */
534 extern void ulock_Init(void);
535 extern int  ulock_getLock(struct ubik_trans *atrans, int atype, int await);
536 extern void ulock_relLock(struct ubik_trans *atrans);
537 extern void ulock_Debug(struct ubik_debug *aparm);
538 /*\}*/
539
540 /*! \name vote.c */
541 extern int uvote_ShouldIRun(void);
542 extern afs_int32 uvote_GetSyncSite(void);
543 extern int uvote_Init(void);
544 extern void ubik_vprint(const char *format, va_list ap)
545     AFS_ATTRIBUTE_FORMAT(__printf__, 1, 0);
546
547 extern void ubik_print(const char *format, ...)
548     AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
549
550 extern void ubik_dprint(const char *format, ...)
551     AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
552
553 extern void ubik_dprint_25(const char *format, ...)
554     AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
555 extern struct vote_data vote_globals;
556 extern void uvote_set_dbVersion(struct ubik_version);
557 extern int uvote_eq_dbVersion(struct ubik_version);
558 extern int uvote_HaveSyncAndVersion(struct ubik_version);
559 /*\}*/
560
561 #endif /* UBIK_INTERNALS */
562
563 extern afs_int32 ubik_nBuffers;
564
565 /*!
566  * \name Public function prototypes
567  */
568
569 /*! \name ubik.c */
570 struct afsconf_cell;
571 extern int ubik_ServerInitByInfo(afs_uint32 myHost, short myPort,
572                                  struct afsconf_cell *info, char clones[],
573                                  const char *pathName,
574                                  struct ubik_dbase **dbase);
575 extern int ubik_ServerInit(afs_uint32 myHost, short myPort,
576                            afs_uint32 serverList[],
577                            const char *pathName, struct ubik_dbase **dbase);
578 extern int ubik_BeginTrans(struct ubik_dbase *dbase,
579                            afs_int32 transMode, struct ubik_trans **transPtr);
580 extern int ubik_BeginTransReadAny(struct ubik_dbase *dbase,
581                                   afs_int32 transMode,
582                                   struct ubik_trans **transPtr);
583 extern int ubik_BeginTransReadAnyWrite(struct ubik_dbase *dbase,
584                                        afs_int32 transMode,
585                                        struct ubik_trans **transPtr);
586 extern int ubik_AbortTrans(struct ubik_trans *transPtr);
587
588 extern int ubik_EndTrans(struct ubik_trans *transPtr);
589 extern int ubik_Read(struct ubik_trans *transPtr, void *buffer,
590                      afs_int32 length);
591 extern int ubik_Flush(struct ubik_trans *transPtr);
592 extern int ubik_Write(struct ubik_trans *transPtr, void *buffer,
593                       afs_int32 length);
594 extern int ubik_Seek(struct ubik_trans *transPtr, afs_int32 fileid,
595                      afs_int32 position);
596 extern int ubik_Tell(struct ubik_trans *transPtr, afs_int32 * fileid,
597                      afs_int32 * position);
598 extern int ubik_Truncate(struct ubik_trans *transPtr,
599                          afs_int32 length);
600 extern int ubik_SetLock(struct ubik_trans *atrans, afs_int32 apos,
601                         afs_int32 alen, int atype);
602 extern int ubik_WaitVersion(struct ubik_dbase *adatabase,
603                             struct ubik_version *aversion);
604 extern int ubik_GetVersion(struct ubik_trans *atrans,
605                            struct ubik_version *avers);
606 extern int ubik_CheckCache(struct ubik_trans *atrans,
607                            ubik_updatecache_func check,
608                            void *rock);
609 extern struct version_data version_globals;
610 /*\}*/
611
612 /*! \name ubikclient.c */
613
614 extern int ubik_ParseClientList(int argc, char **argv, afs_uint32 * aothers);
615 extern unsigned int afs_random(void);
616 extern int ubik_ClientInit(struct rx_connection **serverconns,
617                            struct ubik_client **aclient);
618 extern afs_int32 ubik_ClientDestroy(struct ubik_client *aclient);
619 extern struct rx_connection *ubik_RefreshConn(struct rx_connection *tc);
620 #ifdef UBIK_LEGACY_CALLITER
621 extern afs_int32 ubik_CallIter(int (*aproc) (), struct ubik_client *aclient,
622                                afs_int32 aflags, int *apos, long p1, long p2,
623                                long p3, long p4, long p5, long p6, long p7,
624                                long p8, long p9, long p10, long p11, long p12,
625                                long p13, long p14, long p15, long p16);
626 extern afs_int32 ubik_Call_New(int (*aproc) (), struct ubik_client
627                                *aclient, afs_int32 aflags, long p1, long p2,
628                                long p3, long p4, long p5, long p6, long p7,
629                                long p8, long p9, long p10, long p11, long p12,
630                                long p13, long p14, long p15, long p16);
631 #endif
632 /*\}*/
633
634 /* \name ubikcmd.c */
635 extern int ubik_ParseServerList(int argc, char **argv, afs_uint32 *ahost,
636                                 afs_uint32 *aothers);
637 /*\}*/
638
639 /* \name uinit.c */
640
641 struct rx_securityClass;
642 struct afsconf_dir;
643 extern int ugen_ClientInitCell(struct afsconf_dir *dir,
644                                struct afsconf_cell *info,
645                                int secFlags,
646                                struct ubik_client **uclientp,
647                                int maxservers, const char *serviceid,
648                                int deadtime);
649 extern int ugen_ClientInitServer(const char *confDir, char *cellName,
650                                  int secFlags, struct ubik_client **uclientp,
651                                  int maxservers, char *serviceid,
652                                  int deadtime, afs_uint32 server,
653                                  afs_uint32 port);
654 extern int ugen_ClientInitFlags(const char *confDir, char *cellName,
655                                 int secFlags, struct ubik_client **uclientp,
656                                 int (*secproc) (struct rx_securityClass *,
657                                                 afs_int32),
658                                 int maxservers, char *serviceid,
659                                 int deadtime);
660 extern afs_int32 ugen_ClientInit(int noAuthFlag, const char *confDir,
661                                  char *cellName, afs_int32 sauth,
662                                  struct ubik_client **uclientp,
663                                  int (*secproc) (struct rx_securityClass *sc,
664                                                  afs_int32 scIndex),
665                                  char *funcName,
666                                  afs_int32 gen_rxkad_level,
667                                  afs_int32 maxservers, char *serviceid,
668                                  afs_int32 deadtime, afs_uint32 server,
669                                  afs_uint32 port, afs_int32 usrvid);
670
671 #endif /* UBIK_H */