AFS
view release on metacpan or search on metacpan
XSRETURN_UNDEF;
}
total = 0;
for (i = 0; i < cnt; i++) {
if (dummyPartList.partFlags[i] & PARTVALID) {
Zero(pname, 10, char);
MapPartIdIntoName(dummyPartList.partId[i], pname);
XPUSHs(sv_2mortal(newSVpv(pname, strlen(pname))));
total++;
}
}
SETCODE(0);
XSRETURN(total);
}
void
vos_listvolume(cstruct, name)
AFS::VOS cstruct
char *name
PREINIT:
struct nvldbentry entry;
afs_int32 vcode = 0;
volintInfo *pntr = (volintInfo *)0;
afs_int32 volid;
afs_int32 code, err;
int voltype, foundserv = 0, foundentry = 0;
afs_int32 aserver, apart;
char apartName[10];
int previdx = -1;
HV *volinfo = (HV*)sv_2mortal((SV*)newHV());
PPCODE:
{
volid = vsu_GetVolumeID(name, cstruct, &err); /* -id */
if (volid == 0) {
char buffer[256];
if (err)
set_errbuff(buffer, err);
else
sprintf(buffer, "Unknown volume ID or name '%s'\n", name);
VSETCODE(err ? err : -1, buffer);
XSRETURN_UNDEF;
}
vcode = VLDB_GetEntryByID(volid, -1, &entry);
if (vcode) {
char buffer[256];
sprintf(buffer, "Could not fetch the entry for volume number %u from VLDB \n", volid);
VSETCODE(vcode, buffer);
XSRETURN_UNDEF;
}
MapHostToNetwork(&entry);
if (entry.volumeId[RWVOL] == volid)
voltype = RWVOL;
else if (entry.volumeId[BACKVOL] == volid)
voltype = BACKVOL;
else /* (entry.volumeId[ROVOL] == volid) */
voltype = ROVOL;
do { /* do {...} while (voltype == ROVOL) */
/* Get the entry for the volume. If its a RW vol, get the RW entry.
* It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
* If its a RO vol, get the next RO entry.
*/
GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL), &aserver, &apart,
&previdx);
if (previdx == -1) { /* searched all entries */
if (!foundentry) {
char buffer[256];
sprintf(buffer, "Volume %s does not exist in VLDB\n\n", name);
VSETCODE(ENOENT, buffer);
XSRETURN_UNDEF;
}
break;
}
foundentry = 1;
/* Get information about the volume from the server */
code = UV_ListOneVolume(aserver, apart, volid, &pntr);
if (code) {
char buffer[256];
if (code == ENODEV) {
if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
/* The VLDB says there is no backup volume and its not on disk */
sprintf(buffer, "Volume %s does not exist\n", name);
}
else {
sprintf(buffer,
"Volume does not exist on server %s as indicated by the VLDB\n",
hostutil_GetNameByINet(aserver));
}
}
else {
sprintf(buffer, "examine");
}
if (pntr)
free(pntr);
VSETCODE(code, buffer);
XSRETURN_UNDEF;
}
else {
foundserv = 1;
MapPartIdIntoName(apart, apartName);
/* safe_hv_store(volinfo, "name", 4, newSVpv(name, strlen((char *) name)), 0); */
safe_hv_store(volinfo, "partition", 9, newSVpv(apartName, strlen((char *) apartName)), 0);
VolumeStats(volinfo, 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 */
char buffer[256];
sprintf(buffer, "Volume %s does not exist in VLDB\n", name);
if (pntr)
free(pntr);
VSETCODE(ENOENT, buffer);
XSRETURN_UNDEF;
}
}
if (pntr)
free(pntr);
} while (voltype == ROVOL);
( run in 0.426 second using v1.01-cache-2.11-cpan-b85c58fdc1d )