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