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

Revision 24250, 2.4 KB checked in by broder, 15 years ago (diff)
New Moira snapshot from subversion. Sorry for the large diff - looks like all of the keywords changed in the SVN import process.
Line 
1/* $Id: ubik.c,v 1.7 2009-12-29 17:29:27 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
15#define HDRSIZE             64  /* bytes of header per dbfile */
16#define UBIK_MAGIC      0x354545
17
18extern int dbase_fd;
19struct ubik_dbase *dbase;
20
21int ubik_ServerInit()
22{
23    return(0);
24}
25
26int ubik_BeginTrans(register struct ubik_dbase *dbase,
27                    afs_int32 transMode, struct ubik_trans **transPtr)
28{
29    static int init=0;
30    struct ubik_hdr thdr;
31
32    if (!init) {
33        thdr.version.epoch = htonl(0);
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
45int ubik_BeginTransReadAny()
46{
47    return(0);
48}
49
50int ubik_AbortTrans()
51{
52    return(0);
53}
54
55int ubik_EndTrans(register struct ubik_trans *transPtr)
56{
57    return(0);
58}
59
60int ubik_Tell()
61{
62    return(0);
63}
64
65int ubik_Truncate()
66{
67    return(0);
68}
69
70long ubik_SetLock()
71{
72    return(0);
73}
74
75int ubik_WaitVersion()
76{
77    return(0);
78}
79
80int ubik_CacheUpdate()
81{
82    return(0);
83}
84
85int panic(a, b, c, d)
86char *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
94int ubik_GetVersion(dummy, ver)
95int dummy;
96struct ubik_version *ver;
97{
98    memset(ver, 0, sizeof(struct ubik_version));
99    return(0);
100}
101
102
103int ubik_Seek(tt, afd, pos)
104struct ubik_trans *tt;
105long afd;
106long pos;
107{
108    if (lseek(dbase_fd, pos+HDRSIZE, 0) < 0) {
109        perror("ubik_Seek");
110        return(-1);
111    }
112    return(0);
113}
114
115int ubik_Write(tt, buf, len)
116struct ubik_trans *tt;
117char *buf;
118long 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
130int ubik_Read(tt, buf, len)
131struct ubik_trans *tt;
132char *buf;
133long 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
147struct rx_securityClass *ubik_sc[3];
148
149/* Other declarations */
150
151afsconf_GetNoAuthFlag()
152{
153    return(1);
154}
155
156
157char *prdir = "/dev/null";
158struct prheader cheader;
159int pr_realmNameLen;
160char *pr_realmName;
Note: See TracBrowser for help on using the repository browser.