Protect ubik cache accesses
[openafs.git] / src / ptserver / ubik.c
index 7a6ad11..2124e6c 100644 (file)
@@ -1,16 +1,22 @@
 /* $Id$ */
 
-#include <afs/param.h>
 #include <afsconfig.h>
+#include <afs/param.h>
 
-RCSID("$Header$");
 
 #include <sys/types.h>
+#ifdef AFS_NT40_ENV
+#include <io.h>
+#else
 #include <netinet/in.h>
+#endif
+#include <string.h>
+#include <stdarg.h>
 
 #include <lock.h>
 #define UBIK_INTERNALS
 #include <afs/stds.h>
+#include <afs/cellconfig.h>
 #include <ubik.h>
 #include <rx/xdr.h>
 #include "ptint.h"
@@ -19,135 +25,149 @@ RCSID("$Header$");
 extern int dbase_fd;
 struct ubik_dbase *dbase;
 
-int ubik_ServerInit()
+int
+ubik_ServerInit(afs_int32 myHost, short myPort, afs_int32 serverList[],
+                const char *pathName, struct ubik_dbase **dbase)
 {
-    return(0);
+    return (0);
 }
 
-int ubik_BeginTrans()
+int
+ubik_BeginTrans(register struct ubik_dbase *dbase, afs_int32 transMode, 
+               struct ubik_trans **transPtr)
 {
-    static int init=0;
+    static int init = 0;
     struct ubik_hdr thdr;
 
     if (!init) {
        thdr.version.epoch = htonl(2);
        thdr.version.counter = htonl(0);
        thdr.magic = htonl(UBIK_MAGIC);
-       thdr.size = htonl(HDRSIZE);
+       thdr.size = htons(HDRSIZE);
        lseek(dbase_fd, 0, 0);
        write(dbase_fd, &thdr, sizeof(thdr));
        fsync(dbase_fd);
        init = 1;
     }
-    return(0);
+    return (0);
 }
 
-int ubik_BeginTransReadAny()
+int
+ubik_BeginTransReadAny(register struct ubik_dbase *dbase, afs_int32 transMode,
+                       struct ubik_trans **transPtr)
 {
-    return(0);
+    return (0);
 }
 
-int ubik_AbortTrans()
+int
+ubik_AbortTrans(register struct ubik_trans *transPtr)
 {
-    return(0);
+    return (0);
 }
 
-int ubik_EndTrans()
+int
+ubik_EndTrans(register struct ubik_trans *transPtr)
 {
-    return(0);
+    return (0);
 }
 
-int ubik_Tell()
+int
+ubik_Tell(register struct ubik_trans *transPtr, afs_int32 * fileid,
+          afs_int32 * position)
 {
-    return(0);
+    return (0);
 }
 
-int ubik_Truncate()
+int
+ubik_Truncate(register struct ubik_trans *transPtr, afs_int32 length)
 {
-    return(0);
+    return (0);
 }
 
-long ubik_SetLock()
+int
+ubik_SetLock(struct ubik_trans *atrans, afs_int32 apos, afs_int32 alen,
+             int atype)
 {
-    return(0);
+    return (0);
 }
 
-int ubik_WaitVersion()
+int
+ubik_WaitVersion(register struct ubik_dbase *adatabase,
+                 register struct ubik_version *aversion)
 {
-    return(0);
+    return (0);
 }
 
-int ubik_CacheUpdate()
+int
+ubik_CheckCache(struct ubik_trans *atrans, ubik_updatecache_func cbf, void *rock)
 {
-    return(0);
+    return (0);
 }
 
-int panic(a, b, c, d)
-char *a, *b, *c, *d;
+void
+panic(char *format, ...)
 {
-    printf(a, b, c, d);
+    va_list ap;
+
+    va_start(ap, format);
+    vprintf(format, ap);
+    va_end(ap);
+    
     abort();
-    printf("BACK FROM ABORT\n");    /* shouldn't come back from floating pt exception */
-    exit(1);    /* never know, though */
+    printf("BACK FROM ABORT\n");       /* shouldn't come back from floating pt exception */
+    exit(1);                   /* never know, though */
 }
 
-int ubik_GetVersion(dummy, ver)
-int dummy;
-struct ubik_version *ver;
+int
+ubik_GetVersion(struct ubik_trans *dummy, struct ubik_version *ver)
 {
     memset(ver, 0, sizeof(struct ubik_version));
-    return(0);
+    return (0);
 }
 
 
-int ubik_Seek(tt, afd, pos)
-struct ubik_trans *tt;
-long afd;
-long pos;
+int
+ubik_Seek(struct ubik_trans *tt, afs_int32 afd, afs_int32 pos)
 {
-    if (lseek(dbase_fd, pos+HDRSIZE, 0) < 0) {
+    if (lseek(dbase_fd, pos + HDRSIZE, 0) < 0) {
        perror("ubik_Seek");
-       return(-1);
+       return (-1);
     }
-    return(0);
+    return (0);
 }
 
-int ubik_Write(tt, buf, len)
-struct ubik_trans *tt;
-char *buf;
-long len;
+int
+ubik_Write(struct ubik_trans *tt, void *buf, afs_int32 len)
 {
     int status;
 
     status = write(dbase_fd, buf, len);
     if (status < len) {
        perror("ubik_Write");
-       return(1);
+       return (1);
     }
-    return(0);
+    return (0);
 }
 
-int ubik_Read(tt, buf, len)
-struct ubik_trans *tt;
-char *buf;
-long len;
+int
+ubik_Read(struct ubik_trans *tt, void *buf, afs_int32 len)
 {
     int status;
-    
+
     status = read(dbase_fd, buf, len);
     if (status < 0) {
        perror("ubik_Read");
-       return(1);
+       return (1);
     }
     if (status < len)
-      memset(&buf[status], 0, len - status);
-    return(0);
+       memset((char *)buf + status, 0, len - status);
+    return (0);
 }
 
 
 /* Global declarations from ubik.c */
-afs_int32 ubik_quorum=0;
-struct ubik_dbase *ubik_dbase=0;
+afs_int32 ubik_quorum = 0;
+struct ubik_dbase *ubik_dbase = 0;
 struct ubik_stats ubik_stats;
 afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR];
 afs_int32 ubik_epochTime = 0;
@@ -158,9 +178,10 @@ struct rx_securityClass *ubik_sc[3];
 
 /* Other declarations */
 
-afsconf_GetNoAuthFlag()
+int 
+afsconf_GetNoAuthFlag(struct afsconf_dir *adir)
 {
-    return(1);
+    return (1);
 }