source: trunk/third/moira/afssync/ubik.c @ 23740

Revision 23740, 2.7 KB checked in by broder, 16 years ago (diff)
In moira: * New CVS snapshot (Trac: #195) * Drop patches that have been incorporated upstream. * Update to build without krb4 on systems that no longer have it. This doesn't build yet on squeeze, which lacks a krb4 library, but I'm committing now before I start hacking away at a patch to fix that.
Line 
1/* $Id: ubik.c,v 1.6 2006-05-12 20:20:08 zacheiss Exp $ */
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 <rx/xdr.h>
10#include "print.h"
11#include "prserver.h"
12
13/* Stolen bits of ubik.h. */
14
15struct ubik_version {
16  afs_int32 epoch;
17  afs_int32 counter;
18};
19typedef struct ubik_version ubik_version;
20
21/* ubik header file structure */
22struct 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
32extern int dbase_fd;
33struct ubik_dbase *dbase;
34
35int ubik_ServerInit()
36{
37    return(0);
38}
39
40int ubik_BeginTrans()
41{
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    }
55    return(0);
56}
57
58int ubik_BeginTransReadAny()
59{
60    return(0);
61}
62
63int ubik_AbortTrans()
64{
65    return(0);
66}
67
68int ubik_EndTrans()
69{
70    return(0);
71}
72
73int ubik_Tell()
74{
75    return(0);
76}
77
78int ubik_Truncate()
79{
80    return(0);
81}
82
83long ubik_SetLock()
84{
85    return(0);
86}
87
88int ubik_WaitVersion()
89{
90    return(0);
91}
92
93int ubik_CacheUpdate()
94{
95    return(0);
96}
97
98int panic(a, b, c, d)
99char *a, *b, *c, *d;
100{
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
107int ubik_GetVersion(dummy, ver)
108int dummy;
109struct ubik_version *ver;
110{
111    memset(ver, 0, sizeof(struct ubik_version));
112    return(0);
113}
114
115
116int ubik_Seek(tt, afd, pos)
117struct ubik_trans *tt;
118long afd;
119long pos;
120{
121    if (lseek(dbase_fd, pos+HDRSIZE, 0) < 0) {
122        perror("ubik_Seek");
123        return(-1);
124    }
125    return(0);
126}
127
128int ubik_Write(tt, buf, len)
129struct ubik_trans *tt;
130char *buf;
131long 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
143int ubik_Read(tt, buf, len)
144struct ubik_trans *tt;
145char *buf;
146long 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)
156      memset(&buf[status], 0, len - status);
157    return(0);
158}
159
160struct rx_securityClass *ubik_sc[3];
161
162/* Other declarations */
163
164afsconf_GetNoAuthFlag()
165{
166    return(1);
167}
168
169
170char *prdir = "/dev/null";
171struct prheader cheader;
172int pr_realmNameLen;
173char *pr_realmName;
Note: See TracBrowser for help on using the repository browser.