AFS
view release on metacpan or search on metacpan
sprintf(buffer,
"VOLSER: no such volume - location specified incorrectly or volume does not exist\n");
break;
case VOLSERMULTIRWVOL:
sprintf(buffer,
"VOLSER: multiple RW volumes with same ID, one of which should be deleted\n");
break;
case VOLSERFAILEDOP:
sprintf(buffer, "VOLSER: not all entries were successfully processed\n");
break;
default:
sprintf(buffer, "Unknown ERROR code\n");
break;
}
return 0;
}
#ifdef AFS_PTHREAD_ENV
void IOMGR_Sleep (seconds)
int seconds;
{
double i,j;
croak("DEBUG: IOMGR_Sleep not available ...\nPlease inform the author...");
j = 0.0;
i = 1.0/j;
}
void clock_UpdateTime ()
{
double i,j;
croak("DEBUG: clock_UpdateTime not available ...\nPlease inform the author.. .");
j = 0.0;
i = 1.0/j;
}
int clock_haveCurrentTime ()
{
double i,j;
croak("DEBUG: clock_haveCurrentTime not available...\nPlease inform the auth or...");
j = 0.0;
i = 1.0/j;
return 1;
}
#endif /* AFS_PTHREAD_ENV*/
static int32 not_here(s)
char *s;
{
croak("%s not implemented on this architecture or under this AFS version", s);
return -1;
}
int PrintDiagnostics(astring, acode)
char *astring;
afs_int32 acode;
{
if (acode == EACCES) {
fprintf(STDERR, "You are not authorized to perform the 'vos %s' command (%d)\n",
astring, acode);
}
else {
fprintf(STDERR, "Error in vos %s command.\n", astring);
PrintError("", acode);
}
return 0;
}
/* end of error handling macros */
/* general helper functions */
static struct afsconf_dir *cdir = NULL;
static char *config_dir = NULL;
static int32 internal_GetConfigDir()
{
if (cdir == NULL) {
if (config_dir == NULL) {
#if defined(AFS_3_4)
config_dir = (char *) safemalloc(strlen(AFSCONF_CLIENTNAME) + 1);
strcpy(config_dir, AFSCONF_CLIENTNAME);
#else
config_dir = (char *) safemalloc(strlen(AFSDIR_CLIENT_ETC_DIRPATH) + 1);
strcpy(config_dir, AFSDIR_CLIENT_ETC_DIRPATH);
#endif
}
cdir = afsconf_Open(config_dir);
if (!cdir) {
char buffer[256];
sprintf(buffer, "GetConfigDir: Can't open configuration directory (%s)", config_dir);
PSETCODE(buffer);
return errno;
}
}
return 0;
}
static int32 internal_GetServerConfigDir()
{
if (cdir == NULL) {
if (config_dir == NULL) {
#if defined(AFS_3_4)
config_dir = (char *) safemalloc(strlen(AFSCONF_SERVERNAME) + 1);
strcpy(config_dir, AFSCONF_SERVERNAME);
#else
config_dir = (char *) safemalloc(strlen(AFSDIR_SERVER_ETC_DIRPATH) + 1);
strcpy(config_dir, AFSDIR_SERVER_ETC_DIRPATH);
#endif
}
cdir = afsconf_Open(config_dir);
if (!cdir) {
char buffer[256];
sprintf(buffer, "GetServerConfigDir: Can't open configuration directory (%s)", config_dir);
PSETCODE(buffer);
return errno;
}
}
return 0;
return 0;
if (istatus.procStartTime) {
/* printf(" Process last started at %s (%d proc starts)\n", */
/* DateOf(istatus.procStartTime), istatus.procStarts); */
safe_hv_store(stats, "procStartTime", 13, newSViv(istatus.procStartTime), 0);
safe_hv_store(stats, "procStarts", 10, newSViv(istatus.procStarts), 0);
}
if (istatus.lastAnyExit) {
/* printf(" Last exit at %s\n", DateOf(istatus.lastAnyExit)); */
safe_hv_store(stats, "lastAnyExit", 11, newSViv(istatus.lastAnyExit), 0);
}
if (istatus.lastErrorExit) {
is1 = is2 = is3 = is4 = (char *) 0;
/* printf(" Last error exit at %s, ", DateOf(istatus.lastErrorExit)); */
safe_hv_store(stats, "lastErrorExit", 13, newSViv(istatus.lastErrorExit), 0);
code = BOZO_GetInstanceStrings(aconn, aname, &is1, &is2, &is3, &is4);
/* don't complain about failing call, since could simply mean
* interface mismatch.
*/
if (code == 0) {
if (*is1 != 0) {
/* non-null instance string */
/* printf("by %s, ", is1); */
safe_hv_store(stats, "by", 2, newSVpv(is1, strlen(is1)), 0);
}
if (is1)
free(is1);
if (is2)
free(is2);
if (is3)
free(is3);
if (is4)
free(is4);
}
if (istatus.errorSignal) {
/* if (istatus.errorSignal == SIGTERM) */
/* printf("due to shutdown request\n"); */
/* else */
/* printf("due to signal %d\n", istatus.errorSignal); */
safe_hv_store(stats, "errorSignal", 11, newSViv(istatus.errorSignal), 0);
}
else {
/* printf("by exiting with code %d\n", istatus.errorCode); */
safe_hv_store(stats, "errorCode", 9, newSViv(istatus.errorCode), 0);
}
}
if (aint32p > 1) {
AV *av = (AV *) sv_2mortal((SV *) newAV());
/* try to display all the parms */
for (i = 0;; i++) {
tp = buffer;
code = BOZO_GetInstanceParm(aconn, aname, i, &tp);
if (code)
break;
/* fprintf(stderr, " Command %d is '%s'\n", i+1, buffer); */
av_push(av, newSVpv(buffer, strlen(buffer)));
}
safe_hv_store(stats, "command", 7, newRV_inc((SV *) (av)), 0);
tp = buffer;
code = BOZO_GetInstanceParm(aconn, aname, 999, &tp);
if (!code) {
/* Any type of failure is treated as not having a notifier program */
/* printf(" Notifier is '%s'\n", buffer); */
safe_hv_store(stats, "notifier", 8, newSVpv(buffer, strlen(buffer)), 0);
}
/* printf("\n"); */
}
return 0;
}
static afs_int32 GetServerGoal(aconn, aname)
char *aname;
struct rx_connection *aconn;
{
char buffer[500];
char *tp;
register afs_int32 code;
struct bozo_status istatus;
tp = buffer;
code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
if (code) {
printf("AFS::BOS: failed to get instance info for '%s' (%s)\n", aname, em(code));
/* if we can't get the answer, assume its running */
return BSTAT_NORMAL;
}
if (istatus.goal == 0)
return BSTAT_SHUTDOWN;
else
return BSTAT_NORMAL;
}
#define PARMBUFFERSSIZE 32
static struct SalvageParms {
afs_int32 Optdebug;
afs_int32 Optnowrite;
afs_int32 Optforce;
afs_int32 Optoktozap;
afs_int32 Optrootfiles;
afs_int32 Optsalvagedirs;
afs_int32 Optblockreads;
afs_int32 OptListResidencies;
afs_int32 OptSalvageRemote;
afs_int32 OptSalvageArchival;
afs_int32 OptIgnoreCheck;
afs_int32 OptForceOnLine;
afs_int32 OptUseRootDirACL;
afs_int32 OptTraceBadLinkCounts;
afs_int32 OptDontAskFS;
afs_int32 OptLogLevel;
afs_int32 OptRxDebug;
afs_uint32 OptResidencies;
} mrafsParm;
static int DoSalvage(aconn, aparm1, aparm2, aoutName, showlog, parallel, atmpDir, orphans)
struct rx_connection *aconn;
struct bozo_status istatus;
struct rx_call *tcall;
char *tp;
FILE *outFile;
int closeIt = 0;
char partName[20]; /* canonical name for partition */
char pbuffer[PARMBUFFERSSIZE];
afs_int32 partNumber;
char *notifier = NONOTIFIER;
/* if a partition was specified, canonicalize the name, since
the salvager has a stupid partition ID parser */
if (aparm1) {
partNumber = volutil_GetPartitionID(aparm1);
if (partNumber < 0) {
char buffer[256];
sprintf(buffer, "AFS::BOS: could not parse partition ID '%s'\n", aparm1);
BSETCODE(EINVAL, buffer);
return EINVAL;
}
tp = (char *) volutil_PartitionName(partNumber);
if (!tp) {
char buffer[256];
sprintf(buffer, "AFS::BOS: internal error parsing partition ID '%s'\n",
aparm1);
BSETCODE(EINVAL, buffer);
return EINVAL;
}
strcpy(partName, tp);
}
else
partName[0] = 0;
/* open the file name */
if (aoutName) {
outFile = fopen(aoutName, "w");
if (!outFile) {
char buffer[256];
sprintf(buffer, "AFS::BOS: can't open specified SalvageLog file '%s'\n",
aoutName);
BSETCODE(ENOENT, buffer);
return ENOENT;
}
closeIt = 1; /* close this file later */
}
else {
outFile = stdout;
closeIt = 0; /* don't close this file later */
}
for (code = 2; code < 6; code++)
parms[code] = "";
if (!aparm2)
aparm2 = "";
/* MUST pass canonical (wire-format) salvager path to bosserver */
strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
if (*aparm2 != 0) {
if ((strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) + 1) >
BOZO_BSSIZE) {
char buffer[256];
sprintf(buffer, "AFS::BOS: command line too big\n");
BSETCODE(E2BIG, buffer);
return (E2BIG);
}
strcat(tbuffer, " ");
strcat(tbuffer, partName);
strcat(tbuffer, " ");
strcat(tbuffer, aparm2);
}
else {
if ((strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE) {
char buffer[256];
sprintf(buffer, "AFS::BOS: command line too big\n");
BSETCODE(E2BIG, buffer);
return (E2BIG);
}
strcat(tbuffer, " -f ");
strcat(tbuffer, partName);
}
/* add the parallel option if given */
if (parallel != (char *) 0) {
if ((strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE) {
char buffer[256];
sprintf(buffer, "AFS::BOS: command line too big\n");
BSETCODE(E2BIG, buffer);
return (E2BIG);
}
strcat(tbuffer, " -parallel ");
strcat(tbuffer, parallel);
}
/* add the tmpdir option if given */
if (atmpDir != (char *) 0) {
if ((strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE) {
char buffer[256];
sprintf(buffer, "AFS::BOS: command line too big\n");
BSETCODE(E2BIG, buffer);
return (E2BIG);
}
strcat(tbuffer, " -tmpdir ");
strcat(tbuffer, atmpDir);
}
/* add the orphans option if given */
if (orphans != (char *) 0) {
if ((strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE) {
char buffer[256];
sprintf(buffer, "AFS::BOS: command line too big\n");
BSETCODE(E2BIG, buffer);
return (E2BIG);
}
strcat(tbuffer, " -orphans ");
strcat(tbuffer, orphans);
}
if (mrafsParm.Optdebug)
strcat(tbuffer, " -debug");
if (mrafsParm.Optnowrite)
strcat(tbuffer, " -nowrite");
if (mrafsParm.Optforce)
strcat(tbuffer, " -force");
if (mrafsParm.Optoktozap)
strcat(tbuffer, " -oktozap");
if (mrafsParm.Optrootfiles)
strcat(tbuffer, " -rootfiles");
if (mrafsParm.Optsalvagedirs)
strcat(tbuffer, " -salvagedirs");
if (mrafsParm.Optblockreads)
strcat(tbuffer, " -blockreads");
if (mrafsParm.OptListResidencies)
strcat(tbuffer, " -ListResidencies");
if (mrafsParm.OptSalvageRemote)
strcat(tbuffer, " -SalvageRemote");
if (mrafsParm.OptSalvageArchival)
strcat(tbuffer, " -SalvageArchival");
if (mrafsParm.OptIgnoreCheck)
strcat(tbuffer, " -IgnoreCheck");
if (mrafsParm.OptForceOnLine)
strcat(tbuffer, " -ForceOnLine");
if (mrafsParm.OptUseRootDirACL)
strcat(tbuffer, " -UseRootDirACL");
if (mrafsParm.OptTraceBadLinkCounts)
strcat(tbuffer, " -TraceBadLinkCounts");
if (mrafsParm.OptDontAskFS)
strcat(tbuffer, " -DontAskFS");
if (mrafsParm.OptLogLevel) {
sprintf(pbuffer, " -LogLevel %d", mrafsParm.OptLogLevel);
strcat(tbuffer, pbuffer);
}
if (mrafsParm.OptRxDebug)
strcat(tbuffer, " -rxdebug");
if (mrafsParm.OptResidencies) {
sprintf(pbuffer, " -Residencies %u", mrafsParm.OptResidencies);
strcat(tbuffer, pbuffer);
}
parms[0] = tbuffer;
parms[1] = "now"; /* when to do it */
code = BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1],
parms[2], parms[3], parms[4], notifier);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to start 'salvager' (%s)\n", em(code));
BSETCODE(code, buffer);
goto done;
}
/* now wait for bnode to disappear */
while (1) {
restoreflags = RV_FULLRST;
if ((aoverwrite == AFS_INC) || (aoverwrite == AFS_ABORT)) {
char buffer[256];
sprintf(buffer, "Volume does not exist; Will perform a full restore\n");
VSETCODE(vcode, buffer);
}
}
else if ((!ireadonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
||(ireadonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
restoreflags = RV_FULLRST;
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 (err) {
char buffer[256];
sprintf(buffer,
"Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
Oserver, err);
VSETCODE(err, buffer);
RETVAL = 0;
goto done;
}
if (!vcode || (Opart != apart))
vol_elsewhere = 1;
if (aoverwrite == AFS_ASK) {
if (strcmp(afilename, "") == 0) { /* The file is from standard in */
char buffer[256];
sprintf(buffer,
"Volume exists and no OVERWRITE argument specified; Aborting restore command\n");
VSETCODE(-1, buffer);
RETVAL = 0;
goto done;
}
/* Ask what to do */
if (vol_elsewhere) {
char buffer[256];
sprintf(buffer,
"The volume %s %u already exists on a different server/part\n",
volname, entry.volumeId[voltype]);
VSETCODE(-1, buffer);
fprintf(stderr, "Do you want to do a full restore or abort? [fa](a): ");
}
else {
char buffer[256];
sprintf(buffer, "The volume %s %u already exists in the VLDB\n",
volname, entry.volumeId[voltype]);
VSETCODE(-1, buffer);
fprintf(stderr,
"Do you want to do a full/incremental restore or abort? [fia](a): ");
}
dc = c = getchar();
while (!(dc == EOF || dc == '\n'))
dc = getchar(); /* goto end of line */
if ((c == 'f') || (c == 'F'))
aoverwrite = AFS_FULL;
else if ((c == 'i') || (c == 'I'))
aoverwrite = AFS_INC;
else
aoverwrite = AFS_ABORT;
}
if (aoverwrite == AFS_ABORT) {
char buffer[256];
sprintf(buffer, "Volume exists; Aborting restore command\n");
VSETCODE(-1, buffer);
RETVAL = 0;
goto done;
}
else if (aoverwrite == AFS_FULL) {
restoreflags = RV_FULLRST;
fprintf(stderr, "Volume exists; Will delete and perform full restore\n");
}
else if (aoverwrite == AFS_INC) {
restoreflags = 0;
if (vol_elsewhere) {
char buffer[256];
sprintf(buffer,
"%s volume %u already exists on a different server/part; not allowed\n",
ireadonly ? "RO" : "RW", avolid);
VSETCODE(-1, buffer);
RETVAL = 0;
goto done;
}
}
}
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;
}
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
vos_dump(cstruct, id, time=NULL, file=NULL, server=NULL, partition=NULL, clone=Nullsv, omit=Nullsv)
AFS::VOS cstruct
char *id
char *time
char *file
char *server
char *partition
}
ST(0) = sv_2mortal(newRV_inc((SV *) status));
SETCODE(0);
XSRETURN(1);
done:
;
}
int32
bos_setauth(self, tp)
AFS::BOS self
char *tp
PREINIT:
int32 code = 0;
int32 flag;
CODE:
{
not_here("AFS::BOS::setauth");
RETVAL = 42;
if (strcmp(tp, "on") == 0)
flag = 0; /* auth req.: noauthflag is false */
else if (strcmp(tp, "off") == 0)
flag = 1;
else {
char buffer[256];
sprintf(buffer,
"AFS::BOS: illegal authentication specifier '%s', must be 'off' or 'on'.\n",
tp);
BSETCODE(-1, buffer);
RETVAL = 0;
}
if (RETVAL == 42) {
code = BOZO_SetNoAuthFlag(self, flag);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS %d (failed to set authentication flag)", code);
BSETCODE(code, buffer);
}
SETCODE(code);
RETVAL = (code == 0);
}
}
OUTPUT:
RETVAL
int32
bos_exec(self, cmd)
AFS::BOS self
char *cmd
PREINIT:
int32 code = 0;
CODE:
{
code = BOZO_Exec(self, cmd);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to execute command (%s)\n", em(code));
BSETCODE(code, buffer);
}
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
bos_addhost(self, object, clone=Nullsv)
AFS::BOS self
SV* object
SV * clone
PREINIT:
int32 code = 0;
int len, i;
AV *av;
SV *sv;
char *host;
int iclone;
STRLEN namelen;
CODE:
{
if (!clone) {
clone = newSViv(0);
}
if (!SvIOKp(clone)) {
char buffer[256];
sprintf(buffer, "AFS::BOS: Flag \"clone\" should be numeric.\n");
BSETCODE(-1, buffer);
XSRETURN_UNDEF;
}
iclone = SvIV(clone);
RETVAL = 0;
if (!SvROK(object)) {
av = newAV();
av_push(av,object);
}
else if (SvTYPE(SvRV(object)) == SVt_PVAV) {
av = (AV *) SvRV(object);
}
else {
BSETCODE(-1, "AFS::BOS: HOST not an array reference\n");
XSRETURN_UNDEF;
}
len = av_len(av);
if (len != -1) {
for (i = 0; i <= len; i++) {
sv = *av_fetch(av, i, 0);
if (sv && !SvROK(sv)) {
host = SvPV(sv, namelen);
if (iclone) {
char name[MAXHOSTCHARS];
if (namelen > MAXHOSTCHARS - 3) {
char buffer[80];
sprintf(buffer, "AFS::BOS: host name too long\n");
BSETCODE(E2BIG, buffer);
( run in 1.191 second using v1.01-cache-2.11-cpan-d8267643d1d )