#include <ubik.h>
#include <rx/xdr.h>
#include <rx/rx.h>
+#include <rx/rxkad.h>
#ifdef AFS_NT40_ENV
#include <winsock2.h>
#else
#include <netinet/in.h>
#endif
#include <afs/keys.h>
+#include <afs/cellconfig.h>
#include "vlserver.h"
+#include "vlserver_internal.h"
#include "afs/audit.h"
#ifndef AFS_NT40_ENV
#include <unistd.h>
#endif
extern int smallMem;
-extern extent_mod;
+extern int extent_mod;
extern struct afsconf_dir *vldb_confdir;
extern struct ubik_dbase *VL_dbase;
struct vlheader cheader; /* kept in network byte order */
#define VLDBALLOCLIMIT 10000
#define VLDBALLOCINCR 2048
-static int put_attributeentry();
-static int put_nattributeentry();
-static int RemoveEntry();
-static void ReleaseEntry();
-static int check_vldbentry();
-static int check_nvldbentry();
-static int vldbentry_to_vlentry();
-static int nvldbentry_to_vlentry();
-static get_vldbupdateentry();
-static int repsite_exists();
-static void repsite_compress();
-static void vlentry_to_vldbentry();
-static void vlentry_to_nvldbentry();
-static void vlentry_to_uvldbentry();
-static int InvalidVolname();
-static int InvalidVoltype();
-static int InvalidOperation();
-static int InvalidReleasetype();
-static int IpAddrToRelAddr();
-static int ChangeIPAddr();
+static int put_attributeentry(struct vldbentry **, struct vldbentry **,
+ struct vldbentry **, bulkentries *,
+ struct nvlentry *, afs_int32 *, afs_int32 *);
+static int put_nattributeentry(struct nvldbentry **, struct nvldbentry **,
+ struct nvldbentry **, nbulkentries *,
+ struct nvlentry *, afs_int32, afs_int32,
+ afs_int32 *, afs_int32 *);
+static int RemoveEntry(struct ubik_trans *trans, afs_int32 entryptr,
+ struct nvlentry *tentry);
+static void ReleaseEntry(struct nvlentry *tentry, afs_int32 releasetype);
+static int check_vldbentry(struct vldbentry *aentry);
+static int check_nvldbentry(struct nvldbentry *aentry);
+static int vldbentry_to_vlentry(struct ubik_trans *atrans,
+ struct vldbentry *VldbEntry,
+ struct nvlentry *VlEntry);
+static int nvldbentry_to_vlentry(struct ubik_trans *atrans,
+ struct nvldbentry *VldbEntry,
+ struct nvlentry *VlEntry);
+static int get_vldbupdateentry(struct ubik_trans *trans, afs_int32 blockindex,
+ struct VldbUpdateEntry *updateentry,
+ struct nvlentry *VlEntry);
+static int repsite_exists(struct nvlentry *VlEntry, int server, int partition);
+static void repsite_compress(struct nvlentry *VlEntry, int offset);
+static void vlentry_to_vldbentry(struct nvlentry *VlEntry,
+ struct vldbentry *VldbEntry);
+static void vlentry_to_nvldbentry(struct nvlentry *VlEntry,
+ struct nvldbentry *VldbEntry);
+static void vlentry_to_uvldbentry(struct nvlentry *VlEntry,
+ struct uvldbentry *VldbEntry);
+static int InvalidVolname(char *volname);
+static int InvalidVoltype(afs_int32 voltype);
+static int InvalidOperation(afs_int32 voloper);
+static int InvalidReleasetype(afs_int32 releasetype);
+static int IpAddrToRelAddr(afs_uint32 ipaddr, struct ubik_trans *atrans);
+static int ChangeIPAddr(afs_uint32 ipaddr1, afs_uint32 ipaddr2,
+ struct ubik_trans *atrans);
char *
-rxinfo(rxcall)
- struct rx_call *rxcall;
+rxinfo(struct rx_call *rxcall)
{
int code;
register struct rx_connection *tconn;
/* This is called to initialize the database, set the appropriate locks and make sure that the vldb header is valid */
int
-Init_VLdbase(trans, locktype, this_op)
- struct ubik_trans **trans;
- int locktype; /* indicate read or write transaction */
- int this_op;
+Init_VLdbase(struct ubik_trans **trans,
+ int locktype, /* indicate read or write transaction */
+ int this_op)
{
int errorcode = 0, pass, wl;
}
-/* Create a new vldb entry; both new volume id and name must be unique (non-existant in vldb). */
+/* Create a new vldb entry; both new volume id and name must be unique
+ * (non-existant in vldb).
+ */
afs_int32
-SVL_CreateEntry(rxcall, newentry)
- struct rx_call *rxcall;
- struct vldbentry *newentry;
+SVL_CreateEntry(struct rx_call *rxcall, struct vldbentry *newentry)
{
struct ubik_trans *trans;
afs_int32 errorcode, blockindex;
memset(&tentry, 0, sizeof(struct nvlentry));
/* Convert to its internal representation; both in host byte order */
- if (errorcode = vldbentry_to_vlentry(trans, newentry, &tentry)) {
+ if ((errorcode = vldbentry_to_vlentry(trans, newentry, &tentry))) {
FreeBlock(trans, blockindex);
goto abort;
}
afs_int32
-SVL_CreateEntryN(rxcall, newentry)
- struct rx_call *rxcall;
- struct nvldbentry *newentry;
+SVL_CreateEntryN(struct rx_call *rxcall, struct nvldbentry *newentry)
{
struct ubik_trans *trans;
afs_int32 errorcode, blockindex;
memset(&tentry, 0, sizeof(struct nvlentry));
/* Convert to its internal representation; both in host byte order */
- if (errorcode = nvldbentry_to_vlentry(trans, newentry, &tentry)) {
+ if ((errorcode = nvldbentry_to_vlentry(trans, newentry, &tentry))) {
FreeBlock(trans, blockindex);
goto abort;
}
afs_int32
-SVL_ChangeAddr(rxcall, ip1, ip2)
- struct rx_call *rxcall;
- afs_uint32 ip1, ip2;
+SVL_ChangeAddr(struct rx_call *rxcall, afs_uint32 ip1, afs_uint32 ip2)
{
struct ubik_trans *trans;
afs_int32 errorcode;
goto end;
}
- if (errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op)))
goto end;
VLog(1, ("Change Addr %u -> %u %s\n", ip1, ip2, rxinfo(rxcall)));
- if (errorcode = ChangeIPAddr(ip1, ip2, trans))
+ if ((errorcode = ChangeIPAddr(ip1, ip2, trans)))
goto abort;
else {
errorcode = ubik_EndTrans(trans);
/* Delete a vldb entry given the volume id. */
afs_int32
-SVL_DeleteEntry(rxcall, volid, voltype)
- struct rx_call *rxcall;
- afs_uint32 volid;
- afs_int32 voltype;
+SVL_DeleteEntry(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype)
{
struct ubik_trans *trans;
afs_int32 blockindex, errorcode;
if ((voltype != -1) && (InvalidVoltype(voltype)))
END(VL_BADVOLTYPE);
- if (errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op)))
goto end;
VLog(1, ("Delete Volume %u %s\n", volid, rxinfo(rxcall)));
if (tentry.flags & VLDELETED) { /* Already deleted; return */
ABORT(VL_ENTDELETED);
}
- if (errorcode = RemoveEntry(trans, blockindex, &tentry)) {
+ if ((errorcode = RemoveEntry(trans, blockindex, &tentry))) {
goto abort;
}
errorcode = (ubik_EndTrans(trans));
/* Get a vldb entry given its volume id; make sure it's not a deleted entry. */
-GetEntryByID(rxcall, volid, voltype, aentry, new, this_op)
- struct rx_call *rxcall;
- afs_uint32 volid;
- afs_int32 voltype, new, this_op;
- char *aentry; /* entry data copied here */
+int
+GetEntryByID(struct rx_call *rxcall,
+ afs_uint32 volid,
+ afs_int32 voltype,
+ char *aentry, /* entry data copied here */
+ afs_int32 new,
+ afs_int32 this_op)
{
struct ubik_trans *trans;
afs_int32 blockindex, errorcode;
if ((voltype != -1) && (InvalidVoltype(voltype)))
return VL_BADVOLTYPE;
- if (errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op)))
return errorcode;
VLog(5, ("GetVolumeByID %u (%d) %s\n", volid, new, rxinfo(rxcall)));
}
afs_int32
-SVL_GetEntryByID(rxcall, volid, voltype, aentry)
- struct rx_call *rxcall;
- afs_uint32 volid;
- afs_int32 voltype;
- vldbentry *aentry; /* entry data copied here */
+SVL_GetEntryByID(struct rx_call *rxcall,
+ afs_uint32 volid,
+ afs_int32 voltype,
+ vldbentry *aentry) /* entry data copied here */
{
COUNT_REQ(VLGETENTRYBYID);
return (GetEntryByID(rxcall, volid, voltype, (char *)aentry, 0, this_op));
}
afs_int32
-SVL_GetEntryByIDN(rxcall, volid, voltype, aentry)
- struct rx_call *rxcall;
- afs_uint32 volid;
- afs_int32 voltype;
- nvldbentry *aentry; /* entry data copied here */
+SVL_GetEntryByIDN(struct rx_call *rxcall,
+ afs_uint32 volid,
+ afs_int32 voltype,
+ nvldbentry *aentry) /* entry data copied here */
{
COUNT_REQ(VLGETENTRYBYIDN);
return (GetEntryByID(rxcall, volid, voltype, (char *)aentry, 1, this_op));
}
afs_int32
-SVL_GetEntryByIDU(rxcall, volid, voltype, aentry)
- struct rx_call *rxcall;
- afs_uint32 volid;
- afs_int32 voltype;
- uvldbentry *aentry; /* entry data copied here */
+SVL_GetEntryByIDU(struct rx_call *rxcall,
+ afs_uint32 volid,
+ afs_int32 voltype,
+ uvldbentry *aentry) /* entry data copied here */
{
COUNT_REQ(VLGETENTRYBYIDU);
return (GetEntryByID(rxcall, volid, voltype, (char *)aentry, 2, this_op));
-/* returns true if the id is a decimal integer, in which case we interpret it
- as an id. make the cache manager much simpler */
+/* returns true if the id is a decimal integer, in which case we interpret
+ * it as an id. make the cache manager much simpler */
static int
-NameIsId(aname)
- register char *aname;
+NameIsId(char *aname)
{
register int tc;
- while (tc = *aname++) {
+ while ((tc = *aname++)) {
if (tc > '9' || tc < '0')
return 0;
}
return 1;
}
-/* Get a vldb entry given the volume's name; of course, very similar to VLGetEntryByID() above. */
-GetEntryByName(rxcall, volname, aentry, new, this_op)
- struct rx_call *rxcall;
- char *volname;
- char *aentry; /* entry data copied here */
- int new, this_op;
+/* Get a vldb entry given the volume's name; of course, very similar to
+ * VLGetEntryByID() above. */
+afs_int32
+GetEntryByName(struct rx_call *rxcall,
+ char *volname,
+ char *aentry, /* entry data copied here */
+ int new,
+ int this_op)
{
struct ubik_trans *trans;
afs_int32 blockindex, errorcode;
}
if (InvalidVolname(volname))
return VL_BADNAME;
- if (errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op)))
return errorcode;
VLog(5, ("GetVolumeByName %s (%d) %s\n", volname, new, rxinfo(rxcall)));
blockindex = FindByName(trans, volname, &tentry, &errorcode);
}
afs_int32
-SVL_GetEntryByNameO(rxcall, volname, aentry)
- struct rx_call *rxcall;
- char *volname;
- struct vldbentry *aentry; /* entry data copied here */
+SVL_GetEntryByNameO(struct rx_call *rxcall,
+ char *volname,
+ struct vldbentry *aentry) /* entry data copied here */
{
COUNT_REQ(VLGETENTRYBYNAME);
return (GetEntryByName(rxcall, volname, (char *)aentry, 0, this_op));
afs_int32
-SVL_GetEntryByNameN(rxcall, volname, aentry)
- struct rx_call *rxcall;
- char *volname;
- struct nvldbentry *aentry; /* entry data copied here */
+SVL_GetEntryByNameN(struct rx_call *rxcall,
+ char *volname,
+ struct nvldbentry *aentry) /* entry data copied here */
{
COUNT_REQ(VLGETENTRYBYNAMEN);
return (GetEntryByName(rxcall, volname, (char *)aentry, 1, this_op));
}
afs_int32
-SVL_GetEntryByNameU(rxcall, volname, aentry)
- struct rx_call *rxcall;
- char *volname;
- struct uvldbentry *aentry; /* entry data copied here */
+SVL_GetEntryByNameU(struct rx_call *rxcall,
+ char *volname,
+ struct uvldbentry *aentry) /* entry data copied here */
{
COUNT_REQ(VLGETENTRYBYNAMEU);
return (GetEntryByName(rxcall, volname, (char *)aentry, 2, this_op));
/* Get the current value of the maximum volume id and bump the volume id counter by Maxvolidbump. */
afs_int32
-SVL_GetNewVolumeId(rxcall, Maxvolidbump, newvolumeid)
- struct rx_call *rxcall;
- afs_uint32 Maxvolidbump;
- afs_uint32 *newvolumeid;
+SVL_GetNewVolumeId(struct rx_call *rxcall, afs_uint32 Maxvolidbump,
+ afs_uint32 *newvolumeid)
{
register afs_int32 errorcode;
afs_uint32 maxvolumeid;
if (Maxvolidbump < 0 || Maxvolidbump > MAXBUMPCOUNT)
END(VL_BADVOLIDBUMP);
- if (errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op)))
goto end;
*newvolumeid = maxvolumeid = ntohl(cheader.vital_header.MaxVolumeId);
* VLUpdateEntry) is done. */
afs_int32
-SVL_ReplaceEntry(rxcall, volid, voltype, newentry, releasetype)
- struct rx_call *rxcall;
- afs_uint32 volid;
- afs_int32 voltype;
- struct vldbentry *newentry;
- afs_int32 releasetype;
+SVL_ReplaceEntry(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype,
+ struct vldbentry *newentry, afs_int32 releasetype)
{
struct ubik_trans *trans;
afs_int32 blockindex, errorcode, typeindex;
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL))
END(VL_PERM);
- if (errorcode = check_vldbentry(newentry))
+ if ((errorcode = check_vldbentry(newentry)))
goto end;
if (voltype != -1 && InvalidVoltype(voltype))
if (releasetype && InvalidReleasetype(releasetype))
END(VL_BADRELLOCKTYPE);
- if (errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op)))
goto end;
VLog(1, ("OReplace Volume %u %s\n", volid, rxinfo(rxcall)));
for (typeindex = ROVOL; typeindex <= BACKVOL; typeindex++) {
if (tentry.volumeId[typeindex] != newentry->volumeId[typeindex]) {
if (tentry.volumeId[typeindex])
- if (errorcode =
- UnhashVolid(trans, typeindex, blockindex, &tentry)) {
+ if ((errorcode =
+ UnhashVolid(trans, typeindex, blockindex, &tentry))) {
goto abort;
}
/* we must rehash new id if the id is different and the ID is nonzero */
/* Rehash volname if it changes */
if (strcmp(newentry->name, tentry.name)) { /* Name changes; redo hashing */
- if (errorcode = UnhashVolname(trans, blockindex, &tentry)) {
+ if ((errorcode = UnhashVolname(trans, blockindex, &tentry))) {
goto abort;
}
hashnewname = 1;
/* after this, tentry is new entry, not old one. vldbentry_to_vlentry
* doesn't touch hash chains */
- if (errorcode = vldbentry_to_vlentry(trans, newentry, &tentry)) {
+ if ((errorcode = vldbentry_to_vlentry(trans, newentry, &tentry))) {
goto abort;
}
for (typeindex = ROVOL; typeindex <= BACKVOL; typeindex++) {
if (hashVol[typeindex] && tentry.volumeId[typeindex]) {
- if (errorcode = HashVolid(trans, typeindex, blockindex, &tentry)) {
+ if ((errorcode = HashVolid(trans, typeindex, blockindex, &tentry))) {
goto abort;
}
}
}
afs_int32
-SVL_ReplaceEntryN(rxcall, volid, voltype, newentry, releasetype)
- struct rx_call *rxcall;
- afs_uint32 volid;
- afs_int32 voltype;
- struct nvldbentry *newentry;
- afs_int32 releasetype;
+SVL_ReplaceEntryN(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype,
+ struct nvldbentry *newentry, afs_int32 releasetype)
{
struct ubik_trans *trans;
afs_int32 blockindex, errorcode, typeindex;
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL))
END(VL_PERM);
- if (errorcode = check_nvldbentry(newentry))
+ if ((errorcode = check_nvldbentry(newentry)))
goto end;
if (voltype != -1 && InvalidVoltype(voltype))
if (releasetype && InvalidReleasetype(releasetype))
END(VL_BADRELLOCKTYPE);
- if (errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op)))
goto end;
VLog(1, ("Replace Volume %u %s\n", volid, rxinfo(rxcall)));
for (typeindex = ROVOL; typeindex <= BACKVOL; typeindex++) {
if (tentry.volumeId[typeindex] != newentry->volumeId[typeindex]) {
if (tentry.volumeId[typeindex])
- if (errorcode =
- UnhashVolid(trans, typeindex, blockindex, &tentry)) {
+ if ((errorcode =
+ UnhashVolid(trans, typeindex, blockindex, &tentry))) {
goto abort;
}
/* we must rehash new id if the id is different and the ID is nonzero */
/* Rehash volname if it changes */
if (strcmp(newentry->name, tentry.name)) { /* Name changes; redo hashing */
- if (errorcode = UnhashVolname(trans, blockindex, &tentry)) {
+ if ((errorcode = UnhashVolname(trans, blockindex, &tentry))) {
goto abort;
}
hashnewname = 1;
/* after this, tentry is new entry, not old one. vldbentry_to_vlentry
* doesn't touch hash chains */
- if (errorcode = nvldbentry_to_vlentry(trans, newentry, &tentry)) {
+ if ((errorcode = nvldbentry_to_vlentry(trans, newentry, &tentry))) {
goto abort;
}
for (typeindex = ROVOL; typeindex <= BACKVOL; typeindex++) {
if (hashVol[typeindex] && tentry.volumeId[typeindex]) {
- if (errorcode = HashVolid(trans, typeindex, blockindex, &tentry)) {
+ if ((errorcode = HashVolid(trans, typeindex, blockindex, &tentry))) {
goto abort;
}
}
}
-/* Update a vldb entry (accessed thru its volume id). Almost all of the entry's fields can be modified in a single call by setting the appropriate bits in the Mask field in VldbUpdateentry. */
-/* this routine may never have been tested; use replace entry instead unless you're brave */
+/* Update a vldb entry (accessed thru its volume id). Almost all of the
+ * entry's fields can be modified in a single call by setting the
+ * appropriate bits in the Mask field in VldbUpdateentry. */
+/* this routine may never have been tested; use replace entry instead
+ * unless you're brave */
afs_int32
-SVL_UpdateEntry(rxcall, volid, voltype, updateentry, releasetype)
- struct rx_call *rxcall;
- afs_uint32 volid;
- afs_int32 voltype;
- afs_int32 releasetype;
- struct VldbUpdateEntry *updateentry; /* Update entry copied here */
+SVL_UpdateEntry(struct rx_call *rxcall,
+ afs_uint32 volid,
+ afs_int32 voltype,
+ struct VldbUpdateEntry *updateentry, /* Update entry copied here */
+ afs_int32 releasetype)
{
struct ubik_trans *trans;
afs_int32 blockindex, errorcode;
END(VL_BADVOLTYPE);
if (releasetype && InvalidReleasetype(releasetype))
END(VL_BADRELLOCKTYPE);
- if (errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op)))
goto end;
VLog(1, ("Update Volume %u %s\n", volid, rxinfo(rxcall)));
}
/* Do the actual updating of the entry, tentry. */
- if (errorcode =
- get_vldbupdateentry(trans, blockindex, updateentry, &tentry)) {
+ if ((errorcode =
+ get_vldbupdateentry(trans, blockindex, updateentry, &tentry))) {
goto abort;
}
if (releasetype)
afs_int32
-SVL_UpdateEntryByName(rxcall, volname, updateentry, releasetype)
- struct rx_call *rxcall;
- char *volname;
- afs_int32 releasetype;
- struct VldbUpdateEntry *updateentry; /* Update entry copied here */
+SVL_UpdateEntryByName(struct rx_call *rxcall,
+ char *volname,
+ struct VldbUpdateEntry *updateentry, /* Update entry copied here */
+ afs_int32 releasetype)
{
struct ubik_trans *trans;
afs_int32 blockindex, errorcode;
END(VL_PERM);
if (releasetype && InvalidReleasetype(releasetype))
END(VL_BADRELLOCKTYPE);
- if (errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op)))
goto end;
blockindex = FindByName(trans, volname, &tentry, &errorcode);
}
/* Do the actual updating of the entry, tentry. */
- if (errorcode =
- get_vldbupdateentry(trans, blockindex, updateentry, &tentry)) {
+ if ((errorcode =
+ get_vldbupdateentry(trans, blockindex, updateentry, &tentry))) {
goto abort;
}
if (releasetype)
/* Set a lock to the vldb entry for volid (of type voltype if not -1). */
afs_int32
-SVL_SetLock(rxcall, volid, voltype, voloper)
- struct rx_call *rxcall;
- afs_uint32 volid;
- afs_int32 voltype;
- afs_int32 voloper;
+SVL_SetLock(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype,
+ afs_int32 voloper)
{
afs_int32 timestamp, blockindex, errorcode;
struct ubik_trans *trans;
END(VL_BADVOLTYPE);
if (InvalidOperation(voloper))
END(VL_BADVOLOPER);
- if (errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op)))
goto end;
VLog(1, ("SetLock Volume %u %s\n", volid, rxinfo(rxcall)));
* the lock time stamp. */
afs_int32
-SVL_ReleaseLock(rxcall, volid, voltype, releasetype)
- struct rx_call *rxcall;
- afs_uint32 volid;
- afs_int32 voltype;
- afs_int32 releasetype;
+SVL_ReleaseLock(struct rx_call *rxcall, afs_uint32 volid, afs_int32 voltype,
+ afs_int32 releasetype)
{
afs_int32 blockindex, errorcode;
struct ubik_trans *trans;
END(VL_BADVOLTYPE);
if (releasetype && InvalidReleasetype(releasetype))
END(VL_BADRELLOCKTYPE);
- if (errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKWRITE, this_op)))
goto end;
VLog(1, ("ReleaseLock Volume %u %s\n", volid, rxinfo(rxcall)));
}
-/* ListEntry returns a single vldb entry, aentry, with offset previous_index; the remaining parameters (i.e. next_index) are used so that sequential calls to this routine will get the next (all) vldb entries. */
+/* ListEntry returns a single vldb entry, aentry, with offset previous_index;
+ * the remaining parameters (i.e. next_index) are used so that sequential
+ * calls to this routine will get the next (all) vldb entries.
+ */
afs_int32
-SVL_ListEntry(rxcall, previous_index, count, next_index, aentry)
- struct rx_call *rxcall;
- afs_int32 previous_index;
- afs_int32 *count;
- afs_int32 *next_index;
- struct vldbentry *aentry;
+SVL_ListEntry(struct rx_call *rxcall, afs_int32 previous_index,
+ afs_int32 *count, afs_int32 *next_index,
+ struct vldbentry *aentry)
{
int errorcode;
struct ubik_trans *trans;
struct nvlentry tentry;
COUNT_REQ(VLLISTENTRY);
- if (errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op)))
return errorcode;
VLog(25, ("OListEntry index=%d %s\n", previous_index, rxinfo(rxcall)));
*next_index = NextEntry(trans, previous_index, &tentry, count);
return (ubik_EndTrans(trans));
}
-/* ListEntry returns a single vldb entry, aentry, with offset previous_index; the remaining parameters (i.e. next_index) are used so that sequential calls to this routine will get the next (all) vldb entries. */
+/* ListEntry returns a single vldb entry, aentry, with offset previous_index;
+ * the remaining parameters (i.e. next_index) are used so that sequential
+ * calls to this routine will get the next (all) vldb entries.
+ */
afs_int32
-SVL_ListEntryN(rxcall, previous_index, count, next_index, aentry)
- struct rx_call *rxcall;
- afs_int32 previous_index;
- afs_int32 *count;
- afs_int32 *next_index;
- struct nvldbentry *aentry;
+SVL_ListEntryN(struct rx_call *rxcall, afs_int32 previous_index,
+ afs_int32 *count, afs_int32 *next_index,
+ struct nvldbentry *aentry)
{
int errorcode;
struct ubik_trans *trans;
struct nvlentry tentry;
COUNT_REQ(VLLISTENTRYN);
- if (errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op)))
return errorcode;
VLog(25, ("ListEntry index=%d %s\n", previous_index, rxinfo(rxcall)));
*next_index = NextEntry(trans, previous_index, &tentry, count);
}
-/* Retrieves in vldbentries all vldb entries that match the specified attributes (by server number, partition, volume type, and flag); if volume id is specified then the associated list for that entry is returned. CAUTION: This could be a very expensive call since in most cases sequential search of all vldb entries is performed. */
+/* Retrieves in vldbentries all vldb entries that match the specified
+ * attributes (by server number, partition, volume type, and flag); if volume
+ * id is specified then the associated list for that entry is returned.
+ * CAUTION: This could be a very expensive call since in most cases
+ * sequential search of all vldb entries is performed.
+ */
afs_int32
-SVL_ListAttributes(rxcall, attributes, nentries, vldbentries)
- struct rx_call *rxcall;
- struct VldbListByAttributes *attributes;
- afs_int32 *nentries;
- bulkentries *vldbentries;
+SVL_ListAttributes(struct rx_call *rxcall,
+ struct VldbListByAttributes *attributes,
+ afs_int32 *nentries,
+ bulkentries *vldbentries)
{
int errorcode, allocCount = 0;
struct ubik_trans *trans;
COUNT_REQ(VLLISTATTRIBUTES);
vldbentries->bulkentries_val = 0;
vldbentries->bulkentries_len = *nentries = 0;
- if (errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op)))
return errorcode;
allocCount = VLDBALLOCCOUNT;
Vldbentry = VldbentryFirst = vldbentries->bulkentries_val =
return VL_NOMEM;
}
VldbentryLast = VldbentryFirst + allocCount;
- /* Handle the attribute by volume id totally separate of the rest (thus additional Mask values are ignored if VLLIST_VOLUMEID is set!) */
+ /* Handle the attribute by volume id totally separate of the rest
+ * (thus additional Mask values are ignored if VLLIST_VOLUMEID is set!) */
if (attributes->Mask & VLLIST_VOLUMEID) {
afs_int32 blockindex;
vldbentries->bulkentries_len = 0;
return errorcode;
}
- if (errorcode =
+ if ((errorcode =
put_attributeentry(&Vldbentry, &VldbentryFirst, &VldbentryLast,
- vldbentries, &tentry, nentries, &allocCount)) {
+ vldbentries, &tentry, nentries, &allocCount))) {
COUNT_ABO;
ubik_AbortTrans(trans);
if (vldbentries->bulkentries_val)
}
} else {
afs_int32 nextblockindex = 0, count = 0, k = 0, match = 0;
- while (nextblockindex =
- NextEntry(trans, nextblockindex, &tentry, &count)) {
+ while ((nextblockindex =
+ NextEntry(trans, nextblockindex, &tentry, &count))) {
if (++pollcount > 50) {
#ifndef AFS_PTHREAD_ENV
IOMGR_Poll();
if (attributes->Mask & VLLIST_SERVER) {
int serverindex;
if ((serverindex =
- IpAddrToRelAddr(attributes->server,
- (struct ubik_trans *)0)) == -1)
+ IpAddrToRelAddr(attributes->server, NULL)) == -1)
continue;
for (k = 0; k < OMAXNSERVERS; k++) {
if (tentry.serverNumber[k] == BADSERVERID)
if (!(tentry.flags & attributes->flag))
continue;
}
- if (errorcode =
+ if ((errorcode =
put_attributeentry(&Vldbentry, &VldbentryFirst,
&VldbentryLast, vldbentries, &tentry,
- nentries, &allocCount)) {
+ nentries, &allocCount))) {
COUNT_ABO;
ubik_AbortTrans(trans);
if (vldbentries->bulkentries_val)
}
afs_int32
-SVL_ListAttributesN(rxcall, attributes, nentries, vldbentries)
- struct rx_call *rxcall;
- struct VldbListByAttributes *attributes;
- afs_int32 *nentries;
- nbulkentries *vldbentries;
+SVL_ListAttributesN(struct rx_call *rxcall,
+ struct VldbListByAttributes *attributes,
+ afs_int32 *nentries,
+ nbulkentries *vldbentries)
{
int errorcode, allocCount = 0;
struct ubik_trans *trans;
COUNT_REQ(VLLISTATTRIBUTESN);
vldbentries->nbulkentries_val = 0;
vldbentries->nbulkentries_len = *nentries = 0;
- if (errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op)))
return errorcode;
allocCount = VLDBALLOCCOUNT;
Vldbentry = VldbentryFirst = vldbentries->nbulkentries_val =
return VL_NOMEM;
}
VldbentryLast = VldbentryFirst + allocCount;
- /* Handle the attribute by volume id totally separate of the rest (thus additional Mask values are ignored if VLLIST_VOLUMEID is set!) */
+ /* Handle the attribute by volume id totally separate of the rest
+ * (thus additional Mask values are ignored if VLLIST_VOLUMEID is set!) */
if (attributes->Mask & VLLIST_VOLUMEID) {
afs_int32 blockindex;
vldbentries->nbulkentries_len = 0;
return errorcode;
}
- if (errorcode =
+ if ((errorcode =
put_nattributeentry(&Vldbentry, &VldbentryFirst, &VldbentryLast,
vldbentries, &tentry, 0, 0, nentries,
- &allocCount)) {
+ &allocCount))) {
COUNT_ABO;
ubik_AbortTrans(trans);
if (vldbentries->nbulkentries_val)
}
} else {
afs_int32 nextblockindex = 0, count = 0, k = 0, match = 0;
- while (nextblockindex =
- NextEntry(trans, nextblockindex, &tentry, &count)) {
+ while ((nextblockindex =
+ NextEntry(trans, nextblockindex, &tentry, &count))) {
if (++pollcount > 50) {
#ifndef AFS_PTHREAD_ENV
IOMGR_Poll();
if (attributes->Mask & VLLIST_SERVER) {
int serverindex;
if ((serverindex =
- IpAddrToRelAddr(attributes->server,
- (struct ubik_trans *)0)) == -1)
+ IpAddrToRelAddr(attributes->server, NULL)) == -1)
continue;
for (k = 0; k < NMAXNSERVERS; k++) {
if (tentry.serverNumber[k] == BADSERVERID)
if (!(tentry.flags & attributes->flag))
continue;
}
- if (errorcode =
+ if ((errorcode =
put_nattributeentry(&Vldbentry, &VldbentryFirst,
&VldbentryLast, vldbentries, &tentry, 0,
- 0, nentries, &allocCount)) {
+ 0, nentries, &allocCount))) {
COUNT_ABO;
ubik_AbortTrans(trans);
if (vldbentries->nbulkentries_val)
afs_int32
-SVL_ListAttributesN2(rxcall, attributes, name, startindex, nentries,
- vldbentries, nextstartindex)
- struct rx_call *rxcall;
- struct VldbListByAttributes *attributes;
- char *name; /* Wildcarded volume name */
- afs_int32 startindex;
- afs_int32 *nentries;
- nbulkentries *vldbentries;
- afs_int32 *nextstartindex;
+SVL_ListAttributesN2(struct rx_call *rxcall,
+ struct VldbListByAttributes *attributes,
+ char *name, /* Wildcarded volume name */
+ afs_int32 startindex,
+ afs_int32 *nentries,
+ nbulkentries *vldbentries,
+ afs_int32 *nextstartindex)
{
int errorcode = 0, maxCount = VLDBALLOCCOUNT;
struct ubik_trans *trans;
afs_int32 matchindex = 0;
int serverindex = -1; /* no server found */
int findserver = 0, findpartition = 0, findflag = 0, findname = 0;
- char *t;
int pollcount = 0;
int namematchRWBK, namematchRO, thismatch;
int matchtype = 0;
#ifdef HAVE_POSIX_REGEX
regex_t re;
int need_regfree = 0;
+#else
+ char *t;
#endif
COUNT_REQ(VLLISTATTRIBUTESN2);
/* Get the server index for matching server address */
if (attributes->Mask & VLLIST_SERVER) {
serverindex =
- IpAddrToRelAddr(attributes->server, (struct ubik_trans *)0);
+ IpAddrToRelAddr(attributes->server, NULL);
if (serverindex == -1)
goto done;
findserver = 1;
/* Read each entry and see if it is the one we want */
blockindex = startindex;
- while (blockindex = NextEntry(trans, blockindex, &tentry, &count)) {
+ while ((blockindex = NextEntry(trans, blockindex, &tentry, &count))) {
if (++pollcount > 50) {
#ifndef AFS_PTHREAD_ENV
IOMGR_Poll();
* cases sequential search of all vldb entries is performed.
*/
afs_int32
-SVL_LinkedList(rxcall, attributes, nentries, vldbentries)
- struct rx_call *rxcall;
- struct VldbListByAttributes *attributes;
- afs_int32 *nentries;
- vldb_list *vldbentries;
+SVL_LinkedList(struct rx_call *rxcall,
+ struct VldbListByAttributes *attributes,
+ afs_int32 *nentries,
+ vldb_list *vldbentries)
{
int errorcode;
struct ubik_trans *trans;
int pollcount = 0;
COUNT_REQ(VLLINKEDLIST);
- if (errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op)))
return errorcode;
*nentries = 0;
/* Does this volume exist on the desired server */
if (attributes->Mask & VLLIST_SERVER) {
serverindex =
- IpAddrToRelAddr(attributes->server,
- (struct ubik_trans *)0);
+ IpAddrToRelAddr(attributes->server, NULL);
if (serverindex == -1)
continue;
for (k = 0; k < OMAXNSERVERS; k++) {
}
afs_int32
-SVL_LinkedListN(rxcall, attributes, nentries, vldbentries)
- struct rx_call *rxcall;
- struct VldbListByAttributes *attributes;
- afs_int32 *nentries;
- nvldb_list *vldbentries;
+SVL_LinkedListN(struct rx_call *rxcall,
+ struct VldbListByAttributes *attributes,
+ afs_int32 *nentries,
+ nvldb_list *vldbentries)
{
int errorcode;
struct ubik_trans *trans;
int pollcount = 0;
COUNT_REQ(VLLINKEDLISTN);
- if (errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op)))
return errorcode;
*nentries = 0;
/* Does this volume exist on the desired server */
if (attributes->Mask & VLLIST_SERVER) {
serverindex =
- IpAddrToRelAddr(attributes->server,
- (struct ubik_trans *)0);
+ IpAddrToRelAddr(attributes->server, NULL);
if (serverindex == -1)
continue;
for (k = 0; k < NMAXNSERVERS; k++) {
return (ubik_EndTrans(trans));
}
-/* Get back vldb header statistics (allocs, frees, maxvolumeid, totalentries, etc) and dynamic statistics (number of requests and/or aborts per remote procedure call, etc) */
+/* Get back vldb header statistics (allocs, frees, maxvolumeid,
+ * totalentries, etc) and dynamic statistics (number of requests and/or
+ * aborts per remote procedure call, etc)
+ */
afs_int32
-SVL_GetStats(rxcall, stats, vital_header)
- struct rx_call *rxcall;
- vldstats *stats;
- vital_vlheader *vital_header;
+SVL_GetStats(struct rx_call *rxcall,
+ vldstats *stats,
+ vital_vlheader *vital_header)
{
register afs_int32 errorcode;
struct ubik_trans *trans;
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL)) /* Must be in 'UserList' to use */
return VL_PERM;
#endif
- if (errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op)))
return errorcode;
VLog(5, ("GetStats %s\n", rxinfo(rxcall)));
memcpy((char *)vital_header, (char *)&cheader.vital_header,
* through the VLDB, but that's life.
*/
afs_int32
-SVL_GetAddrs(rxcall, Handle, spare2, spare3, nentries, addrsp)
- struct rx_call *rxcall;
- afs_int32 Handle, spare2;
- struct VLCallBack *spare3;
- afs_int32 *nentries;
- bulkaddrs *addrsp;
+SVL_GetAddrs(struct rx_call *rxcall,
+ afs_int32 Handle,
+ afs_int32 spare2,
+ struct VLCallBack *spare3,
+ afs_int32 *nentries,
+ bulkaddrs *addrsp)
{
register afs_int32 errorcode;
struct ubik_trans *trans;
addrsp->bulkaddrs_val = 0;
memset(spare3, 0, sizeof(struct VLCallBack));
- if (errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op)))
return errorcode;
VLog(5, ("GetAddrs\n"));
}
for (i = 0; i <= MAXSERVERID; i++) {
- if (*taddrp = ntohl(cheader.IpMappedAddr[i])) {
+ if ((*taddrp = ntohl(cheader.IpMappedAddr[i]))) {
taddrp++;
nservers++;
}
#define PADDR(addr) VLog(0,("%d.%d.%d.%d", (addr>>24)&0xff, (addr>>16)&0xff, (addr>>8) &0xff, addr&0xff));
afs_int32
-SVL_RegisterAddrs(rxcall, uuidp, spare1, addrsp)
- struct rx_call *rxcall;
- afsUUID *uuidp;
- afs_int32 spare1;
- bulkaddrs *addrsp;
+SVL_RegisterAddrs(struct rx_call *rxcall, afsUUID *uuidp, afs_int32 spare1,
+ bulkaddrs *addrsp)
{
afs_int32 code;
struct ubik_trans *trans;
COUNT_REQ(VLREGADDR);
if (!afsconf_SuperUser(vldb_confdir, rxcall, NULL))
return (VL_PERM);
- if (code = Init_VLdbase(&trans, LOCKWRITE, this_op))
+ if ((code = Init_VLdbase(&trans, LOCKWRITE, this_op)))
return code;
/* Eliminate duplicates from IP address list */
}
afs_int32
-SVL_GetAddrsU(rxcall, attributes, uuidpo, uniquifier, nentries, addrsp)
- struct rx_call *rxcall;
- struct ListAddrByAttributes *attributes;
- afsUUID *uuidpo;
- afs_int32 *uniquifier, *nentries;
- bulkaddrs *addrsp;
+SVL_GetAddrsU(struct rx_call *rxcall,
+ struct ListAddrByAttributes *attributes,
+ afsUUID *uuidpo,
+ afs_int32 *uniquifier,
+ afs_int32 *nentries,
+ bulkaddrs *addrsp)
{
register afs_int32 errorcode, index = -1, offset;
struct ubik_trans *trans;
addrsp->bulkaddrs_len = *nentries = 0;
addrsp->bulkaddrs_val = 0;
VLog(5, ("GetAddrsU %s\n", rxinfo(rxcall)));
- if (errorcode = Init_VLdbase(&trans, LOCKREAD, this_op))
+ if ((errorcode = Init_VLdbase(&trans, LOCKREAD, this_op)))
return errorcode;
if (attributes->Mask & VLADDR_IPADDR) {
ubik_AbortTrans(trans);
return VL_NOENT;
}
- if (errorcode =
- FindExtentBlock(trans, &attributes->uuid, 0, -1, &exp, &base)) {
+ if ((errorcode =
+ FindExtentBlock(trans, &attributes->uuid, 0, -1, &exp, &base))) {
ubik_AbortTrans(trans);
return errorcode;
}
/* Routine that copies the given vldb entry to the output buffer, vldbentries. */
static int
-put_attributeentry(Vldbentry, VldbentryFirst, VldbentryLast, vldbentries,
- entry, nentries, alloccnt)
- struct vldbentry **Vldbentry, **VldbentryFirst, **VldbentryLast;
- bulkentries *vldbentries;
- struct nvlentry *entry;
- afs_int32 *nentries, *alloccnt;
+put_attributeentry(struct vldbentry **Vldbentry,
+ struct vldbentry **VldbentryFirst,
+ struct vldbentry **VldbentryLast,
+ bulkentries *vldbentries,
+ struct nvlentry *entry,
+ afs_int32 *nentries,
+ afs_int32 *alloccnt)
{
vldbentry *reall;
afs_int32 allo;
}
static int
-put_nattributeentry(Vldbentry, VldbentryFirst, VldbentryLast, vldbentries,
- entry, matchtype, matchindex, nentries, alloccnt)
- struct nvldbentry **Vldbentry, **VldbentryFirst, **VldbentryLast;
- nbulkentries *vldbentries;
- struct nvlentry *entry;
- afs_int32 matchtype, matchindex, *nentries, *alloccnt;
+put_nattributeentry(struct nvldbentry **Vldbentry,
+ struct nvldbentry **VldbentryFirst,
+ struct nvldbentry **VldbentryLast,
+ nbulkentries *vldbentries,
+ struct nvlentry *entry,
+ afs_int32 matchtype,
+ afs_int32 matchindex,
+ afs_int32 *nentries,
+ afs_int32 *alloccnt)
{
nvldbentry *reall;
afs_int32 allo;
/* Common code to actually remove a vldb entry from the database. */
static int
-RemoveEntry(trans, entryptr, tentry)
- struct ubik_trans *trans;
- afs_int32 entryptr;
- struct nvlentry *tentry;
+RemoveEntry(struct ubik_trans *trans, afs_int32 entryptr,
+ struct nvlentry *tentry)
{
register int errorcode;
- if (errorcode = UnthreadVLentry(trans, entryptr, tentry))
+ if ((errorcode = UnthreadVLentry(trans, entryptr, tentry)))
return errorcode;
- if (errorcode = FreeBlock(trans, entryptr))
+ if ((errorcode = FreeBlock(trans, entryptr)))
return errorcode;
return 0;
}
static void
-ReleaseEntry(tentry, releasetype)
- struct nvlentry *tentry;
- afs_int32 releasetype;
+ReleaseEntry(struct nvlentry *tentry, afs_int32 releasetype)
{
if (releasetype & LOCKREL_TIMESTAMP)
tentry->LockTimestamp = 0;
}
-/* Verify that the incoming vldb entry is valid; multi type of error codes are returned. */
+/* Verify that the incoming vldb entry is valid; multi type of error codes
+ * are returned. */
static int
-check_vldbentry(aentry)
- struct vldbentry *aentry;
+check_vldbentry(struct vldbentry *aentry)
{
afs_int32 i;
}
static int
-check_nvldbentry(aentry)
- struct nvldbentry *aentry;
+check_nvldbentry(struct nvldbentry *aentry)
{
afs_int32 i;
/* Convert from the external vldb entry representation to its internal
(more compact) form. This call should not change the hash chains! */
static int
-vldbentry_to_vlentry(atrans, VldbEntry, VlEntry)
- struct ubik_trans *atrans;
- struct vldbentry *VldbEntry;
- struct nvlentry *VlEntry;
+vldbentry_to_vlentry(struct ubik_trans *atrans,
+ struct vldbentry *VldbEntry,
+ struct nvlentry *VlEntry)
{
int i, serverindex;
}
static int
-nvldbentry_to_vlentry(atrans, VldbEntry, VlEntry)
- struct ubik_trans *atrans;
- struct nvldbentry *VldbEntry;
- struct nvlentry *VlEntry;
+nvldbentry_to_vlentry(struct ubik_trans *atrans,
+ struct nvldbentry *VldbEntry,
+ struct nvlentry *VlEntry)
{
int i, serverindex;
}
-/* Update the vldb entry with the new fields as indicated by the value of the Mask entry in the updateentry structure. All necessary validation checks are performed. */
-static
-get_vldbupdateentry(trans, blockindex, updateentry, VlEntry)
- struct ubik_trans *trans;
- afs_int32 blockindex;
- struct VldbUpdateEntry *updateentry;
- struct nvlentry *VlEntry;
+/* Update the vldb entry with the new fields as indicated by the value of
+ * the Mask entry in the updateentry structure. All necessary validation
+ * checks are performed.
+ */
+static int
+get_vldbupdateentry(struct ubik_trans *trans,
+ afs_int32 blockindex,
+ struct VldbUpdateEntry *updateentry,
+ struct nvlentry *VlEntry)
{
int i, j, errorcode, serverindex;
if (updateentry->Mask & VLUPDATE_VOLUMENAME) {
if (InvalidVolname(updateentry->name))
return VL_BADNAME;
- if (errorcode = UnhashVolname(trans, blockindex, VlEntry))
+ if ((errorcode = UnhashVolname(trans, blockindex, VlEntry)))
return errorcode;
strncpy(VlEntry->name, updateentry->name, sizeof(VlEntry->name));
HashVolname(trans, blockindex, VlEntry);
}
if (updateentry->Mask & VLUPDATE_VOLNAMEHASH) {
- if (errorcode = UnhashVolname(trans, blockindex, VlEntry)) {
+ if ((errorcode = UnhashVolname(trans, blockindex, VlEntry))) {
if (errorcode != VL_NOENT)
return errorcode;
}
VlEntry->cloneId = updateentry->cloneId;
}
if (updateentry->Mask & VLUPDATE_RWID) {
- if (errorcode = UnhashVolid(trans, RWVOL, blockindex, VlEntry)) {
+ if ((errorcode = UnhashVolid(trans, RWVOL, blockindex, VlEntry))) {
if (errorcode != VL_NOENT)
return errorcode;
}
VlEntry->volumeId[RWVOL] = updateentry->spares3; /* rw id */
- if (errorcode = HashVolid(trans, RWVOL, blockindex, VlEntry))
+ if ((errorcode = HashVolid(trans, RWVOL, blockindex, VlEntry)))
return errorcode;
}
if (updateentry->Mask & VLUPDATE_READONLYID) {
- if (errorcode = UnhashVolid(trans, ROVOL, blockindex, VlEntry)) {
+ if ((errorcode = UnhashVolid(trans, ROVOL, blockindex, VlEntry))) {
if (errorcode != VL_NOENT)
return errorcode;
}
VlEntry->volumeId[ROVOL] = updateentry->ReadOnlyId;
- if (errorcode = HashVolid(trans, ROVOL, blockindex, VlEntry))
+ if ((errorcode = HashVolid(trans, ROVOL, blockindex, VlEntry)))
return errorcode;
}
if (updateentry->Mask & VLUPDATE_BACKUPID) {
- if (errorcode = UnhashVolid(trans, BACKVOL, blockindex, VlEntry)) {
+ if ((errorcode = UnhashVolid(trans, BACKVOL, blockindex, VlEntry))) {
if (errorcode != VL_NOENT)
return errorcode;
}
VlEntry->volumeId[BACKVOL] = updateentry->BackupId;
- if (errorcode = HashVolid(trans, BACKVOL, blockindex, VlEntry))
+ if ((errorcode = HashVolid(trans, BACKVOL, blockindex, VlEntry)))
return errorcode;
}
if (updateentry->Mask & VLUPDATE_REPSITES) {
}
-/* Check if the specified [server,partition] entry is found in the vldb entry's repsite table; it's offset in the table is returned, if it's present there. */
+/* Check if the specified [server,partition] entry is found in the vldb
+ * entry's repsite table; it's offset in the table is returned, if it's
+ * present there. */
static int
-repsite_exists(VlEntry, server, partition)
- struct nvlentry *VlEntry;
- int server, partition;
+repsite_exists(struct nvlentry *VlEntry, int server, int partition)
{
int i;
-/* Repsite table compression: used when deleting a repsite entry so that all active repsite entries are on the top of the table. */
+/* Repsite table compression: used when deleting a repsite entry so that
+ * all active repsite entries are on the top of the table. */
static void
-repsite_compress(VlEntry, offset)
- struct nvlentry *VlEntry;
- int offset;
+repsite_compress(struct nvlentry *VlEntry, int offset)
{
int repsite_offset = offset;
for (;
}
-/* Convert from the internal (compacted) vldb entry to the external representation used by the interface. */
+/* Convert from the internal (compacted) vldb entry to the external
+ * representation used by the interface. */
static void
-vlentry_to_vldbentry(VlEntry, VldbEntry)
- struct nvlentry *VlEntry;
- struct vldbentry *VldbEntry;
+vlentry_to_vldbentry(struct nvlentry *VlEntry, struct vldbentry *VldbEntry)
{
int i, j;
}
-/* Convert from the internal (compacted) vldb entry to the external representation used by the interface. */
+/* Convert from the internal (compacted) vldb entry to the external
+ * representation used by the interface. */
static void
-vlentry_to_nvldbentry(VlEntry, VldbEntry)
- struct nvlentry *VlEntry;
- struct nvldbentry *VldbEntry;
+vlentry_to_nvldbentry(struct nvlentry *VlEntry, struct nvldbentry *VldbEntry)
{
int i, j;
}
static void
-vlentry_to_uvldbentry(VlEntry, VldbEntry)
- struct nvlentry *VlEntry;
- struct uvldbentry *VldbEntry;
+vlentry_to_uvldbentry(struct nvlentry *VlEntry, struct uvldbentry *VldbEntry)
{
int i, j;
/* Verify that the volname is a valid volume name. */
static int
-InvalidVolname(volname)
- char *volname;
+InvalidVolname(char *volname)
{
char *map;
int slen;
/* Verify that the given volume type is valid. */
static int
-InvalidVoltype(voltype)
- afs_int32 voltype;
+InvalidVoltype(afs_int32 voltype)
{
if (voltype != RWVOL && voltype != ROVOL && voltype != BACKVOL)
return 1;
static int
-InvalidOperation(voloper)
- afs_int32 voloper;
+InvalidOperation(afs_int32 voloper)
{
if (voloper != VLOP_MOVE && voloper != VLOP_RELEASE
&& voloper != VLOP_BACKUP && voloper != VLOP_DELETE
}
static int
-InvalidReleasetype(releasetype)
- afs_int32 releasetype;
+InvalidReleasetype(afs_int32 releasetype)
{
if ((releasetype & LOCKREL_TIMESTAMP) || (releasetype & LOCKREL_OPCODE)
|| (releasetype & LOCKREL_AFSID))
}
static int
-IpAddrToRelAddr(ipaddr, atrans)
- struct ubik_trans *atrans;
- register afs_uint32 ipaddr;
+IpAddrToRelAddr(register afs_uint32 ipaddr, struct ubik_trans *atrans)
{
register int i, j;
register afs_int32 code, base, index;
}
static int
-ChangeIPAddr(ipaddr1, ipaddr2, atrans)
- struct ubik_trans *atrans;
- register afs_uint32 ipaddr1, ipaddr2;
+ChangeIPAddr(afs_uint32 ipaddr1, afs_uint32 ipaddr2, struct ubik_trans *atrans)
{
int i, j;
afs_int32 code;
/* see if the vlserver is back yet */
afs_int32
-SVL_ProbeServer(rxcall)
- struct rx_call *rxcall;
+SVL_ProbeServer(struct rx_call *rxcall)
{
return 0;
}
#include <rx/xdr.h>
#include <ubik.h>
#include "vlserver.h"
+#include "vlserver_internal.h"
extern struct vlheader cheader;
struct vlheader xheader;
extern struct extentaddr *ex_addr[];
int vldbversion = 0;
-static int index_OK();
+static int index_OK(struct ubik_trans *trans, afs_int32 blockindex);
#define ERROR_EXIT(code) {error=(code); goto error_exit;}
/* Hashing algorithm based on the volume id; HASHSIZE must be prime */
afs_int32
-IDHash(volumeid)
- afs_int32 volumeid;
+IDHash(afs_int32 volumeid)
{
return ((abs(volumeid)) % HASHSIZE);
}
/* Hashing algorithm based on the volume name; name's size is implicit (64 chars) and if changed it should be reflected here. */
afs_int32
-NameHash(volumename)
- register char *volumename;
+NameHash(register char *volumename)
{
register unsigned int hash;
register int i;
/* package up seek and write into one procedure for ease of use */
afs_int32
-vlwrite(trans, offset, buffer, length)
- struct ubik_trans *trans;
- afs_int32 offset;
- char *buffer;
- afs_int32 length;
+vlwrite(struct ubik_trans *trans, afs_int32 offset, void *buffer,
+ afs_int32 length)
{
afs_int32 errorcode;
- if (errorcode = ubik_Seek(trans, 0, offset))
+ if ((errorcode = ubik_Seek(trans, 0, offset)))
return errorcode;
return (ubik_Write(trans, buffer, length));
}
/* Package up seek and read into one procedure for ease of use */
afs_int32
-vlread(trans, offset, buffer, length)
- struct ubik_trans *trans;
- afs_int32 offset;
- char *buffer;
- afs_int32 length;
+vlread(struct ubik_trans *trans, afs_int32 offset, char *buffer,
+ afs_int32 length)
{
afs_int32 errorcode;
- if (errorcode = ubik_Seek(trans, 0, offset))
+ if ((errorcode = ubik_Seek(trans, 0, offset)))
return errorcode;
return (ubik_Read(trans, buffer, length));
}
/* take entry and convert to network order and write to disk */
afs_int32
-vlentrywrite(trans, offset, buffer, length)
- struct ubik_trans *trans;
- afs_int32 offset;
- char *buffer;
- afs_int32 length;
+vlentrywrite(struct ubik_trans *trans, afs_int32 offset, void *buffer,
+ afs_int32 length)
{
struct vlentry oentry;
struct nvlentry nentry, *nep;
/* read entry and convert to host order and write to disk */
afs_int32
-vlentryread(trans, offset, buffer, length)
- struct ubik_trans *trans;
- afs_int32 offset;
- char *buffer;
- afs_int32 length;
+vlentryread(struct ubik_trans *trans, afs_int32 offset, char *buffer,
+ afs_int32 length)
{
struct vlentry *oep, tentry;
struct nvlentry *nep, *nbufp;
/* Convenient write of small critical vldb header info to the database. */
int
-write_vital_vlheader(trans)
- register struct ubik_trans *trans;
+write_vital_vlheader(register struct ubik_trans *trans)
{
if (vlwrite
(trans, 0, (char *)&cheader.vital_header, sizeof(vital_vlheader)))
* (extent_mod tells us the on-disk copy is bad).
*/
afs_int32
-readExtents(trans)
- struct ubik_trans *trans;
+readExtents(struct ubik_trans *trans)
{
afs_uint32 extentAddr;
afs_int32 error = 0, code;
/* Check that the database has been initialized. Be careful to fail in a safe
manner, to avoid bogusly reinitializing the db. */
afs_int32
-CheckInit(trans, builddb)
- struct ubik_trans *trans;
- int builddb;
+CheckInit(struct ubik_trans *trans, int builddb)
{
afs_int32 error = 0, i, code, ubcode = 0;
afs_int32
-GetExtentBlock(trans, base)
- register struct ubik_trans *trans;
- register afs_int32 base;
+GetExtentBlock(register struct ubik_trans *trans, register afs_int32 base)
{
afs_int32 blockindex, code, error = 0;
afs_int32
-FindExtentBlock(trans, uuidp, createit, hostslot, expp, basep)
- register struct ubik_trans *trans;
- afsUUID *uuidp;
- afs_int32 createit, hostslot, *basep;
- struct extentaddr **expp;
+FindExtentBlock(register struct ubik_trans *trans, afsUUID *uuidp,
+ afs_int32 createit, afs_int32 hostslot,
+ struct extentaddr **expp, afs_int32 *basep)
{
afsUUID tuuid;
struct extentaddr *exp;
/* Allocate a free block of storage for entry, returning address of a new
zeroed entry (or zero if something is wrong). */
afs_int32
-AllocBlock(trans, tentry)
- register struct ubik_trans *trans;
- struct nvlentry *tentry;
+AllocBlock(register struct ubik_trans *trans, struct nvlentry *tentry)
{
register afs_int32 blockindex;
/* Free a block given its index. It must already have been unthreaded. Returns zero for success or an error code on failure. */
int
-FreeBlock(trans, blockindex)
- struct ubik_trans *trans;
- afs_int32 blockindex;
+FreeBlock(struct ubik_trans *trans, afs_int32 blockindex)
{
struct nvlentry tentry;
}
-/* Look for a block by volid and voltype (if not known use -1 which searches all 3 volid hash lists. Note that the linked lists are read in first from the database header. If found read the block's contents into the area pointed to by tentry and return the block's index. If not found return 0. */
+/* Look for a block by volid and voltype (if not known use -1 which searches
+ * all 3 volid hash lists. Note that the linked lists are read in first from
+ * the database header. If found read the block's contents into the area
+ * pointed to by tentry and return the block's index. If not found return 0.
+ */
afs_int32
-FindByID(trans, volid, voltype, tentry, error)
- struct ubik_trans *trans;
- afs_uint32 volid;
- afs_int32 voltype;
- struct nvlentry *tentry;
- afs_int32 *error;
+FindByID(struct ubik_trans *trans, afs_uint32 volid, afs_int32 voltype,
+ struct nvlentry *tentry, afs_int32 *error)
{
register afs_int32 typeindex, hashindex, blockindex;
}
-/* Look for a block by volume name. If found read the block's contents into the area pointed to by tentry and return the block's index. If not found return 0. */
+/* Look for a block by volume name. If found read the block's contents into
+ * the area pointed to by tentry and return the block's index. If not
+ * found return 0.
+ */
afs_int32
-FindByName(trans, volname, tentry, error)
- struct ubik_trans *trans;
- char *volname;
- struct nvlentry *tentry;
- afs_int32 *error;
+FindByName(struct ubik_trans *trans, char *volname, struct nvlentry *tentry,
+ afs_int32 *error)
{
register afs_int32 hashindex;
register afs_int32 blockindex;
char tname[VL_MAXNAMELEN];
- /* remove .backup or .readonly extensions for stupid backwards compatibility */
+ /* remove .backup or .readonly extensions for stupid backwards
+ * compatibility
+ */
hashindex = strlen(volname); /* really string length */
if (hashindex >= 8 && strcmp(volname + hashindex - 7, ".backup") == 0) {
/* this is a backup volume */
}
int
-HashNDump(trans, hashindex)
- struct ubik_trans *trans;
- int hashindex;
-
+HashNDump(struct ubik_trans *trans, int hashindex)
{
register int i = 0;
register int blockindex;
int
-HashIdDump(trans, hashindex)
- struct ubik_trans *trans;
- int hashindex;
-
+HashIdDump(struct ubik_trans *trans, int hashindex)
{
register int i = 0;
register int blockindex;
}
-/* Add a block to the hash table given a pointer to the block and its index. The block is threaded onto both hash tables and written to disk. The routine returns zero if there were no errors. */
+/* Add a block to the hash table given a pointer to the block and its index.
+ * The block is threaded onto both hash tables and written to disk. The
+ * routine returns zero if there were no errors.
+ */
int
-ThreadVLentry(trans, blockindex, tentry)
- struct ubik_trans *trans;
- afs_int32 blockindex;
- struct nvlentry *tentry;
+ThreadVLentry(struct ubik_trans *trans, afs_int32 blockindex,
+ struct nvlentry *tentry)
{
int errorcode;
if (!index_OK(trans, blockindex))
return VL_BADINDEX;
/* Insert into volid's hash linked list */
- if (errorcode = HashVolid(trans, RWVOL, blockindex, tentry))
+ if ((errorcode = HashVolid(trans, RWVOL, blockindex, tentry)))
return errorcode;
- /* For rw entries we also enter the RO and BACK volume ids (if they exist) in the hash tables; note all there volids (RW, RO, BACK) should not be hashed yet! */
+ /* For rw entries we also enter the RO and BACK volume ids (if they
+ * exist) in the hash tables; note all there volids (RW, RO, BACK)
+ * should not be hashed yet! */
if (tentry->volumeId[ROVOL]) {
- if (errorcode = HashVolid(trans, ROVOL, blockindex, tentry))
+ if ((errorcode = HashVolid(trans, ROVOL, blockindex, tentry)))
return errorcode;
}
if (tentry->volumeId[BACKVOL]) {
- if (errorcode = HashVolid(trans, BACKVOL, blockindex, tentry))
+ if ((errorcode = HashVolid(trans, BACKVOL, blockindex, tentry)))
return errorcode;
}
}
-/* Remove a block from both the hash tables. If success return 0, else return an error code. */
+/* Remove a block from both the hash tables. If success return 0, else
+ * return an error code. */
int
-UnthreadVLentry(trans, blockindex, aentry)
- struct ubik_trans *trans;
- afs_int32 blockindex;
- struct nvlentry *aentry;
+UnthreadVLentry(struct ubik_trans *trans, afs_int32 blockindex,
+ struct nvlentry *aentry)
{
register afs_int32 errorcode, typeindex;
if (!index_OK(trans, blockindex))
return VL_BADINDEX;
- if (errorcode = UnhashVolid(trans, RWVOL, blockindex, aentry))
+ if ((errorcode = UnhashVolid(trans, RWVOL, blockindex, aentry)))
return errorcode;
/* Take the RO/RW entries of their respective hash linked lists. */
for (typeindex = ROVOL; typeindex <= BACKVOL; typeindex++) {
- if (errorcode = UnhashVolid(trans, typeindex, blockindex, aentry))
+ if ((errorcode = UnhashVolid(trans, typeindex, blockindex, aentry)))
return errorcode;
}
/* Take it out of the Volname hash list */
- if (errorcode = UnhashVolname(trans, blockindex, aentry))
+ if ((errorcode = UnhashVolname(trans, blockindex, aentry)))
return errorcode;
/* Update cheader entry */
/* cheader must have be read before this routine is called. */
int
-HashVolid(trans, voltype, blockindex, tentry)
- struct ubik_trans *trans;
- afs_int32 voltype;
- afs_int32 blockindex;
- struct nvlentry *tentry;
+HashVolid(struct ubik_trans *trans, afs_int32 voltype, afs_int32 blockindex,
+ struct nvlentry *tentry)
{
afs_int32 hashindex, errorcode;
- struct vlentry ventry;
+ struct nvlentry ventry;
if (FindByID
(trans, tentry->volumeId[voltype], voltype, &ventry, &errorcode))
/* cheader must have be read before this routine is called. */
int
-UnhashVolid(trans, voltype, blockindex, aentry)
- struct ubik_trans *trans;
- afs_int32 voltype;
- afs_int32 blockindex;
- struct nvlentry *aentry;
+UnhashVolid(struct ubik_trans *trans, afs_int32 voltype, afs_int32 blockindex,
+ struct nvlentry *aentry)
{
int hashindex, nextblockindex, prevblockindex;
struct nvlentry tentry;
int
-HashVolname(trans, blockindex, aentry)
- struct ubik_trans *trans;
- afs_int32 blockindex;
- struct nvlentry *aentry;
+HashVolname(struct ubik_trans *trans, afs_int32 blockindex,
+ struct nvlentry *aentry)
{
register afs_int32 hashindex;
register afs_int32 code;
int
-UnhashVolname(trans, blockindex, aentry)
- struct ubik_trans *trans;
- afs_int32 blockindex;
- struct nvlentry *aentry;
+UnhashVolname(struct ubik_trans *trans, afs_int32 blockindex,
+ struct nvlentry *aentry)
{
register afs_int32 hashindex, nextblockindex, prevblockindex;
struct nvlentry tentry;
}
-/* Returns the vldb entry tentry at offset index; remaining is the number of entries left; the routine also returns the index of the next sequential entry in the vldb */
+/* Returns the vldb entry tentry at offset index; remaining is the number of
+ * entries left; the routine also returns the index of the next sequential
+ * entry in the vldb
+ */
afs_int32
-NextEntry(trans, blockindex, tentry, remaining)
- struct ubik_trans *trans;
- afs_int32 blockindex;
- struct nvlentry *tentry;
- afs_int32 *remaining;
+NextEntry(struct ubik_trans *trans, afs_int32 blockindex,
+ struct nvlentry *tentry, afs_int32 *remaining)
{
register afs_int32 lastblockindex;
}
-/* Routine to verify that index is a legal offset to a vldb entry in the table */
+/* Routine to verify that index is a legal offset to a vldb entry in the
+ * table
+ */
static int
-index_OK(trans, blockindex)
- struct ubik_trans *trans;
- afs_int32 blockindex;
+index_OK(struct ubik_trans *trans, afs_int32 blockindex)
{
if ((blockindex < sizeof(cheader))
|| (blockindex >= ntohl(cheader.vital_header.eofPtr)))