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