AFS
view release on metacpan or search on metacpan
examples/v2/vos/examine view on Meta::CPAN
$AFS::CODE and print "AFS::CODE = $AFS::CODE\n";
print_vol($vollist);
print_vldb($vldblist);
sub print_vol {
my $vollist = shift;
print "$vollist->{name} \t$vollist->{volid} $vollist->{type} \t $vollist->{size} K $vollist->{inUse}\n";
print "\t$vollist->{server} $vollist->{partition}\n";
print "\tRWrite $vollist->{parentID} ROnly $vollist->{cloneID} Backup $vollist->{backupID}\n";
print "\tMaxQuota $vollist->{maxquota} K\n";
print "\tCreation ", ctime($vollist->{creationDate}), "\n";
print "\tCopy ", ctime($vollist->{copyDate}), "\n";
print "\tBackup ", ctime($vollist->{backupDate}), "\n";
print "\tLast Update ", ctime($vollist->{updateDate}), "\n";
print "\t$vollist->{dayUse} accesses in the past day (i.e., vnode references)\n";
}
sub print_vldb {
my ($vldblist) = @_;
examples/v2/vos/listvolume view on Meta::CPAN
my $vollist = $vos->listvolume($volume);
$AFS::CODE and print "AFS::CODE = $AFS::CODE\n";
$Debugging && print_debug($vollist) && exit;
print_volume($vollist);
sub print_volume {
my $vollist = shift;
print "$vollist->{name} \t$vollist->{parentID} $vollist->{type} \t $vollist->{size} K $vollist->{inUse}\n";
print "\t$vollist->{server} $vollist->{partition}\n";
print "\tRWrite $vollist->{parentID} ROnly $vollist->{cloneID} Backup $vollist->{backupID}\n";
print "\tMaxQuota $vollist->{maxquota} K\n";
print "\tCreation ", ctime($vollist->{creationDate}), "\n";
print "\tCopy ", ctime($vollist->{copyDate}), "\n";
print "\tBackup ", ctime($vollist->{backupDate}), "\n";
print "\tLast Access ", ctime($vollist->{accessDate}), "\n";
print "\tLast Update ", ctime($vollist->{updateDate}), "\n";
print "\t$vollist->{dayUse} accesses in the past day (i.e., vnode references)\n";
}
sub print_debug {
pod/v2/afsperlvos.pod view on Meta::CPAN
If you set EXTENDED (default 0) to 1, it returns extensive statistics
about access patterns for each volume. If you set FAST (default 0) to
1, it returns only the volume IDs and the numbers of volumes.
The return value is a reference to a hash table containing the values
from the C structure C<volintinfo>. The hash table has the following
keys
backupID cloneID creationDate
dayUse inUse maxquota
parentID server size
status type updateDate
copyDate backupDate accessDate
volid
It calls the AFS system library function I<UV_ListPartitions>.
You can find an example how to print the entire content of the
returned hash reference in the C<examples/v2/vos> directory.
=item B<$vollist = $vos-E<gt>listvolume(VOLUME);>
case VL_REPSFULL:
sprintf(buffer, "VLDB: run out of space for replication sites\n");
break;
case VL_NOREPSERVER:
sprintf(buffer, "VLDB: no such repsite server exists\n");
break;
case VL_DUPREPSERVER:
sprintf(buffer, "VLDB: replication site server already exists\n");
break;
case VL_RWNOTFOUND:
sprintf(buffer, "VLDB: parent r/w entry not found\n");
break;
case VL_BADREFCOUNT:
sprintf(buffer, "VLDB: illegal reference count number\n");
break;
case VL_SIZEEXCEEDED:
sprintf(buffer, "VLDB: vldb size for attributes exceeded\n");
break;
case VL_BADENTRY:
sprintf(buffer, "VLDB: bad incoming vldb entry\n");
break;
safe_hv_store(stats, "cellid", 6, newSViv(entry->cellid), 0);
safe_hv_store(stats, "next", 4, newSViv(entry->next), 0);
safe_hv_store(stats, "nextID", 6, newSViv(entry->nextID), 0);
safe_hv_store(stats, "nextname", 8, newSViv(entry->nextname), 0);
safe_hv_store(stats, "ngroups", 7, newSViv(entry->ngroups), 0);
safe_hv_store(stats, "nusers", 6, newSViv(entry->nusers), 0);
safe_hv_store(stats, "count", 5, newSViv(entry->count), 0);
safe_hv_store(stats, "instance", 8, newSViv(entry->instance), 0);
safe_hv_store(stats, "owned", 5, newSViv(entry->owned), 0);
safe_hv_store(stats, "nextOwned", 9, newSViv(entry->nextOwned), 0);
safe_hv_store(stats, "parent", 6, newSViv(entry->parent), 0);
safe_hv_store(stats, "sibling", 7, newSViv(entry->sibling), 0);
safe_hv_store(stats, "child", 5, newSViv(entry->child), 0);
safe_hv_store(stats, "reserved0", 9, newSViv(entry->reserved[0]), 0);
safe_hv_store(stats, "reserved1", 9, newSViv(entry->reserved[1]), 0);
safe_hv_store(stats, "reserved2", 9, newSViv(entry->reserved[2]), 0);
safe_hv_store(stats, "reserved3", 9, newSViv(entry->reserved[3]), 0);
safe_hv_store(stats, "reserved4", 9, newSViv(entry->reserved[4]), 0);
return 1;
}
}
else {
safe_hv_store(vol, "inUse", 5, newSVpv("Off-line", 8), 0);
*totalNotOK += 1;
}
MapPartIdIntoName(part, pname);
strcpy(hostname, (char *) hostutil_GetNameByINet(server));
safe_hv_store(vol, "server", 6, newSVpv(hostname, strlen((char *) hostname)), 0);
safe_hv_store(vol, "backupID", 8, newSViv(pntr->backupID), 0);
safe_hv_store(vol, "parentID", 8, newSViv(pntr->parentID), 0);
safe_hv_store(vol, "cloneID", 7, newSViv(pntr->cloneID), 0);
safe_hv_store(vol, "maxquota", 8, newSViv(pntr->maxquota), 0);
safe_hv_store(vol, "creationDate", 12, newSViv(pntr->creationDate), 0);
#ifdef OpenAFS /* copy taken from <src/volser/vos.c> OpenAFS-1.2.11 FULL_LISTVOL_SWITCH*/
safe_hv_store(vol, "copyDate", 8, newSViv(pntr->copyDate), 0);
if (!pntr->backupDate)
safe_hv_store(vol, "backupDate", 10, newSVpv("Never", 5), 0);
else
safe_hv_store(vol, "backupDate", 10, newSViv(pntr->backupDate), 0);
if (pntr->accessDate)
}
else {
safe_hv_store(stats, "inUse", 5, newSVpv("Off-line", 8), 0);
(*a_totalNotOKP)++;
}
MapPartIdIntoName(a_partID, pname);
strcpy(hostname, (char *) hostutil_GetNameByINet(a_servID));
safe_hv_store(stats, "server", 6, newSVpv(hostname, strlen((char *) hostname)), 0);
safe_hv_store(stats, "partition", 9, newSVpv(pname, strlen(pname)), 0);
safe_hv_store(stats, "parentID", 8, newSViv(a_xInfoP->parentID), 0);
safe_hv_store(stats, "cloneID", 7, newSViv(a_xInfoP->cloneID), 0);
safe_hv_store(stats, "backupID", 8, newSViv(a_xInfoP->backupID), 0);
safe_hv_store(stats, "maxquota", 8, newSViv(a_xInfoP->maxquota), 0);
safe_hv_store(stats, "creationDate", 12, newSViv(a_xInfoP->creationDate), 0);
#ifdef OpenAFS /* copy taken from <src/volser/vos.c> OpenAFS-1.2.11 FULL_LISTVOL_SWITCH*/
safe_hv_store(stats, "copyDate", 8, newSViv(a_xInfoP->copyDate), 0);
if (!a_xInfoP->backupDate)
safe_hv_store(stats, "backupDate", 10, newSVpv("Never", 5), 0);
else
safe_hv_store(stats, "backupDate", 10, newSViv(a_xInfoP->backupDate), 0);
void
fs_lsmount(path,follow=1)
char * path
int32 follow
CODE:
{
struct ViceIoctl vi;
int32 code;
char space[MAXSIZE];
char *dir, *file;
char parent[1024];
if (strlen(path) > (sizeof(parent) - 1))
code = EINVAL;
else {
strcpy(parent, path);
file = strrchr(parent, '/');
if (file) {
dir = parent;
*file++ = '\0';
}
else {
dir = ".";
file = parent;
}
vi.in_size = strlen(file) + 1;
vi.in = file;
vi.out_size = MAXSIZE;
vi.out = (caddr_t) space;
code = pioctl(dir, VIOC_AFS_STAT_MT_PT, &vi, follow);
}
SETCODE(code);
}
int32
fs_rmmount(path)
char * path
CODE:
{
struct ViceIoctl vi;
int32 code;
char *file, *dir;
char parent[1024];
if (strlen(path) > (sizeof(parent) - 1))
code = EINVAL;
else {
strcpy(parent, path);
file = strrchr(parent, '/');
if (file) {
dir = parent;
*file++ = '\0';
}
else {
dir = ".";
file = parent;
}
vi.in_size = strlen(file) + 1;
vi.in = file;
vi.out_size = 0;
code = pioctl(dir, VIOC_AFS_DELETE_MT_PT, &vi, 0);
}
SETCODE(code);
RETVAL = (code == 0);
int32
fs_mkmount(mountp,volume,rw=0,cell=0)
char * mountp
char * volume
int32 rw
char * cell
CODE:
{
char buffer[1024];
char parent[1024];
int32 code = 0;
if (cell && (cell[0] == '\0' || cell[0] == '0'))
cell = NULL;
if (strlen(mountp) > (sizeof(parent) - 1))
code = EINVAL;
else {
char *p;
strcpy(parent, mountp);
p = strrchr(parent, '/');
if (p)
*p = 0;
else
strcpy(parent, ".");
if (!isafs(parent))
code = EINVAL;
}
if (code == 0) {
sprintf(buffer, "%c%s%s%s.",
rw ? '%' : '#', cell ? cell : "", cell ? ":" : "", volume);
code = symlink(buffer, mountp);
}
SETCODE(code);
RETVAL = (code == 0);
char *server
char *partition
char *name
char *file
char *id
SV * inter
char *overwrite
SV * offline
SV * readonly
PREINIT:
afs_int32 avolid, aparentid, aserver, apart, code, vcode, err;
afs_int32 aoverwrite = AFS_ASK;
int restoreflags, voltype = RWVOL, ireadonly = 0, ioffline = 0;
char afilename[NameLen], avolname[VOLSER_MAXVOLNAME +1];
char volname[VOLSER_MAXVOLNAME +1];
struct nvldbentry entry;
CODE:
{
aparentid = 0;
if (!inter) {
inter = newSViv(0);
}
if (!offline) {
offline = newSViv(0);
}
if (!readonly) {
readonly = newSViv(0);
}
if ((!SvIOKp(inter))) {
if ((aoverwrite == AFS_INC) || (aoverwrite == AFS_ABORT))
fprintf(stderr, "%s Volume does not exist; Will perform a full restore\n",
ireadonly ? "RO" : "RW");
if (avolid == 0) {
avolid = entry.volumeId[voltype];
}
else if (entry.volumeId[voltype] != 0 && entry.volumeId[voltype] != avolid) {
avolid = entry.volumeId[voltype];
}
aparentid = entry.volumeId[RWVOL];
}
else { /* volume exists - do we do a full incremental or abort */
int Oserver, Opart, Otype, vol_elsewhere = 0;
struct nvldbentry Oentry;
int c, dc;
if (avolid == 0) {
avolid = entry.volumeId[voltype];
}
else if (entry.volumeId[voltype] != 0 && entry.volumeId[voltype] != avolid) {
avolid = entry.volumeId[voltype];
}
aparentid = entry.volumeId[RWVOL];
/* A file name was specified - check if volume is on another partition */
vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
if (vcode) {
SETCODE(0);
RETVAL = 0;
goto done;
}
vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
}
if ((ioffline))
restoreflags |= RV_OFFLINE;
if (ireadonly)
restoreflags |= RV_RDONLY;
/* restoreflags |= RV_CRNEW; */
/* restoreflags |= RV_LUDUMP; */
#ifdef OpenAFS_1_4_05
code = UV_RestoreVolume2(aserver, apart, avolid, aparentid, avolname,
restoreflags, WriteData, afilename);
#else
code = UV_RestoreVolume(aserver, apart, avolid, avolname,
restoreflags, WriteData, afilename);
#endif
if (code) {
PrintDiagnostics("restore", code);
SETCODE(code);
RETVAL = 0;
goto done;
#fprintf(stderr,
# "Warning: Entry for volume number %u exists in VLDB (but we're zapping it anyway!)\n",
# volid);
}
if (zapbackupid) {
volintInfo *pntr = (volintInfo *) 0;
if (!backupid) {
code = UV_ListOneVolume(server, part, volid, &pntr);
if (!code) {
if (volid == pntr->parentID)
backupid = pntr->backupID;
if (pntr)
free(pntr);
}
}
if (backupid) {
code = UV_VolumeZap(server, part, backupid);
if (code) {
PrintDiagnostics("zap", code);
SETCODE(code);
src/inc/Test/Builder.pm view on Meta::CPAN
$in_eval = 1 if $sub =~ /^\(eval\)/;
}
$Test_Died = 1 unless $in_eval;
};
sub _ending {
my $self = shift;
_sanity_check();
# Don't bother with an ending if this is a forked copy. Only the parent
# should do the ending.
do{ _my_exit($?) && return } if $Original_Pid != $$;
# Bailout if plan() was never called. This is so
# "require Test::Simple" doesn't puke.
do{ _my_exit(0) && return } if !$Have_Plan && !$Test_Died;
# Figure out if we passed or failed and print helpful messages.
if( @Test_Results ) {
# The plan? We have no plan.
( run in 0.419 second using v1.01-cache-2.11-cpan-a5abf4f5562 )