[24319] | 1 | /* $Id: ubik.c 3956 2010-01-05 20:56:56Z zacheiss $ */ |
---|
[23095] | 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 | |
---|
| 18 | extern int dbase_fd; |
---|
| 19 | struct ubik_dbase *dbase; |
---|
| 20 | |
---|
| 21 | int ubik_ServerInit() |
---|
| 22 | { |
---|
| 23 | return(0); |
---|
| 24 | } |
---|
| 25 | |
---|
[24250] | 26 | int ubik_BeginTrans(register struct ubik_dbase *dbase, |
---|
| 27 | afs_int32 transMode, struct ubik_trans **transPtr) |
---|
[23095] | 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 | |
---|
| 45 | int ubik_BeginTransReadAny() |
---|
| 46 | { |
---|
| 47 | return(0); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | int ubik_AbortTrans() |
---|
| 51 | { |
---|
| 52 | return(0); |
---|
| 53 | } |
---|
| 54 | |
---|
[24250] | 55 | int ubik_EndTrans(register struct ubik_trans *transPtr) |
---|
[23095] | 56 | { |
---|
| 57 | return(0); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | int ubik_Tell() |
---|
| 61 | { |
---|
| 62 | return(0); |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | int ubik_Truncate() |
---|
| 66 | { |
---|
| 67 | return(0); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | long ubik_SetLock() |
---|
| 71 | { |
---|
| 72 | return(0); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | int ubik_WaitVersion() |
---|
| 76 | { |
---|
| 77 | return(0); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | int ubik_CacheUpdate() |
---|
| 81 | { |
---|
| 82 | return(0); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | int panic(a, b, c, d) |
---|
| 86 | char *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 | |
---|
| 94 | int ubik_GetVersion(dummy, ver) |
---|
| 95 | int dummy; |
---|
| 96 | struct ubik_version *ver; |
---|
| 97 | { |
---|
| 98 | memset(ver, 0, sizeof(struct ubik_version)); |
---|
| 99 | return(0); |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | int ubik_Seek(tt, afd, pos) |
---|
| 104 | struct ubik_trans *tt; |
---|
| 105 | long afd; |
---|
| 106 | long pos; |
---|
| 107 | { |
---|
| 108 | if (lseek(dbase_fd, pos+HDRSIZE, 0) < 0) { |
---|
| 109 | perror("ubik_Seek"); |
---|
| 110 | return(-1); |
---|
| 111 | } |
---|
| 112 | return(0); |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | int ubik_Write(tt, buf, len) |
---|
| 116 | struct ubik_trans *tt; |
---|
| 117 | char *buf; |
---|
| 118 | long 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 | |
---|
| 130 | int ubik_Read(tt, buf, len) |
---|
| 131 | struct ubik_trans *tt; |
---|
| 132 | char *buf; |
---|
| 133 | long 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 | |
---|
| 147 | struct rx_securityClass *ubik_sc[3]; |
---|
| 148 | |
---|
| 149 | /* Other declarations */ |
---|
| 150 | |
---|
| 151 | afsconf_GetNoAuthFlag() |
---|
| 152 | { |
---|
| 153 | return(1); |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | |
---|
| 157 | char *prdir = "/dev/null"; |
---|
| 158 | struct prheader cheader; |
---|
| 159 | int pr_realmNameLen; |
---|
| 160 | char *pr_realmName; |
---|