afsconfig-and-rcsid-all-around-20010705
[openafs.git] / src / ptserver / ubik.c
1 /* $Id$ */
2
3 #include <afs/param.h>
4 #include <afsconfig.h>
5
6 RCSID("$Header$");
7
8 #include <sys/types.h>
9 #include <netinet/in.h>
10
11 #include <lock.h>
12 #define UBIK_INTERNALS
13 #include <afs/stds.h>
14 #include <ubik.h>
15 #include <rx/xdr.h>
16 #include "ptint.h"
17 #include "ptserver.h"
18
19 extern int dbase_fd;
20 struct ubik_dbase *dbase;
21
22 int ubik_ServerInit()
23 {
24     return(0);
25 }
26
27 int ubik_BeginTrans()
28 {
29     static int init=0;
30     struct ubik_hdr thdr;
31
32     if (!init) {
33         thdr.version.epoch = htonl(2);
34         thdr.version.counter = htonl(0);
35         thdr.magic = htonl(UBIK_MAGIC);
36         thdr.size = htonl(HDRSIZE);
37         lseek(dbase_fd, 0, 0);
38         write(dbase_fd, &thdr, sizeof(thdr));
39         fsync(dbase_fd);
40         init = 1;
41     }
42     return(0);
43 }
44
45 int ubik_BeginTransReadAny()
46 {
47     return(0);
48 }
49
50 int ubik_AbortTrans()
51 {
52     return(0);
53 }
54
55 int ubik_EndTrans()
56 {
57     return(0);
58 }
59
60 int ubik_Tell()
61 {
62     return(0);
63 }
64
65 int ubik_Truncate()
66 {
67     return(0);
68 }
69
70 long ubik_SetLock()
71 {
72     return(0);
73 }
74
75 int ubik_WaitVersion()
76 {
77     return(0);
78 }
79
80 int ubik_CacheUpdate()
81 {
82     return(0);
83 }
84
85 int panic(a, b, c, d)
86 char *a, *b, *c, *d;
87 {
88     printf(a, b, c, d);
89     abort();
90     printf("BACK FROM ABORT\n");    /* shouldn't come back from floating pt exception */
91     exit(1);    /* never know, though */
92 }
93
94 int ubik_GetVersion(dummy, ver)
95 int dummy;
96 struct ubik_version *ver;
97 {
98     memset(ver, 0, sizeof(struct ubik_version));
99     return(0);
100 }
101
102
103 int ubik_Seek(tt, afd, pos)
104 struct ubik_trans *tt;
105 long afd;
106 long pos;
107 {
108     if (lseek(dbase_fd, pos+HDRSIZE, 0) < 0) {
109         perror("ubik_Seek");
110         return(-1);
111     }
112     return(0);
113 }
114
115 int ubik_Write(tt, buf, len)
116 struct ubik_trans *tt;
117 char *buf;
118 long len;
119 {
120     int status;
121
122     status = write(dbase_fd, buf, len);
123     if (status < len) {
124         perror("ubik_Write");
125         return(1);
126     }
127     return(0);
128 }
129
130 int ubik_Read(tt, buf, len)
131 struct ubik_trans *tt;
132 char *buf;
133 long len;
134 {
135     int status;
136     
137     status = read(dbase_fd, buf, len);
138     if (status < 0) {
139         perror("ubik_Read");
140         return(1);
141     }
142     if (status < len)
143       memset(&buf[status], 0, len - status);
144     return(0);
145 }
146
147
148 /* Global declarations from ubik.c */
149 afs_int32 ubik_quorum=0;
150 struct ubik_dbase *ubik_dbase=0;
151 struct ubik_stats ubik_stats;
152 afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR];
153 afs_int32 ubik_epochTime = 0;
154 afs_int32 urecovery_state = 0;
155
156 struct rx_securityClass *ubik_sc[3];
157
158
159 /* Other declarations */
160
161 afsconf_GetNoAuthFlag()
162 {
163     return(1);
164 }
165
166
167 char *prdir = "/dev/null";
168 struct prheader cheader;
169 int pr_realmNameLen;
170 char *pr_realmName;