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