10 #include <afs/cellconfig.h>
11 #define UBIK_INTERNALS
19 struct ubik_dbase
*dbase
;
22 ubik_ServerInit(afs_uint32 myHost
, short myPort
, afs_uint32 serverList
[],
23 const char *pathName
, struct ubik_dbase
**dbase
)
29 ubik_BeginTrans(struct ubik_dbase
*dbase
, afs_int32 transMode
,
30 struct ubik_trans
**transPtr
)
37 memset(&thdr
, 0, sizeof(thdr
));
38 thdr
.version
.epoch
= htonl(2);
39 thdr
.version
.counter
= htonl(0);
40 thdr
.magic
= htonl(UBIK_MAGIC
);
41 thdr
.size
= htons(HDRSIZE
);
42 if (lseek(dbase_fd
, 0, 0) == (off_t
)-1)
44 count
= write(dbase_fd
, &thdr
, sizeof(thdr
));
47 else if (count
!= sizeof(thdr
))
57 ubik_BeginTransReadAny(struct ubik_dbase
*dbase
, afs_int32 transMode
,
58 struct ubik_trans
**transPtr
)
64 ubik_AbortTrans(struct ubik_trans
*transPtr
)
70 ubik_EndTrans(struct ubik_trans
*transPtr
)
76 ubik_Tell(struct ubik_trans
*transPtr
, afs_int32
* fileid
,
83 ubik_Truncate(struct ubik_trans
*transPtr
, afs_int32 length
)
89 ubik_SetLock(struct ubik_trans
*atrans
, afs_int32 apos
, afs_int32 alen
,
96 ubik_WaitVersion(struct ubik_dbase
*adatabase
,
97 struct ubik_version
*aversion
)
103 ubik_CheckCache(struct ubik_trans
*atrans
, ubik_updatecache_func cbf
, void *rock
)
105 return (*cbf
)(atrans
, rock
);
109 panic(char *format
, ...)
113 va_start(ap
, format
);
118 printf("BACK FROM ABORT\n"); /* shouldn't come back from floating pt exception */
119 exit(1); /* never know, though */
123 ubik_GetVersion(struct ubik_trans
*dummy
, struct ubik_version
*ver
)
125 memset(ver
, 0, sizeof(struct ubik_version
));
131 ubik_Seek(struct ubik_trans
*tt
, afs_int32 afd
, afs_int32 pos
)
133 if (lseek(dbase_fd
, pos
+ HDRSIZE
, 0) < 0) {
141 ubik_Write(struct ubik_trans
*tt
, void *buf
, afs_int32 len
)
145 status
= write(dbase_fd
, buf
, len
);
147 perror("ubik_Write");
154 ubik_Read(struct ubik_trans
*tt
, void *buf
, afs_int32 len
)
158 status
= read(dbase_fd
, buf
, len
);
164 memset((char *)buf
+ status
, 0, len
- status
);
169 /* Global declarations from ubik.c */
170 afs_int32 ubik_quorum
= 0;
171 struct ubik_dbase
*ubik_dbase
= 0;
172 struct ubik_stats ubik_stats
;
173 afs_uint32 ubik_host
[UBIK_MAX_INTERFACE_ADDR
];
174 afs_int32 ubik_epochTime
= 0;
175 afs_int32 urecovery_state
= 0;
177 struct rx_securityClass
*ubik_sc
[3];
180 /* Other declarations */
183 afsconf_GetNoAuthFlag(struct afsconf_dir
*adir
)
189 char *prdir
= "/dev/null";
190 struct prheader cheader
;