#include <afs/budb_prototypes.h>
#include <afs/butc.h>
#include <afs/bubasics.h> /* PA */
+#include <afs/afsint.h>
#include <afs/volser.h>
#include <afs/voldefs.h> /* PA */
#include <afs/vldbint.h> /* PA */
}
/* No server entry added. Add one */
if (!(*ss)) {
- *ss = (struct serversort *)malloc(sizeof(struct serversort));
+ *ss = calloc(1, sizeof(struct serversort));
if (!(*ss)) {
afs_com_err(whoami, BC_NOMEM, NULL);
*ss = 0;
return (BC_NOMEM);
}
- memset(*ss, 0, sizeof(struct serversort));
(*ss)->ipaddr = server;
(*ss)->next = *serverlist;
*serverlist = *ss;
}
/* No partition entry added. Add one */
if (!(*ps)) {
- *ps = (struct partitionsort *)malloc(sizeof(struct partitionsort));
+ *ps = calloc(1, sizeof(struct partitionsort));
if (!(*ps)) {
afs_com_err(whoami, BC_NOMEM, NULL);
free(*ss);
*ss = 0;
return (BC_NOMEM);
}
- memset(*ps, 0, sizeof(struct partitionsort));
(*ps)->part = partition;
(*ps)->next = (*ss)->partitions;
(*ss)->partitions = *ps;
*avols = (struct bc_volumeDump *)0;
bulkentries.nbulkentries_len = 0;
bulkentries.nbulkentries_val = 0;
+ memset(&attributes, 0, sizeof(attributes));
/* For each of the volume set entries - collect the volumes that match it */
for (tve = avs->ventries; tve; tve = tve->next) {
bulkentries.nbulkentries_val = 0;
nsi = -1;
tcode =
- ubik_Call(VL_ListAttributesN2, uclient, 0, &attributes,
+ ubik_VL_ListAttributesN2(uclient, 0, &attributes,
tve->name, si, &nentries, &bulkentries, &nsi);
if (tcode)
ERROR(tcode);
ei = entries[e].matchindex & 0xffff;
et = (entries[e].matchindex >> 16) & 0xffff;
switch (et) {
- case ITSRWVOL:{
+ case VLSF_RWVOL:{
et = RWVOL;
break;
}
- case ITSBACKVOL:{
+ case VLSF_BACKVOL:{
et = BACKVOL;
break;
}
- case ITSROVOL:{
+ case VLSF_ROVOL:{
et = ROVOL;
break;
}
if (add) {
/* Allocate a volume dump structure and its name */
- tvd = (struct bc_volumeDump *)
- malloc(sizeof(struct bc_volumeDump));
+ tvd = calloc(1, sizeof(struct bc_volumeDump));
if (!tvd) {
afs_com_err(whoami, BC_NOMEM, NULL);
ERROR(BC_NOMEM);
}
- memset(tvd, 0, sizeof(*tvd));
- tvd->name = (char *)malloc(strlen(entries[e].name) + 10);
+ tvd->name = malloc(strlen(entries[e].name) + 10);
if (!(tvd->name)) {
afs_com_err(whoami, BC_NOMEM, NULL);
free(tvd);
/* Free memory allocated during VL call */
if (bulkentries.nbulkentries_val) {
- free((char *)bulkentries.nbulkentries_val);
+ free(bulkentries.nbulkentries_val);
bulkentries.nbulkentries_val = 0;
entries = 0;
}
error_exit:
if (bulkentries.nbulkentries_val) {
- free((char *)bulkentries.nbulkentries_val);
+ free(bulkentries.nbulkentries_val);
}
return (code);
} /*EvalVolumeSet2 */
*/
for (index = 0; 1; index = next_index) { /*w */
memset(&entry, 0, sizeof(entry));
- code = ubik_Call(VL_ListEntry, /*Routine to invoke */
- uclient, /*Ubik client structure */
+ code = ubik_VL_ListEntry(uclient, /*Ubik client structure */
0, /*Ubik flags */
index, /*Current index */
&count, /*Ptr to working variable */
/* If the RW name matches the volume set entry, take
* it and exit. First choice is to use the RW volume.
*/
- if (entry.serverFlags[srvpartpair] & ITSRWVOL) {
- if (entry.flags & RW_EXISTS) {
+ if (entry.serverFlags[srvpartpair] & VLSF_RWVOL) {
+ if (entry.flags & VLF_RWEXISTS) {
sprintf(patt, "%s", entry.name);
#ifdef HAVE_POSIX_REGEX
code = regexec(&re, patt, 0, NULL, 0);
/* If the BK name matches the volume set entry, take
* it and exit. Second choice is to use the BK volume.
*/
- if (entry.flags & BACK_EXISTS) {
+ if (entry.flags & VLF_BACKEXISTS) {
sprintf(patt, "%s.backup", entry.name);
#ifdef HAVE_POSIX_REGEX
code = regexec(&re, patt, 0, NULL, 0);
* it, but continue searching. Further entries may be
* RW or backup entries that will match.
*/
- else if (!found && (entry.serverFlags[srvpartpair] & ITSROVOL)
- && (entry.flags & RO_EXISTS)) {
+ else if (!found && (entry.serverFlags[srvpartpair] & VLSF_ROVOL)
+ && (entry.flags & VLF_ROEXISTS)) {
sprintf(patt, "%s.readonly", entry.name);
#ifdef HAVE_POSIX_REGEX
code = regexec(&re, patt, 0, NULL, 0);
}
total++;
- tvd = (struct bc_volumeDump *)
- malloc(sizeof(struct bc_volumeDump));
+ tvd = calloc(1, sizeof(struct bc_volumeDump));
if (!tvd) {
afs_com_err(whoami, BC_NOMEM, NULL);
return (BC_NOMEM);
}
- memset(tvd, 0, sizeof(*tvd));
- tvd->name = (char *)malloc(strlen(entry.name) + 10);
+ tvd->name = malloc(strlen(entry.name) + 10);
if (!(tvd->name)) {
afs_com_err(whoami, BC_NOMEM, NULL);
free(tvd);
char *
bc_CopyString(char *astring)
{
- afs_int32 tlen;
char *tp;
if (!astring)
return (NULL); /* propagate null strings easily */
- tlen = strlen(astring);
- tp = (char *)malloc(tlen + 1); /* don't forget the terminating null */
+ tp = strdup(astring);
if (!tp) {
afs_com_err(whoami, BC_NOMEM, NULL);
return (tp);
}
- strcpy(tp, astring);
return tp;
}
return (NULL);
}
- string = (char *)malloc(length); /* allocate the string */
+ string = malloc(length); /* allocate the string */
if (!string) {
afs_com_err(whoami, BC_NOMEM, NULL);
return (NULL);
{
int i;
int usefulJobRunning = 1;
+ int printWaiting = 1;
extern dlqlinkT statusHead;
- afs_com_err(whoami, 0, "waiting for job termination");
-
while (usefulJobRunning) {
usefulJobRunning = (dlqEmpty(&statusHead) ? 0 : 1);
if (dispatchLock.excl_locked)
}
/* Wait 5 seconds and check again */
- if (usefulJobRunning)
+ if (usefulJobRunning) {
+ if (printWaiting) {
+ afs_com_err(whoami, 0, "waiting for job termination");
+ printWaiting = 0;
+ }
IOMGR_Sleep(5);
+ }
}
return (lastTaskCode);
}
}
/* specified other destination host */
- if (as->parms[0].items) {
- tp = as->parms[0].items->data;
- if (bc_ParseHost(tp, &destServ)) {
- afs_com_err(whoami, 0, "Failed to locate destination host '%s'", tp);
- return -1;
- }
+ tp = as->parms[0].items->data;
+ if (bc_ParseHost(tp, &destServ)) {
+ afs_com_err(whoami, 0, "Failed to locate destination host '%s'", tp);
+ return -1;
}
/* specified other destination partition */
- if (as->parms[1].items) {
- tp = as->parms[1].items->data;
- if (bc_GetPartitionID(tp, &destPartition)) {
- afs_com_err(whoami, 0, "Can't parse destination partition '%s'", tp);
- return -1;
- }
+ tp = as->parms[1].items->data;
+ if (bc_GetPartitionID(tp, &destPartition)) {
+ afs_com_err(whoami, 0, "Can't parse destination partition '%s'", tp);
+ return -1;
}
for (ti = as->parms[2].items; ti; ti = ti->next) {
/* build list of volume items */
- tvol = (struct bc_volumeDump *)malloc(sizeof(struct bc_volumeDump));
+ tvol = calloc(1, sizeof(struct bc_volumeDump));
if (!tvol) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
}
- memset(tvol, 0, sizeof(struct bc_volumeDump));
- tvol->name = (char *)malloc(VOLSER_MAXVOLNAME + 1);
+ tvol->name = malloc(VOLSER_MAXVOLNAME + 1);
if (!tvol->name) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
if (as->parms[5].items) {
for (ti = as->parms[5].items; ti; ti = ti->next)
portCount++;
- ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
+ ports = malloc(portCount * sizeof(afs_int32));
if (!ports) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
if (as->parms[2].items) {
for (ti = as->parms[2].items; ti; ti = ti->next)
portCount++;
- ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
+ ports = malloc(portCount * sizeof(afs_int32));
if (!ports) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
}
/* Allocate a volumeDump structure and link it in */
- tvol =
- (struct bc_volumeDump *)malloc(sizeof(struct bc_volumeDump));
- memset(tvol, 0, sizeof(struct bc_volumeDump));
+ tvol = calloc(1, sizeof(struct bc_volumeDump));
- tvol->name = (char *)malloc(VOLSER_MAXVOLNAME + 1);
+ tvol->name = malloc(VOLSER_MAXVOLNAME + 1);
if (!tvol->name) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
if (as->parms[2].items) {
for (ti = as->parms[2].items; ti; ti = ti->next)
portCount++;
- ports = (afs_int32 *) malloc(portCount * sizeof(afs_int32));
+ ports = malloc(portCount * sizeof(afs_int32));
if (!ports) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
/* get the port number, if one was specified */
if (as->parms[2].items) {
- portp = (afs_int32 *) malloc(sizeof(afs_int32));
+ portp = malloc(sizeof(afs_int32));
if (!portp) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
sprintf(statusPtr->taskName, "Scheduled Dump");
statusPtr->jobNumber = bc_jobNumber();
statusPtr->scheduledDump = atTime;
- statusPtr->cmdLine = (char *)malloc(length);
+ statusPtr->cmdLine = malloc(length);
if (!statusPtr->cmdLine) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
* global variables so this can take place in main.
*/
if (loadfile) {
- loadFile = (char *)malloc(strlen(as->parms[6].items->data) + 1);
+ loadFile = strdup(as->parms[6].items->data);
if (!loadFile) {
afs_com_err(whoami, BC_NOMEM, NULL);
return BC_NOMEM;
}
- strcpy(loadFile, as->parms[6].items->data);
return 0;
}
detail = (as->parms[0].items ? 1 : 0); /* print more details */
code =
- ubik_Call(BUDB_DbVerify, udbHandle.uh_client, 0, &status, &orphans,
+ ubik_BUDB_DbVerify(udbHandle.uh_client, 0, &status, &orphans,
&host);
if (code) {
havetime = 1;
}
- port = (as->parms[3].items ? getPortOffset(as->parms[3].items->data) : 0); /* -port */
+ port = (as->parms[3].items ? getPortOffset(as->parms[3].items->data) : 0); /* -portoffset */
if (as->parms[5].items) /* -dbonly */
port = -1;
if (havegroupid)
groupId = atoi(as->parms[4].items->data);
- noexecute = (as->parms[7].items ? 1 : 0);
+ if (as->parms[7].items || as->parms[8].items) {
+ /* -noexecute (hidden) or -dryrun used */
+ noexecute = 1;
+ } else {
+ noexecute = 0;
+ }
/* Get the time to delete to */
if (as->parms[2].items) { /* -to */
for (i = 0; i < numEntries; i++) { /*f */
struct dumpedVol *insPtr, **prevPtr;
- tempPtr =
- (struct dumpedVol *)malloc(sizeof(struct dumpedVol));
+ tempPtr = calloc(1, sizeof(struct dumpedVol));
if (!tempPtr)
ERROR(BC_NOMEM);
- memset(tempPtr, 0, sizeof(*tempPtr));
tempPtr->incTime = volumeEntry[i].clone;
tempPtr->dumpID = volumeEntry[i].dump;
strncpy(tempPtr->tapeName, volumeEntry[i].tape,
/* now get the list of tapes */
for (tapeNumber = dumpEntry.tapes.b; tapeNumber <= dumpEntry.tapes.maxTapes; tapeNumber++) { /*f */
- tapeLinkPtr = (struct tapeLink *)malloc(sizeof(struct tapeLink));
+ tapeLinkPtr = calloc(1, sizeof(struct tapeLink));
if (!tapeLinkPtr) {
afs_com_err(whoami, BC_NOMEM, NULL);
ERROR(BC_NOMEM);
}
- memset(tapeLinkPtr, 0, sizeof(*tapeLinkPtr));
code = bcdb_FindTapeSeq(dumpid, tapeNumber, &tapeLinkPtr->tapeEntry);
if (code) {
code = 0;
for (i = 0; i < vl.budb_volumeList_len; i++) {
link = &tapeLinkPtr->firstVolume;
- volumeLinkPtr =
- (struct volumeLink *)malloc(sizeof(struct volumeLink));
+ volumeLinkPtr = calloc(1, sizeof(struct volumeLink));
if (!volumeLinkPtr) {
afs_com_err(whoami, BC_NOMEM, NULL);
ERROR(BC_NOMEM);
}
- memset(volumeLinkPtr, 0, sizeof(*volumeLinkPtr));
memcpy(&volumeLinkPtr->volumeEntry,
&vl.budb_volumeList_val[i],
dl.budb_dumpList_val = 0;
/* outline algorithm */
- code = ubik_Call(BUDB_GetDumps, udbHandle.uh_client, 0, BUDB_MAJORVERSION, BUDB_OP_NPREVIOUS, "", /* no name */
+ code = ubik_BUDB_GetDumps(udbHandle.uh_client, 0, BUDB_MAJORVERSION, BUDB_OP_NPREVIOUS, "", /* no name */
0, /* start */
ndumps, /* end */
index, /* index */