for (currp = readdir(cdirp); currp; currp = readdir(cdirp)) {
if (afsd_debug) {
printf("%s: Current directory entry:\n", rn);
-#if defined(AFS_USR_DFBSD_ENV)
+#if defined(AFS_SGI62_ENV) || defined(AFS_USR_DARWIN100_ENV)
+ printf("\tinode=%" AFS_INT64_FMT ", reclen=%d, name='%s'\n",
+ currp->d_ino, currp->d_reclen, currp->d_name);
+#elif defined(AFS_USR_DFBSD_ENV)
printf("\tinode=%d, name='%s'\n", currp->d_ino,
currp->d_name);
#else
afs_global_procp = (struct usr_proc *)
afs_osi_Alloc(sizeof(struct usr_proc));
usr_assert(afs_global_procp != NULL);
- afs_global_procp->p_pid = getpid();
+ afs_global_procp->p_pid = osi_getpid();
afs_global_procp->p_ppid = (pid_t) 1;
afs_global_procp->p_ucred = afs_global_ucredp;
#define offset_t usr_offset_t
#define getpid() usr_getpid()
#define setpag(A,B,C,D) usr_setpag((A),(B),(C),(D))
+#define osi_getpid() afs_pointer_to_int(usr_thread_self())
#ifdef pid_t
#undef pid_t
#endif
#endif
#define NBPG 4096
-#define panic(S) do{fprintf(stderr, S);assert(0);}while(0)
+#define panic(S) do{fprintf(stderr, "%s", S);assert(0);}while(0)
#define abort() assert(0)
#define usr_assert(A) assert(A)
(lp)->logElements++; \
MACRO_END
-#if defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
+#if defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)) || defined(AFS_DARWIN_ENV) && defined(__amd64__)
#define ICL_APPENDLONG(lp, x) \
MACRO_BEGIN \
ICL_APPENDINT32((lp), ((x) >> 32) & 0xffffffffL); \
while (1) {
if (alock->count == 0) {
/* lock not held, we win */
-#ifdef AFS_SUN5_ENV
- alock->proc = (char *)ttoproc(curthread);
-#else
-#ifdef AFS_64BITPOINTER_ENV
- /* To shut up SGI compiler on remark(1413) warnings. */
- alock->proc = (char *)(long)MyPidxx;
-#else /* AFS_64BITPOINTER_ENV */
- alock->proc = (char *)MyPidxx;
-#endif /* AFS_64BITPOINTER_ENV */
-#endif
+ alock->proc = afs_int_to_pointer(MyPidxx2Pid(MyPidxx));
alock->count = 1;
return;
-#ifdef AFS_SUN5_ENV
- } else if (alock->proc == (char *)ttoproc(curthread)) {
-#else
-#ifdef AFS_64BITPOINTER_ENV
- /* To shut up SGI compiler on remark(1413) warnings. */
- } else if (alock->proc == (char *)(long)MyPidxx) {
-#else /* AFS_64BITPOINTER_ENV */
- } else if (alock->proc == (char *)MyPidxx) {
-#endif /* AFS_64BITPOINTER_ENV */
-#endif
+ } else if (alock->proc == afs_int_to_pointer(MyPidxx2Pid(MyPidxx))) {
/* lock is held, but by us, so we win anyway */
alock->count++;
return;
{
AFS_STATCNT(afs_CheckBozonLockBlocking);
if (alock->count || (alock->flags & AFS_BOZONWAITING))
-#ifdef AFS_SUN5_ENV
- if (alock->proc != (char *)ttoproc(curthread))
-#else
-#ifdef AFS_64BITPOINTER_ENV
- /* To shut up SGI compiler on remark(1413) warnings. */
- if (alock->proc != (char *)(long)MyPidxx)
-#else /* AFS_64BITPOINTER_ENV */
- if (alock->proc != (char *)MyPidxx)
-#endif /* AFS_64BITPOINTER_ENV */
-#endif
+ if (alock->proc != afs_int_to_pointer(MyPidxx2Pid(MyPidxx)))
return 1;
return 0;
}
typedef struct timeval osi_timeval_t;
#endif /* AFS_SGI61_ENV */
+#ifndef UKERNEL
#define osi_getpid() getpid()
-
-#define osi_getpid() getpid()
+#endif
/*
* osi_ThreadUnique() should yield a value that can be found in ps
#ifdef AFS_FBSD50_ENV
/* should use curthread, but 'ps' can't display it */
#define osi_ThreadUnique() curproc
-#else
-#ifdef AFS_LINUX_ENV
+#elif defined(AFS_LINUX_ENV)
#define osi_ThreadUnique() (current->pid)
+#elif defined(UKERNEL)
+#define osi_ThreadUnique() osi_getpid()
#else
#define osi_ThreadUnique() getpid()
#endif
-#endif
* For distribution and copying rights, see the file "mit-copyright.h"
*/
-#if !defined(lint) && !defined(SABER)
-static char *rcsid = "$Id$";
-#endif /* lint || SABER */
-
#include <afs/stds.h>
#include "aklog.h"
printf("Using Kerberos V5 ticket natively\n");
#ifndef HAVE_NO_KRB5_524
- status = krb5_524_conv_principal (context, v5cred->client, &k4name, &k4inst, &k4realm);
+ status = krb5_524_conv_principal (context, v5cred->client,
+ (char *) &k4name,
+ (char *) &k4inst,
+ (char *) &k4realm);
if (status) {
afs_com_err(progname, status, "while converting principal "
"to Kerberos V4 format");
return -1;
}
-static int
-hex2char(char c)
-{
- if (c <= 9)
- return (c + 48);
-
- return (c - 10 + 'a');
-}
-
int
main(int argc, char *argv[])
{
memset(atoken, 0, sizeof *atoken);
if (evil) {
+ size_t elen = enc_part->length;
atoken->kvno = RXKAD_TKT_TYPE_KERBEROS_V5_ENCPART_ONLY;
if (afs_krb5_skip_ticket_wrapper(afscred->ticket.data,
afscred->ticket.length, &enc_part->data,
- &enc_part->length)) {
+ &elen)) {
afs_com_err(rn, 0, "Can't unwrap %s AFS credential",
cellconfig->name);
KLOGEXIT(1);
{
char *err1, *err2;
- fprintf(log, str);
+ fprintf(log, "%s", str);
if (error1) {
err2 = "vols";
switch (error1) {
/* Handle Case 1 */
memset(&vhptr, 0, sizeof(struct volumeHeader));
memcpy(&vhptr, buffer + bufloc, firstSplice);
- memcpy(&vhptr + firstSplice, buffer + bufloc + firstSplice + padLen,
+ /* probably GCC bug 37060; however, no guarantee on length of buffer */
+ tempvhptr = (struct volumeHeader *)(buffer + firstSplice);
+ memcpy(tempvhptr, buffer + bufloc + firstSplice + padLen,
nextSplice);
HEADER_CHECKS(vhptr, header);
-DAFS_AFSDB_ENV \
-DAFS_FREELANCE_CLIENT \
-DAFS_64BITPOINTER_ENV \
+ -DAFS_64BITUSERPOINTER_ENV \
-DAFS_64BIT_ENV \
-DAFS_64BIT_CLIENT \
-DAFS_LARGEFILE_ENV \
#define __alpha 1
#define AFS_LINUX_64BIT_KERNEL 1
#define AFS_64BITPOINTER_ENV 1 /* pointers are 64 bits */
+#define AFS_64BITUSERPOINTER_ENV 1
#else /* !defined(UKERNEL) */
#define AFS_64BIT_ENV 1
#define AFS_64BIT_CLIENT 1
#define AFS_64BITPOINTER_ENV 1
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFS_64BIT_IOPS_ENV 1 /* Needed for NAMEI */
#define AFS_FBSD_ENV 1
#define AFS_FBSD40_ENV 1
#define AFS_64BIT_ENV 1
#define AFS_64BIT_CLIENT 1
#define AFS_64BITPOINTER_ENV 1
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFS_64BIT_IOPS_ENV 1 /* Needed for NAMEI */
#define AFS_FBSD_ENV 1
#define AFS_FBSD40_ENV 1
#define AFS_64BIT_ENV 1
#define AFS_64BIT_CLIENT 1
#define AFS_64BITPOINTER_ENV 1
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFS_64BIT_IOPS_ENV 1 /* Needed for NAMEI */
#define AFS_FBSD_ENV 1
#define AFS_FBSD40_ENV 1
#define AFS_AMD64_LINUX26_ENV 1
#define AFS_LINUX_64BIT_KERNEL 1
#define AFS_64BITPOINTER_ENV 1 /* pointers are 64 bits */
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFS_MAXVCOUNT_ENV 1
#else /* !defined(UKERNEL) */
#define SYS_NAME_ID SYS_NAME_ID_amd64_nbsd30
#define AFS_64BITPOINTER_ENV 1
+#define AFS_64BITUSERPOINTER_ENV 1
#ifndef UKERNEL
/* This section for kernel libafs compiles only */
#define SYS_NAME_ID SYS_NAME_ID_amd64_nbsd40
#define AFS_64BITPOINTER_ENV 1
+#define AFS_64BITUSERPOINTER_ENV 1
#ifndef UKERNEL
/* This section for kernel libafs compiles only */
#define AFS_X86_XBSD_ENV 1
#define AFS_X86_ENV 1
#define AFS_64BITPOINTER_ENV 1
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFSLITTLE_ENDIAN 1
#endif /* AFS_AMD64_PARAM_H */
#define AFS_X86_XBSD_ENV 1
#define AFS_X86_ENV 1
#define AFS_64BITPOINTER_ENV 1
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFSLITTLE_ENDIAN 1
#endif /* AFS_AMD64_PARAM_H */
#define AFS_X86_XBSD_ENV 1
#define AFS_X86_ENV 1
#define AFS_64BITPOINTER_ENV 1
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFSLITTLE_ENDIAN 1
#endif /* AFS_AMD64_PARAM_H */
#define AFS_X86_XBSD_ENV 1
#define AFS_X86_ENV 1
#define AFS_64BITPOINTER_ENV 1
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFSLITTLE_ENDIAN 1
#endif /* AFS_AMD64_PARAM_H */
#define AFS_X86_XBSD_ENV 1
#define AFS_X86_ENV 1
#define AFS_64BITPOINTER_ENV 1
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFSLITTLE_ENDIAN 1
#endif /* AFS_AMD64_PARAM_H */
#define AFS_X86_XBSD_ENV 1
#define AFS_X86_ENV 1
#define AFS_64BITPOINTER_ENV 1
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFSLITTLE_ENDIAN 1
#endif /* AFS_AMD64_PARAM_H */
#define AFS_X86_XBSD_ENV 1
#define AFS_X86_ENV 1
#define AFS_64BITPOINTER_ENV 1
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFSLITTLE_ENDIAN 1
#endif /* AFS_AMD64_PARAM_H */
#define AFS_64BIT_CLIENT 1
#if defined(__LP64__)
#define AFS_64BITPOINTER_ENV 1 /* pointers are 64 bits. */
+#define AFS_64BITUSERPOINTER_ENV 1
#endif
#include <afs/afs_sysnames.h>
#define AFS_64BIT_ENV 1 /* Defines afs_int32 as int, not long. */
#define AFS_64BIT_CLIENT 1
#define AFS_64BITPOINTER_ENV 1 /* pointers are 64 bits. */
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFS_64BIT_IOPS_ENV 1
#include <afs/afs_sysnames.h>
#define AFS_64BIT_CLIENT 1
#if defined(__LP64__)
#define AFS_64BITPOINTER_ENV 1 /* pointers are 64 bits. */
+#define AFS_64BITUSERPOINTER_ENV 1
#endif
#include <afs/afs_sysnames.h>
#define AFS_64BIT_CLIENT 1
#if defined(__LP64__)
#define AFS_64BITPOINTER_ENV 1 /* pointers are 64 bits. */
+#define AFS_64BITUSERPOINTER_ENV 1
#endif
#include <afs/afs_sysnames.h>
#define AFS_IA64_LINUX26_ENV 1
#define AFS_LINUX_64BIT_KERNEL 1
#define AFS_64BITPOINTER_ENV 1 /* pointers are 64 bits. */
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFS_MAXVCOUNT_ENV 1
#else /* !defined(UKERNEL) */
#define AFS_PPC64_LINUX26_ENV 1
#define AFS_LINUX_64BIT_KERNEL 1
#define AFS_64BITPOINTER_ENV 1 /* pointers are 64 bits */
+#define AFS_64BITUSERPOINTER_ENV 1
#else /* !defined(UKERNEL) */
#define AFS_S390X_LINUX26_ENV 1
#define AFS_64BITPOINTER_ENV 1
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFS_64BIT_KERNEL 1
#else /* !defined(UKERNEL) */
#define AFS_S390X_LINUX26_ENV 1
#define AFS_64BITPOINTER_ENV 1
+#define AFS_64BITUSERPOINTER_ENV 1
#endif /* !defined(UKERNEL) */
#define AFS_64BIT_ENV 1 /* Defines afs_int32 as int, not long. */
#define AFS_64BIT_CLIENT 1
#define AFS_64BITPOINTER_ENV 1 /* pointers are 64 bits. */
+#define AFS_64BITUSERPOINTER_ENV 1
#define AFS_HAVE_FFS 1 /* Use system's ffs. */
#define AFS_HAVE_STATVFS 1 /* System supports statvfs */
#error Unsupported architecture
#endif
#define AFS_VFSINCL_ENV 1
-
+#ifdef __amd64__
+#define AFS_64BITUSERPOINTER_ENV 1
+#endif
+#define AFS_64BIT_SIZEOF 1 /* seriously? */
#include <afs/afs_sysnames.h>
#define AFS_DARWIN_ENV
#else
#error Unsupported architecture
#endif
+#ifdef __amd64__
+#define AFS_64BITUSERPOINTER_ENV 1
+#endif
#include <afs/afs_sysnames.h>
#define AFS_USERSPACE_ENV
hdr_static_inline(unsigned long) afs_printable_uint32_lu(afs_uint32 d) { return (unsigned long) d; }
+#ifdef AFS_64BITUSERPOINTER_ENV
+#define afs_pointer_to_int(p) ((afs_uint32) (afs_uint64) (p))
+#define afs_int_to_pointer(i) ((void *) (afs_uint64) (i))
+#else
+#define afs_pointer_to_int(p) ((afs_uint32) (p))
+#define afs_int_to_pointer(i) ((void *) (i))
+#endif
+
#if !defined(__GNUC__) || __GNUC__ < 2
#define AFS_UNUSED
#else
unsigned char *t_in_p = (unsigned char *)t_input;
#ifdef MUSTALIGN
- if ((afs_int32) ivec & 3) {
+ if (afs_pointer_to_int(ivec) & 3) {
memcpy((char *)&t_output[0], (char *)ivec++, sizeof(t_output[0]));
memcpy((char *)&t_output[1], (char *)ivec, sizeof(t_output[1]));
} else
for (i = 0; length > 0; i++, length -= 8) {
/* get input */
#ifdef MUSTALIGN
- if ((afs_int32) input & 3) {
+ if (afs_pointer_to_int(input) & 3) {
memcpy((char *)&t_input[0], (char *)input++, sizeof(t_input[0]));
memcpy((char *)&t_input[1], (char *)input++, sizeof(t_input[1]));
} else
}
/* copy temp output and save it for checksum */
#ifdef MUSTALIGN
- if ((afs_int32) output & 3) {
+ if (afs_pointer_to_int(output) & 3) {
memcpy((char *)output++, (char *)&t_output[0], sizeof(t_output[0]));
memcpy((char *)output, (char *)&t_output[1], sizeof(t_output[1]));
} else
abort();
}
#endif
- if ((afs_uint32) clear & 3) {
+ if (afs_pointer_to_int(clear) & 3) {
memcpy((char *)(&L_save), (char *)clear, sizeof(L_save));
clear=((afs_uint32*)clear)+1;
memcpy((char *)(&R_save), (char *)clear, sizeof(R_save));
*/
#ifdef MUSTALIGN
- if ((afs_int32) cipher & 3) {
+ if (afs_pointer_to_int(cipher) & 3) {
L_save = L2; /* cant bcopy a reg */
R_save = R2;
memcpy((char *)cipher, (char *)&L_save, sizeof(L_save));
if (encrypt) {
#ifdef MUSTALIGN
- if ((afs_int32) ivec & 3) {
+ if (afs_pointer_to_int(ivec) & 3) {
memcpy((char *)&xor_0, (char *)ivec++, sizeof(xor_0));
memcpy((char *)&xor_1, (char *)ivec, sizeof(xor_1));
} else
for (i = 0; length > 0; i++, length -= 8) {
/* get input */
#ifdef MUSTALIGN
- if ((afs_int32) input & 3) {
+ if (afs_pointer_to_int(input) & 3) {
memcpy((char *)&t_input[0], (char *)input,
sizeof(t_input[0]));
memcpy((char *)&t_input[1], (char *)(input + 1),
* case both input and output are the same space.
*/
#ifdef MUSTALIGN
- if ((afs_int32) input & 3) {
+ if (afs_pointer_to_int(input) & 3) {
memcpy((char *)&xor_0, (char *)input++, sizeof(xor_0));
xor_0 ^= t_output[0];
memcpy((char *)&xor_1, (char *)input++, sizeof(xor_1));
/* copy temp output and save it for cbc */
#ifdef MUSTALIGN
- if ((afs_int32) output & 3) {
+ if (afs_pointer_to_int(output) & 3) {
memcpy((char *)output++, (char *)&t_output[0],
sizeof(t_output[0]));
memcpy((char *)output++, (char *)&t_output[1],
else {
/* decrypt */
#ifdef MUSTALIGN
- if ((afs_int32) ivec & 3) {
+ if (afs_pointer_to_int(ivec) & 3) {
memcpy((char *)&xor_0, (char *)ivec++, sizeof(xor_0));
memcpy((char *)&xor_1, (char *)ivec, sizeof(xor_1));
} else
for (i = 0; length > 0; i++, length -= 8) {
/* get input */
#ifdef MUSTALIGN
- if ((afs_int32) input & 3) {
+ if (afs_pointer_to_int(input) & 3) {
memcpy((char *)&t_input[0], (char *)input++,
sizeof(t_input[0]));
memcpy((char *)&t_input[1], (char *)input++,
t_output[1] ^= xor_1;
/* copy temp output */
#ifdef MUSTALIGN
- if ((afs_int32) output & 3) {
+ if (afs_pointer_to_int(output) & 3) {
memcpy((char *)output++, (char *)&t_output[0],
sizeof(t_output[0]));
memcpy((char *)output++, (char *)&t_output[1],
oanswer.SeqBody = (char *)&answer;
version = 1;
code =
- ubik_Call(KAA_Authenticate, conn, 0, name, instance, start, end,
- &arequest, &oanswer, 0, 0);
+ ubik_KAA_Authenticate(conn, 0, name, instance, start, end,
+ &arequest, &oanswer);
if (code == RXGEN_OPCODE) {
oanswer.MaxSeqLen = sizeof(answer_old);
oanswer.SeqBody = (char *)&answer_old;
version = 0;
code =
- ubik_Call(KAA_Authenticate_old, conn, 0, name, instance,
- start, end, &arequest, &oanswer);
+ ubik_KAA_Authenticate_old(conn, 0, name, instance,
+ start, end, &arequest, &oanswer);
}
if (code == RXGEN_OPCODE) {
code = KAOLDINTERFACE;
version = 1;
code =
- ubik_Call(KAT_GetTicket, conn, 0, auth_token->kvno, auth_domain,
+ ubik_KAT_GetTicket(conn, 0, auth_token->kvno, auth_domain,
&aticket, name, instance, &atimes, &oanswer);
if (code == RXGEN_OPCODE) {
oanswer.SeqLen = 0; /* this may be set by first call */
oanswer.SeqBody = (char *)&answer_old;
version = 0;
code =
- ubik_Call(KAT_GetTicket_old, conn, 0, auth_token->kvno,
+ ubik_KAT_GetTicket_old(conn, 0, auth_token->kvno,
auth_domain, &aticket, name, instance, &atimes,
&oanswer);
if (code == RXGEN_OPCODE) {
LOCK_GLOBAL_MUTEX;
#if defined(AFS_S390_LINUX20_ENV) && !defined(AFS_S390X_LINUX20_ENV)
code =
- ubik_Call_New(KAM_SetPassword, conn, 0, name, instance, 0, 0,
- *newkey);
+ ubik_KAM_SetPassword(conn, UBIK_CALL_NEW, name, instance, 0, 0, *(EncryptionKey *)newkey);
#else
code =
- ubik_Call_New(KAM_SetPassword, conn, 0, name, instance, 0, *newkey);
+ ubik_KAM_SetPassword(conn, UBIK_CALL_NEW, name, instance, 0, *(EncryptionKey *)newkey);
#endif
UNLOCK_GLOBAL_MUTEX;
return code;
#include <afsconfig.h>
#include <afs/param.h>
-
#include <mit-cpyright.h>
#include <stdio.h>
#endif
while (!ok) {
- printf(prompt);
+ printf("%s", prompt);
fflush(stdout);
#ifdef CROSSMSDOS
h19line(s, sizeof(s), 0);
extern afs_uint32 life_to_time(afs_uint32 start, unsigned char life);
extern unsigned char time_to_life(afs_uint32 start, afs_uint32 end);
+/* crc.c */
+extern void _rxkad_crc_init_table(void);
+extern afs_uint32 _rxkad_crc_update(const char *p, size_t len, afs_uint32 res);
+
/* ticket5.c */
extern int tkt_DecodeTicket5(char *ticket, afs_int32 ticket_len,
int (*get_key) (void *, int,
/*! \name ubik client flags */
#define UPUBIKONLY 1 /*!< only check servers presumed functional */
+#define UBIK_CALL_NEW 2 /*!< use the semantics of ubik_Call_New */
/*\}*/
/*! \name RX services types */
long p3, long p4, long p5, long p6, long p7,
long p8, long p9, long p10, long p11, long p12,
long p13, long p14, long p15, long p16);
+extern afs_int32 ubik_Call_New(int (*aproc) (), register struct ubik_client
+ *aclient, afs_int32 aflags, long p1, long p2,
+ long p3, long p4, long p5, long p6, long p7,
+ long p8, long p9, long p10, long p11, long p12,
+ long p13, long p14, long p15, long p16);
#endif
-
/*\}*/
/* \name ubikcmd.c */
static int *calls_needsync[SYNCCOUNT]; /* proc calls that need the sync site */
static int synccount = 0;
-/*!
- * call this instead of stub and we'll guarantee to find a host that's up.
- *
- * \todo In the future, we should also put in a protocol to find the sync site.
- */
-afs_int32
-ubik_Call(int (*aproc) (), register struct ubik_client *aclient,
- afs_int32 aflags, long p1, long p2, long p3, long p4,
- long p5, long p6, long p7, long p8, long p9, long p10,
- long p11, long p12, long p13, long p14, long p15, long p16)
-{
- afs_int32 rcode, code, newHost, thisHost, i, count;
- int chaseCount, pass, needsync, inlist, j;
- struct rx_connection *tc;
- struct rx_peer *rxp;
- short origLevel;
-
- if (!aclient)
- return UNOENT;
- LOCK_UBIK_CLIENT(aclient);
-
- restart:
- origLevel = aclient->initializationState;
- rcode = UNOSERVERS;
- chaseCount = inlist = needsync = 0;
-
- LOCK_UCLNT_CACHE;
- for (j = 0; ((j < SYNCCOUNT) && calls_needsync[j]); j++) {
- if (calls_needsync[j] == (int *)aproc) {
- inlist = needsync = 1;
- break;
- }
- }
- UNLOCK_UCLNT_CACHE;
- /*
- * First pass, we try all servers that are up.
- * Second pass, we try all servers.
- */
- for (pass = 0; pass < 2; pass++) { /*p */
- /* For each entry in our servers list */
- for (count = 0;; count++) { /*s */
-
- if (needsync) {
- /* Need a sync site. Lets try to quickly find it */
- if (aclient->syncSite) {
- newHost = aclient->syncSite; /* already in network order */
- aclient->syncSite = 0; /* Will reset if it works */
- } else if (aclient->conns[3]) {
- /* If there are fewer than four db servers in a cell,
- * there's no point in making the GetSyncSite call.
- * At best, it's a wash. At worst, it results in more
- * RPCs than you would otherwise make.
- */
- tc = aclient->conns[count];
- if (tc && rx_ConnError(tc)) {
- aclient->conns[count] = tc = ubik_RefreshConn(tc);
- }
- if (!tc)
- break;
- code = VOTE_GetSyncSite(tc, &newHost);
- if (aclient->initializationState != origLevel)
- goto restart; /* somebody did a ubik_ClientInit */
- if (code)
- newHost = 0;
- newHost = htonl(newHost); /* convert to network order */
- } else {
- newHost = 0;
- }
- if (newHost) {
- /* position count at the appropriate slot in the client
- * structure and retry. If we can't find in slot, we'll
- * just continue through the whole list
- */
- for (i = 0; i < MAXSERVERS && aclient->conns[i]; i++) {
- rxp = rx_PeerOf(aclient->conns[i]);
- thisHost = rx_HostOf(rxp);
- if (!thisHost)
- break;
- if (thisHost == newHost) {
- if (chaseCount++ > 2)
- break; /* avoid loop asking */
- count = i; /* this index is the sync site */
- break;
- }
- }
- }
- }
- /*needsync */
- tc = aclient->conns[count];
- if (tc && rx_ConnError(tc)) {
- aclient->conns[count] = tc = ubik_RefreshConn(tc);
- }
- if (!tc)
- break;
-
- if ((pass == 0) && (aclient->states[count] & CFLastFailed)) {
- continue; /* this guy's down */
- }
-
- rcode =
- (*aproc) (tc, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
- p12, p13, p14, p15, p16);
- if (aclient->initializationState != origLevel) {
- /* somebody did a ubik_ClientInit */
- if (rcode)
- goto restart; /* call failed */
- else
- goto done; /* call suceeded */
- }
- if (rcode < 0) { /* network errors */
- aclient->states[count] |= CFLastFailed; /* Mark serer down */
- } else if (rcode == UNOTSYNC) {
- needsync = 1;
- } else if (rcode != UNOQUORUM) {
- /* either misc ubik code, or misc appl code, or success. */
- aclient->states[count] &= ~CFLastFailed; /* mark server up */
- goto done; /* all done */
- }
- } /*s */
- } /*p */
-
- done:
- if (needsync) {
- if (!inlist) { /* Remember proc call that needs sync site */
- LOCK_UCLNT_CACHE;
- calls_needsync[synccount % SYNCCOUNT] = (int *)aproc;
- synccount++;
- UNLOCK_UCLNT_CACHE;
- inlist = 1;
- }
- if (!rcode) { /* Remember the sync site - cmd successful */
- rxp = rx_PeerOf(aclient->conns[count]);
- aclient->syncSite = rx_HostOf(rxp);
- }
- }
- UNLOCK_UBIK_CLIENT(aclient);
- return rcode;
-}
-
/*!
return code;
}
+/*!
+ * \brief This is part of an iterator. It doesn't handle finding sync sites.
+ */
+afs_int32
+ubik_CallIter(int (*aproc) (), struct ubik_client *aclient,
+ afs_int32 aflags, int *apos, long p1, long p2,
+ long p3, long p4, long p5, long p6, long p7,
+ long p8, long p9, long p10, long p11, long p12,
+ long p13, long p14, long p15, long p16)
+{
+ return CallIter(aproc, aclient, aflags, apos, p1, p2, p3, p4, p5, p6, p7,
+ p8, p9, p10, p11, p12, p13, p14, p15, p16, NEED_LOCK);
+}
+
/*!
* \brief Call this instead of stub and we'll guarantee to find a host that's up.
*
}
/*!
- * \brief This is part of an iterator. It doesn't handle finding sync sites.
+ * call this instead of stub and we'll guarantee to find a host that's up.
+ *
+ * \todo In the future, we should also put in a protocol to find the sync site.
*/
afs_int32
-ubik_CallIter(int (*aproc) (), struct ubik_client *aclient,
- afs_int32 aflags, int *apos, long p1, long p2,
- long p3, long p4, long p5, long p6, long p7,
- long p8, long p9, long p10, long p11, long p12,
- long p13, long p14, long p15, long p16)
+ubik_Call(int (*aproc) (), register struct ubik_client *aclient,
+ afs_int32 aflags, long p1, long p2, long p3, long p4,
+ long p5, long p6, long p7, long p8, long p9, long p10,
+ long p11, long p12, long p13, long p14, long p15, long p16)
{
- return CallIter(aproc, aclient, aflags, apos, p1, p2, p3, p4, p5, p6, p7,
- p8, p9, p10, p11, p12, p13, p14, p15, p16, NEED_LOCK);
+ afs_int32 rcode, code, newHost, thisHost, i, count;
+ int chaseCount, pass, needsync, inlist, j;
+ struct rx_connection *tc;
+ struct rx_peer *rxp;
+ short origLevel;
+
+ if (aflags & UBIK_CALL_NEW)
+ return ubik_Call_New(aproc, aclient, aflags, p1, p2, p3, p4,
+ p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15,
+ p16);
+
+ if (!aclient)
+ return UNOENT;
+ LOCK_UBIK_CLIENT(aclient);
+
+ restart:
+ origLevel = aclient->initializationState;
+ rcode = UNOSERVERS;
+ chaseCount = inlist = needsync = 0;
+
+ LOCK_UCLNT_CACHE;
+ for (j = 0; ((j < SYNCCOUNT) && calls_needsync[j]); j++) {
+ if (calls_needsync[j] == (int *)aproc) {
+ inlist = needsync = 1;
+ break;
+ }
+ }
+ UNLOCK_UCLNT_CACHE;
+ /*
+ * First pass, we try all servers that are up.
+ * Second pass, we try all servers.
+ */
+ for (pass = 0; pass < 2; pass++) { /*p */
+ /* For each entry in our servers list */
+ for (count = 0;; count++) { /*s */
+
+ if (needsync) {
+ /* Need a sync site. Lets try to quickly find it */
+ if (aclient->syncSite) {
+ newHost = aclient->syncSite; /* already in network order */
+ aclient->syncSite = 0; /* Will reset if it works */
+ } else if (aclient->conns[3]) {
+ /* If there are fewer than four db servers in a cell,
+ * there's no point in making the GetSyncSite call.
+ * At best, it's a wash. At worst, it results in more
+ * RPCs than you would otherwise make.
+ */
+ tc = aclient->conns[count];
+ if (tc && rx_ConnError(tc)) {
+ aclient->conns[count] = tc = ubik_RefreshConn(tc);
+ }
+ if (!tc)
+ break;
+ code = VOTE_GetSyncSite(tc, &newHost);
+ if (aclient->initializationState != origLevel)
+ goto restart; /* somebody did a ubik_ClientInit */
+ if (code)
+ newHost = 0;
+ newHost = htonl(newHost); /* convert to network order */
+ } else {
+ newHost = 0;
+ }
+ if (newHost) {
+ /* position count at the appropriate slot in the client
+ * structure and retry. If we can't find in slot, we'll
+ * just continue through the whole list
+ */
+ for (i = 0; i < MAXSERVERS && aclient->conns[i]; i++) {
+ rxp = rx_PeerOf(aclient->conns[i]);
+ thisHost = rx_HostOf(rxp);
+ if (!thisHost)
+ break;
+ if (thisHost == newHost) {
+ if (chaseCount++ > 2)
+ break; /* avoid loop asking */
+ count = i; /* this index is the sync site */
+ break;
+ }
+ }
+ }
+ }
+ /*needsync */
+ tc = aclient->conns[count];
+ if (tc && rx_ConnError(tc)) {
+ aclient->conns[count] = tc = ubik_RefreshConn(tc);
+ }
+ if (!tc)
+ break;
+
+ if ((pass == 0) && (aclient->states[count] & CFLastFailed)) {
+ continue; /* this guy's down */
+ }
+
+ rcode =
+ (*aproc) (tc, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
+ p12, p13, p14, p15, p16);
+ if (aclient->initializationState != origLevel) {
+ /* somebody did a ubik_ClientInit */
+ if (rcode)
+ goto restart; /* call failed */
+ else
+ goto done; /* call suceeded */
+ }
+ if (rcode < 0) { /* network errors */
+ aclient->states[count] |= CFLastFailed; /* Mark serer down */
+ } else if (rcode == UNOTSYNC) {
+ needsync = 1;
+ } else if (rcode != UNOQUORUM) {
+ /* either misc ubik code, or misc appl code, or success. */
+ aclient->states[count] &= ~CFLastFailed; /* mark server up */
+ goto done; /* all done */
+ }
+ } /*s */
+ } /*p */
+
+ done:
+ if (needsync) {
+ if (!inlist) { /* Remember proc call that needs sync site */
+ LOCK_UCLNT_CACHE;
+ calls_needsync[synccount % SYNCCOUNT] = (int *)aproc;
+ synccount++;
+ UNLOCK_UCLNT_CACHE;
+ inlist = 1;
+ }
+ if (!rcode) { /* Remember the sync site - cmd successful */
+ rxp = rx_PeerOf(aclient->conns[count]);
+ aclient->syncSite = rx_HostOf(rxp);
+ }
+ }
+ UNLOCK_UBIK_CLIENT(aclient);
+ return rcode;
}
static int
Quit(char *msg)
{
- fprintf(stderr, msg);
+ fprintf(stderr, "%s", msg);
exit(1);
}
* of 100 digits.
*
* - The 'p' specifier for printing pointers is implemented using
- * compile time knowledge. (AFS_64BITPOINTER_ENV)
+ * compile time knowledge. (AFS_64BITUSERPOINTER_ENV)
*
* - Floating-point specifier (%e, %f, %g) are implemented by
* calling the standard sprintf, and thus may be unsafe.
break;
}
case 'p' : {
-#ifdef AFS_64BITPOINTER_ENV
+#ifdef AFS_64BITUSERPOINTER_ENV
u_longest arg = (u_longest)va_arg(ap, void*);
#else
u_longest arg = (unsigned long)va_arg(ap, void*);
seed ^= uuid_time.seed[3];
#if defined(KERNEL) && defined(AFS_XBSD_ENV)
rand_irand += seed + (afs_uint32) curproc->p_pid;
+#elif defined(UKERNEL)
+ rand_irand += seed + (afs_uint32) osi_getpid();
#else
rand_irand += seed + (afs_uint32) getpid();
#endif
#else
com->hdr.pid = getpid();
#ifdef AFS_PTHREAD_ENV
- com->hdr.tid = (afs_int32)pthread_self();
+ com->hdr.tid = afs_pointer_to_int(pthread_self());
#else
{
PROCESS handle = LWP_ThreadId();
ip1 = 0xffffffff;
}
- vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
+ vcode = ubik_VL_ChangeAddr(cstruct, UBIK_CALL_NEW, ntohl(ip1), ntohl(ip2));
if (vcode) {
if (remove) {
fprintf(STDERR, "Could not remove server %s from the VLDB\n",
m_addrs.bulkaddrs_len = 0;
vcode =
ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, m_uuid,
- (afs_int32 *)&vlcb, &m_nentries, &m_addrs);
+ (afs_int32 *)&vlcb, &m_nentries,
+ &m_addrs);
if (vcode) {
fprintf(STDERR,
"vos: could not list the multi-homed server addresses\n");
static int
ListAddrs(register struct cmd_syndesc *as, void *arock)
{
- afs_int32 vcode;
+ afs_int32 vcode, m_uniq=0;
afs_int32 i, printuuid = 0;
struct VLCallBack vlcb;
afs_int32 nentries;
m_addrs.bulkaddrs_len = 0;
vcode =
- ubik_Call_New(VL_GetAddrs, cstruct, 0, 0, 0, &vlcb, &nentries,
- &m_addrs);
+ ubik_VL_GetAddrs(cstruct, UBIK_CALL_NEW, 0, 0, &vlcb, &nentries,
+ &m_addrs);
if (vcode) {
fprintf(STDERR, "vos: could not list the server addresses\n");
PrintError("", vcode);
m_attrs.index = i;
vcode =
- ubik_Call_New(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
- &vlcb, &m_nentries, &m_addrs);
+ ubik_VL_GetAddrsU(cstruct, UBIK_CALL_NEW, &m_attrs, &m_uuid,
+ &m_uniq, &m_nentries, &m_addrs);
if (vcode == VL_NOENT) {
if (m_attrs.Mask == VLADDR_UUID) {
int
PrintError(char *msg, afs_int32 errcode)
{
- fprintf(STDERR, msg);
+ fprintf(STDERR, "%s", msg);
/*replace by a big switch statement */
switch (errcode) {
case 0:
}
#define ONERROR(ec, ep, es) if (ec) { fprintf(STDERR, (es), (ep)); error = (ec); goto rfail; }
+#define ONERROR0(ec, es) if (ec) { fprintf(STDERR, (es)); error = (ec); goto rfail; }
#define ERROREXIT(ec) { error = (ec); goto rfail; }
/* Get a "transaction" on this replica. Create the volume
roclone = ((roindex == -1) ? 0 : 1);
rwindex = Lp_GetRwIndex(&entry);
if (rwindex < 0)
- ONERROR(VOLSERNOVOL, 0, "There is no RW volume \n");
+ ONERROR0(VOLSERNOVOL, "There is no RW volume \n");
/* Make sure we have a RO volume id to work with */
if (entry.volumeId[ROVOL] == INVALID_BID) {
results.manyResults_val =
(afs_int32 *) malloc(sizeof(afs_int32) * nservers + 1);
if (!replicas || !times || !!!results.manyResults_val || !toconns)
- ONERROR(ENOMEM, 0,
+ ONERROR0(ENOMEM,
"Failed to create transaction on the release clone\n");
memset(replicas, 0, (sizeof(struct replica) * nservers + 1));
if (!fullrelease && code)
ONERROR(VOLSERNOVOL, afromvol,
"Old clone is inaccessible. Try vos release -f %u.\n");
- ONERROR(code, 0, "Failed to create transaction on the release clone\n");
+ ONERROR0(code, "Failed to create transaction on the release clone\n");
VDONE;
/* For each index in the VLDB */
}
}
-
/* returns 0 if failed */
afs_uint32
vsu_GetVolumeID(char *astring, struct ubik_client *acstruct, afs_int32 *errp)
char *end;
afs_uint32 result;
result = strtoul(astring, &end, 10);
- if (result != ULONG_MAX && *end == '\0')
+ if (result != UINT_MAX && *end == '\0')
return result;
}