#include <signal.h>
#endif
#include "volser_prototypes.h"
+#include "vsutils_prototypes.h"
+#include "lockprocs_prototypes.h"
#ifdef HAVE_POSIX_REGEX
#include <regex.h>
#endif
+/* Local Prototypes */
+int PrintDiagnostics(char *astring, afs_int32 acode);
+int GetVolumeInfo(afs_int32 volid, afs_int32 *server, afs_int32 *part,
+ afs_int32 *voltype, struct nvldbentry *rentry);
+
struct tqElem {
afs_int32 volid;
struct tqElem *next;
cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
+cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL, "don't resolve addresses"); \
#define ERROR_EXIT(code) {error=(code); goto error_exit;}
-extern int verbose;
int rxInitDone = 0;
struct rx_connection *tconn;
afs_int32 tserver;
FD_ZERO(&in);
FD_SET((int)(ufd->handle), &in);
/* don't timeout if read blocks */
+#if defined(AFS_PTHREAD_ENV)
+ select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
+#else
IOMGR_Select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
#endif
+#endif
error = USD_READ(ufd, buffer, blksize, &nbytes);
if (error) {
fprintf(STDERR, "File system read failed\n");
USD_SEEK(ufd, filesize, SEEK_END, &currOffset);
hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32));
USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
- USD_READ(ufd, &buffer, sizeof(afs_uint32), &got);
+ USD_READ(ufd, (char *)&buffer, sizeof(afs_uint32), &got);
if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
error = VOLSERBADOP;
FD_ZERO(&out);
FD_SET((int)(ufd->handle), &out);
/* don't timeout if write blocks */
+#if defined(AFS_PTHREAD_ENV)
+ select(((int)(ufd->handle)) + 1, &out, 0, 0, 0);
+#else
IOMGR_Select(((int)(ufd->handle)) + 1, 0, &out, 0, 0);
#endif
+#endif
error =
USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
if (error) {
return (error);
}
-#if SIZEOF_TIME_T!=4
static char *
vos_ctime(afs_int32 *timep)
{
time_t foo = *timep;
return ctime(&foo);
}
-#else
-#define vos_ctime ctime
-#endif
static void
DisplayFormat(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
*totalOK += 1;
} else {
fprintf(STDOUT, "Off-line");
- *totalNotOK++;
+ *totalNotOK += 1;
}
if (pntr->needsSalvaged == 1)
fprintf(STDOUT, "**needs salvage**");
int quiet;
{
int totalOK, totalNotOK, totalBusy, i;
- afs_int32 volid;
+ afs_int32 volid = 0;
totalOK = 0;
totalNotOK = 0;
int totalNotOK; /*Total screwed volumes */
int totalBusy; /*Total busy volumes */
int i; /*Loop variable */
- afs_int32 volid; /*Current volume ID */
+ afs_int32 volid = 0; /*Current volume ID */
/*
* Initialize counters and (global!!) queues.
int totalNotOK; /*Total screwed volumes */
int totalBusy; /*Total busy volumes */
int i; /*Loop variable */
- afs_int32 volid; /*Current volume ID */
+ afs_int32 volid = 0; /*Current volume ID */
/*
* Initialize counters and (global!!) queues.
}
static void
-PostVolumeStats(entry)
- struct nvldbentry *entry;
+PostVolumeStats(struct nvldbentry *entry)
{
SubEnumerateEntry(entry);
/* Check for VLOP_ALLOPERS */
} /*XVolumeStats */
static void
-VolumeStats(pntr, entry, server, part, voltype)
- volintInfo *pntr;
- struct nvldbentry *entry;
- int voltype;
- afs_int32 server, part;
+VolumeStats_int(volintInfo *pntr, struct nvldbentry *entry, afs_int32 server,
+ afs_int32 part, int voltype)
{
int totalOK, totalNotOK, totalBusy;
EnumerateEntry(&entry);
} else
#endif /* FULL_LISTVOL_SWITCH */
- VolumeStats(pntr, &entry, aserver, apart, voltype);
+ VolumeStats_int(pntr, &entry, aserver, apart, voltype);
if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
/* The VLDB says there is no backup volume yet we found one on disk */
afs_int32 flags, code, err;
char fromPartName[10], toPartName[10];
- struct diskPartition partition; /* for space check */
+ struct diskPartition64 partition; /* for space check */
volintInfo *p;
volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
* check target partition for space to move volume
*/
- code = UV_PartitionInfo(toserver, toPartName, &partition);
+ code = UV_PartitionInfo64(toserver, toPartName, &partition);
if (code) {
fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
exit(1);
}
if (TESTM)
- fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
+ fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
partition.free);
p = (volintInfo *) 0;
afs_int32 volid, fromserver, toserver, frompart, topart, code, err, flags;
char fromPartName[10], toPartName[10], *tovolume;
struct nvldbentry entry;
- struct diskPartition partition; /* for space check */
+ struct diskPartition64 partition; /* for space check */
volintInfo *p;
volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
* check target partition for space to move volume
*/
- code = UV_PartitionInfo(toserver, toPartName, &partition);
+ code = UV_PartitionInfo64(toserver, toPartName, &partition);
if (code) {
fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
exit(1);
}
if (TESTM)
- fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
+ fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
partition.free);
p = (volintInfo *) 0;
afs_int32 volid, fromserver, toserver, frompart, topart, tovolid;
afs_int32 code, err, flags;
char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
- struct nvldbentry entry;
- struct diskPartition partition; /* for space check */
+ struct diskPartition64 partition; /* for space check */
volintInfo *p, *q;
p = (volintInfo *) 0;
* check target partition for space to move volume
*/
- code = UV_PartitionInfo(toserver, toPartName, &partition);
+ code = UV_PartitionInfo64(toserver, toPartName, &partition);
if (code) {
fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
exit(1);
}
if (TESTM)
- fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
+ fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
partition.free);
/* Don't do this again if we did it above */
afs_int32 avolid, aparentid, aserver, apart, code, vcode, err;
afs_int32 aoverwrite = ASK;
afs_int32 acreation = 0, alastupdate = 0;
- int restoreflags, readonly = 0, offline = 0, voltype = RWVOL;
+ int restoreflags = 0;
+ int readonly = 0, offline = 0, voltype = RWVOL;
char prompt;
char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
char volname[VOLSER_MAXVOLNAME + 1];
{
afs_int32 apart, int32list, fast;
afs_int32 aserver, code;
- volintInfo *pntr, *oldpntr;
+ volintInfo *pntr;
+ volintInfo *oldpntr = NULL;
afs_int32 count;
int i;
char *base;
- volintXInfo *xInfoP, *origxInfoP; /*Ptr to current/orig extended vol info */
+ volintXInfo *xInfoP;
+ volintXInfo *origxInfoP = NULL; /*Ptr to current/orig extended vol info */
int wantExtendedInfo; /*Do we want extended vol info? */
char pname[10];
}
}
+ if (as->parms[3].items) {
+ flags |= 2; /* don't update */
+ }
+
if (as->parms[2].items) {
/* Synchronize an individual volume */
volname = as->parms[2].items->data;
if (tserver) {
fprintf(STDOUT, " with state of server %s", as->parms[0].items->data);
}
- if (flags) {
+ if (flags & 1) {
MapPartIdIntoName(pnum, part);
fprintf(STDOUT, " partition %s\n", part);
}
pnum = -1;
}
+ if (as->parms[2].items) {
+ flags |= 2; /* don't update */
+ }
code = UV_SyncServer(tserver, pnum, flags, 0 /*unused */ );
if (code) {
PrintDiagnostics("syncserv", code);
exit(1);
}
- if (flags) {
+ if (flags & 1) {
MapPartIdIntoName(pnum, part);
fprintf(STDOUT, "Server %s partition %s synchronized with VLDB\n",
as->parms[0].items->data, part);
return 0;
}
-GetVolumeInfo(volid, server, part, voltype, rentry)
- afs_int32 *server, volid, *part, *voltype;
- register struct nvldbentry *rentry;
+int
+GetVolumeInfo(afs_int32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *voltype,
+ struct nvldbentry *rentry)
{
afs_int32 vcode;
int i, index = -1;
static int
DeleteEntry(register struct cmd_syndesc *as, void *arock)
{
- afs_int32 apart;
+ afs_int32 apart = 0;
afs_int32 avolid;
afs_int32 vcode;
struct VldbListByAttributes attributes;
struct VldbListByAttributes attributes;
nbulkentries arrayEntries;
struct nvldbentry *vllist, *tarray = 0, *ttarray;
- afs_int32 centries, nentries = 0, tarraysize, parraysize;
+ afs_int32 centries, nentries = 0;
+ afs_int32 tarraysize = 0;
+ afs_int32 parraysize;
int j;
char pname[10];
int quiet, sort, lock;
int comp = 0;
struct cmd_item *ti;
char *ccode;
- int match;
+ int match = 0;
memset(&attributes, 0, sizeof(struct VldbListByAttributes));
attributes.Mask = 0;
UnlockVLDB(register struct cmd_syndesc *as, void *arock)
{
afs_int32 apart;
- afs_int32 aserver, code;
+ afs_int32 aserver = NULL;
+ afs_int32 code;
afs_int32 vcode;
struct VldbListByAttributes attributes;
nbulkentries arrayEntries;
afs_int32 apart;
afs_int32 aserver, code;
char pname[10];
- struct diskPartition partition;
+ struct diskPartition64 partition;
struct partList dummyPartList;
int i, cnt;
int printSummary=0, sumPartitions=0;
- afs_uint64 sumFree, sumStorage, tmp;
+ afs_uint64 sumFree, sumStorage;
ZeroInt64(sumFree);
ZeroInt64(sumStorage);
for (i = 0; i < cnt; i++) {
if (dummyPartList.partFlags[i] & PARTVALID) {
MapPartIdIntoName(dummyPartList.partId[i], pname);
- code = UV_PartitionInfo(aserver, pname, &partition);
+ code = UV_PartitionInfo64(aserver, pname, &partition);
if (code) {
fprintf(STDERR, "Could not get information on partition %s\n",
pname);
exit(1);
}
fprintf(STDOUT,
- "Free space on partition %s: %d K blocks out of total %d\n",
+ "Free space on partition %s: %" AFS_INT64_FMT " K blocks out of total %" AFS_INT64_FMT "\n",
pname, partition.free, partition.minFree);
sumPartitions++;
- FillInt64(tmp,0,partition.free);
- AddUInt64(sumFree,tmp,&sumFree);
- FillInt64(tmp,0,partition.minFree);
- AddUInt64(sumStorage,tmp,&sumStorage);
+ AddUInt64(sumFree,partition.free,&sumFree);
+ AddUInt64(sumStorage,partition.minFree,&sumStorage);
}
}
if (printSummary) {
static void
print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
- int print, int noresolve)
+ int print)
{
afs_int32 vcode;
afs_int32 i, j;
m_addrs.bulkaddrs_len = 0;
vcode =
ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, &m_uuid,
- &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");
ListAddrs(register struct cmd_syndesc *as, void *arock)
{
afs_int32 vcode;
- afs_int32 i, noresolve = 0, printuuid = 0;
+ afs_int32 i, printuuid = 0;
struct VLCallBack vlcb;
afs_int32 nentries;
bulkaddrs m_addrs;
m_attrs.ipaddr = ntohl(saddr);
}
if (as->parms[2].items) {
- noresolve = 1;
- }
- if (as->parms[3].items) {
printuuid = 1;
}
return (vcode);
}
- print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid, noresolve);
+ print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid);
i++;
if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
afs_int32 server, volid, code, i, same;
struct nvldbentry entry, storeEntry;
afs_int32 vcode;
- afs_int32 rwindex;
+ afs_int32 rwindex = 0;
afs_int32 rwserver = 0;
- afs_int32 rwpartition;
- afs_int32 roindex;
+ afs_int32 rwpartition = 0;
+ afs_int32 roindex = 0;
afs_int32 roserver = 0;
- afs_int32 ropartition;
+ afs_int32 ropartition = 0;
int force = 0;
struct rx_connection *aconn;
char c, dc;
return 0;
}
-PrintDiagnostics(astring, acode)
- char *astring;
- afs_int32 acode;
+int
+PrintDiagnostics(char *astring, afs_int32 acode)
{
if (acode == EACCES) {
fprintf(STDERR,
verbose = 1;
else
verbose = 0;
+ if (as->parms[17].items) /* -noresolve flag set */
+ noresolve = 1;
+ else
+ noresolve = 0;
return 0;
}
cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
+ cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
COMMONPARMS;
ts = cmd_CreateSyntax("syncserv", SyncServer, NULL,
"synchronize server with VLDB");
cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
+ cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
COMMONPARMS;
ts = cmd_CreateSyntax("examine", ExamineVolume, NULL,
"list the IP address of all file servers registered in the VLDB");
cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
- cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL,
- "don't resolve addresses");
cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
"print uuid of hosts");
COMMONPARMS;