#include <afsconfig.h>
#include <afs/param.h>
+#include <roken.h>
+
+#include <afs/afs_AdminErrors.h>
#include "vsprocs.h"
#include "vosutils.h"
#include "lockprocs.h"
#include "../adminutil/afs_AdminInternal.h"
-#include <afs/afs_AdminErrors.h>
#include "afs_vosAdmin.h"
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef AFS_NT40_ENV
-#include <io.h>
-#endif
static afs_int32 GroupEntries(struct rx_connection *server, volintInfo * pntr, afs_int32 count,
struct qHead *myQueue, afs_int32 apart);
afs_int32 error, code, tid, rcode;
error = 0;
- code = 0;
if (okvol == 0) {
code = AFSVolTransCreate(aconn, delvol, apart, ITOffline, &tid);
struct destServer destination;
struct nvldbentry entry;
- int islocked, pntg;
- afs_int32 error;
+ int islocked;
int same;
afs_int32 store_flags;
fromtid = 0;
totid = 0;
clonetid = 0;
- error = 0;
volid = 0;
- pntg = 0;
backupId = 0;
newVol = 0;
*/
fromconn = UV_Bind(cellHandle, afromserver, AFSCONF_VOLUMEPORT);
fromtid = 0;
- pntg = 1;
tst =
AFSVolTransCreate(fromconn, afromvol, afrompart, ITOffline,
}
fromtid = 0;
- error = 0;
goto fail_UV_MoveVolume;
}
}
}
- pntg = 1;
toconn = UV_Bind(cellHandle, atoserver, AFSCONF_VOLUMEPORT); /* get connections to the servers */
fromconn = UV_Bind(cellHandle, afromserver, AFSCONF_VOLUMEPORT);
fromtid = totid = 0; /* initialize to uncreated */
DelVol(struct rx_connection *conn, afs_uint32 vid, afs_int32 part,
afs_int32 flags)
{
- afs_int32 acode, ccode, rcode, tid;
- ccode = rcode = tid = 0;
+ afs_int32 acode, rcode, tid;
+ rcode = tid = 0;
acode = AFSVolTransCreate(conn, vid, part, flags, &tid);
if (!acode) { /* It really was there */
acode = AFSVolDeleteVolume(conn, tid);
- ccode = AFSVolEndTrans(conn, tid, &rcode);
- if (!ccode)
- ccode = rcode;
+ AFSVolEndTrans(conn, tid, &rcode);
}
return acode;
afs_int32 * transPtr, afs_int32 * timePtr, afs_status_p st)
{
int rc = 0;
- afs_status_t tst = 0, etst = 0;
+ afs_status_t tst = 0;
afs_uint32 volid;
struct volser_status tstatus;
int rcode;
/* If the volume does not exist, create it */
if (!volid || tst) {
- char volname[64];
+ char volname[VL_MAXNAMELEN];
if (volid && (tst != VNOVOL)) {
goto fail_GetTrans;
}
- strcpy(volname, vldbEntryPtr->name);
- strcat(volname, ".readonly");
+ strlcpy(volname, vldbEntryPtr->name, sizeof(volname));
+ if (strlcat(volname, ".readonly", sizeof(volname))
+ >= sizeof(volname)) {
+ tst = ENOMEM;
+ goto fail_GetTrans;
+ }
tst =
AFSVolCreateVolume(*connPtr, vldbEntryPtr->serverPartition[index],
fail_GetTrans:
if ((rc == 0) && (*transPtr)) {
- etst = AFSVolEndTrans(*connPtr, *transPtr, &rcode);
+ AFSVolEndTrans(*connPtr, *transPtr, &rcode);
*transPtr = 0;
- if (!etst)
- etst = rcode;
}
if (st != NULL) {
cookie.clone = 0;
nservers = entry.nServers / 2; /* how many to do at once, excluding clone */
- replicas =
- (struct replica *)malloc(sizeof(struct replica) * nservers + 1);
- times = (struct release *)malloc(sizeof(struct release) * nservers + 1);
- toconns =
- (struct rx_connection **)malloc(sizeof(struct rx_connection *) *
- nservers + 1);
- results.manyResults_val =
- (afs_int32 *) malloc(sizeof(afs_int32) * nservers + 1);
+ replicas = calloc(nservers + 1, sizeof(struct replica));
+ times = calloc(nservers + 1, sizeof(struct release));
+ toconns = calloc(nservers + 1, sizeof(struct rx_connection *));
+ results.manyResults_val = calloc(nservers + 1, sizeof(afs_int32));
if (!replicas || !times || !!!results.manyResults_val || !toconns) {
tst = ADMNOMEM;
goto fail_UV_ReleaseVolume;
}
- memset(replicas, 0, (sizeof(struct replica) * nservers + 1));
- memset(times, 0, (sizeof(struct release) * nservers + 1));
- memset(toconns, 0, (sizeof(struct rx_connection *) * nservers + 1));
- memset(results.manyResults_val, 0, (sizeof(afs_int32) * nservers + 1));
-
/* Create a transaction on the cloned volume */
tst =
AFSVolTransCreate(fromconn, cloneVolId, afrompart, ITBusy, &fromtid);
}
#endif
nbytes = blockSize;
- buffer = (char *)malloc(blockSize);
+ buffer = malloc(blockSize);
if (!buffer) {
return ADMNOMEM;
}
afs_int32 error, code;
error = 0;
- fd = -1;
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0666);
if (fd < 0 || fstat(fd, &status) < 0) {
afs_int32 rcode;
struct nvldbentry entry;
- afs_int32 error;
int islocked;
islocked = 0;
- error = 0;
rxError = 0;
- fromcall = (struct rx_call *)0;
fromconn = (struct rx_connection *)0;
fromtid = 0;
fromcall = (struct rx_call *)0;
- islocked = 0;
if (!aVLDB_GetEntryByID(cellHandle, afromvol, -1, &entry, &tst)) {
goto fail_UV_DumpVolume;
}
int blockSize;
fd_set in;
afs_int32 error = 0;
- int done = 0;
int nbytes;
#ifdef AFS_NT40_ENV
blockSize = 4096;
}
#endif
- buffer = (char *)malloc(blockSize);
+ buffer = malloc(blockSize);
if (!buffer) {
return ADMNOMEM;
}
- while (!error && !done) {
+ while (!error) {
FD_ZERO(&in);
FD_SET(fd, &in);
#ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
error = ADMVOSRESTOREFILEREADFAIL;
break;
}
- if (nbytes == 0) {
- done = 1;
+
+ if (nbytes == 0)
break;
- }
+
if (rx_Write(call, buffer, nbytes) != nbytes) {
error = ADMVOSRESTOREFILEWRITEFAIL;
break;
afs_int32 error, code;
error = 0;
- fd = -1;
fd = open(filename, 0);
if (fd < 0 || fstat(fd, &status) < 0) {
afs_int32 temptid;
int success;
struct nvldbentry entry;
- afs_int32 error;
int islocked;
struct restoreCookie cookie;
int reuseID;
memset(&cookie, 0, sizeof(cookie));
islocked = 0;
- success = 0;
- error = 0;
reuseID = 1;
tocall = (struct rx_call *)0;
- toconn = (struct rx_connection *)0;
tempconn = (struct rx_connection *)0;
totid = 0;
temptid = 0;
{
struct aqueue elem;
int success, temp;
- afs_uint32 temp1, temp2;
+ afs_uint32 temp2;
afs_int32 vcode;
afs_uint32 maxVolid = 0;
struct nvldbentry entry;
continue;
}
if (maxVolid <= elem.ids[RWVOL]) {
- temp1 = maxVolid;
temp2 = elem.ids[RWVOL] - maxVolid + 1;
maxVolid = 0;
- vcode =
- ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2,
- &maxVolid);
+ vcode = ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2,
+ &maxVolid);
+ if (vcode)
+ return vcode;
+
maxVolid += temp2;
}
if (maxVolid <= elem.ids[ROVOL]) {
- temp1 = maxVolid;
temp2 = elem.ids[ROVOL] - maxVolid + 1;
maxVolid = 0;
- vcode =
- ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2,
- &maxVolid);
+ vcode = ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2,
+ &maxVolid);
+ if (vcode)
+ return vcode;
+
maxVolid += temp2;
}
if (maxVolid <= elem.ids[BACKVOL]) {
- temp1 = maxVolid;
- temp2 = elem.ids[BACKVOL] - temp1 + 1;
+ temp2 = elem.ids[BACKVOL] - maxVolid + 1;
maxVolid = 0;
- vcode =
- ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2,
- &maxVolid);
+ vcode = ubik_VL_GetNewVolumeId(cellHandle->vos, 0, temp2,
+ &maxVolid);
+ if (vcode)
+ return vcode;
+
maxVolid += temp2;
}
aVLDB_GetEntryByID(cellHandle, elem.ids[RWVOL], RWVOL, &entry, &tst);
int islocked = 0;
int pass = 0;
afs_int32 modentry = 0;
- afs_int32 delentry = 0;
if (modified) {
*modified = 0;
if (tst) {
goto fail_CheckVldb;
}
- delentry = 1;
} else {
/* Replace old entry with our new one */
if (!VLDB_ReplaceEntry
{
int rc = 0;
afs_status_t tst = 0;
- afs_int32 code, vcode;
int noError;
afs_int32 nentries, tentries = 0;
struct VldbListByAttributes attributes;
afs_int32 si, nsi;
afs_int32 modified = 0;
- code = 0;
- vcode = 0;
noError = 1;
arrayEntries.nbulkentries_val = 0;
int rc = 0;
afs_status_t tst = 0;
afs_status_t etst = 0;
- afs_int32 rcode, error;
+ afs_int32 rcode;
int i, index;
char nameBuffer[256];
afs_int32 tid;
struct rx_connection *aconn;
int islocked;
- error = 0;
aconn = (struct rx_connection *)0;
tid = 0;
islocked = 0;
error = VOLSERBADOP;
}
} else { /*create a fresh entry */
- qPtr = (struct aqueue *)malloc(sizeof(struct aqueue));
+ qPtr = malloc(sizeof(struct aqueue));
if (pntr->type == RWVOL) {
qPtr->isValid[RWVOL] = 1;
qPtr->isValid[BACKVOL] = 0;
UV_VolumeZap(afs_cell_handle_p cellHandle, struct rx_connection *server,
unsigned int partition, afs_uint32 volumeId, afs_status_p st)
{
- afs_int32 rcode, ttid, error, code;
+ afs_int32 rcode, ttid;
int rc = 0;
afs_status_t tst = 0;
- code = 0;
- error = 0;
ttid = 0;
tst = AFSVolTransCreate(server, volumeId, partition, ITOffline, &ttid);