view release on metacpan or search on metacpan
- setrestart
* updated POD documentation of AFS::VLDB
updated argument description for VOLUME in several
methods: "(volume name or volume ID number)"
* fixed method AFS::VOS->create
* extended method AFS::VOS->dump: added "omitdir" option
* added new method AFS::ACL->is_clean
* modified AFS::ACL->cleanacl: uses method "is_clean" to check if
there is anything to do
* method AFS::VOS->listvolume provides also the values "copyDate",
"backupDate", and "accessDate"
* patched example for AFS::KTC_TOKEN->SetToken to handle several
tokens
* updated example scripts for all AFS modules
Developer-visible changes:
* rewrite of method AFS::VOS->backupsys
* concatenate compiler flags in Makefile.PL
* cleaned up compiler warnings
* cleaned up memory allocation for the AFS::PTS, AFS::VOS, AFS::VLDB,
and AFS::BOS modules
* closed memory leaks because of multiple calls to "rx_Init" in the
AFS::PTS, AFS::VOS, AFS::VLDB, and AFS::BOS modules
* converted "integer" checks to "Scalar::Util(looks_like_number)"
utility for all AFS::VOS methods and all AFS::VOS examples
Version 2.2.3 (released 17 Feb 2005, revision 679)
NOTICE:
* This release does not support AFS system libraries version 3.4 or
version 3.5
User-visible changes:
* now supports Perl "threaded" version on several platforms
* fixed method AFS::VOS->backupsys: fixed segmentation error and
added some error handling
* fixed method AFS::VLDB->delentry: added some error handling
Developer-visible changes:
* modified AFS.xs functions "SendFile", "ReceiveFile",
and "DoSalvage" to handle "threaded" and "unthreaded" case
* modified AFS.xs: added dummy functions for "threaded" case
* redesigned the computing of the VERSION numbers
examples/v2/vldb/listvldb
examples/v2/vldb/listvldbentry
examples/v2/vldb/lock
examples/v2/vldb/removeaddr
examples/v2/vldb/remsite
examples/v2/vldb/syncserv
examples/v2/vldb/syncvldb
examples/v2/vldb/syncvldbentry
examples/v2/vldb/unlock
examples/v2/vldb/unlockvldb
examples/v2/vos/backup
examples/v2/vos/backupsys
examples/v2/vos/constructor
examples/v2/vos/create
examples/v2/vos/dump
examples/v2/vos/examine
examples/v2/vos/listpart
examples/v2/vos/listvol
examples/v2/vos/listvolume
examples/v2/vos/move
examples/v2/vos/offline
examples/v2/vos/online
examples/v2/vos/backup view on Meta::CPAN
my ($vos, $volume, $ok);
die "Usage: $0 volume\n" if $#ARGV < 0;
$volume = shift;
$vos = AFS::VOS->new;
$AFS::CODE and print "AFS::CODE = $AFS::CODE\n";
$ok = $vos->backup($volume);
if ($AFS::CODE) { print "AFS::CODE = $AFS::CODE\n"; }
else { print "Created backup volume for $volume \n"; }
examples/v2/vos/backupsys view on Meta::CPAN
use v5.10.0;
use blib;
use strict;
use warnings;
use AFS::VOS;
use Scalar::Util qw(looks_like_number);
my ($vos, $prefix, $server, $part, $exclude, $xprefix, $dry);
my ($tbackup, $fbackup, $tbcount, $fbcount);
die "Usage: $0 [prefix server partition exclude xprefix dryrun]\n" if $#ARGV > 5;
$dry = 1 if $#ARGV == -1;
$prefix = shift // '';
$server = shift // '';
$part = shift // '';
$exclude = shift // 0;
$xprefix = shift // '';
$dry = shift // $dry // 0;
examples/v2/vos/backupsys view on Meta::CPAN
else { $would = ''; }
$vos = AFS::VOS->new;
$AFS::CODE and print "AFS::CODE = $AFS::CODE\n" and die;
my @prefix = ($prefix);
my @xprefix = ();
@xprefix = ($xprefix) if $xprefix;
# -prefix <>+ -server <> -partition <> -exclude -xprefix <>+ -dryrun
($tbackup, $fbackup) = $vos->backupsys(\@prefix, $server, $part, $exclude, \@xprefix, $dry);
$AFS::CODE and print "AFS::CODE = $AFS::CODE\n" and die;
if (defined $tbackup) { $tbcount = @$tbackup; }
else { $tbcount = 0; }
if (defined $tbackup) { $fbcount = @$fbackup; }
else { $fbcount = 0; }
if ($tbcount) {
foreach (@$tbackup) {
print "\t$_\n";
}
}
if ($fbcount) {
foreach (@$fbackup) {
print "\t$_\n";
}
}
print "Total volumes $would backed up: ", $tbcount, "; $would failed to backup: ", $fbcount, "\n";
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) = @_;
print "\tRWrite: $vldblist->{$volume}->{RWrite} \n";
print "\tnumber of sites -> $vldblist->{$volume}->{nServers}\n";
foreach my $srv (@{$vldblist->{$volume}->{server}}) {
examples/v2/vos/listvolume view on Meta::CPAN
$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 {
my $vollist = shift;
foreach my $key (sort keys %{$vollist}) {
printf("%20s %s\n", $key, $vollist->{$key});
examples/v2/vos/zap view on Meta::CPAN
#!/usr/local/bin/perl
use v5.10.0;
use blib;
use strict;
use warnings;
use AFS::VOS;
use Scalar::Util qw(looks_like_number);
my ($vos, $server, $part, $volume, $force, $backup, $volid);
die "Usage: $0 server partition volume [force [backup]]\n" if $#ARGV < 2;
$server = shift;
$part = shift;
$volume = shift;
$force = shift // 0;
$backup = shift // 0;
if (defined $force and !looks_like_number($force)) { warn "$0: FORCE is not an INTEGER ...\n"; }
else { $force = int($force); }
if (defined $backup and !looks_like_number($backup)) { warn "$0: BACKUP is not an INTEGER ...\n"; }
else { $backup = int($backup); }
$vos = AFS::VOS->new;
$AFS::CODE and print "AFS::CODE = $AFS::CODE\n" and die;
$volid = $vos->zap($server, $part, $volume, $force, $backup);
if ($AFS::CODE) { print "AFS::CODE = $AFS::CODE\n"; }
else { printf "Volume %u deleted\n", $volid; }
pod/v2/afsperlvldb.pod view on Meta::CPAN
actually released. If a read-only copy already exists at the site, it
is not affected. However, if this read-only site was the last site
housing any version of the volume, then the entire VLDB entry is
removed, even if a copy of the read-only version still actually exists
at the site.It calls the AFS system library function I<UV_RemoveSite>.
=item B<$ok = $vldb-E<gt>syncserv(SERVER [, PARTITION]);>
Verifies that each volume mentioned in a VLDB entry actually exists at
the site indicated in the entry. It checks all VLDB entries that
mention a read/write, read-only, or backup site either on any
partition on the file server machine specified by the SERVER argument,
or on the one partition specified by the SERVER and PARTITION
arguments.
It calls the AFS system library function I<UV_SyncServer>.
=item B<$ok = $vldb-E<gt>syncvldb(SERVER [, PARTITION]);>
Verifies that the status of the volumes housed either on all
partitions on the file server machine specified by the SERVER
argument, or on the single partition specified by the SERVER and
pod/v2/afsperlvos.pod view on Meta::CPAN
=head1 NAME
B<AFS::VOS> - Class to communicate with the B<AFS Volume Server>
=head1 SYNOPSIS
use AFS::VOS;
my $vos = AFS::VOS->new(1, 120, 1);
my $ok = $vos->backup('volume');
$vos->DESTROY;
$vos = AFS::VOS->new;
$ok = $vos->dump('volume', 0, 'dump.vol', '', '', 1, 1);
$ok = $vos->dump('volume', 0, 'dump.vol');
$ok = $vos->restore('serv1', '/vicepa', 'volume', 'dump.vol', 0, 1);
my $volid = $vos->create('serv1', '/vicepa', 'volume');
$volid = $vos->move('volume', 'serv1', 'vicepa', 'serv2', 'vicepb');
pod/v2/afsperlvos.pod view on Meta::CPAN
$ok = $vos->release('volume');
my $stat = $vos->status('serv1', '/vicepa');
print "Status is: $stat\n";
$ok = $vos->rename('oldvol', 'newvol');
$ok = $vos->setquota('volume', 6500, 1);
$volid = $vos->zap('serv1', '/vicepa', 'volume');
my ($tBack, $tFail) = $vos->backupsys('home', 'serv', '/vicepc');
($tBack, $tFail) = $vos->backupsys(['home', 'data'], 'serv', '/vicepc');
my @parts = $vos->listpart('serv1');
my $vols = $vos->listvol('serv1', '/vicepa');
my $partinfo = $vos->partinfo('volume');
=head1 DESCRIPTION
This class is used to communicate with the B<AFS Volume Server>, which
pod/v2/afsperlvos.pod view on Meta::CPAN
=item B<$vos-E<gt>DESTROY;>
Destroys the ubik connection to the Volume Server and frees the
ubik_client structure.
=item B<INSTANCE METHODS>
=item S< >
=item B<$ok = $vos-E<gt>backup(VOLUME);>
Clones the indicated read/write volume to create a backup version,
placing it at the same site as the read/write version. VOLUME
specifies either the complete name or volume ID number of the
read/write source volume.
It calls the AFS system library function I<UV_BackupVolume>.
=item B<($SUCCESS, $FAILED) = $vos-E<gt>backupsys([PREFIX [, SERVER [, PARTITION [, EXCLUDE [, XPREFIX [, DRYRUN]]]]]]);>
=item B<($SUCCESS, $FAILED) = $vos-E<gt>backupsys([\@PREFIX [, SERVER [, PARTITION [, EXCLUDE [, \@XPREFIX [, DRYRUN]]]]]]);>
Clones each indicated read/write volume to create a backup version,
placing each clone at the same site as its read/write source version.
To clone a various numbers of volumes, combine the arguments as indicated:
* For every volume listed in the VLDB, omit all of the arguments.
* To clone only volumes that reside on one file server machine,
specify the SERVER argument,
* To clone only volumes that reside on one partition, combine the
SERVER and the PARTITION arguments. The PARTITION argument can
pod/v2/afsperlvos.pod view on Meta::CPAN
A volume whose name includes the string is placed on the set of
volumes to be cloned.
* In XPREFIX a character string or regular expression is specified.
A volume whose name includes the string is removed from the set of
volumes to be cloned.
If EXCLUDE (default 0) is set to 1 it reverses the meaning of the
PREFIX or XPREFIX argument. It returns two array references
containing a list of SUCCESSfully backed up site name and a list of
site name which are FAILED to backup. If DRYRUN (default 0) is set to
1 then SUCCESS contains a list of the volumes to be cloned, without
actually cloning them.
It calls the AFS system library function I<UV_BackupVolume>.
=item B<$volid = $vos-E<gt>create(SERVER, PARTITION, VOLUME [, MAXQUOTA [, VOLID, ROVOLID]]);>
Creates a read/write VOLUME at the site specified by the SERVER and
PARTITION arguments. The volume's space quota is set to 5000 kilobyte
blocks by default. Use the MAXQUOTA argument to specify a different
pod/v2/afsperlvos.pod view on Meta::CPAN
These two arguments (VOLID, ROVOLID) are supported when the AFS Perl
modules are linked with the OpenAFS system libraries v1.4.12 or later.
It returns the volume id number of the new volume. It calls the AFS
system library function I<UV_CreateVolume2> or I<UV_CreateVolume3>
(OpenAFS v.1.4.12 or later).
=item B<$ok = $vos-E<gt>dump(VOLUME [, TIME [, FILE [, SERVER, PARTITION, CLONE_FLG, OMIT_FLG]]]);>
Converts the contents of the indicated volume, which can be
read/write, read-only or backup, into ASCII format. VOLUME specifies
either the complete name or volume ID number of the volume. The
Volume Server writes the converted contents to the FILE or to the
standard output stream (default). To dump the complete contents of a
volume (create a full dump), set TIME to 0 (default). To create an
incremental dump, which includes only the files and directories in the
volume that have modification timestamps later than a certain time,
specify a date and time as the value for the TIME argument. By
default, the VL server consults the Volume Location Database (VLDB) to
learn the volume's location. To dump the read-only volume from a
particular site, use the SERVER and PARTITION arguments to specify the
pod/v2/afsperlvos.pod view on Meta::CPAN
with the PARTITION argument.
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);>
Returns information about the volume header of the indicated volume.
pod/v2/afsperlvos.pod view on Meta::CPAN
It calls the AFS system library function I<UV_VolserStatus>.
=item B<$volid = $vos-E<gt>zap(SERVER, PARTITION, ID [, FORCE [, BACKUP]]);>
Removes the specified volume ID number of the volume from the site
defined by the SERVER and PARTITION arguments, without attempting to
change the corresponding Volume Location Database (VLDB) entry. Set
FORCE (default 0) to 1 to remove the volume even though it cannot be
attached (brought online). Use this flag only after the failure of
previous attempts to remove the volume. Set BACKUP (default 0) to 1 to
remove the backup version of the read/write volume. It returns the
volume id number of the removed volume.
It calls the AFS system library function I<UV_VolumeZap>.
=back
=head1 AUTHORS
The code and documentation for this class were contributed by Stanford
Linear Accelerator Center, a department of Stanford University. This
documentation were written by
static int VolNameOK(name)
char *name;
{
int total;
total = strlen(name);
if (!strcmp(&name[total - 9], ".readonly")) {
return 0;
}
else if (!strcmp(&name[total - 7], ".backup")) {
return 0;
}
else {
return 1;
}
}
static int IsNumeric(name)
char *name;
{
*totalOK += 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)
safe_hv_store(vol, "accessDate", 10, newSViv(pntr->accessDate), 0);
#endif
if (!pntr->updateDate)
safe_hv_store(vol, "updateDate", 10, newSVpv("Never", 5), 0);
else
safe_hv_store(vol, "updateDate", 10, newSViv(pntr->updateDate), 0);
safe_hv_store(vol, "dayUse", 6, newSViv(pntr->dayUse), 0);
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);
if (a_xInfoP->accessDate)
safe_hv_store(stats, "accessDate", 10, newSViv(a_xInfoP->accessDate), 0);
#endif
if (!a_xInfoP->updateDate) {
safe_hv_store(stats, "updateDate", 10, newSVpv("Never", 5), 0);
}
else {
safe_hv_store(stats, "updateDate", 10, newSViv(a_xInfoP->updateDate), 0);
}
static int VolumeInfoCmd(stats, name)
HV *stats;
char *name;
{
struct nvldbentry entry;
afs_int32 vcode;
/* printf("DEBUG-1-VolumeInfoCmd %s \n", name); */
/* The vlserver will handle names with the .readonly
* and .backup extension as well as volume ids.
*/
vcode = VLDB_GetEntryByName(name, &entry);
/* printf("DEBUG-2-VolumeInfoCmd %d \n", vcode); */
if (vcode)
return (vcode);
/* printf("DEBUG-3-VolumeInfoCmd \n"); */
MapHostToNetwork(&entry);
/* printf("DEBUG-4-VolumeInfoCmd \n"); */
myEnumerateEntry(stats, &entry);
int voltype;
int *previdx;
{
int i, istart, vtype;
*server = -1;
*part = -1;
/* Doesn't check for non-existance of backup volume */
if ((voltype == RWVOL) || (voltype == BACKVOL)) {
vtype = ITSRWVOL;
istart = 0; /* seach the entire entry */
}
else {
vtype = ITSROVOL;
/* Seach from beginning of entry or pick up where we left off */
istart = ((*previdx < 0) ? 0 : *previdx + 1);
}
if (!ISNAMEVALID(name)) {
char buffer[256];
sprintf(buffer,
"AFS::VOS: the name of the root volume %s exceeds the size limit of %d\n",
name, VOLSER_OLDMAXVOLNAME - 10);
VSETCODE(E2BIG, buffer);
goto done;
}
if (!VolNameOK(name)) {
char buffer[256];
sprintf(buffer, "Illegal volume name %s, should not end in .readonly or .backup\n",
name);
VSETCODE(EINVAL, buffer);
goto done;
}
if (IsNumeric(name)) {
char buffer[256];
sprintf(buffer, "Illegal volume name %s, should not be a number\n", name);
VSETCODE(EINVAL, buffer);
goto done;
}
SETCODE(0);
RETVAL = (int32)volid;
done:
;
}
OUTPUT:
RETVAL
int32
vos_backup(cstruct, name)
AFS::VOS cstruct
char *name
PREINIT:
int32 avolid, aserver, apart, vtype, code, err;
int32 buvolid, buserver, bupart, butype;
struct nvldbentry entry;
struct nvldbentry buentry;
CODE:
{
RETVAL = 0;
}
/* verify this is a readwrite volume */
if (vtype != RWVOL) {
char buffer[256];
sprintf(buffer, "%s not RW volume\n", name);
VSETCODE(-1, buffer);
goto done;
}
/* is there a backup volume already? */
if (entry.flags & BACK_EXISTS) {
/* yep, where is it? */
buvolid = entry.volumeId[BACKVOL];
code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
if (code) {
SETCODE(code);
goto done;
}
if (err) {
char buffer[256];
sprintf(buffer,
"Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
buserver);
VSETCODE(err, buffer);
goto done;
}
if (!code) {
char buffer[256];
sprintf(buffer, "FATAL ERROR: backup volume %u exists on server %u\n",
buvolid, buserver);
VSETCODE(-1, buffer);
goto done;
}
}
/* nope, carry on */
code = UV_BackupVolume(aserver, apart, avolid);
if (code) {
PrintDiagnostics("backup", code);
SETCODE(0);
goto done;
}
#fprintf(STDOUT, "Created backup volume for %s \n", name);
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
if (code1 && code2) {
char buffer[256];
sprintf(buffer, "AFS::VOS: Could not find entry for volume %s or %s\n", oldname,
newname);
VSETCODE(-1, buffer);
goto done;
}
if (!VolNameOK(oldname)) {
char buffer[256];
sprintf(buffer, "Illegal volume name %s, should not end in .readonly or .backup\n",
oldname);
VSETCODE(-1, buffer);
goto done;
}
if (!ISNAMEVALID(newname)) {
char buffer[256];
sprintf(buffer, "AFS::VOS: the new volume name %s exceeds the size limit of %d\n",
newname, VOLSER_OLDMAXVOLNAME - 10);
VSETCODE(-1, buffer);
goto done;
}
if (!VolNameOK(newname)) {
char buffer[256];
sprintf(buffer, "Illegal volume name %s, should not end in .readonly or .backup\n",
newname);
VSETCODE(-1, buffer);
goto done;
}
if (IsNumeric(newname)) {
char buffer[256];
sprintf(buffer, "Illegal volume name %s, should not be a number\n", newname);
VSETCODE(-1, buffer);
goto done;
}
if (!ISNAMEVALID(avolname)) {
char buffer[256];
sprintf(buffer, "AFS::VOS: the name of the volume %s exceeds the size limit\n",
avolname);
VSETCODE(-1, buffer);
RETVAL = 0;
goto done;
}
if (!VolNameOK(avolname)) {
char buffer[256];
sprintf(buffer, "Illegal volume name %s, should not end in .readonly or .backup\n",
avolname);
VSETCODE(-1, buffer);
RETVAL = 0;
goto done;
}
if (file && strlen(file) != 0) {
strcpy(afilename, file);
if (!FileExists(afilename)) {
char buffer[256];
sprintf(buffer, "Can't access file %s\n", afilename);
SETCODE(0);
RETVAL = volid;
done:
;
}
OUTPUT:
RETVAL
int32
vos_zap(cstruct, servername, parti, id, force=Nullsv, backup=Nullsv)
AFS::VOS cstruct
char *servername
char *parti
char *id
SV * force
SV * backup
PREINIT:
struct nvldbentry entry;
int32 volid, code, server, part, iforce=0, zapbackupid=0, backupid=0, err;
CODE:
{
if (!force)
force = newSViv(0);
if (!backup)
backup = newSViv(0);
if ((!SvIOKp(force))) {
char buffer[256];
sprintf(buffer, "Flag \"force\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
RETVAL = 0;
goto done;
}
else
iforce = 1; /* -force */
if ((!SvIOKp(backup))) {
char buffer[256];
sprintf(buffer, "Flag \"backup\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
RETVAL = 0;
goto done;
}
else
zapbackupid = 1; /* -backup */
RETVAL = 0;
volid = vsu_GetVolumeID(id, cstruct, &err);
if (volid == 0) {
char buffer[256];
if (err)
set_errbuff(buffer, err);
else
sprintf(buffer, "AFS::VOS: can't find volume '%s'\n", id);
VSETCODE(err ? err : -1, buffer);
set_errbuff(buffer, code);
else
sprintf(buffer, "AFS::VOS: partition %s does not exist on the server\n",
servername);
VSETCODE(code ? code : -1, buffer);
goto done;
}
code = VLDB_GetEntryByID(volid, -1, &entry);
if (!code) {
if (volid == entry.volumeId[RWVOL])
backupid = entry.volumeId[BACKVOL];
#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);
goto done;
}
fprintf(STDOUT, "Backup Volume %u deleted\n", backupid);
}
}
code = UV_VolumeZap(server, part, volid);
if (code) {
PrintDiagnostics("zap", code);
SETCODE(code);
goto done;
}
#fprintf(STDOUT, "Volume %u deleted\n", volid);
SETCODE(0);
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
void
vos__backupsys(cstruct, seenprefix=Nullsv, servername=NULL, partition=NULL, exclude=Nullsv, seenxprefix=Nullsv, noaction=Nullsv)
AFS::VOS cstruct
SV * seenprefix
char *servername
char *partition
SV * exclude
SV * seenxprefix
SV * noaction
PREINIT:
int32 apart=0, avolid;
int32 aserver=0, code, aserver1, apart1;
int previdx=-1, error, same;
char *ccode, *itp;
int match = 0;
STRLEN prfxlength=0;
SV *regex;
AV *av;
AV *av1 = (AV*)sv_2mortal((SV*)newAV());
AV *av2 = (AV*)sv_2mortal((SV*)newAV());
PPCODE:
{
/* printf("vos-backupsys DEBUG-1 server %s part %s exclude %d noaction %d \n", servername, partition, (int)SvIV(exclude), (int)SvIV(noaction)); */
if (!exclude)
exclude = newSViv(0);
if (!noaction)
noaction = newSViv(0);
if ((!SvIOKp(exclude))) {
char buffer[256];
sprintf(buffer, "Flag \"exclude\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
XSRETURN_UNDEF;
}
else
iexclude = SvIV(exclude); /* -exclude */
/* printf("vos-backupsys DEBUG-2: iexclude = %d \n", iexclude); */
if ((!SvIOKp(noaction))) {
char buffer[256];
sprintf(buffer, "Flag \"noaction\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
XSRETURN_UNDEF;
}
else
inoaction = SvIV(noaction); /* -noaction */
Zero(&attributes, 1, VldbListByAttributes);
attributes.Mask = 0;
/* printf("vos-backupsys DEBUG-3\n"); */
if (servername && (strlen(servername) != 0)) { /* -server */
/* printf("vos-backupsys DEBUG-4\n"); */
aserver = GetServer(servername);
if (aserver == 0) {
char buffer[256];
sprintf(buffer, "AFS::VOS: server '%s' not found in host table\n", servername);
VSETCODE(-1, buffer);
XSRETURN_UNDEF;
}
attributes.server = ntohl(aserver);
attributes.Mask |= VLLIST_SERVER;
}
else {
servername = NULL;
}
/* printf("vos-backupsys DEBUG-5\n"); */
if (partition && (strlen(partition) != 0)) { /* -partition */
/* printf("vos-backupsys DEBUG-6\n"); */
apart = volutil_GetPartitionID(partition);
if (apart < 0) {
char buffer[256];
sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", partition);
VSETCODE(-1, buffer);
XSRETURN_UNDEF;
}
attributes.partition = apart;
attributes.Mask |= VLLIST_PARTITION;
}
else {
partition = NULL;
}
/* printf("vos-backupsys DEBUG-7\n"); */
/* Check to make sure the prefix and xprefix expressions compile ok */
if (seenprefix && (prfxlength = sv_len(seenprefix)) == 0)
seenprefix = NULL;
/* printf("vos-backupsys DEBUG-7-1 PrfxLen %d\n", prfxlength); */
if (seenprefix && (! (SvTYPE(SvRV(seenprefix)) == SVt_PVAV))) {
VSETCODE(-1, "AFS::VOS: PREFIX not an array reference");
XSRETURN_UNDEF;
}
if (seenprefix) {
av = (AV *) SvRV(seenprefix);
len = av_len(av);
/* printf("vos-backupsys DEBUG-7-2 Len %d\n", len); */
if (len != -1) {
for (j = 0; j <= len; j++) {
regex = *av_fetch(av, j, 0);
itp = SvPV_nolen(regex);
if (strncmp(itp, "^", 1) == 0) {
ccode = (char *) re_comp(itp);
if (ccode) {
char buffer[256];
sprintf(buffer,
"Unrecognizable PREFIX regular expression: '%s': %s\n", itp,
ccode);
VSETCODE(ccode, buffer);
XSRETURN_UNDEF;
}
}
} /*for loop */
/* printf("vos-backupsys DEBUG-8 RE %s \n", itp); */
}
}
/* printf("vos-backupsys DEBUG-9\n"); */
if (seenxprefix && (prfxlength = sv_len(seenxprefix)) == 0)
seenxprefix = NULL;
/* printf("vos-backupsys DEBUG-10\n"); */
if (seenxprefix && (! (SvTYPE(SvRV(seenxprefix)) == SVt_PVAV))) {
VSETCODE(-1, "AFS::VOS: XPREFIX not an array reference");
XSRETURN_UNDEF;
}
if (seenxprefix) {
/* printf("vos-backupsys DEBUG-11\n"); */
av = (AV *) SvRV(seenxprefix);
len = av_len(av);
if (len != -1) {
for (j = 0; j <= len; j++) {
regex = *av_fetch(av, j, 0);
itp = SvPV_nolen(regex);
if (strncmp(itp, "^", 1) == 0) {
ccode = (char *) re_comp(itp);
if (ccode) {
char buffer[256];
"Unrecognizable XPREFIX regular expression: '%s': %s\n", itp,
ccode);
VSETCODE(ccode, buffer);
XSRETURN_UNDEF;
}
}
} /*for */
}
}
/* printf("vos-backupsys DEBUG-12\n"); */
Zero(&arrayEntries, 1, nbulkentries); /* initialize to hint the stub to alloc space */
vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
if (vcode) {
VSETCODE(vcode, "Could not access the VLDB for attributes");
XSRETURN_UNDEF;
}
/* a bunch of output generation code deleted. A.W. */
/* printf("vos-backupsys DEBUG-13\n"); */
for (j = 0; j < nentries; j++) { /* process each vldb entry */
vllist = &arrayEntries.nbulkentries_val[j];
/* printf("vos-backupsys DEBUG-13-1 Name %s\n", vllist->name); */
if (seenprefix) {
av = (AV *) SvRV(seenprefix);
len = av_len(av);
/* printf("vos-backupsys DEBUG-14 Len %d\n", len); */
for (i = 0; i <= len; i++) {
regex = *av_fetch(av, i, 0);
itp = SvPV_nolen(regex);
/* printf("vos-backupsys DEBUG-14-1 RE %s \n", itp); */
if (strncmp(itp, "^", 1) == 0) {
ccode = (char *) re_comp(itp);
if (ccode) {
char buffer[256];
sprintf(buffer, "Error in PREFIX regular expression: '%s': %s\n",
itp, ccode);
VSETCODE(ccode, buffer);
XSRETURN_UNDEF;
}
match = (re_exec(vllist->name) == 1);
}
else {
match = (strncmp(vllist->name, itp, strlen(itp)) == 0);
}
if (match)
break;
}
}
else {
match = 1;
/* printf("vos-backupsys DEBUG-15 MATCH %d\n", match); */
}
/* Without the -exclude flag: If it matches the prefix, then
* check if we want to exclude any from xprefix.
* With the -exclude flag: If it matches the prefix, then
* check if we want to add any from xprefix.
*/
if (match && seenxprefix) {
av = (AV *) SvRV(seenxprefix);
len = av_len(av);
}
else {
if (strncmp(vllist->name, itp, strlen(itp)) == 0) {
match = 0;
break;
}
}
}
}
/* printf("vos-backupsys DEBUG-16-1: exclude %d match %d\n", iexclude, match); */
if (iexclude)
match = !match; /* -exclude will reverse the match */
if (!match)
continue; /* Skip if no match */
/* printf("vos-backupsys DEBUG-16-2: noaction %d match %d\n", inoaction, match); */
/* Print list of volumes to backup */
if (inoaction) {
av_push(av1, newSVpv(vllist->name, strlen(vllist->name)));
continue;
}
/* printf("vos-backupsys DEBUG-17\n"); */
if (!(vllist->flags & RW_EXISTS)) {
if (verbose) {
fprintf(STDOUT, "Omitting to backup %s since RW volume does not exist \n",
vllist->name);
fprintf(STDOUT, "\n");
}
fflush(STDOUT);
continue;
}
/* printf("vos-backupsys DEBUG-18\n"); */
avolid = vllist->volumeId[RWVOL];
MapHostToNetwork(vllist);
GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
if (aserver1 == -1 || apart1 == -1) {
av_push(av2, newSVpv(vllist->name, strlen(vllist->name)));
fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n", vllist->name);
totalFail++;
continue;
}
/* printf("vos-backupsys DEBUG-19\n"); */
if (aserver) {
same = VLDB_IsSameAddrs(aserver, aserver1, &error);
if (error) {
av_push(av2, newSVpv(vllist->name, strlen(vllist->name)));
fprintf(stderr,
"Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
aserver, error);
totalFail++;
continue;
}
}
/* printf("vos-backupsys DEBUG-20\n"); */
if ((aserver && !same) || (apart && (apart != apart1))) {
if (verbose) {
fprintf(STDOUT,
"Omitting to backup %s since the RW is in a different location\n",
vllist->name);
}
continue;
}
if (verbose) {
time_t now = time(0);
fprintf(STDOUT, "Creating backup volume for %s on %s", vllist->name, ctime(&now));
fflush(STDOUT);
}
/* printf("vos-backupsys DEBUG-21\n"); */
code = UV_BackupVolume(aserver1, apart1, avolid);
if (code) {
av_push(av2, newSVpv(vllist->name, strlen(vllist->name)));
fprintf(STDOUT, "Could not backup %s\n", vllist->name);
totalFail++;
}
else {
av_push(av1, newSVpv(vllist->name, strlen(vllist->name)));
totalBack++;
}
} /* process each vldb entry */
/* printf("vos-backupsys DEBUG-22: Succ %d Fail %d\n", totalBack, totalFail); */
if (arrayEntries.nbulkentries_val)
free(arrayEntries.nbulkentries_val);
SETCODE(0);
XPUSHs(sv_2mortal(newRV_inc((SV *) (av1))));
XPUSHs(sv_2mortal(newRV_inc((SV *) (av2))));
XSRETURN(2);
}
void
}
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");
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)
src/VOS/VOS.pm view on Meta::CPAN
my $clear = shift || 0;
if (defined $quota and !looks_like_number($quota)) { warn "VOS::setquota: QUOTA is not an INTEGER ...\n"; return 0; }
else { $quota = int($quota); }
if (defined $clear and !looks_like_number($clear)) { warn "VOS::setquota: CLEAR is not an INTEGER ...\n"; return 0; }
else { $clear = int($clear); }
$self->_setfields($volume, $quota, $clear);
}
sub backupsys {
my $self = shift;
my ($prefix, $server, $partition, $exclude, $xprefix, $dryrun) = @_;
my (@Prefix, @XPrefix, $pcount);
if (!defined $dryrun) { $dryrun = 0; }
if (!defined $xprefix) { @XPrefix = (); }
elsif (! ref($xprefix)) { @XPrefix = split(/ /, $xprefix); }
else { @XPrefix = @{$xprefix}; }
if (!defined $exclude) { $exclude = 0; }
if (!defined $partition) { $partition = ''; }
if (!defined $server) { $server = ''; }
if (!defined $prefix) { @Prefix = (''); }
elsif (! ref($prefix)) { @Prefix = split(/ /, $prefix); }
else { @Prefix = @{$prefix}; }
if (!($pcount = @Prefix)) {@Prefix = (''); }
return($self->_backupsys(\@Prefix, $server, $partition, $exclude, \@XPrefix, $dryrun))
}
1;
src/VOS/t/VOS.t view on Meta::CPAN
$vollist = $vos->listvol($server, $part, 'a', 1);
like($AFS::CODE, qr/Flag "fast" should be numeric/, 'vos->listvol(server part no_fast extended)');
$vollist = $vos->listvol($server, $part, 1, 1);
like($AFS::CODE, qr/FAST and EXTENDED flags are mutually exclusive/, 'vos->listvol(server part fast extended)');
$vollist = $vos->listvol($server, 'no_part', 1, 0);
like($AFS::CODE, qr/could not interpret partition name/, 'vos->listvol(server no_part fast extended)');
$vollist = $vos->listvol($server, $part);
isa_ok($vollist->{$part}->{'root.afs'}, 'HASH', 'vos->listvol(server partition)');
$vos->zap($server, $part, 'root.afs', 0, 'a');
like($AFS::CODE, qr/Flag "backup" should be numeric/, 'vos->zap(server part volume force no_backup)');
$vos->zap($server, $part, 'root.afs', 'a', 0);
like($AFS::CODE, qr/Flag "force" should be numeric/, 'vos->zap(server part volume no_force backup)');
$vos->zap($server, $part, 'no_volume', 0, 0);
like($AFS::CODE, qr/VLDB: no such entry/, 'vos->zap(server part no_volume 0 0)');
$vos->zap($server, 'no_part', 'root.afs', 0, 0);
like($AFS::CODE, qr/could not interpret partition name/, 'vos->zap(server no_part volume 0 0)');
$vos->zap('no_server', $part, 'root.afs', 0, 0);
like($AFS::CODE, qr/not found in host table/, 'vos->zap(no_server part volume 0 0)');
$vos->offline($server, $part, 'root.afs', 0, 'a');
like($AFS::CODE, qr/Flag "sleep" should be numeric/, 'vos->offline(server part volume busy no_sleep)');
$vos->offline($server, $part, 'root.afs', 'a', 0);
src/VOS/t/VOS.t view on Meta::CPAN
like($AFS::CODE, qr/not found in host table/, 'vos->partinfo(no_server)');
$vos->partinfo($server, 'no_part');
like($AFS::CODE, qr/could not interpret partition name/, 'vos->partinfo(no_part)');
isa_ok($vos->partinfo($server), 'HASH', 'vos->partinfo(server)');
$vos->status('no_server');
like($AFS::CODE, qr/not found in host table/, 'vos->status(no_server)');
my $status = $vos->status($server);
like($status, qr/transactions/, 'vos->status(server)');
$vos->backupsys('prefix', $server, $part, 0, 'xprefix', 'noaction');
like($AFS::CODE, qr/Flag "noaction" should be numeric/, 'vos->backupsys(prefix server part exclude xprefix no_dryrun)');
$vos->backupsys('prefix', $server, $part, 'no_exclude', 'xprefix', 1);
like($AFS::CODE, qr/Flag "exclude" should be numeric/, 'vos->backupsys(prefix server part no_exclude xprefix dryrun)');
$vos->backupsys('prefix', 'no_server');
like($AFS::CODE, qr/not found in host table/, 'vos->backupsys(no_server)');
$vos->backupsys('prefix', $server, 'no_part');
like($AFS::CODE, qr/could not interpret partition name/, 'vos->backupsys(no_part)');
$vos->listvolume('no_volume');
like($AFS::CODE, qr/no such entry/, 'vos->listvolume(no_volume)');
$vos->DESTROY;
ok(! defined $vos, 'vos->DESTROY');
can_ok('AFS::VOS', qw(backup));
can_ok('AFS::VOS', qw(create));
can_ok('AFS::VOS', qw(dump));
can_ok('AFS::VOS', qw(move));
can_ok('AFS::VOS', qw(offline));
can_ok('AFS::VOS', qw(online));
can_ok('AFS::VOS', qw(release));
can_ok('AFS::VOS', qw(remove));
can_ok('AFS::VOS', qw(rename));
can_ok('AFS::VOS', qw(restore));
can_ok('AFS::VOS', qw(setquota));