From b0114ea8083db68f7058bf0bf99c7de086c30783 Mon Sep 17 00:00:00 2001 From: Sam Hartman Date: Fri, 19 Jan 2001 20:54:21 +0000 Subject: [PATCH] Initial revision --- src/config/Makefile.s390_linux22 | 50 +++ src/config/Makefile.sun4x_58 | 51 +++ src/config/param.s390_linux22.h | 67 ++++ src/config/param.s390_linux22_usr.h | 56 +++ src/des/conf-s390-linux.h | 15 + src/ptserver/pt_util.c | 530 ++++++++++++++++++++++++++++ src/ptserver/ubik.c | 165 +++++++++ 7 files changed, 934 insertions(+) create mode 100644 src/config/Makefile.s390_linux22 create mode 100644 src/config/Makefile.sun4x_58 create mode 100644 src/config/param.s390_linux22.h create mode 100644 src/config/param.s390_linux22_usr.h create mode 100644 src/des/conf-s390-linux.h create mode 100644 src/ptserver/pt_util.c create mode 100644 src/ptserver/ubik.c diff --git a/src/config/Makefile.s390_linux22 b/src/config/Makefile.s390_linux22 new file mode 100644 index 000000000..a8ee3b65d --- /dev/null +++ b/src/config/Makefile.s390_linux22 @@ -0,0 +1,50 @@ +# Copyright 1998 Transarc Corporation +# +# Keep macros within each section in sorted order for clean diff displays. +# +# AFS_OSTYPE used to indicate suffixes and os specific subdirectories. +AFS_OSTYPE = LINUX + +# Base directory for linux kernel source. Actually a prefix which is complete +# when LINUX_VERS is appended to it. +LINUX_SRCDIR = /usr/src/linux- +# Default list of Linux kernels to build. Build will run only if all +# can be built. To build a different set, specify LINUX_VERS to make. +LINUX_VERS = 2.2.16 + +# +# compilation and link editor flags +DBG=-g +OPTMZ=-O2 +PAM_CFLAGS = -O2 -Dlinux -DLINUX_PAM -fPIC +# Put -O2 here to _ensure_ all Makefiles pick it up. +XCFLAGS= -O2 +MT_CFLAGS=-DAFS_PTHREAD_ENV -pthread -D_REENTRANT ${XCFLAGS} +XLDFLAGS= +SHARE_LDFLAGS = -shared -Xlinker -x +SHLIB_SUFFIX=so +SHLIB_CFLAGS= +# +# libraries +MTLIBS=-lpthread +TXLIBS= /usr/lib/libncurses.so +XLIBS= +# +# programs +AR=ar +AS=as +CP=cp +INSTALL=${SRCDIR}bin/install +LD=gcc +MT_CC=gcc +MV=mv +RANLIB=ranlib +RM=rm +WASHTOOL=${SRCDIR}bin/washtool +# +# Other OS specific requirements +# +YACC = bison -y +LEX = flex -l +# Used in des library. +CRYPT_OBJ = crypt.o diff --git a/src/config/Makefile.sun4x_58 b/src/config/Makefile.sun4x_58 new file mode 100644 index 000000000..3701bfda6 --- /dev/null +++ b/src/config/Makefile.sun4x_58 @@ -0,0 +1,51 @@ +# Keep macros within each section in sorted order for clean diff displays. +# +# AFS_OSTYPE used to indicate suffixes and os specific subdirectories. +AFS_OSTYPE = SOLARIS +# +# compilation and link editor flags +XCFLAGS=-dy -Bdynamic +MT_CFLAGS=-mt -DAFS_PTHREAD_ENV ${XCFLAGS} +PAM_CFLAGS = -KPIC +PAMLIBS= -lc -lpam -lsocket -lnsl -lm +SHARE_LDFLAGS = -G -Bsymbolic +LWP_OPTMZ=-g +OPTMZ=-O +DBG=-g + +## Compilation flags for 64 bit Solaris +XCFLAGS64 = ${XCFLAGS} -xarch=v9 + +# +# libraries +XLIBS=-lsocket -lnsl -lintl -ldl +TXLIBS=-lcurses +MTLIBS=-lpthread -lsocket +XLIBELFA=-lelf +XLIBKVM=-lkvm +# +SHLIB_SUFFIX=so +SHLIB_CFLAGS=-KPIC +# +# programs +AR=/usr/ccs/bin/ar +AS=as +CC=/opt/SUNWspro/bin/cc +MT_CC=/opt/SUNWspro/bin/cc +CP=/bin/cp +INSTALL=${SRCDIR}bin/install +LEX=lex +LD= /usr/ccs/bin/ld +LORDER = /usr/ccs/bin/lorder +MV=mv +RANLIB=/bin/true +RM=rm +STRIP= /usr/ccs/bin/strip +WASHTOOL=${SRCDIR}bin/washtool +# +# this is for the vol package +FS_CONV_SOL26= $(DESTDIR)root.server/usr/afs/bin/fs_conv_sol26 +# +# This is the XBSA make flag and pathname to XBSA header files (xbsa.h) +XBSA_FLAGS=-Dxbsa +XBSADIR=/opt/tivoli/tsm/client/api/bin/xopen diff --git a/src/config/param.s390_linux22.h b/src/config/param.s390_linux22.h new file mode 100644 index 000000000..f9fbb048d --- /dev/null +++ b/src/config/param.s390_linux22.h @@ -0,0 +1,67 @@ +/* Copyright (C) 1998 by Transarc Corporation */ + + +#ifndef _PARAM_S390_LINUX22_H_ +#define _PARAM_S390_LINUX22_H_ + +/* In user space the AFS_LINUX20_ENV should be sufficient. In the kernel, + * it's a judgment call. If something is obviously s390 specific, use that + * #define instead. Note that "20" refers to the linux 2.0 kernel. The "2" + * in the sysname is the current version of the client. This takes into + * account the perferred OS user space configuration as well as the kernel. + */ + +#define AFS_LINUX20_ENV 1 +#define AFS_LINUX22_ENV 1 +#define AFS_S390_LINUX20_ENV 1 +#define AFS_S390_LINUX22_ENV 1 +#define AFS_NONFSTRANS 1 + +#define AFS_MOUNT_AFS "afs" /* The name of the filesystem type. */ +#define AFS_SYSCALL 137 +#define AFS_64BIT_IOPS_ENV 1 +#define AFS_NAMEI_ENV 1 /* User space interface to file system */ +#include + +#define AFS_USERSPACE_IP_ADDR 1 +#define RXK_LISTENER_ENV 1 +#define AFS_GCPAGS 0 /* if nonzero, garbage collect PAGs */ + + +/* Machine / Operating system information */ +#define SYS_NAME "s390_linux22" +#define SYS_NAME_ID SYS_NAME_ID_s390_linux22 +#define AFSBIG_ENDIAN 1 +#define AFS_HAVE_FFS 1 /* Use system's ffs. */ +#define AFS_HAVE_STATVFS 0 /* System doesn't support statvfs */ +#define AFS_VM_RDWR_ENV 1 /* read/write implemented via VM */ + +#if defined(__KERNEL__) && !defined(KDUMP_KERNEL) +#include +#ifdef CONFIG_SMP +#undef CONFIG_SMP +#endif +/* Using "AFS_SMP" to map to however many #define's are required to get + * MP to compile for Linux + */ +#ifdef AFS_SMP +#define CONFIG_SMP +#ifndef CONFIG_S390_LOCAL_APIC +#define CONFIG_S390_LOCAL_APIC +#endif +#define __SMP__ +#define AFS_GLOBAL_SUNLOCK +#endif + +#endif /* __KERNEL__ && !DUMP_KERNEL*/ + +#ifdef KERNEL +#ifndef MIN +#define MIN(A,B) ((A) < (B) ? (A) : (B)) +#endif +#ifndef MAX +#define MAX(A,B) ((A) > (B) ? (A) : (B)) +#endif +#endif /* KERNEL */ + +#endif /* _PARAM_S390_LINUX20_H_ */ diff --git a/src/config/param.s390_linux22_usr.h b/src/config/param.s390_linux22_usr.h new file mode 100644 index 000000000..b26439c04 --- /dev/null +++ b/src/config/param.s390_linux22_usr.h @@ -0,0 +1,56 @@ +/* Copyright (C) 1998 by Transarc Corporation */ + + +#ifndef _PARAM_USR_S390_LINUX22_H_ +#define _PARAM_USR_S390_LINUX22_H_ + +/* In user space the AFS_LINUX20_ENV should be sufficient. In the kernel, + * it's a judgment call. If something is obviously s390 specific, use that + * #define instead. Note that "20" refers to the linux 2.0 kernel. The "2" + * in the sysname is the current version of the client. This takes into + * account the perferred OS user space configuration as well as the kernel. + */ + +#define UKERNEL 1 /* user space kernel */ +#define AFS_ENV 1 +#define AFS_USR_LINUX20_ENV 1 +#define AFS_USR_LINUX22_ENV 1 +#define AFS_NONFSTRANS 1 + +#define AFS_MOUNT_AFS "afs" /* The name of the filesystem type. */ +#define AFS_SYSCALL 137 +#define AFS_64BIT_IOPS_ENV 1 +#define AFS_NAMEI_ENV 1 /* User space interface to file system */ +#include + +#define AFS_USERSPACE_IP_ADDR 1 +#define RXK_LISTENER_ENV 1 +#define AFS_GCPAGS 0 /* if nonzero, garbage collect PAGs */ + + +/* Machine / Operating system information */ +#define SYS_NAME "s390_linux22" +#define SYS_NAME_ID SYS_NAME_ID_s390_linux22 +#define AFSBIG_ENDIAN 1 +#define AFS_HAVE_FFS 1 /* Use system's ffs. */ +#define AFS_HAVE_STATVFS 0 /* System doesn't support statvfs */ +#define AFS_VM_RDWR_ENV 1 /* read/write implemented via VM */ + +#define afsio_iov uio_iov +#define afsio_iovcnt uio_iovcnt +#define afsio_offset uio_offset +#define afsio_seg uio_segflg +#define afsio_fmode uio_fmode +#define afsio_resid uio_resid +#define AFS_UIOSYS 1 +#define AFS_UIOUSER UIO_USERSPACE +#define AFS_CLBYTES MCLBYTES +#define AFS_MINCHANGE 2 +#define VATTR_NULL usr_vattr_null + +#define AFS_DIRENT +#ifndef CMSERVERPREF +#define CMSERVERPREF +#endif + +#endif /* _PARAM_USR_S390_LINUX22_H_ */ diff --git a/src/des/conf-s390-linux.h b/src/des/conf-s390-linux.h new file mode 100644 index 000000000..90a74d7b5 --- /dev/null +++ b/src/des/conf-s390-linux.h @@ -0,0 +1,15 @@ +/* + * Copyright 1988 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * Machine-type definitions: Linux on Intel + */ + +#include + +#define BITS32 +#define BIG +#define MSBFIRST +#define MUSTALIGN diff --git a/src/ptserver/pt_util.c b/src/ptserver/pt_util.c new file mode 100644 index 000000000..7ffe0646c --- /dev/null +++ b/src/ptserver/pt_util.c @@ -0,0 +1,530 @@ +/* $Id: pt_util.c,v 1.1 2001/01/19 20:55:42 hartmans Exp $ */ + +/* + * + * pt_util: Program to dump the AFS protection server database + * into an ascii file. + * + * Assumptions: We *cheat* here and read the datafile directly, ie. + * not going through the ubik distributed data manager. + * therefore the database must be quiescent for the + * output of this program to be valid. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#define UBIK_INTERNALS +#include +#include +#include +#include "ptint.h" +#include "ptserver.h" +#include "pterror.h" + +#define IDHash(x) (abs(x) % HASHSIZE) +#define print_id(x) ( ((flags&DO_SYS)==0 && (x<-32767 || x>97536)) || \ + ((flags&DO_OTR)==0 && (x>-32768 && x<97537))) + +extern char *optarg; +extern int optind; +extern int errno; + +int display_entry(); +void add_group(); +void display_groups(); +void display_group(); +void fix_pre(); +char *checkin(); +char *check_core(); +char *id_to_name(); + +struct hash_entry { + char h_name[PR_MAXNAMELEN]; + int h_id; + struct hash_entry *next; +}; +struct hash_entry *hat[HASHSIZE]; + +static struct contentry prco; +static struct prentry pre; +static struct prheader prh; +static struct ubik_version uv; + +struct grp_list { + struct grp_list *next; + long groups[1024]; +}; +static struct grp_list *grp_head=0; +static long grp_count=0; + +struct usr_list { + struct usr_list *next; + char name[PR_MAXNAMELEN]; + long uid; +}; +static struct usr_list *usr_head=0; + +char buffer[1024]; +int dbase_fd; +FILE *dfp; + +#define FMT_BASE "%-10s %d/%d %d %d %d\n" +#define FMT_MEM " %-8s %d\n" + +#define DO_USR 1 +#define DO_GRP 2 +#define DO_MEM 4 +#define DO_SYS 8 +#define DO_OTR 16 + +int nflag = 0; +int wflag = 0; +int flags = 0; + +main(argc, argv) +int argc; +char **argv; +{ + register int i; + register long code; + long cc, upos, gpos; + struct prentry uentry, gentry; + struct ubik_hdr *uh; + char *dfile = 0; + char *pfile = "/usr/afs/db/prdb.DB0"; + + while ((cc = getopt(argc, argv, "wugmxsnp:d:")) != EOF) { + switch (cc) { + case 'p': + pfile = optarg; + break; + case 'd': + dfile = optarg; + break; + case 'n': + nflag++; + break; + case 'w': + wflag++; + break; + case 'u': + flags |= DO_USR; + break; + case 'm': + flags |= (DO_GRP|DO_MEM); + break; + case 'g': + flags |= DO_GRP; + break; + case 's': + flags |= DO_SYS; + break; + case 'x': + flags |= DO_OTR; + break; + default: + fprintf(stderr, + "Usage: pt_util [options] [-d data] [-p prdb]\n"); + fputs(" Options:\n", stderr); + fputs(" -w Update prdb with contents of data file\n", stderr); + fputs(" -u Display users\n", stderr); + fputs(" -g Display groups\n", stderr); + fputs(" -m Display group members\n", stderr); + fputs(" -n Follow name hash chains (not id hashes)\n", stderr); + fputs(" -s Display only system data\n", stderr); + fputs(" -x Display extra users/groups\n", stderr); + exit(1); + } + } + if ((dbase_fd = open(pfile, (wflag ? O_RDWR : O_RDONLY)|O_CREAT, 0600)) + < 0) { + fprintf(stderr, "pt_util: cannot open %s: %s\n", + pfile, strerror(errno)); + exit (1); + } + if (read(dbase_fd, buffer, HDRSIZE) < 0) { + fprintf(stderr, "pt_util: error reading %s: %s\n", + pfile, strerror(errno)); + exit (1); + } + + if (dfile) { + if ((dfp = fopen(dfile, wflag ? "r" : "w")) == 0) { + fprintf(stderr, "pt_util: error opening %s: %s\n", + dfile, strerror(errno)); + exit(1); + } + } else + dfp = (wflag ? stdin : stdout); + + uh = (struct ubik_hdr *)buffer; + if (ntohl(uh->magic) != UBIK_MAGIC) + fprintf(stderr, "pt_util: %s: Bad UBIK_MAGIC. Is %x should be %x\n", + pfile, ntohl(uh->magic), UBIK_MAGIC); + memcpy(&uv, &uh->version, sizeof(struct ubik_version)); + if (wflag && uv.epoch==0 && uv.counter==0) { + uv.epoch=2; /* a ubik version of 0 or 1 has special meaning */ + memcpy(&uh->version, &uv, sizeof(struct ubik_version)); + lseek(dbase_fd, 0, SEEK_SET); + if (write(dbase_fd, buffer, HDRSIZE) < 0) { + fprintf(stderr, "pt_util: error writing ubik version to %s: %s\n", + pfile, strerror(errno)); + exit (1); + } + } + fprintf(stderr, "Ubik Version is: %d.%d\n", + uv.epoch, uv.counter); + if (read(dbase_fd, &prh, sizeof(struct prheader)) < 0) { + fprintf(stderr, "pt_util: error reading %s: %s\n", + pfile, strerror(errno)); + exit (1); + } + + Initdb(); + initialize_pt_error_table(); + + if (wflag) { + struct usr_list *u; + + while(fgets(buffer, sizeof(buffer), dfp)) { + int id, oid, cid, flags, quota, uid; + char name[PR_MAXNAMELEN], mem[PR_MAXNAMELEN]; + + if (isspace(*buffer)) { + sscanf(buffer, "%s %d", mem, &uid); + + for (u=usr_head; u; u=u->next) + if (u->uid && u->uid==uid) break; + if (u) { + /* Add user - deferred because it is probably foreign */ + u->uid = 0; + if (FindByID(0, uid)) + code = PRIDEXIST; + else { + if (!code && (flags&(PRGRP|PRQUOTA))==(PRGRP|PRQUOTA)){ + gentry.ngroups++; + code = pr_WriteEntry(0,0,gpos,&gentry); + if (code) + fprintf(stderr, "Error setting group count on %s: %s\n", + name, error_message(code)); + } + code = CreateEntry + (0, u->name, &uid, 1/*idflag*/, 1/*gflag*/, + SYSADMINID/*oid*/, SYSADMINID/*cid*/); + } + if (code) + fprintf(stderr, "Error while creating %s: %s\n", + u->name, error_message(code)); + continue; + } + /* Add user to group */ + if (id==ANYUSERID || id==AUTHUSERID || uid==ANONYMOUSID) { + code = PRPERM; + } else if ((upos=FindByID(0,uid)) && (gpos=FindByID(0,id))) { + code = pr_ReadEntry(0,0,upos,&uentry); + if (!code) code = pr_ReadEntry(0,0,gpos,&gentry); + if (!code) code = AddToEntry (0, &gentry, gpos, uid); + if (!code) code = AddToEntry (0, &uentry, upos, id); + } else + code = PRNOENT; + + if (code) + fprintf(stderr, "Error while adding %s to %s: %s\n", + mem, name, error_message(code)); + } else { + sscanf(buffer, "%s %d/%d %d %d %d", + name, &flags, "a, &id, &oid, &cid); + + if (FindByID(0, id)) + code = PRIDEXIST; + else + code = CreateEntry(0, name, &id, 1/*idflag*/, + flags&PRGRP, oid, cid); + if (code == PRBADNAM) { + u = (struct usr_list *)malloc(sizeof(struct usr_list)); + u->next = usr_head; + u->uid = id; + strcpy(u->name, name); + usr_head = u; + } else + if (code) { + fprintf(stderr, "Error while creating %s: %s\n", + name, error_message(code)); + } else if ((flags&PRACCESS) || + (flags&(PRGRP|PRQUOTA))==(PRGRP|PRQUOTA)) { + gpos = FindByID(0, id); + code = pr_ReadEntry(0,0,gpos,&gentry); + if (!code) { + gentry.flags = flags; + gentry.ngroups = quota; + code = pr_WriteEntry(0,0,gpos,&gentry); + } + if (code) + fprintf(stderr,"Error while setting flags on %s: %s\n", + name, error_message(code)); + } + } + } + for (u=usr_head; u; u=u->next) + if (u->uid) + fprintf(stderr, "Error while creating %s: %s\n", + u->name, error_message(PRBADNAM)); + } else { + for (i = 0; i < HASHSIZE; i++) { + upos = nflag ? ntohl(prh.nameHash[i]) : ntohl(prh.idHash[i]); + while (upos) + upos = display_entry(upos); + } + if (flags & DO_GRP) + display_groups(); + } + + lseek (dbase_fd, 0, L_SET); /* rewind to beginning of file */ + if (read(dbase_fd, buffer, HDRSIZE) < 0) { + fprintf(stderr, "pt_util: error reading %s: %s\n", + pfile, strerror(errno)); + exit (1); + } + uh = (struct ubik_hdr *)buffer; + if ((uh->version.epoch != uv.epoch) || + (uh->version.counter != uv.counter)) { + fprintf(stderr, "pt_util: Ubik Version number changed during execution.\n"); + fprintf(stderr, "Old Version = %d.%d, new version = %d.%d\n", + uv.epoch, uv.counter, uh->version.epoch, + uh->version.counter); + } + close (dbase_fd); + exit (0); +} + +int display_entry (offset) +int offset; +{ + register int i; + + lseek (dbase_fd, offset+HDRSIZE, L_SET); + read(dbase_fd, &pre, sizeof(struct prentry)); + + fix_pre(&pre); + + if ((pre.flags & PRFREE) == 0) { + if (pre.flags & PRGRP) { + if (flags & DO_GRP) + add_group(pre.id); + } else { + if (print_id(pre.id) && (flags&DO_USR)) + fprintf(dfp, FMT_BASE, + pre.name, pre.flags, pre.ngroups, + pre.id, pre.owner, pre.creator); + checkin(&pre); + } + } + return(nflag ? pre.nextName: pre.nextID); +} + +void add_group(id) + long id; +{ + struct grp_list *g; + register long i; + + i = grp_count++ % 1024; + if (i == 0) { + g = (struct grp_list *)malloc(sizeof(struct grp_list)); + g->next = grp_head; + grp_head = g; + } + g = grp_head; + g->groups[i] = id; +} + +void display_groups() +{ + register int i, id; + struct grp_list *g; + + g = grp_head; + while (grp_count--) { + i = grp_count%1024; + id = g->groups[i]; + display_group(id); + if (i==0) { + grp_head = g->next; + free(g); + g = grp_head; + } + } +} + +void display_group(id) + int id; +{ + register int i, offset; + int print_grp = 0; + + offset = ntohl(prh.idHash[IDHash(id)]); + while (offset) { + lseek(dbase_fd, offset+HDRSIZE, L_SET); + if (read(dbase_fd, &pre, sizeof(struct prentry)) < 0) { + fprintf(stderr, "pt_util: read i/o error: %s\n", + strerror(errno)); + exit (1); + } + fix_pre(&pre); + if (pre.id == id) + break; + offset = pre.nextID; + } + + if (print_id(id)) { + fprintf(dfp, FMT_BASE, + pre.name, pre.flags, pre.ngroups, + pre.id, pre.owner, pre.creator); + print_grp = 1; + } + + if ((flags&DO_MEM) == 0) + return; + + for (i=0; iflags = ntohl(pre->flags); + pre->id = ntohl(pre->id); + pre->cellid = ntohl(pre->cellid); + pre->next = ntohl(pre->next); + pre->nextID = ntohl(pre->nextID); + pre->nextName = ntohl(pre->nextName); + pre->owner = ntohl(pre->owner); + pre->creator = ntohl(pre->creator); + pre->ngroups = ntohl(pre->ngroups); + pre->nusers = ntohl(pre->nusers); + pre->count = ntohl(pre->count); + pre->instance = ntohl(pre->instance); + pre->owned = ntohl(pre->owned); + pre->nextOwned = ntohl(pre->nextOwned); + pre->parent = ntohl(pre->parent); + pre->sibling = ntohl(pre->sibling); + pre->child = ntohl(pre->child); + for (i = 0; i < PRSIZE; i++) { + pre->entries[i] = ntohl(pre->entries[i]); + } +} + +char *id_to_name(id) +int id; +{ + register int offset; + static struct prentry pre; + char *name; + + name = check_core(id); + if (name) return(name); + offset = ntohl(prh.idHash[IDHash(id)]); + while (offset) { + lseek(dbase_fd, offset+HDRSIZE, L_SET); + if (read(dbase_fd, &pre, sizeof(struct prentry)) < 0) { + fprintf(stderr, "pt_util: read i/o error: %s\n", + strerror(errno)); + exit (1); + } + pre.id = ntohl(pre.id); + if (pre.id == id) { + name = checkin(&pre); + return(name); + } + offset = ntohl(pre.nextID); + } + return 0; +} + +char *checkin(pre) +struct prentry *pre; +{ + struct hash_entry *he, *last; + register int id; + + id = pre->id; + last = (struct hash_entry *)0; + he = hat[IDHash(id)]; + while (he) { + if (id == he->h_id) return(he->h_name); + last = he; + he = he->next; + } + he = (struct hash_entry *)malloc(sizeof(struct hash_entry)); + if (he == 0) { + fprintf(stderr, "pt_util: No Memory for internal hash table.\n"); + exit (1); + } + he->h_id = id; + he->next = (struct hash_entry *)0; + strncpy(he->h_name, pre->name, PR_MAXNAMELEN); + if (last == (struct hash_entry *)0) hat[IDHash(id)] = he; + else last->next = he; + return(he->h_name); +} + +char *check_core(id) +register int id; +{ + struct hash_entry *he; + he = hat[IDHash(id)]; + while (he) { + if (id == he->h_id) return(he->h_name); + he = he->next; + } + return 0; +} diff --git a/src/ptserver/ubik.c b/src/ptserver/ubik.c new file mode 100644 index 000000000..a9733fff5 --- /dev/null +++ b/src/ptserver/ubik.c @@ -0,0 +1,165 @@ +/* $Id: ubik.c,v 1.1 2001/01/19 20:55:46 hartmans Exp $ */ + +#include +#include + +#include +#define UBIK_INTERNALS +#include +#include +#include +#include "ptint.h" +#include "ptserver.h" + +extern int dbase_fd; +struct ubik_dbase *dbase; + +int ubik_ServerInit() +{ + return(0); +} + +int ubik_BeginTrans() +{ + 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); + lseek(dbase_fd, 0, 0); + write(dbase_fd, &thdr, sizeof(thdr)); + fsync(dbase_fd); + init = 1; + } + return(0); +} + +int ubik_BeginTransReadAny() +{ + return(0); +} + +int ubik_AbortTrans() +{ + return(0); +} + +int ubik_EndTrans() +{ + return(0); +} + +int ubik_Tell() +{ + return(0); +} + +int ubik_Truncate() +{ + return(0); +} + +long ubik_SetLock() +{ + return(0); +} + +int ubik_WaitVersion() +{ + return(0); +} + +int ubik_CacheUpdate() +{ + return(0); +} + +int panic(a, b, c, d) +char *a, *b, *c, *d; +{ + printf(a, b, c, d); + abort(); + 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; +{ + memset(ver, 0, sizeof(struct ubik_version)); + return(0); +} + + +int ubik_Seek(tt, afd, pos) +struct ubik_trans *tt; +long afd; +long pos; +{ + if (lseek(dbase_fd, pos+HDRSIZE, 0) < 0) { + perror("ubik_Seek"); + return(-1); + } + return(0); +} + +int ubik_Write(tt, buf, len) +struct ubik_trans *tt; +char *buf; +long len; +{ + int status; + + status = write(dbase_fd, buf, len); + if (status < len) { + perror("ubik_Write"); + return(1); + } + return(0); +} + +int ubik_Read(tt, buf, len) +struct ubik_trans *tt; +char *buf; +long len; +{ + int status; + + status = read(dbase_fd, buf, len); + if (status < 0) { + perror("ubik_Read"); + return(1); + } + if (status < len) + memset(&buf[status], 0, len - status); + return(0); +} + + +/* Global declarations from ubik.c */ +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; +afs_int32 urecovery_state = 0; + +struct rx_securityClass *ubik_sc[3]; + + +/* Other declarations */ + +afsconf_GetNoAuthFlag() +{ + return(1); +} + + +char *prdir = "/dev/null"; +struct prheader cheader; +int pr_realmNameLen; +char *pr_realmName; -- 2.39.5