AFS
view release on metacpan or search on metacpan
sprintf(buffer, "Volume is already on line\n");
break;
case VDISKFULL:
sprintf(buffer, "Partition is full\n");
break;
case VOVERQUOTA:
sprintf(buffer, "Volume max quota exceeded\n");
break;
case VBUSY:
sprintf(buffer, "Volume temporarily unavailable\n");
break;
case VMOVED:
sprintf(buffer, "Volume has moved to another server\n");
break;
case VL_IDEXIST:
sprintf(buffer, "VLDB: volume Id exists in the vldb\n");
break;
case VL_IO:
sprintf(buffer, "VLDB: a read terminated too early\n");
break;
case VL_NAMEEXIST:
sprintf(buffer, "VLDB: volume entry exists in the vldb\n");
break;
case VL_CREATEFAIL:
sprintf(buffer, "VLDB: internal creation failure\n");
break;
case VL_NOENT:
sprintf(buffer, "VLDB: no such entry\n");
break;
case VL_EMPTY:
sprintf(buffer, "VLDB: vldb database is empty\n");
break;
case VL_ENTDELETED:
sprintf(buffer, "VLDB: entry is deleted (soft delete)\n");
break;
case VL_BADNAME:
sprintf(buffer, "VLDB: volume name is illegal\n");
break;
case VL_BADINDEX:
sprintf(buffer, "VLDB: index was out of range\n");
break;
case VL_BADVOLTYPE:
sprintf(buffer, "VLDB: bad volume type\n");
break;
case VL_BADSERVER:
sprintf(buffer, "VLDB: illegal server number (not within limits)\n");
break;
case VL_BADPARTITION:
sprintf(buffer, "VLDB: bad partition number\n");
break;
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;
case VL_BADVOLIDBUMP:
sprintf(buffer, "VLDB: illegal max volid increment\n");
break;
case VL_IDALREADYHASHED:
sprintf(buffer, "VLDB: (RO/BACK) Id already hashed\n");
break;
case VL_ENTRYLOCKED:
sprintf(buffer, "VLDB: vldb entry is already locked\n");
break;
case VL_BADVOLOPER:
sprintf(buffer, "VLDB: bad volume operation code\n");
break;
case VL_BADRELLOCKTYPE:
sprintf(buffer, "VLDB: bad release lock type\n");
break;
case VL_RERELEASE:
sprintf(buffer, "VLDB: status report: last release was aborted\n");
break;
case VL_BADSERVERFLAG:
sprintf(buffer, "VLDB: invalid replication site server flag\n");
break;
case VL_PERM:
sprintf(buffer, "VLDB: no permission access for call\n");
break;
case VOLSERREAD_DUMPERROR:
sprintf(buffer, "VOLSER: Problems encountered in reading the dump file !\n");
break;
case VOLSERDUMPERROR:
sprintf(buffer, "VOLSER: Problems encountered in doing the dump !\n");
break;
case VOLSERATTACH_ERROR:
sprintf(buffer, "VOLSER: Could not attach the volume\n");
break;
case VOLSERDETACH_ERROR:
sprintf(buffer, "VOLSER: Could not detach the volume\n");
break;
case VOLSERILLEGAL_PARTITION:
sprintf(buffer, "VOLSER: encountered illegal partition number\n");
break;
case VOLSERBAD_ACCESS:
sprintf(buffer, "VOLSER: permission denied, not a super user\n");
break;
case VOLSERVLDB_ERROR:
sprintf(buffer, "VOLSER: error detected in the VLDB\n");
break;
case VOLSERBADNAME:
sprintf(buffer, "VOLSER: error in volume name\n");
break;
case VOLSERVOLMOVED:
sprintf(buffer, "VOLSER: volume has moved\n");
int convertflags;
{
int32 code;
char name[PR_MAXNAMELEN];
char buff[128];
int i;
safe_hv_store(stats, "id", 2, newSViv(entry->id), 0);
safe_hv_store(stats, "name", 4, newSVpv(entry->name, strlen(entry->name)), 0);
if (convertflags) {
safe_hv_store(stats, "flags", 5, newSVpv(parse_flags_ptsaccess(entry->flags), 5), 0);
}
else {
safe_hv_store(stats, "flags", 5, newSViv(entry->flags), 0);
}
if (lookupids) {
code = internal_pr_name(server, entry->owner, name);
if (code)
safe_hv_store(stats, "owner", 5, newSViv(entry->owner), 0);
else
safe_hv_store(stats, "owner", 5, newSVpv(name, strlen(name)), 0);
code = internal_pr_name(server, entry->creator, name);
if (code)
safe_hv_store(stats, "creator", 7, newSViv(entry->creator), 0);
else
safe_hv_store(stats, "creator", 7, newSVpv(name, strlen(name)), 0);
for (i = 0; i < 10; i++) {
sprintf(buff, "entries%d", i);
code = internal_pr_name(server, entry->entries[i], name);
if (code)
safe_hv_store(stats, buff, strlen(buff), newSViv(entry->entries[i]), 0);
else
safe_hv_store(stats, buff, strlen(buff), newSVpv(name, strlen(name)), 0);
}
}
else {
safe_hv_store(stats, "owner", 5, newSViv(entry->owner), 0);
safe_hv_store(stats, "creator", 7, newSViv(entry->creator), 0);
for (i = 0; i < 10; i++) {
sprintf(buff, "entries%d", i);
safe_hv_store(stats, buff, strlen(buff), newSViv(entry->entries[i]), 0);
}
}
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;
}
static int32 check_name_for_id(name, id)
char *name;
int32 id;
{
char buff[32];
sprintf(buff, "%d", id);
return strcmp(buff, name) == 0;
}
/* end of helper functions for PTS class: */
/* helper functions for VOS && VLDB class: */
/* copy taken from <src/util/regex.c> OpenAFS-1.4.14.1 */
/*
* constants for re's
*/
#define CBRA 1
#define CCHR 2
#define CDOT 4
#define CCL 6
#define NCCL 8
#define CDOL 10
#define CEOF 11
#define CKET 12
#define CBACK 18
#define CSTAR 01
#define ESIZE 512
#define NBRA 9
static char expbuf[ESIZE], *braslist[NBRA], *braelist[NBRA];
static char circf;
/* forward defs
*/
static int advance(register char *lp, register char *ep);
static int backref(register int i, register char *lp);
static int cclass(register char *set, register char c, int af);
/*
* compile the regular expression argument into a dfa
*/
char *
re_comp(register char *sp)
{
register int c;
register char *ep = expbuf;
static int FileExists(filename)
char *filename;
{
usd_handle_t ufd;
int code;
afs_hyper_t size;
code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
if (code) {
return 0;
}
code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
USD_CLOSE(ufd);
if (code) {
return 0;
}
return 1;
}
static void myDisplayFormat(vol, pntr, server, part, totalOK, totalNotOK, totalBusy, fast)
HV *vol;
volintInfo *pntr;
afs_int32 server, part;
int *totalOK, *totalNotOK, *totalBusy;
int fast;
{
char pname[10];
char hostname[256];
if (fast) {
safe_hv_store(vol, "volid", 5, newSViv(pntr->volid), 0);
}
else {
safe_hv_store(vol, "status", 6, newSViv(pntr->status), 0);
safe_hv_store(vol, "volid", 5, newSViv(pntr->volid), 0);
if (pntr->status == VOK) {
safe_hv_store(vol, "name", 4, newSVpv(pntr->name, strlen((char *) pntr->name)), 0);
if (pntr->type == 0)
safe_hv_store(vol, "type", 4, newSVpv("RW", 2), 0);
if (pntr->type == 1)
safe_hv_store(vol, "type", 4, newSVpv("RO", 2), 0);
if (pntr->type == 2)
safe_hv_store(vol, "type", 4, newSVpv("BK", 2), 0);
safe_hv_store(vol, "size", 4, newSViv(pntr->size), 0);
if (pntr->inUse == 1) {
safe_hv_store(vol, "inUse", 5, newSVpv("On-line", 7), 0);
*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);
}
else if (pntr->status == VBUSY) {
*totalBusy += 1;
qPut(&busyHead, pntr->volid);
}
else {
*totalNotOK += 1;
qPut(¬okHead, pntr->volid);
}
}
}
static void myXDisplayFormat(stats, a_xInfoP, a_servID, a_partID, a_totalOKP,
a_totalNotOKP, a_totalBusyP)
HV *stats;
volintXInfo *a_xInfoP;
afs_int32 a_servID;
afs_int32 a_partID;
int *a_totalOKP;
int *a_totalNotOKP;
int *a_totalBusyP;
{ /*XDisplayFormat */
char hostname[256];
char pname[10];
HV *stat1 = (HV *) sv_2mortal((SV *) newHV());
HV *stat2 = (HV *) sv_2mortal((SV *) newHV());
HV *stat3 = (HV *) sv_2mortal((SV *) newHV());
HV *stat4 = (HV *) sv_2mortal((SV *) newHV());
HV *stat5 = (HV *) sv_2mortal((SV *) newHV());
HV *stat6 = (HV *) sv_2mortal((SV *) newHV());
HV *stat7 = (HV *) sv_2mortal((SV *) newHV());
HV *stat8 = (HV *) sv_2mortal((SV *) newHV());
/* Fully-detailed listing. */
safe_hv_store(stats, "status", 6, newSViv(a_xInfoP->status), 0);
safe_hv_store(stats, "volid", 5, newSViv(a_xInfoP->volid), 0);
if (a_xInfoP->status == VOK) {
/* Volume's status is OK - all the fields are valid. */
if (a_xInfoP->type == 0)
safe_hv_store(stats, "type", 4, newSVpv("RW", 2), 0);
if (a_xInfoP->type == 1)
safe_hv_store(stats, "type", 4, newSVpv("RO", 2), 0);
if (a_xInfoP->type == 2)
safe_hv_store(stats, "type", 4, newSVpv("BK", 2), 0);
safe_hv_store(stats, "size", 4, newSViv(a_xInfoP->size), 0);
safe_hv_store(stats, "filecount", 9, newSViv(a_xInfoP->filecount), 0);
if (a_xInfoP->inUse == 1) {
safe_hv_store(stats, "inUse", 5, newSVpv("On-line", 7), 0);
(*a_totalOKP)++;
}
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);
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);
}
safe_hv_store(stats, "dayUse", 6, newSViv(a_xInfoP->dayUse), 0);
safe_hv_store(stat1, "samenet", 7,
newSViv(a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]), 0);
safe_hv_store(stat1, "samenetauth", 11,
newSViv(a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]), 0);
safe_hv_store(stat1, "diffnet", 7,
newSViv(a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]), 0);
safe_hv_store(stat1, "diffnetauth", 11,
newSViv(a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]), 0);
safe_hv_store(stats, "Reads", 5, newRV_inc((SV *) (stat1)), 0);
safe_hv_store(stat2, "samenet", 7,
newSViv(a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]), 0);
safe_hv_store(stat2, "samenetauth", 11,
newSViv(a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]), 0);
safe_hv_store(stat2, "diffnet", 7,
newSViv(a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]), 0);
safe_hv_store(stat2, "diffnetauth", 11,
newSViv(a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]), 0);
safe_hv_store(stats, "Writes", 6, newRV_inc((SV *) (stat2)), 0);
safe_hv_store(stat3, "fileSameAuthor", 12,
newSViv(a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0]), 0);
safe_hv_store(stat3, "fileDiffAuthor", 12,
newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0]), 0);
safe_hv_store(stat3, "dirSameAuthor", 11,
newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0]), 0);
safe_hv_store(stat3, "dirDiffAuthor", 11,
newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]), 0);
safe_hv_store(stats, "0-60sec", 7, newRV_inc((SV *) (stat3)), 0);
safe_hv_store(stat4, "fileSameAuthor", 12,
newSViv(a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1]), 0);
safe_hv_store(stat4, "fileDiffAuthor", 12,
newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1]), 0);
safe_hv_store(stat4, "dirSameAuthor", 11,
newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1]), 0);
safe_hv_store(stat4, "dirDiffAuthor", 11,
newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]), 0);
safe_hv_store(stats, "1-10min", 7, newRV_inc((SV *) (stat4)), 0);
CODE:
{
#ifdef VIOC_SETRXKCRYPT
struct ViceIoctl vi;
int32 code, flag;
if (strcmp(as, "on") == 0)
flag = 1;
else if (strcmp(as, "off") == 0)
flag = 0;
else {
warn("setcrypt: %s must be \"on\" or \"off\".\n", as);
SETCODE(EINVAL);
XSRETURN_UNDEF;
}
vi.in = (char *) &flag;
vi.in_size = sizeof(flag);
vi.out_size = 0;
code = pioctl(0, VIOC_SETRXKCRYPT, &vi, 1);
SETCODE(code);
RETVAL = (code == 0);
#else
not_here("AFS::CM::setcrypt");
#endif
}
OUTPUT:
RETVAL
void
fs_whichcell(dir,follow=1)
char * dir
int32 follow
CODE:
{
struct ViceIoctl vi;
int32 code;
char space[MAXSIZE];
vi.in_size = 0;
vi.out_size = MAXSIZE;
vi.out = (caddr_t) space;
code = pioctl(dir, VIOC_FILE_CELL_NAME, &vi, follow);
SETCODE(code);
ST(0) = sv_newmortal();
if (code == 0) {
sv_setpv(ST(0), space);
}
}
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);
ST(0) = sv_newmortal();
if (code == 0) {
sv_setpv(ST(0), space);
}
}
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);
}
OUTPUT:
RETVAL
int32
fs_flushvolume(path,follow=1)
char * path
int32 follow
CODE:
{
struct ViceIoctl vi;
int32 code;
char space[MAXSIZE];
vi.in_size = 0;
vi.out_size = MAXSIZE;
vi.out = (caddr_t) space;
code = pioctl(path, VIOC_FLUSHVOLUME, &vi, follow);
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
fs_flush(path,follow=1)
char * path
int32 follow
CODE:
{
struct ViceIoctl vi;
int32 code;
char space[MAXSIZE];
vi.in_size = 0;
vi.out_size = MAXSIZE;
vi.out = (caddr_t) space;
code = pioctl(path, VIOCFLUSH, &vi, follow);
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
fs_flushcb(path,follow=1)
char * path
int32 follow
CODE:
struct ViceIoctl vi;
int32 code;
char space[MAXSIZE];
struct VolumeStatus *status;
char *input;
vi.in_size = sizeof(*status) + 3;
vi.in = space;
vi.out_size = MAXSIZE;
vi.out = space;
status = (VolumeStatus *) space;
status->MinQuota = -1;
status->MaxQuota = newquota;
input = (char *) status + sizeof(*status);
*(input++) = '\0'; /* never set name: this call doesn't change vldb */
*(input++) = '\0'; /* offmsg */
*(input++) = '\0'; /* motd */
code = pioctl(path, VIOCSETVOLSTAT, &vi, follow);
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
void
fs_getquota(path,follow=1)
char * path
int32 follow
PPCODE:
{
struct ViceIoctl vi;
int32 code;
char space[MAXSIZE];
struct VolumeStatus *status;
vi.out_size = MAXSIZE;
vi.in_size = 0;
vi.in = 0;
vi.out = space;
code = pioctl(path, VIOCGETVOLSTAT, &vi, follow);
SETCODE(code);
if (code == 0) {
status = (VolumeStatus *)space;
EXTEND(sp, 1);
PUSHs(sv_2mortal(newSViv(status->MaxQuota)));
}
}
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);
}
OUTPUT:
RETVAL
int32
fs_checkvolumes()
CODE:
{
struct ViceIoctl vi;
int32 code;
vi.in_size = 0;
vi.out_size = 0;
code = pioctl(NULL, VIOCCKBACK, &vi, 0);
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
fs_checkconn()
CODE:
{
struct ViceIoctl vi;
int32 code;
int32 status;
vi.in_size = 0;
vi.out_size = sizeof(status);
vi.out = (caddr_t) & status;
code = pioctl(NULL, VIOCCKCONN, &vi, 0);
SETCODE(code);
RETVAL = (status == 0);
}
OUTPUT:
RETVAL
int32
fs_getcacheparms()
PPCODE:
{
struct ViceIoctl vi;
int32 code;
int32 stats[16];
vi.in_size = 0;
vi.in = 0;
vi.out_size = sizeof(stats);
vi.out = (char *) stats;
GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
if (previdx == -1) {
char buffer[256];
sprintf(buffer, "Volume %s does not exist in VLDB\n\n", name);
VSETCODE(ENOENT, buffer);
goto done;
}
Zero(&info, 1, volintInfo);
info.volid = volid;
info.type = RWVOL;
info.creationDate = -1;
info.updateDate = -1;
info.dayUse = -1;
info.maxquota = -1;
info.flags = -1;
info.spare0 = -1;
info.spare1 = -1;
info.spare2 = -1;
info.spare3 = -1;
info.maxquota = SvIV(mquota);
clear = SvIV(clearuse);
if (clear)
info.dayUse = 0;
code = UV_SetVolumeInfo(aserver, apart, volid, &info);
if (code) {
char buffer[256];
sprintf(buffer, "Could not update volume info fields for volume number %u\n", volid);
VSETCODE(code, buffer);
}
else
SETCODE(code);
RETVAL = 1;
done:
;
#else
not_here("AFS::VOS::setfields");
#endif
}
OUTPUT:
RETVAL
int32
vos_restore(cstruct,server,partition,name,file=NULL,id=NULL,inter=Nullsv,overwrite=NULL,offline=Nullsv,readonly=Nullsv)
AFS::VOS cstruct
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))) {
char buffer[256];
sprintf(buffer, "Flag \"inter\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
RETVAL = 0;
goto done;
}
else
aoverwrite = AFS_ASK;
if ((!SvIOKp(offline))) {
char buffer[256];
sprintf(buffer, "Flag \"offline\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
RETVAL = 0;
goto done;
}
else
ioffline = SvIV(offline);
if ((!SvIOKp(readonly))) {
char buffer[256];
sprintf(buffer, "Flag \"readonly\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
RETVAL = 0;
goto done;
}
else
ireadonly = SvIV(readonly);
if (id && strlen(id) != 0) {
avolid = vsu_GetVolumeID(id, cstruct, &err);
if (avolid == 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);
RETVAL = 0;
goto done;
}
}
else
avolid = 0;
if (overwrite && strlen(overwrite) != 0) {
if ((strcmp(overwrite, "a") == 0) || (strcmp(overwrite, "abort") == 0)) {
aoverwrite = AFS_ABORT;
}
else if ((strcmp(overwrite, "f") == 0) || (strcmp(overwrite, "full") == 0)) {
aoverwrite = AFS_FULL;
}
VSETCODE(code ? code : -1, buffer);
RETVAL = 0;
goto done;
}
strcpy(avolname, name);
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);
VSETCODE(-1, buffer);
RETVAL = 0;
goto done;
}
}
else {
strcpy(afilename, "");
}
/* Check if volume exists or not */
vsu_ExtractName(volname, avolname);
vcode = VLDB_GetEntryByName(volname, &entry);
if (vcode) { /* no volume - do a full restore */
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
SV * clone
SV * omit
PREINIT:
afs_int32 avolid, aserver, apart, voltype, fromdate=0, code=0, err, i;
char filename[NameLen];
struct nvldbentry entry;
afs_int32 omitdirs = 0;
CODE:
{
if (!clone)
clone = newSViv(0);
if (!omit)
omit = newSViv(0);
if ((!SvIOKp(omit))) {
char buffer[256];
sprintf(buffer, "Flag \"omit\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
RETVAL = 0;
goto done;
}
else
omitdirs = SvIV(omit); /* -omit */
/* printf("vos_dump DEBUG-1 clone = %d omit = %d omitdirs = %d \n", clone, omit, omitdirs); */
RETVAL = 0;
rx_SetRxDeadTime(60 * 10);
for (i = 0; i < MAXSERVERS; i++) {
struct rx_connection *rxConn = ubik_GetRPCConn((struct ubik_client *) cstruct, i);
if (rxConn == 0)
break;
rx_SetConnDeadTime(rxConn, rx_connDeadTime);
if (rxConn->service)
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);
goto done;
}
part = volutil_GetPartitionID(parti);
if (part < 0) {
char buffer[256];
sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", parti);
VSETCODE(-1, buffer);
goto done;
}
server = GetServer(servername);
if (!server) {
char buffer[256];
sprintf(buffer, "AFS::VOS: host '%s' not found in host table\n", servername);
VSETCODE(-1, buffer);
goto done;
}
if (iforce) { /* -force */
code = UV_NukeVolume(server, part, volid);
if (code) {
PrintDiagnostics("zap", code);
SETCODE(code);
goto done;
}
SETCODE(0);
RETVAL = volid;
goto done;
}
if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
char buffer[256];
if (code)
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);
RETVAL = volid;
done:
;
}
OUTPUT:
RETVAL
int32
vos_offline(cstruct, servername, parti, id, busy=Nullsv, sleep=Nullsv)
AFS::VOS cstruct
char* servername
char* parti
char *id
SV * busy
SV * sleep
PREINIT:
int32 server, partition, volid;
int32 code, err=0;
int32 ibusy=0, isleep=0, transflag, transdone;
CODE:
{
if (!busy)
busy = newSViv(0);
if (!sleep)
sleep = newSViv(0);
if ((!SvIOKp(busy))) {
char buffer[256];
sprintf(buffer, "Flag \"busy\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
RETVAL = 0;
goto done;
}
else
ibusy = SvIV(busy); /* -busy */
if ((!SvIOKp(sleep))) {
char buffer[256];
( run in 0.263 second using v1.01-cache-2.11-cpan-496ff517765 )