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