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