AFS
view release on metacpan or search on metacpan
ST(0) = sv_newmortal();
if (code == 0) {
sv_setpv(ST(0), space + sizeof(set));
}
}
void
fs_getcrypt()
CODE:
{
#ifdef VIOC_GETRXKCRYPT
struct ViceIoctl vi;
int32 code, flag;
char space[MAXSIZE];
vi.in_size = 0;
vi.out_size = MAXSIZE;
vi.out = (caddr_t) space;
code = pioctl(0, VIOC_GETRXKCRYPT, &vi, 1);
SETCODE(code);
ST(0) = sv_newmortal();
if (code == 0) {
bcopy((char *) space, &flag, sizeof(int32));
sv_setiv(ST(0), flag);
}
#else
not_here("AFS::CM::getcrypt");
#endif
}
int32
fs_setcrypt(as)
char *as
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];
vi.in_size = 0;
vi.out_size = MAXSIZE;
vi.out = (caddr_t) space;
code = pioctl(path, VIOCFLUSHCB, &vi, follow);
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
fs_setquota(path,newquota,follow=1)
char * path
int32 newquota
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;
code = pioctl(NULL, VIOCGETCACHEPARMS, &vi, 0);
SETCODE(code);
if (code == 0) {
EXTEND(sp, 2);
PUSHs(sv_2mortal(newSViv(stats[0])));
PUSHs(sv_2mortal(newSViv(stats[1])));
}
}
int32
fs_setcachesize(size)
int32 size
CODE:
{
struct ViceIoctl vi;
int32 code;
vi.in_size = sizeof(size);;
vi.in = (char *) &size;
vi.out_size = 0;
vi.out = 0;
code = pioctl(NULL, VIOCSETCACHESIZE, &vi, 0);
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
fs_unlog()
CODE:
{
struct ViceIoctl vi;
int32 code;
vi.in_size = 0;
vi.out_size = 0;
code = pioctl(NULL, VIOCUNLOG, &vi, 0);
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
fs_getfid(path,follow=1)
char * path
int32 follow
PPCODE:
{
struct ViceIoctl vi;
int32 code;
struct VenusFid vf;
vi.in_size = 0;
vi.out_size = sizeof(vf);
vi.out = (char *) &vf;
code = pioctl(path, VIOCGETFID, &vi, follow);
SETCODE(code);
if (code == 0) {
EXTEND(sp, 4);
PUSHs(sv_2mortal(newSViv(vf.Cell)));
PUSHs(sv_2mortal(newSViv(vf.Fid.Volume)));
PUSHs(sv_2mortal(newSViv(vf.Fid.Vnode)));
PUSHs(sv_2mortal(newSViv(vf.Fid.Unique)));
}
}
int32
fs_isafs(path,follow=1)
char * path
int32 follow
CODE:
{
int32 code;
RETVAL = isafs(path, follow);
if (!RETVAL)
code = errno;
else
code = 0;
SETCODE(code);
}
OUTPUT:
RETVAL
int32
fs_cm_access(path,perm="read",follow=1)
char * path
char * perm
int32 follow
CODE:
{
struct ViceIoctl vi;
int32 code;
int32 rights;
code = canonical_parse_rights(perm, &rights);
if (code == 0) {
code = vi.in_size = sizeof(rights);
vi.in = (char *) &rights;
vi.out_size = 0;
vi.out = 0;
code = pioctl(path, VIOCACCESS, &vi, follow);
}
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
fs_ascii2rights(perm)
char * perm
CODE:
{
int32 code, rights = -1;
code = canonical_parse_rights(perm, &rights);
SETCODE(code);
if (code != 0)
rights = -1;
RETVAL = rights;
}
OUTPUT:
RETVAL
void
fs_rights2ascii(perm)
int32 perm
CODE:
{
char *p;
p = format_rights(perm);
SETCODE(0);
ST(0) = sv_newmortal();
sv_setpv(ST(0), p);
}
void
fs_crights(perm)
char * perm
CODE:
{
int32 code;
int32 rights;
code = canonical_parse_rights(perm, &rights);
SETCODE(code);
ST(0) = sv_newmortal();
if (code == 0) {
sv_setpv(ST(0), format_rights(rights));
}
}
void
fs_getcellstatus(cell=0)
char * cell
PPCODE:
{
struct ViceIoctl vi;
struct afsconf_cell info;
int32 code, flags;
if (cell && (cell[0] == '\0' || cell[0] == '0'))
cell = NULL;
code = internal_GetCellInfo(cell, 0, &info);
if (code != 0) {
XSRETURN_UNDEF;
}
else {
vi.in_size = strlen(info.name) + 1;
vi.in = info.name;
vi.out_size = sizeof(flags);
vi.out = (char *) &flags;
code = pioctl(0, VIOC_GETCELLSTATUS, &vi, 0);
SETCODE(code);
if (code == 0) {
EXTEND(sp, 1);
PUSHs(sv_2mortal(newSViv((flags & 0x2) == 0)));
XSRETURN(1);
}
}
}
sv = av_fetch(object, 1, 0);
if (sv) {
SV *snh = *sv;
if (SvROK(snh) && (SvTYPE(SvRV(snh)) == SVt_PVHV)) {
nh = (HV *) SvRV(snh);
}
}
plen = nlen = 0;
p = acls;
*p = 0;
code = 0;
if (ph) {
hv_iterinit(ph);
while ((code == 0) && (he = hv_iternext(ph))) {
I32 len;
name = hv_iterkey(he, &len);
perm = SvPV(hv_iterval(ph, he), PL_na);
code = canonical_parse_rights(perm, &rights);
if (code == 0 && rights && !name_is_numeric(name)) {
sprintf(p, "%s\t%d\n", name, rights);
p += strlen(p);
plen++;
}
}
}
if (code == 0 && nh) {
hv_iterinit(nh);
while ((code == 0) && (he = hv_iternext(nh))) {
I32 len;
name = hv_iterkey(he, &len);
perm = SvPV(hv_iterval(nh, he), PL_na);
code = canonical_parse_rights(perm, &rights);
if (code == 0 && rights && !name_is_numeric(name)) {
sprintf(p, "%s\t%d\n", name, rights);
p += strlen(p);
nlen++;
}
}
}
if (code == 0) {
sprintf(space, "%d\n%d\n%s", plen, nlen, acls);
vi.in_size = strlen(space) + 1;
vi.in = space;
vi.out_size = 0;
vi.out = 0;
code = pioctl(dir, VIOCSETAL, &vi, follow);
}
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
MODULE = AFS PACKAGE = AFS::KTC_PRINCIPAL PREFIX = ktcp_
AFS::KTC_PRINCIPAL
ktcp__new(class,name,...)
char * class
char * name
PPCODE:
{
struct ktc_principal *p;
int32 code;
if (items != 2 && items != 4)
croak("Usage: AFS::KTC_PRINCIPAL->new(USER.INST@CELL) or AFS::KTC_PRINCIPAL->new(USER, INST, CELL)");
p = (struct ktc_principal *) safemalloc(sizeof(struct ktc_principal));
p->name[0] = '\0';
p->instance[0] = '\0';
p->cell[0] = '\0';
if (items == 2) {
code = ka_ParseLoginName(name, p->name, p->instance, p->cell);
}
else {
STRLEN nlen, ilen, clen;
char *i = (char *) SvPV(ST(2), ilen);
char *c = (char *) SvPV(ST(3), clen);
nlen = strlen(name);
if (nlen > MAXKTCNAMELEN - 1 || ilen > MAXKTCNAMELEN - 1 || clen > MAXKTCREALMLEN - 1)
code = KABADNAME;
else {
strcpy(p->name, name);
strcpy(p->instance, i);
strcpy(p->cell, c);
code = 0;
}
}
SETCODE(code);
ST(0) = sv_newmortal();
if (code == 0) {
sv_setref_pv(ST(0), "AFS::KTC_PRINCIPAL", (void *) p);
}
else {
safefree(p);
}
XSRETURN(1);
}
void
ktcp_set(p,name,...)
AFS::KTC_PRINCIPAL p
char * name
PPCODE:
{
int32 code;
if (items != 2 && items != 4)
croak("Usage: set($user.$inst@$cell) or set($user,$inst,$cell)");
if (items == 2) {
code = ka_ParseLoginName(name, p->name, p->instance, p->cell);
}
else {
STRLEN nlen, ilen, clen;
char *i = (char *) SvPV(ST(2), ilen);
char *c = (char *) SvPV(ST(3), clen);
nlen = strlen(name);
if (nlen > MAXKTCNAMELEN - 1 || ilen > MAXKTCNAMELEN - 1 || clen > MAXKTCREALMLEN - 1)
code = KABADNAME;
else {
strcpy(p->name, name);
strcpy(p->instance, i);
strcpy(p->cell, c);
code = 0;
}
}
SETCODE(code);
EXTEND(sp, 1);
PUSHs(sv_2mortal(newSViv(code == 0)));
}
int32
ktcp_DESTROY(p)
AFS::KTC_PRINCIPAL p
CODE:
{
safefree(p);
# SETCODE(0); this spoils the ERROR code
RETVAL = 1;
}
OUTPUT:
RETVAL
void
ktcp_name(p,name=0)
AFS::KTC_PRINCIPAL p
char * name
PPCODE:
{
int32 code = 0;
if (name != 0) {
int nlen = strlen(name);
if (nlen > MAXKTCNAMELEN - 1)
code = KABADNAME;
else
strcpy(p->name, name);
SETCODE(code);
}
if (code == 0) {
EXTEND(sp, 1);
PUSHs(sv_2mortal(newSVpv(p->name, strlen(p->name))));
}
}
void
ktcp_instance(p,instance=0)
AFS::KTC_PRINCIPAL p
char * instance
PPCODE:
{
int32 code = 0;
if (instance != 0) {
int ilen = strlen(instance);
if (ilen > MAXKTCNAMELEN - 1)
code = KABADNAME;
else
strcpy(p->instance, instance);
SETCODE(code);
}
if (code == 0) {
EXTEND(sp, 1);
PUSHs(sv_2mortal(newSVpv(p->instance, strlen(p->instance))));
}
}
void
ktcp_cell(p,cell=0)
AFS::KTC_PRINCIPAL p
char * cell
PPCODE:
{
int32 code = 0;
if (cell != 0) {
int clen = strlen(cell);
if (clen > MAXKTCREALMLEN - 1)
code = KABADNAME;
else
strcpy(p->cell, cell);
SETCODE(code);
}
if (code == 0) {
EXTEND(sp, 1);
PUSHs(sv_2mortal(newSVpv(p->cell, strlen(p->cell))));
}
}
void
ktcp_principal(p)
AFS::KTC_PRINCIPAL p
PPCODE:
{
int32 code = 0;
char buffer[MAXKTCNAMELEN + MAXKTCNAMELEN + MAXKTCREALMLEN + 3];
sprintf(buffer, "%s%s%s%s%s", p->name,
p->instance[0] ? "." : "", p->instance, p->cell[0] ? "@" : "", p->cell);
EXTEND(sp, 1);
PUSHs(sv_2mortal(newSVpv(buffer, strlen(buffer))));
SETCODE(code);
}
MODULE = AFS PACKAGE = AFS::KTC_TOKEN PREFIX = ktct_
int32
ktct_DESTROY(t)
AFS::KTC_TOKEN t
CODE:
{
if (t && t != &the_null_token) safefree(t);
# SETCODE(0); this spoils the ERROR code
RETVAL = 1;
}
OUTPUT:
RETVAL
int32
ktct_startTime(t)
AFS::KTC_TOKEN t
PPCODE:
{
EXTEND(sp,1);
PUSHs(sv_2mortal(newSViv(t->startTime)));
}
int32
ktct_endTime(t)
AFS::KTC_TOKEN t
PPCODE:
{
EXTEND(sp,1);
PUSHs(sv_2mortal(newSViv(t->endTime)));
}
int32
ktct_kvno(t)
AFS::KTC_TOKEN t
PPCODE:
{
EXTEND(sp,1);
PUSHs(sv_2mortal(newSViv(t->kvno)));
}
int32
ktct_ticketLen(t)
AFS::KTC_TOKEN t
PPCODE:
{
EXTEND(sp,1);
PUSHs(sv_2mortal(newSViv(t->ticketLen)));
}
void
ktct_ticket(t)
AFS::KTC_TOKEN t
PPCODE:
{
EXTEND(sp,1);
PUSHs(sv_2mortal(newSVpv(t->ticket,t->ticketLen)));
}
void
ktct_sessionKey(t)
AFS::KTC_TOKEN t
PPCODE:
{
struct ktc_encryptionKey *key;
SV *sv;
key = (struct ktc_encryptionKey *) safemalloc(sizeof(*key));
*key = t->sessionKey;
sv = sv_newmortal();
EXTEND(sp, 1);
sv_setref_pv(sv, "AFS::KTC_EKEY", (void *) key);
PUSHs(sv);
}
void
ktct_string(t)
AFS::KTC_TOKEN t
PPCODE:
{
EXTEND(sp,1);
PUSHs(sv_2mortal(newSVpv((char*)t,sizeof(*t))));
}
MODULE = AFS PACKAGE = AFS::KTC_EKEY PREFIX = ktck_
int32
ktck_DESTROY(k)
AFS::KTC_EKEY k
CODE:
{
safefree(k);
# SETCODE(0); this spoils the ERROR code
RETVAL = 1;
}
OUTPUT:
RETVAL
void
ktck_string(k)
AFS::KTC_EKEY k
PPCODE:
{
EXTEND(sp,1);
PUSHs(sv_2mortal(newSVpv((char*)k,sizeof(*k))));
}
MODULE = AFS PACKAGE = AFS::VOS PREFIX = vos_
AFS::VOS
vos_new(class=0, verb=Nullsv, timeout=Nullsv, noauth=Nullsv, localauth=Nullsv, tcell=NULL, crypt=Nullsv)
char * class
SV * verb
SV * timeout
SV * noauth
SV * localauth
char * tcell
SV * crypt
PREINIT:
int32 code;
extern int verbose;
int itimeout, inoauth, ilocalauth, icrypt;
PPCODE:
{
if (!verb) {
verb = newSViv(0);
}
if (!timeout) {
timeout = newSViv(90);
}
if (!noauth) {
noauth = newSViv(0);
}
if (!localauth) {
localauth = newSViv(0);
}
if (!crypt) {
crypt = newSViv(0);
}
if (tcell && (tcell[0] == '\0' || tcell[0] == '0'))
tcell = NULL;
if ((verb) && (!SvIOKp(verb))) {
char buffer[256];
sprintf(buffer, "Flag \"verb\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
XSRETURN_UNDEF;
}
verbose = SvIV(verb);
if ((timeout) && (!SvIOKp(timeout))) {
char buffer[256];
sprintf(buffer, "Flag \"timeout\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
XSRETURN_UNDEF;
itimeout = SvIV(timeout);
if ((noauth) && (!SvIOKp(noauth))) {
char buffer[256];
sprintf(buffer, "Flag \"noauth\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
XSRETURN_UNDEF;
}
inoauth = SvIV(noauth);
if ((localauth) && (!SvIOKp(localauth))) {
char buffer[256];
sprintf(buffer, "Flag \"localauth\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
XSRETURN_UNDEF;
}
ilocalauth = SvIV(localauth);
if ((crypt) && (!SvIOKp(crypt))) {
char buffer[256];
sprintf(buffer, "Flag \"crypt\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
XSRETURN_UNDEF;
}
icrypt = SvIV(crypt);
/* Initialize the ubik_client connection */
rx_SetRxDeadTime(itimeout); /* timeout seconds inactivity before declared dead */
cstruct = (struct ubik_client *) 0;
if (icrypt) /* -crypt specified */
vsu_SetCrypt(1);
code = internal_vsu_ClientInit((inoauth != 0),
AFSDIR_CLIENT_ETC_DIRPATH, tcell, ilocalauth,
&cstruct, UV_SetSecurity);
if (code == 0) {
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "AFS::VOS", (void *) cstruct);
XSRETURN(1);
}
else {
XSRETURN_UNDEF;
}
}
int32
vos__DESTROY(self)
AFS::VOS self
PREINIT:
int32 code;
CODE:
{
code = ubik_ClientDestroy((struct ubik_client *) self);
/* printf("DEBUG-23 %d \n", code); */
SETCODE(code);
/* printf("DEBUG-24 \n"); */
RETVAL = (code == 0);
/* printf("DEBUG-25 \n"); */
}
OUTPUT:
RETVAL
void
vos_status(cstruct, aserver)
AFS::VOS cstruct
char *aserver
PREINIT:
afs_int32 server, code;
transDebugInfo *pntr;
afs_int32 count;
char buffer[256];
CODE:
{
server = GetServer(aserver);
if (!server) {
sprintf(buffer, "AFS::VOS: host '%s' not found in host table\n", aserver);
VSETCODE(-1, buffer);
XSRETURN_UNDEF;
}
code = UV_VolserStatus(server, &pntr, &count);
if (code) {
PrintDiagnostics("status", code);
SETCODE(1);
XSRETURN_UNDEF;
}
ST(0) = sv_newmortal();
SETCODE(0);
if (count == 0) {
sprintf(buffer, "No active transactions on %s\n", aserver);
sv_setpv(ST(0), buffer);
}
else {
sprintf(buffer, "Total transactions: %d\n", count);
sv_setpv(ST(0), buffer);
}
XSRETURN(1);
}
int32
vos_release(cstruct, name, force=Nullsv)
AFS::VOS cstruct
char *name
SV * force
PREINIT:
struct nvldbentry entry;
afs_int32 avolid, aserver, apart, vtype, code, err;
int iforce;
CODE:
{
if (!force) {
force = newSViv(0);
}
if (!SvIOKp(force)) {
char buffer[256];
sprintf(buffer, "Flag \"force\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
XSRETURN_UNDEF;
}
iforce = SvIV(force);
RETVAL = 0;
avolid = vsu_GetVolumeID(name, 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", name);
VSETCODE(err ? err : ENOENT, buffer);
goto done;
}
code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
if (code) {
SETCODE(code);
goto done;
}
if (vtype != RWVOL) {
char buffer[256];
sprintf(buffer, "%s not a RW volume\n", name);
VSETCODE(ENOENT, buffer);
goto done;
}
if (!ISNAMEVALID(entry.name)) {
char buffer[256];
sprintf(buffer, "Volume name %s is too long, rename before releasing\n", entry.name);
VSETCODE(E2BIG, buffer);
goto done;
}
code = UV_ReleaseVolume(avolid, aserver, apart, iforce);
if (code) {
PrintDiagnostics("release", code);
SETCODE(code);
goto done;
}
#fprintf(STDOUT, "Released volume %s successfully\n", name);
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
vos_create(cstruct, server, partition, name, maxquota=Nullsv, vid=Nullsv, rovid=Nullsv)
AFS::VOS cstruct
char *server
char *partition
char *name
SV * maxquota
SV * vid
SV * rovid
PREINIT:
int32 pnum;
int32 code;
struct nvldbentry entry;
int32 vcode;
int32 quota = 5000;
afs_int32 tserver;
#ifdef OpenAFS_1_4_12
afs_uint32 volid = 0, rovolid = 0, bkvolid = 0;
afs_uint32 *arovolid = NULL;
#else
afs_int32 volid = 0;
#endif
CODE:
{
if (!maxquota)
maxquota = newSViv(0);
if (!vid)
vid = newSViv(0);
if (!rovid)
rovid = newSViv(0);
RETVAL = 0;
/* printf("vos-create DEBUG-1 server %s part %s vol %s maxq %d vid %d rovid %d \n", server, partition, name, SvIV(maxquota), SvIV(vid), SvIV(rovid)); */
tserver = GetServer(server);
if (!tserver) {
char buffer[256];
sprintf(buffer, "AFS::VOS: host '%s' not found in host table\n", server);
VSETCODE(ENOENT, buffer);
goto done;
}
pnum = volutil_GetPartitionID(partition);
if (pnum < 0) {
char buffer[256];
sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", partition);
VSETCODE(ENOENT, buffer);
goto done;
}
if (!IsPartValid(pnum, tserver, &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",
partition);
VSETCODE(code ? code : ENOENT, buffer);
goto done;
if (!vcode) {
char buffer[256];
sprintf(buffer, "Volume %s already exists\n", name);
#PrintDiagnostics("create", code);
VSETCODE(EEXIST, buffer);
goto done;
}
/* printf("vos-create DEBUG-2 server %d part %d vol %s maxq %d vid %d rovid %d \n", tserver, pnum, name, SvIV(maxquota), SvIV(vid), SvIV(rovid)); */
if ((maxquota) && (!SvIOKp(maxquota))) {
char buffer[256];
sprintf(buffer, "Initial quota should be numeric.\n");
VSETCODE(EINVAL, buffer);
goto done;
}
quota = SvIV(maxquota);
/* printf("vos-create DEBUG-3 quota %d \n", quota); */
#ifdef OpenAFS_1_4_12
if ((vid) && (!SvIOKp(vid))) {
/* printf("vos-create DEBUG-4 vid %d \n", SvIV(vid)); */
char buffer[256];
sprintf(buffer, "Given volume ID should be numeric.\n");
VSETCODE(EINVAL, buffer);
goto done;
}
/* printf("vos-create DEBUG-5 vid %d \n", SvIV(vid)); */
volid = SvIV(vid);
/* printf("vos-create DEBUG-6 volid %d \n", volid); */
if ((rovid) && (!SvIOKp(rovid))) {
/* printf("vos-create DEBUG-7 rovid %d \n", SvIV(rovid)); */
char buffer[256];
sprintf(buffer, "Given RO volume ID should be numeric.\n");
VSETCODE(EINVAL, buffer);
goto done;
}
/* printf("vos-create DEBUG-8 rovid %d \n", SvIV(rovid)); */
arovolid = &rovolid;
rovolid = SvIV(rovid);
/* printf("vos-create DEBUG-9 rovolid %d \n", rovolid); */
if (rovolid == 0) {
arovolid = NULL;
}
code = UV_CreateVolume3(tserver, pnum, name, quota, 0, 0, 0, 0, &volid, arovolid, &bkvolid);
#else
code = UV_CreateVolume2(tserver, pnum, name, quota, 0, 0, 0, 0, &volid);
#endif
if (code) {
#PrintDiagnostics("create", code);
SETCODE(code);
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;
avolid = vsu_GetVolumeID(name, cstruct, &err);
if (avolid == 0) {
char buffer[256];
if (err)
set_errbuff(buffer, err);
else
sprintf(buffer, "AFS::VOS: can't find volume ID or name '%s'\n", name);
VSETCODE(err ? err : ENOENT, buffer);
goto done;
}
code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
if (code) {
SETCODE(code);
goto done;
}
/* 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;
}
/* is it local? */
code = VLDB_IsSameAddrs(buserver, aserver, &err);
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
vos_remove(cstruct, name, servername=NULL, parti=NULL)
AFS::VOS cstruct
char *name
char *servername
char *parti
PREINIT:
afs_int32 err, code = 0;
afs_int32 server = 0, partition = -1, volid;
afs_int32 idx, j;
CODE:
{
RETVAL = 0;
if (servername && strlen(servername) != 0) {
server = GetServer(servername);
if (!server) {
char buffer[256];
sprintf(buffer, "AFS::VOS: server '%s' not found in host table\n", servername);
VSETCODE(ENOENT, buffer);
goto done;
}
}
if (parti && strlen(parti) != 0) {
partition = volutil_GetPartitionID(parti);
if (partition < 0) {
char buffer[256];
sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", parti);
VSETCODE(EINVAL, buffer);
goto done;
}
/* Check for validity of the partition */
if (!IsPartValid(partition, server, &code)) {
char buffer[256];
if (code)
set_errbuff(buffer, code);
else
sprintf(buffer, "AFS::VOS: partition %s does not exist on the server\n",
parti);
VSETCODE(ENOENT, buffer);
goto done;
}
}
volid = vsu_GetVolumeID(name, cstruct, &err);
if (volid == 0) {
char buffer[256];
sprintf(buffer, "Can't find volume name '%s' in VLDB\n", name);
if (err)
set_errbuff(buffer, err);
VSETCODE(ENOENT, buffer);
goto done;
}
/* If the server or partition option are not complete, try to fill
* them in from the VLDB entry.
*/
if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS)) ||
((volid == entry.volumeId[BACKVOL]) && (entry.flags & BACK_EXISTS))) {
idx = Lp_GetRwIndex(&entry);
if ((idx == -1) ||
(server && (server != entry.serverNumber[idx])) ||
((partition != -1) && (partition != entry.serverPartition[idx]))) {
char buffer[256];
sprintf(buffer, "AFS::VOS: Volume '%s' no match\n", name);
VSETCODE(ENOENT, buffer);
goto done;
}
}
else if ((volid == entry.volumeId[ROVOL]) && (entry.flags & RO_EXISTS)) {
for (idx = -1, j = 0; j < entry.nServers; j++) {
if (entry.serverFlags[j] != ITSROVOL)
continue;
if (((server == 0) || (server == entry.serverNumber[j])) &&
((partition == -1) || (partition == entry.serverPartition[j]))) {
if (idx != -1) {
char buffer[256];
sprintf(buffer, "AFS::VOS: Volume '%s' matches more than one RO\n",
name);
VSETCODE(ENOENT, buffer);
goto done;
}
idx = j;
}
}
if (idx == -1) {
char buffer[256];
sprintf(buffer, "AFS::VOS: Volume '%s' no match\n", name);
VSETCODE(ENOENT, buffer);
goto done;
}
}
else {
char buffer[256];
sprintf(buffer, "AFS::VOS: Volume '%s' no match\n", name);
VSETCODE(ENOENT, buffer);
goto done;
}
server = htonl(entry.serverNumber[idx]);
partition = entry.serverPartition[idx];
}
code = UV_DeleteVolume(server, partition, volid);
if (code) {
PrintDiagnostics("remove", code);
SETCODE(code);
goto done;
}
SETCODE(0);
RETVAL = volid;
done:
;
}
OUTPUT:
RETVAL
int32
vos_rename(cstruct,oldname,newname)
AFS::VOS cstruct
char * oldname
char * newname
PREINIT:
afs_int32 code1, code2, code;
struct nvldbentry entry;
CODE:
{
RETVAL = 0;
code1 = VLDB_GetEntryByName(oldname, &entry);
if (code1) {
char buffer[256];
sprintf(buffer, "AFS::VOS: Could not find entry for volume %s\n", oldname);
VSETCODE(-1, buffer);
goto done;
}
code2 = VLDB_GetEntryByName(newname, &entry);
if ((!code1) && (!code2)) { /*the newname already exists */
char buffer[256];
sprintf(buffer, "AFS::VOS: volume %s already exists\n", newname);
VSETCODE(-1, buffer);
goto done;
}
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;
}
MapHostToNetwork(&entry);
code = UV_RenameVolume(&entry, oldname, newname);
if (code) {
PrintDiagnostics("rename", code);
SETCODE(code);
goto done;
}
#fprintf(STDOUT, "Renamed volume %s to %s\n", oldname, newname);
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
vos__setfields(cstruct, name, mquota=Nullsv, clearuse=Nullsv)
AFS::VOS cstruct
char *name
SV * mquota
SV * clearuse
PREINIT:
#ifdef OpenAFS
struct nvldbentry entry;
volintInfo info;
int32 volid;
int32 clear, code, err;
int32 aserver, apart;
int previdx = -1;
#endif
CODE:
{
#ifdef OpenAFS
if (!mquota)
mquota = newSViv(-1);
if (!clearuse)
clearuse = newSViv(0);
if ((!SvIOKp(mquota))) { /* -max <quota> */
char buffer[256];
sprintf(buffer, "invalid quota value\n");
VSETCODE(EINVAL, buffer);
goto done;
}
if ((!SvIOKp(clearuse))) { /* -clearuse */
char buffer[256];
sprintf(buffer, "flag \"clearuse\" is not an integer\n");
VSETCODE(EINVAL, buffer);
goto done;
}
/* printf("vos-setfields DEBUG-1 name %s mquota %d clearuse %d \n", name, (int)SvIV(mquota), (int)SvIV(clearuse)); */
RETVAL = 0;
volid = vsu_GetVolumeID(name, cstruct, &err); /* -id */
if (volid == 0) {
char buffer[256];
if (err)
set_errbuff(buffer, err);
else
sprintf(buffer, "Unknown volume ID or name '%s'\n", name);
VSETCODE(err ? err : -1, buffer);
goto done;
}
code = VLDB_GetEntryByID(volid, RWVOL, &entry);
if (code) {
char buffer[256];
sprintf(buffer, "Could not fetch the entry for volume number %u from VLDB \n", volid);
VSETCODE(code, buffer);
goto done;
}
MapHostToNetwork(&entry);
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 ((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)
rxConn->service->connDeadTime = rx_connDeadTime;
}
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 : ENOENT, buffer);
goto done;
}
if ((server && (strlen(server) != 0)) || (partition && (strlen(partition) != 0))) {
if (!(server && (strlen(server) != 0)) || !(partition && (strlen(partition) != 0))) {
char buffer[256];
sprintf(buffer, "Must specify both SERVER and PARTITION arguments\n");
VSETCODE(-1, buffer);
if (time && strcmp(time, "0")) {
code = ktime_DateToInt32(time, &fromdate);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::VOS: failed to parse date '%s' (error=%d))\n", time, code);
VSETCODE(code, buffer);
goto done;
}
}
if (file && (strlen(file) != 0)) {
strcpy(filename, file);
}
else {
strcpy(filename, "");
}
#ifdef OpenAFS_1_4_05
int iclone = 0;
retry_dump:
/* printf("vos_dump DEBUG-2 clone = %d omitdirs = %d \n", clone, omitdirs); */
if ((!SvIOKp(clone))) {
char buffer[256];
sprintf(buffer, "Flag \"clone\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
RETVAL = 0;
goto done;
}
else
iclone = SvIV(clone);
if (iclone) {
/* printf("vos_dump DEBUG-2-1 clone = %d omitdirs = %d \n", clone, omitdirs); */
code = UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
DumpFunction, filename, omitdirs);
} else {
/* printf("vos_dump DEBUG-2-2 clone = %d omitdirs = %d \n", clone, omitdirs); */
code = UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
filename, omitdirs);
}
/* printf("vos_dump DEBUG-3 code = %d \n", code); */
if ((code == RXGEN_OPCODE) && (omitdirs)) {
omitdirs = 0;
goto retry_dump;
}
#else
/* printf("vos_dump DEBUG-4 \n"); */
code = UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction, filename);
/* printf("vos_dump DEBUG-5 code = %d \n", code); */
#endif
if (code) {
PrintDiagnostics("dump", code);
SETCODE(code);
goto done;
}
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
void
vos_partinfo(cstruct, server, partname=NULL)
AFS::VOS cstruct
char *server
char *partname
PREINIT:
afs_int32 apart;
afs_int32 aserver, code;
char pname[10];
#ifdef OpenAFS_1_4_64
struct diskPartition64 partition;
#else
struct diskPartition partition;
#endif
struct partList dummyPartList;
int i, cnt;
HV *partlist = (HV*)sv_2mortal((SV*)newHV());
PPCODE:
{
apart = -1;
aserver = GetServer(server);
if (aserver == 0) {
char buffer[256];
sprintf(buffer, "AFS::VOS: server '%s' not found in host table\n", server);
VSETCODE(-1, buffer);
XSRETURN_UNDEF;
}
if (partname && (strlen(partname) != 0)) {
apart = volutil_GetPartitionID(partname);
if (apart < 0) {
char buffer[256];
sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", partname);
VSETCODE(-1, buffer);
XSRETURN_UNDEF;
}
dummyPartList.partId[0] = apart;
dummyPartList.partFlags[0] = PARTVALID;
cnt = 1;
}
if (apart != -1) {
if (!IsPartValid(apart, aserver, &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",
partname);
VSETCODE(code ? code : -1, buffer);
XSRETURN_UNDEF;
}
}
else {
code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
if (code) {
PrintDiagnostics("listpart", code);
SETCODE(code);
XSRETURN_UNDEF;
}
/*
check source partition for space to clone volume
*/
MapPartIdIntoName(topart, toPartName);
MapPartIdIntoName(frompart, fromPartName);
/*
check target partition for space to move volume
*/
#ifdef OpenAFS_1_4_64
code = UV_PartitionInfo64(toserver, toPartName, &partition);
#else
code = UV_PartitionInfo(toserver, toPartName, &partition);
#endif
if (code) {
char buffer[256];
sprintf(buffer, "AFS::VOS: cannot access partition %s\n", toPartName);
VSETCODE(code, buffer);
goto done;
}
p = (volintInfo *) 0;
code = UV_ListOneVolume(fromserver, frompart, volid, &p);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::VOS:cannot access volume %u\n", volid);
free(p);
VSETCODE(code, buffer);
goto done;
}
if (partition.free <= p->size) {
char buffer[256];
sprintf(buffer, "AFS::VOS: no space on target partition %s to move volume %u\n",
toPartName, volid);
VSETCODE(-1, buffer);
if (p)
free(p);
goto done;
}
if (p)
free(p);
/* successful move still not guaranteed but shoot for it */
code = UV_MoveVolume(volid, fromserver, frompart, toserver, topart);
if (code) {
PrintDiagnostics("move", code);
SETCODE(code);
goto done;
}
#SETCODE(1); ???
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);
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);
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];
sprintf(buffer, "Flag \"sleep\" should be numeric.\n");
VSETCODE(EINVAL, buffer);
RETVAL = 0;
goto done;
}
else
isleep = SvIV(sleep); /* -sleep */
RETVAL = 0;
server = GetServer(servername);
if (server == 0) {
char buffer[256];
sprintf(buffer, "AFS::VOS: server '%s' not found in host table\n", servername);
VSETCODE(-1, buffer);
goto done;
}
partition = volutil_GetPartitionID(parti);
if (partition < 0) {
char buffer[256];
sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", parti);
VSETCODE(ENOENT, buffer);
goto done;
}
volid = vsu_GetVolumeID(id, cstruct, &err); /* -id */
if (!volid) {
char buffer[256];
if (err)
set_errbuff(buffer, err);
else
sprintf(buffer, "Unknown volume ID or name '%s'\n", servername);
VSETCODE(err ? err : -1, buffer);
goto done;
}
transflag = (ibusy ? ITBusy : ITOffline);
transdone = (isleep ? 0 /*online */ : VTOutOfService);
if (ibusy && !isleep) {
char buffer[256];
sprintf(buffer, "SLEEP argument must be used with BUSY flag\n");
VSETCODE(-1, buffer);
goto done;
}
code = UV_SetVolume(server, partition, volid, transflag, transdone, isleep);
if (code) {
char buffer[256];
sprintf(buffer, "Failed to set volume. Code = %d\n", code);
VSETCODE(code, buffer);
goto done;
}
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
vos_online(cstruct, servername, parti, id)
AFS::VOS cstruct
char* servername
char* parti
char *id
PREINIT:
int32 server, partition, volid;
int32 code, err=0;
CODE:
{
RETVAL = 0;
server = GetServer(servername);
if (server == 0) {
char buffer[256];
sprintf(buffer, "AFS::VOS: server '%s' not found in host table\n", servername);
VSETCODE(-1, buffer);
goto done;
}
partition = volutil_GetPartitionID(parti);
if (partition < 0) {
char buffer[256];
sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", parti);
VSETCODE(ENOENT, buffer);
goto done;
}
volid = vsu_GetVolumeID(id, cstruct, &err); /* -id */
if (!volid) {
char buffer[256];
if (err)
set_errbuff(buffer, err);
else
sprintf(buffer, "Unknown volume ID or name '%s'\n", servername);
VSETCODE(err ? err : -1, buffer);
goto done;
}
code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ , 0 /*sleep */ );
if (code) {
char buffer[256];
sprintf(buffer, "Failed to set volume. Code = %d\n", code);
VSETCODE(code, buffer);
goto done;
}
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;
int32 vcode, iexclude=0, inoaction=0;
struct VldbListByAttributes attributes;
nbulkentries arrayEntries;
register struct nvldbentry *vllist;
int32 nentries;
int j, i, len, verbose = 1;
afs_int32 totalBack=0;
afs_int32 totalFail=0;
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 */
free(pntr);
} while (voltype == ROVOL);
SETCODE(0);
ST(0) = sv_2mortal(newRV_inc((SV *) volinfo));
XSRETURN(1);
}
MODULE = AFS PACKAGE = AFS::VLDB PREFIX = vldb_
AFS::VLDB
vldb_new(class=0, verb=0, timeout=90, noauth=0, localauth=0, tcell=NULL, crypt=0)
char * class
int verb
int timeout
int noauth
int localauth
char * tcell
int crypt
PREINIT:
int32 code = -1;
extern int verbose;
PPCODE:
{
if (tcell && (tcell[0] == '\0' || tcell[0] == '0'))
tcell = NULL;
/* Initialize the ubik_client connection */
rx_SetRxDeadTime(timeout); /* timeout seconds inactivity before declared dead */
cstruct = (struct ubik_client *) 0;
verbose = verb;
if (crypt) /* -crypt specified */
vsu_SetCrypt(1);
code = internal_vsu_ClientInit((noauth != 0),
AFSDIR_CLIENT_ETC_DIRPATH, tcell, localauth,
&cstruct, UV_SetSecurity);
if (code == 0) {
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "AFS::VLDB", (void *) cstruct);
XSRETURN(1);
}
else
XSRETURN_UNDEF;
}
int32
vldb__DESTROY(self)
AFS::VLDB self
PREINIT:
int32 code = 0;
CODE:
{
code = ubik_ClientDestroy(self);
/* printf("DEBUG-23 %d \n", code); */
SETCODE(code);
/* printf("DEBUG-24 \n"); */
RETVAL = (code == 0);
/* printf("DEBUG-25 \n"); */
}
OUTPUT:
RETVAL
int32
vldb_addsite(cstruct, server, partition, id, roid=NULL, valid=0)
AFS::VLDB cstruct
char *server
char *partition
char *id
char *roid
int valid
PREINIT:
int32 code = 1;
CODE:
{
afs_int32 avolid, aserver, apart, err, arovolid=0;
char avolname[VOLSER_MAXVOLNAME + 1];
if (roid && (roid[0] == '\0' || roid[0] == '0'))
roid = NULL;
RETVAL = 0;
/* printf("vldb_addsite DEBUG-1 server %s part %s Vol/Id %s RO-Vol/ID %s ValID %d \n", server, partition, id, roid, valid); */
#ifdef OpenAFS_1_4
vsu_ExtractName(avolname, id);
#else
strcpy(avolname, id);
#endif
/* printf("vldb_addsite DEBUG-2 id %s avolname %s \n", id, avolname); */
avolid = vsu_GetVolumeID(avolname, cstruct, &err);
/* printf("vldb_addsite DEBUG-3 Vol-Nam %s Vol-ID %d \n", avolname, avolid); */
if (avolid == 0) {
char buffer[256];
if (err)
set_errbuff(buffer, err);
else
sprintf(buffer, "AFS::VLDB: can't find volume '%s'\n", id);
VSETCODE(err ? err : -1, buffer);
goto done;
}
#ifdef OpenAFS_1_4_12
if (roid) {
/* printf("vldb_addsite DEBUG-4 Roid %s AROVolid %d\n", roid, arovolid); */
vsu_ExtractName(avolname, roid);
arovolid = vsu_GetVolumeID(avolname, cstruct, &err);
/* printf("vldb_addsite DEBUG-5 Roid %s AROVolid %d\n", roid, arovolid); */
if (!arovolid) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: invalid ro volume id '%s'\n", roid);
VSETCODE(-1, buffer);
goto done;
}
}
#endif
aserver = GetServer(server);
if (aserver == 0) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: server '%s' not found in host table\n", server);
VSETCODE(-1, buffer);
goto done;
}
apart = volutil_GetPartitionID(partition);
if (apart < 0) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: could not interpret partition name '%s'\n", partition);
VSETCODE(-1, buffer);
goto done;
}
if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
char buffer[256];
if (code)
set_errbuff(buffer, code);
else
sprintf(buffer, "AFS::VLDB: partition %s does not exist on the server\n",
partition);
VSETCODE(code ? code : -1, buffer);
goto done;
}
#if defined(OpenAFS_1_4_12)
code = UV_AddSite2(aserver, apart, avolid, arovolid, valid);
#else
#if defined(OpenAFS_1_4_07)
code = UV_AddSite(aserver, apart, avolid, valid);
#else
code = UV_AddSite(aserver, apart, avolid);
#endif
#endif
if (code) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: addsite didn't work\n");
VSETCODE(code, buffer);
goto done;
}
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
vldb_changeloc(cstruct, id, server, partition)
AFS::VLDB cstruct
char *id
char *server
char *partition
PREINIT:
#ifdef OpenAFS
afs_int32 avolid, aserver, apart, code, err;
#endif
CODE:
{
#ifdef OpenAFS
/* printf("DEBUG-1\n"); */
RETVAL = 0;
avolid = vsu_GetVolumeID(id, cstruct, &err);
if (avolid == 0) {
char buffer[256];
if (err)
set_errbuff(buffer, err);
else
sprintf(buffer, "AFS::VLDB: can't find volume '%s'\n", id);
VSETCODE(err ? err : -1, buffer);
goto done;
}
/* printf("DEBUG-2\n"); */
aserver = GetServer(server);
if (aserver == 0) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: server '%s' not found in host table\n", server);
VSETCODE(-1, buffer);
goto done;
}
/* printf("DEBUG-3\n"); */
apart = volutil_GetPartitionID(partition);
if (apart < 0) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: could not interpret partition name '%s'\n", partition);
VSETCODE(-1, buffer);
/* printf("DEBUG-3.1\n"); */
goto done;
}
/* printf("DEBUG-4\n"); */
if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
char buffer[256];
if (code)
set_errbuff(buffer, code);
else
sprintf(buffer, "AFS::VLDB: partition %s does not exist on the server\n", server);
VSETCODE(code ? code : -1, buffer);
goto done;
}
/* printf("DEBUG-5\n"); */
code = UV_ChangeLocation(aserver, apart, avolid);
if (code) {
VSETCODE(code, "changeloc");
goto done;
}
SETCODE(0);
RETVAL = 1;
done:
;
#else
not_here("AFS::VLDB::changeloc");
#endif
}
OUTPUT:
RETVAL
void
vldb__listvldb(cstruct, name=NULL, servername=NULL, parti=NULL, lock=0)
AFS::VLDB cstruct
char *name
char *servername
char *parti
int lock
PREINIT:
afs_int32 apart;
afs_int32 aserver, code;
afs_int32 vcode;
struct VldbListByAttributes attributes;
nbulkentries arrayEntries;
struct nvldbentry *vllist;
afs_int32 centries, nentries = 0;
int j;
afs_int32 thisindex, nextindex;
HV *status, *stats;
PPCODE:
{
status = (HV *) sv_2mortal((SV *) newHV());
if (name && strlen(name) == 0)
name = NULL;
if (servername && strlen(servername) == 0)
servername = NULL;
if (parti && strlen(parti) == 0)
parti = NULL;
/* printf("DEBUG-0 name %s, server %s, part %s lock %d \n", name, servername, parti, */
aserver = 0;
apart = 0;
attributes.Mask = 0;
/* printf("DEBUG-1 \n"); */
/* If the volume name is given, Use VolumeInfoCmd to look it up
* and not ListAttributes.
*/
if (name) {
/* printf("DEBUG-2 \n"); */
if (lock) {
char buffer[256];
/* printf("DEBUG-3 \n"); */
sprintf(buffer,
"AFS::VLDB: illegal use of '-locked' switch, need to specify server and/or partition\n");
VSETCODE(-1, buffer);
XSRETURN_UNDEF;
}
/* printf("DEBUG-4 \n"); */
stats = (HV *) sv_2mortal((SV *) newHV());
code = VolumeInfoCmd(stats, name);
if (code) {
char buffer[256];
set_errbuff(buffer, code);
VSETCODE(code, buffer);
XSRETURN_UNDEF;
}
/* Only matches the RW volume name */
avolid = vllist->volumeId[RWVOL];
vcode = ubik_Call(VL_DeleteEntry, cstruct, 0, avolid, RWVOL);
if (vcode) {
fprintf(STDOUT, "Could not delete VDLB entry for %s\n", vllist->name);
totalFail++;
PrintError("", vcode);
continue;
}
else {
totalBack++;
}
fflush(STDOUT);
} /*for */
EXTEND(sp, 2);
PUSHs(sv_2mortal(newSViv(totalBack)));
PUSHs(sv_2mortal(newSViv(totalFail)));
if (arrayEntries.nbulkentries_val)
free(arrayEntries.nbulkentries_val);
done:
;
}
int32
vldb_lock(cstruct, id)
AFS::VLDB cstruct
char *id
PREINIT:
afs_int32 avolid, vcode, err;
CODE:
{
RETVAL = 0;
avolid = vsu_GetVolumeID(id, cstruct, &err);
if (avolid == 0) {
char buffer[256];
if (err)
set_errbuff(buffer, err);
else
sprintf(buffer, "AFS::VLDB: can't find volume '%s'\n", id);
VSETCODE(err ? err : -1, buffer);
goto done;
}
vcode = ubik_Call(VL_SetLock, cstruct, 0, avolid, -1, VLOP_DELETE);
if (vcode) {
char buffer[256];
sprintf(buffer, "Could not lock VLDB entry for volume %s\n", id);
VSETCODE(vcode, buffer);
goto done;
}
/* fprintf(STDOUT, "Locked VLDB entry for volume %s\n", id); */
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
vldb_unlock(cstruct, id)
AFS::VLDB cstruct
char *id
PREINIT:
afs_int32 avolid, code, err;
CODE:
{
RETVAL = 0;
avolid = vsu_GetVolumeID(id, cstruct, &err);
if (avolid == 0) {
char buffer[256];
if (err)
set_errbuff(buffer, err);
else
sprintf(buffer, "AFS::VLDB: can't find volume '%s'\n", id);
VSETCODE(err ? err : -1, buffer);
goto done;
}
code = UV_LockRelease(avolid);
if (code) {
VSETCODE(code, "unlock");
goto done;
}
/* fprintf(STDOUT,"Released lock on vldb entry for volume %s\n",id); */
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
vldb_unlockvldb(cstruct, server=NULL, partition=NULL)
AFS::VLDB cstruct
char *server
char *partition
PREINIT:
afs_int32 apart = -1;
afs_int32 aserver = 0,code;
afs_int32 vcode;
struct VldbListByAttributes attributes;
nbulkentries arrayEntries;
register struct nvldbentry *vllist;
afs_int32 nentries;
int j;
afs_int32 volid;
afs_int32 totalE = 0;
CODE:
{
RETVAL = 0;
attributes.Mask = 0;
if (server && (strlen(server) != 0)) { /* server specified */
aserver = GetServer(server);
if (aserver == 0) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: server '%s' not found in host table\n", server);
VSETCODE(-1, buffer);
goto done;
}
attributes.server = ntohl(aserver);
attributes.Mask |= VLLIST_SERVER;
}
if (partition && (strlen(partition) != 0)) { /* partition specified */
apart = volutil_GetPartitionID(partition);
if (apart < 0) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: could not interpret partition name '%s'\n",
partition);
VSETCODE(-1, buffer);
goto done;
}
if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
char buffer[256];
if (code)
set_errbuff(buffer, code);
else
sprintf(buffer, "AFS::VLDB: partition %s does not exist on the server\n",
partition);
VSETCODE(code ? code : -1, buffer);
goto done;
}
attributes.partition = apart;
attributes.Mask |= VLLIST_PARTITION;
}
attributes.flag = VLOP_ALLOPERS;
attributes.Mask |= VLLIST_FLAG;
Zero(&arrayEntries, 1, nbulkentries); /*initialize to hint the stub to alloc space */
vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
if (vcode) {
char buffer[256];
sprintf(buffer, "Could not access the VLDB for attributes\n");
VSETCODE(vcode, buffer);
goto done;
}
for (j = 0; j < nentries; j++) { /* process each entry */
vllist = &arrayEntries.nbulkentries_val[j];
volid = vllist->volumeId[RWVOL];
vcode =
ubik_Call(VL_ReleaseLock, cstruct, 0, volid, -1,
LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
if (vcode) {
char buffer[256];
sprintf(buffer, "Could not unlock entry for volume %s\n", vllist->name);
VSETCODE(vcode, buffer);
totalE++;
}
}
if (totalE)
fprintf(STDOUT, "Could not unlock %u VLDB entries of %u locked entries\n", totalE,
nentries);
if (arrayEntries.nbulkentries_val)
free(arrayEntries.nbulkentries_val);
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
vldb__syncvldb(cstruct, server=NULL, partition=NULL, volname=NULL)
AFS::VLDB cstruct
char *server
char *partition
char *volname
PREINIT:
afs_int32 pname = 0, code; /* part name */
int flags = 0;
afs_int32 tserver = 0;
CODE:
{
RETVAL = 0;
/* printf("server %s, part %s volume %s \n", server, partition, volname); */
if (server && (strlen(server) != 0)) {
tserver = GetServer(server);
if (!tserver) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: host '%s' not found in host table\n", server);
VSETCODE(-1, buffer);
goto done;
}
}
if (partition && (strlen(partition) != 0)) {
pname = volutil_GetPartitionID(partition);
if (pname < 0) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: could not interpret partition name '%s'\n",
partition);
VSETCODE(-1, buffer);
goto done;
}
if (!tserver) {
char buffer[256];
sprintf(buffer, "The PARTITION argument requires a SERVER argument\n");
VSETCODE(-1, buffer);
goto done;
}
if (!IsPartValid(pname, tserver, &code)) { /*check for validity of the partition */
char buffer[256];
if (code)
set_errbuff(buffer, code);
else
sprintf(buffer, "AFS::VLDB: partition %s does not exist on the server\n",
partition);
VSETCODE(code ? code : -1, buffer);
goto done;
}
flags = 1;
}
if (volname && (strlen(volname) != 0)) {
/* Synchronize an individual volume */
code = UV_SyncVolume(tserver, pname, volname, flags);
}
else {
if (!tserver) {
char buffer[256];
sprintf(buffer, "Without a VOLUME argument, the server argument is required\n");
VSETCODE(-1, buffer);
goto done;
}
code = UV_SyncVldb(tserver, pname, flags, 0 /*unused */ );
}
if (code) {
char buffer[256];
set_errbuff(buffer, code);
VSETCODE(code, buffer);
#PrintDiagnostics("syncvldb", code);
#SETCODE(code);
goto done;
}
else
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
vldb__changeaddr(cstruct, oldip, newip, remove=0)
AFS::VLDB cstruct
char *oldip
char *newip
int32 remove
PREINIT:
int32 ip1, ip2, vcode;
CODE:
{
RETVAL = 0;
ip1 = GetServer(oldip);
if (!ip1) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: invalid host address\n");
VSETCODE(EINVAL, buffer);
goto done;
}
if ((newip && (strlen(newip)) && remove) || (!newip && !remove)) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: Must specify either 'NEWADDR <addr>' or 'REMOVE' flag\n");
VSETCODE(EINVAL, buffer);
goto done;
}
if (newip && (strlen(newip)) != 0) {
ip2 = GetServer(newip);
if (!ip2) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: invalid host address\n");
VSETCODE(EINVAL, buffer);
goto done;
}
}
else {
/* Play a trick here. If we are removing an address, ip1 will be -1
* and ip2 will be the original address. This switch prevents an
* older revision vlserver from removing the IP address.
*/
remove = 1;
ip2 = ip1;
ip1 = 0xffffffff;
}
vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
if (vcode) {
char buffer[256];
if (remove) {
char buff[80];
sprintf(buff, "Could not remove server %s from the VLDB", oldip);
if (vcode == VL_NOENT) {
sprintf(buffer, "%s\nvlserver does not support the REMOVE flag or VLDB: no such entry", buff);
}
else {
sprintf(buffer, "%s\n", buff);
}
}
else {
sprintf(buffer, "Could not change server %s to server %s\n", oldip, newip);
}
VSETCODE(vcode, buffer);
goto done;
}
if (remove) {
fprintf(STDOUT, "Removed server %s from the VLDB\n", oldip);
}
else {
fprintf(STDOUT, "Changed server %s to server %s\n", oldip, newip);
}
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
vldb_remsite(cstruct,server,partition,name)
AFS::VLDB cstruct
char *server
char *partition
char *name
PREINIT:
afs_int32 avolid, aserver, apart, code = 1, err;
char avolname[VOLSER_MAXVOLNAME + 1];
CODE:
{
RETVAL = 0;
#ifdef OpenAFS_1_4
vsu_ExtractName(avolname, name);
#else
strcpy(avolname, name);
#endif
avolid = vsu_GetVolumeID(avolname, cstruct, &err);
if (avolid == 0) {
char buffer[256];
if (err)
set_errbuff(buffer, err);
else
sprintf(buffer, "AFS::VLDB: can't find volume '%s'\n", avolname);
VSETCODE(err ? err : -1, buffer);
goto done;
}
aserver = GetServer(server);
if (aserver == 0) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: server '%s' not found in host table\n", server);
VSETCODE(-1, buffer);
goto done;
}
apart = volutil_GetPartitionID(partition);
if (apart < 0) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: could not interpret partition name '%s'\n", partition);
VSETCODE(-1, buffer);
goto done;
}
code = UV_RemoveSite(aserver, apart, avolid);
printf("\n");
if (code) {
PrintDiagnostics("remsite", code);
SETCODE(code);
goto done;
}
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
int32
vldb_syncserv(cstruct, servername, parti=NULL)
AFS::VLDB cstruct
char *servername
char *parti
PREINIT:
afs_int32 pname = 0, code; /* part name */
afs_int32 tserver;
int flags = 0;
CODE:
{
RETVAL = 0;
tserver = GetServer(servername);
if (!tserver) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: host '%s' not found in host table\n", servername);
VSETCODE(-1, buffer);
goto done;
}
if (parti && (strlen(parti) != 0)) {
pname = volutil_GetPartitionID(parti);
if (pname < 0) {
char buffer[256];
sprintf(buffer, "AFS::VLDB: could not interpret partition name '%s'\n", parti);
VSETCODE(-1, buffer);
goto done;
}
if (!IsPartValid(pname, tserver, &code)) { /*check for validity of the partition */
char buffer[256];
if (code)
set_errbuff(buffer, code);
else
sprintf(buffer, "AFS::VLDB: partition %s does not exist on the server\n",
parti);
VSETCODE(code ? code : -1, buffer);
goto done;
}
flags = 1;
}
code = UV_SyncServer(tserver, pname, flags, 0 /*unused */ );
if (code) {
PrintDiagnostics("syncserv", code);
SETCODE(code);
goto done;
}
SETCODE(0);
RETVAL = 1;
done:
;
}
OUTPUT:
RETVAL
MODULE = AFS PACKAGE = AFS::BOS PREFIX = bos_
AFS::BOS
bos_new(class=0, servname, noauth=0, localauth=0, cell=0, aencrypt=1)
char * class
char *servname
int noauth
int localauth
char *cell
int aencrypt
PREINIT:
int32 code = -1;
AFS__BOS server;
PPCODE:
{
/* printf("bos new DEBUG-1 \n"); */
if (cell && (cell[0] == '\0' || cell[0] == '0'))
cell = NULL;
/* printf("bos new call internal_new DEBUG-2 \n"); */
server = internal_bos_new(&code, servname, localauth, noauth, aencrypt, cell);
/* SETCODE(code); */
/* printf("bos new return internal_new DEBUG-3 \n"); */
if (code == 0) {
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "AFS::BOS", (void *) server);
XSRETURN(1);
}
else
XSRETURN_UNDEF;
}
int32
bos__DESTROY(self)
AFS::BOS self
CODE:
{
rx_DestroyConnection(self);
/* printf("bos DEBUG rx_Destroy\n"); */
RETVAL = 1;
}
OUTPUT:
RETVAL
void
bos__status(self, lng=0, object=NULL)
AFS::BOS self
int lng
SV* object
PREINIT:
int i;
afs_int32 code = 0;
char ibuffer[BOZO_BSSIZE];
char *tp;
int int32p;
HV *status, *stats;
PPCODE:
{
int32p = (lng != 0 ? 2 : 0);
status = (HV *) sv_2mortal((SV *) newHV());
if (object && (! (SvTYPE(SvRV(object)) == SVt_PVAV))) {
BSETCODE(-1, "AFS::BOS: SERVER not an array reference\n");
XSRETURN_UNDEF;
goto done;
}
if (object && (SvTYPE(SvRV(object)) == SVt_PVAV)) {
AV *av;
SV *sv;
char *instance;
STRLEN namelen;
int i, len;
int firstTime = 1;
av = (AV *) SvRV(object);
len = av_len(av);
if (len != -1) {
for (i = 0; i <= len; i++) {
sv = *av_fetch(av, i, 0);
if (sv) {
stats = (HV *) sv_2mortal((SV *) newHV());
instance = (char *) safemalloc(BOZO_BSSIZE);
instance = SvPV(sv, namelen);
code = DoStat(stats, instance, self, int32p, firstTime);
if (code) {
XSRETURN_UNDEF;
goto done;
}
safe_hv_store(status, instance, strlen(instance), newRV_inc((SV *) (stats)),
0);
firstTime = 0;
}
}
}
}
else {
for (i = 0;; i++) {
/* for each instance */
tp = ibuffer;
code = BOZO_EnumerateInstance(self, i, &tp);
if (code == BZDOM) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to contact host's bosserver (%s).\n",
em(code));
BSETCODE(code, buffer);
break;
}
stats = (HV *) sv_2mortal((SV *) newHV());
code = DoStat(stats, ibuffer, self, int32p, (i == 0));
if (code) {
XSRETURN_UNDEF;
goto done;
}
safe_hv_store(status, ibuffer, strlen(ibuffer), newRV_inc((SV *) (stats)), 0);
}
}
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);
goto done;
}
name[0] = '[';
strcpy(&name[1], host);
strcat((char *) &name, "]");
code = BOZO_AddCellHost(self, name);
}
else {
code = BOZO_AddCellHost(self, host);
}
if (code) {
char buffer[240];
sprintf(buffer, "AFS::BOS: failed to add host '%s' (%s)\n", host,
em(code));
BSETCODE(code, buffer);
}
}
} /* for loop */
}
SETCODE(code);
RETVAL = (code == 0);
done:
;
}
OUTPUT:
RETVAL
int32
bos_removehost(self, object)
AFS::BOS self
SV* object
PREINIT:
int32 code = 0;
char *host;
int len, i;
AV *av;
SV *sv;
CODE:
{
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_nolen(sv);
code = BOZO_DeleteCellHost(self, host);
if (code) {
char buffer[240];
sprintf(buffer, "AFS::BOS: failed to delete host '%s' (%s)\n", host,
em(code));
BSETCODE(code, buffer);
}
}
} /* for loop */
}
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
bos_prune(self, all=0, bak=0, old=0, core=0)
AFS::BOS self
int all
int bak
int old
int core
PREINIT:
int32 code = 0, flags = 0;
CODE:
{
if (bak)
flags |= BOZO_PRUNEBAK;
if (old)
flags |= BOZO_PRUNEOLD;
if (core)
flags |= BOZO_PRUNECORE;
if (all)
flags |= 0xff;
if (!flags) {
char buffer[256];
sprintf(buffer, "AFS::BOS nothing to prune");
BSETCODE(999, buffer);
RETVAL = 0;
}
else {
code = BOZO_Prune(self, flags);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS has failed to prune server files");
BSETCODE(code, buffer);
}
SETCODE(code);
RETVAL = (code == 0);
}
}
OUTPUT:
RETVAL
int32
bos_adduser(self, object)
AFS::BOS self
SV * object
PREINIT:
int32 code = 0;
char *name;
int len, i;
AV *av;
SV *sv;
CODE:
{
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: USER 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)) {
name = SvPV_nolen(sv);
code = BOZO_AddSUser(self, name);
if (code) {
char buffer[240];
sprintf(buffer, "AFS::BOS: failed to add user '%s' (%s)\n", name,
em(code));
BSETCODE(code, buffer);
}
}
} /* for loop */
}
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
bos_removeuser(self, object)
AFS::BOS self
SV* object
PREINIT:
int32 code = 0;
char *name;
int len, i;
AV *av;
SV *sv;
CODE:
{
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: USER 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)) {
name = SvPV_nolen(sv);
code = BOZO_DeleteSUser(self, name);
if (code) {
char buffer[240];
sprintf(buffer, "AFS::BOS: failed to delete user");
if (code == ENOENT)
sprintf(buffer, "%s (no such user)\n", buffer);
else
sprintf(buffer, "%s (%s)\n", em(code), buffer);
BSETCODE(code, buffer);
}
}
} /* for loop */
}
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
bos_addkey(self, kvno, string=NULL)
AFS::BOS self
int32 kvno
char *string
PREINIT:
int32 code = 0;
struct ktc_encryptionKey tkey;
char *tcell = (char *) 0; /* use current cell */
char buf[BUFSIZ], ver[BUFSIZ];
CODE:
{
not_here("AFS::BOS::addkey");
Zero(&tkey, 1, struct ktc_encryptionKey);
RETVAL = 42;
if (string)
strcpy(buf, string);
else {
/* prompt for key */
code = des_read_pw_string(buf, sizeof(buf), "input key: ", 0);
if (code || strlen(buf) == 0) {
char buffer[256];
sprintf(buffer, "Bad key: \n");
BSETCODE(code ? code : -1, buffer);
RETVAL = 0;
}
code = des_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0);
if (code || strlen(ver) == 0) {
char buffer[256];
sprintf(buffer, "Bad key: \n");
BSETCODE(code ? code : -1, buffer);
RETVAL = 0;
}
if (strcmp(ver, buf) != 0) {
char buffer[256];
sprintf(buffer, "\nInput key mismatch\n");
BSETCODE(-1, buffer);
RETVAL = 0;
}
}
if (RETVAL == 42) {
if (kvno == 999) {
/* bcrypt key */
strcpy((char *) &tkey, buf);
}
else { /* kerberos key */
ka_StringToKey(buf, tcell, &tkey);
}
code = BOZO_AddKey(self, kvno, &tkey);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to set key %d (%s)\n", kvno, em(code));
BSETCODE(code, buffer);
}
SETCODE(code);
RETVAL = (code == 0);
}
if (tcell)
free(tcell);
}
OUTPUT:
RETVAL
int32
bos_removekey(self, object)
AFS::BOS self
SV* object
PREINIT:
int32 code = 0;
int32 temp;
CODE:
{
not_here("AFS::BOS::removekey");
if (SvIOK(object)) {
temp = (int32) SvIV(object);
code = BOZO_DeleteKey(self, temp);
}
else if (SvTYPE(SvRV(object)) == SVt_PVAV) {
/* object is array ref */
int len, i;
AV *av;
SV *sv;
av = (AV *) SvIV(object);
len = av_len(av);
if (len != -1) {
for (i = 0; i <= len; i++) {
sv = *av_fetch(av, i, 0);
if (sv) {
temp = SvIV(sv);
code = BOZO_DeleteKey(self, temp);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to deletekey");
BSETCODE(code, buffer);
}
}
} /* for loop */
}
}
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
bos__create(self, name, type, object, notifier=NULL)
AFS::BOS self
char *name
char *type
SV *object
char *notifier
PREINIT:
int32 i, len, code = 0;
char *parms[6];
AV *av; SV *sv;
STRLEN namelen;
CODE:
{
if (SvTYPE(SvRV(object)) != SVt_PVAV) {
code = -1;
BSETCODE(code, "AFS::BOS COMMAND not an array reference\n");
goto done;
}
for (i = 0; i < 6; i++)
parms[i] = "";
av = (AV *) SvRV(object);
len = av_len(av);
if (len != -1) {
for (i = 0; i <= len && i < 6; i++) {
sv = *av_fetch(av, i, 0);
if (sv)
parms[i] = SvPV(sv, namelen);
}
}
if (notifier == NULL)
notifier = NONOTIFIER;
code = BOZO_CreateBnode(self, type, name, parms[0], parms[1], parms[2],
parms[3], parms[4], notifier);
if (code) {
char buffer[256];
sprintf(buffer,
"AFS::BOS: failed to create new server instance %s of type '%s' (%s)\n", name,
type, em(code));
BSETCODE(code, buffer);
goto done;
}
SETCODE(code);
done:
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
bos__restart(self, bosserver=0, all=0, object=NULL)
AFS::BOS self
int bosserver
int all
SV *object
PREINIT:
int32 code = 0;
CODE:
{
if (bosserver) {
if (object != NULL) {
char buffer[256];
sprintf(buffer,
"AFS::BOS: can't specify both 'bosserver' and specific servers to restart.\n");
BSETCODE(-1, buffer);
RETVAL = 0;
goto done;
}
code = BOZO_ReBozo(self);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to restart bosserver (%s)\n", em(code));
BSETCODE(code, buffer);
}
RETVAL = (code == 0);
goto done;
}
if (object == NULL) {
if (all) {
code = BOZO_RestartAll(self);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to restart servers (%s)\n", em(code));
BSETCODE(code, buffer);
}
}
else {
char buffer[256];
sprintf(buffer, "AFS::BOS: To restart all processes please specify 'all'\n");
BSETCODE(-1, buffer);
}
RETVAL = (code == 0);
goto done;
}
else {
if (all) {
char buffer[256];
sprintf(buffer, "AFS::BOS: Can't use 'all' along with individual instances\n");
BSETCODE(-1, buffer);
RETVAL = 0;
goto done;
}
else {
AV *av;
SV *sv;
STRLEN namelen;
char *instance;
int i, len;
if (SvTYPE(SvRV(object)) != SVt_PVAV) {
BSETCODE(-1, "AFS::BOS: SERVER not an array reference\n");
RETVAL = 0;
goto done;
}
av = (AV *) SvRV(object);
len = av_len(av);
if (len != -1) {
for (i = 0; i <= len && i < 6; i++) {
sv = *av_fetch(av, i, 0);
if (sv) {
instance = (char *) safemalloc(BOZO_BSSIZE);
instance = SvPV(sv, namelen);
code = BOZO_Restart(self, instance);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to restart instance %s (%s)\n",
instance, em(code));
BSETCODE(code, buffer);
}
}
} /* for loop */
SETCODE(code);
RETVAL = (code == 0);
}
}
}
done:
;
}
OUTPUT:
RETVAL
int32
bos_setrestart(self, time, general=Nullsv, newbinary=Nullsv)
AFS::BOS self
char *time
SV * general
SV * newbinary
PREINIT:
int32 code = 0, count = 0;
struct ktime restartTime;
afs_int32 type;
int igeneral;
int inewbinary;
CODE:
{
if (!general) {
general = newSViv(0);
}
if (!SvIOKp(general)) {
char buffer[256];
sprintf(buffer, "AFS::BOS: Flag \"general\" should be numeric.\n");
BSETCODE(-1, buffer);
XSRETURN_UNDEF;
}
if (!newbinary) {
newbinary = newSViv(0);
}
if (!SvIOKp(newbinary)) {
char buffer[256];
sprintf(buffer, "AFS::BOS: Flag \"newbinary\" should be numeric.\n");
BSETCODE(-1, buffer);
XSRETURN_UNDEF;
}
igeneral = SvIV(general);
inewbinary = SvIV(newbinary);
if (igeneral) {
count++;
type = 1;
}
if (inewbinary) {
count++;
type = 2;
}
if (count > 1) {
char buffer[80];
sprintf(buffer, "AFS::BOS: can't specify more than one restart time at a time\n");
BSETCODE(-1, buffer);
goto done;
}
if (count == 0)
type = 1; /* by default set general restart time */
if (code = ktime_ParsePeriodic(time, &restartTime)) {
char buffer[240];
sprintf(buffer, "AFS::BOS: failed to parse '%s' as periodic restart time(%s)\n",
time, em(code));
BSETCODE(code, buffer);
goto done;
}
code = BOZO_SetRestartTime(self, type, &restartTime);
if (code) {
char buffer[240];
sprintf(buffer, "AFS::BOS: failed to set restart time at server (%s)\n", em(code));
BSETCODE(code, buffer);
goto done;
}
code = 0;
SETCODE(code);
done:
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
void
bos_getrestart(self)
AFS::BOS self
PREINIT:
int32 code = 0;
struct ktime generalTime, newBinaryTime;
char messageBuffer[256];
PPCODE:
{
code = BOZO_GetRestartTime(self, 1, &generalTime);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to retrieve restart information (%s)\n", em(code));
BSETCODE(code, buffer);
XSRETURN_UNDEF;
}
code = BOZO_GetRestartTime(self, 2, &newBinaryTime);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to retrieve restart information (%s)\n", em(code));
BSETCODE(code, buffer);
XSRETURN_UNDEF;
}
code = ktime_DisplayString(&generalTime, messageBuffer);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to decode restart time (%s)\n", em(code));
BSETCODE(code, buffer);
strcpy(messageBuffer, "");
}
XPUSHs(sv_2mortal(newSVpv(messageBuffer, strlen(messageBuffer))));
code = ktime_DisplayString(&newBinaryTime, messageBuffer);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to decode restart time (%s)\n", em(code));
BSETCODE(code, buffer);
strcpy(messageBuffer, "");
}
XPUSHs(sv_2mortal(newSVpv(messageBuffer, strlen(messageBuffer))));
XSRETURN(2);
}
void
bos_listusers(self)
AFS::BOS self
PREINIT:
int i;
int32 code = 0;
char tbuffer[256];
char *tp;
PPCODE:
{
for (i = 0;; i++) {
tp = tbuffer;
code = BOZO_ListSUsers(self, i, &tp);
STRLEN namelen;
CODE:
{
/* printf("DEBUG-bos-delete-1 \n"); */
if (!SvROK(object)) {
/* printf("DEBUG-bos-delete-2 \n"); */
name = (char *) SvPV_nolen(object);
code = BOZO_DeleteBnode(self, name);
if (code) {
char buffer[256];
/* printf("DEBUG-bos-delete-3 %d \n", code); */
if (code == BZBUSY)
sprintf(buffer, "AFS::BOS: can't delete running instance '%s'\n", name);
else
sprintf(buffer, "AFS::BOS: failed to delete instance '%s' (%s)\n", name,
em(code));
BSETCODE(code, buffer);
/* printf("DEBUG-bos-delete-4 %s \n", buffer); */
goto done;
}
}
else if (SvTYPE(SvRV(object)) == SVt_PVAV) {
/* printf("DEBUG-bos-delete-5 \n"); */
av = (AV *) SvRV(object);
len = av_len(av);
if (len != -1) {
/* printf("DEBUG-bos-delete-6 \n"); */
for (i = 0; i <= len; i++) {
sv = *av_fetch(av, i, 0);
if (sv) {
name = (char *) safemalloc(BOZO_BSSIZE);
name = SvPV(sv, namelen);
/* printf("DEBUG-bos-delete-7 %s\n", name); */
code = BOZO_DeleteBnode(self, name);
/* printf("DEBUG-bos-delete-8 %d \n", code); */
if (code) {
char buffer[256];
if (code == BZBUSY)
sprintf(buffer, "AFS::BOS: can't delete running instance '%s'\n",
name);
else
sprintf(buffer, "AFS::BOS: failed to delete instance '%s' (%s)\n",
name, em(code));
BSETCODE(code, buffer);
goto done;
}
}
} /* for loop */
}
}
SETCODE(0);
/* printf("DEBUG-bos-delete-9 \n"); */
done:
RETVAL = (code == 0);
/* printf("DEBUG-bos-delete-10 \n"); */
/* if (name) */
/* Safefree(name); */
/* printf("DEBUG-bos-delete-11 \n"); */
}
OUTPUT:
RETVAL
void
bos_getlog(self, file)
AFS::BOS self
char* file
PREINIT:
register struct rx_call *tcall;
int32 code = 0;
char buf, c[255];
int error, num = 0, i = 0;
PPCODE:
{
tcall = rx_NewCall(self);
code = StartBOZO_GetLog(tcall, file);
if (code) {
char buffer[256];
rx_EndCall(tcall, code);
sprintf(buffer, "AFS::BOS error %d (while reading log)\n", code);
BSETCODE(code, buffer);
XSRETURN_UNDEF;
}
/* copy data */
error = 0;
while (1) {
code = rx_Read(tcall, &buf, 1);
if (code != 1) {
error = EIO;
break;
}
if (buf == 0)
break; /* the end delimeter */
/* putchar(buf); */
c[i++] = buf;
if (buf == '\n') {
XPUSHs(sv_2mortal(newSVpv(c, i)));
i = 0;
num++;
}
}
code = rx_EndCall(tcall, error);
#if (tcall)
# Safefree(tcall);
/* fall through into cleanup code */
XSRETURN(num);
}
int32
bos__start(self, object=NULL)
AFS::BOS self
SV * object
PREINIT:
int32 code = 0;
CODE:
{
if (object && (! (SvTYPE(SvRV(object)) == SVt_PVAV))) {
code = -1;
BSETCODE(code, "AFS::BOS: SERVER not an array reference\n");
goto done;
}
if (object && (SvTYPE(SvRV(object)) == SVt_PVAV)) {
AV *av;
SV *sv;
char *instance;
STRLEN namelen;
int i, len;
av = (AV *) SvRV(object);
len = av_len(av);
if (len != -1) {
for (i = 0; i <= len; i++) {
sv = *av_fetch(av, i, 0);
if (sv) {
/* instance = (char *) safemalloc(BOZO_BSSIZE); */
Newx(instance, BOZO_BSSIZE, char);
instance = SvPV(sv, namelen);
code = BOZO_SetStatus(self, instance, BSTAT_NORMAL);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to start instance %s (%s)\n",
instance, em(code));
BSETCODE(code, buffer);
goto done;
}
/*if (instance) */
/* Safefree(instance); */
}
} /* for loop */
}
}
SETCODE(code);
done:
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
bos__startup(self, object=NULL)
AFS::BOS self
SV * object
PREINIT:
int32 code = 0;
CODE:
{
if (object && (! (SvTYPE(SvRV(object)) == SVt_PVAV))) {
code = -1;
BSETCODE(code, "AFS::BOS: SERVER not an array reference\n");
goto done;
}
if (object && (SvTYPE(SvRV(object)) == SVt_PVAV)) {
AV *av;
SV *sv;
char *instance;
STRLEN namelen;
int i, len;
av = (AV *) SvRV(object);
len = av_len(av);
if (len != -1) {
for (i = 0; i <= len; i++) {
sv = *av_fetch(av, i, 0);
if (sv) {
/* instance = (char *) safemalloc(BOZO_BSSIZE); */
Newx(instance, BOZO_BSSIZE, char);
instance = SvPV(sv, namelen);
code = BOZO_SetTStatus(self, instance, BSTAT_NORMAL);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to start instance %s (%s)\n",
instance, em(code));
BSETCODE(code, buffer);
goto done;
}
/*if (instance) */
/* Safefree(instance); */
}
} /* for loop */
}
}
else {
code = BOZO_StartupAll(self);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to startup servers (%s)\n", em(code));
BSETCODE(code, buffer);
goto done;
}
}
SETCODE(code);
done:
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
bos__stop(self, object=NULL, wait=0)
AFS::BOS self
SV * object
int wait
PREINIT:
int32 code = 0;
CODE:
{
/* printf("DEBUG-XS-bos-stop-1 \n"); */
if (object && (! (SvTYPE(SvRV(object)) == SVt_PVAV))) {
code = -1;
BSETCODE(code, "AFS::BOS: SERVER not an array reference\n");
goto done;
}
/* printf("DEBUG-XS-bos-stop-2 \n"); */
if (object && (SvTYPE(SvRV(object)) == SVt_PVAV)) {
AV *av;
SV *sv;
char *instance;
STRLEN namelen;
int i, len;
/* printf("DEBUG-XS-bos-stop-3 \n"); */
av = (AV *) SvRV(object);
len = av_len(av);
if (len != -1) {
for (i = 0; i <= len; i++) {
sv = *av_fetch(av, i, 0);
if (sv) {
/* instance = (char *) safemalloc(BOZO_BSSIZE); */
Newx(instance, BOZO_BSSIZE, char);
instance = SvPV(sv, namelen);
/* printf("DEBUG-XS-bos-stop-3-1 %d %s\n", len, instance); */
code = BOZO_SetStatus(self, instance, BSTAT_SHUTDOWN);
/* printf("DEBUG-XS-bos-stop-3-2 %d \n", code); */
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to change stop instance %s (%s)\n",
instance, em(code));
BSETCODE(code, buffer);
goto done;
}
/*if (instance) */
/* Safefree(instance); */
}
} /* for loop */
}
/* printf("DEBUG-XS-bos-stop-4 \n"); */
}
/* printf("DEBUG-XS-bos-stop-5 \n"); */
if (wait) {
/* printf("DEBUG-XS-bos-stop-5-1 \n"); */
code = BOZO_WaitAll(self);
/* printf("DEBUG-XS-bos-stop-5-2 %d \n", code); */
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: can't wait for processes to shutdown (%s)\n",
em(code));
BSETCODE(code, buffer);
goto done;
}
}
/* printf("DEBUG-XS-bos-stop-6 \n"); */
SETCODE(code);
done:
/* printf("DEBUG-XS-bos-stop-7 \n"); */
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
bos__shutdown(self, object=NULL, wait=0)
AFS::BOS self
SV * object
int wait
PREINIT:
int32 code = 0;
CODE:
{
if (object && (! (SvTYPE(SvRV(object)) == SVt_PVAV))) {
code = -1;
BSETCODE(code, "AFS::BOS: SERVER not an array reference\n");
goto done;
}
if (object && (SvTYPE(SvRV(object)) == SVt_PVAV)) {
AV *av;
SV *sv;
char *instance;
STRLEN namelen;
int i, len;
av = (AV *) SvRV(object);
len = av_len(av);
if (len != -1) {
for (i = 0; i <= len; i++) {
sv = *av_fetch(av, i, 0);
if (sv) {
/* instance = (char *) safemalloc(BOZO_BSSIZE); */
Newx(instance, BOZO_BSSIZE, char);
instance = SvPV(sv, namelen);
code = BOZO_SetTStatus(self, instance, BSTAT_SHUTDOWN);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to shutdown instance %s (%s)\n",
instance, em(code));
BSETCODE(code, buffer);
goto done;
}
/*if (instance) */
/* Safefree(instance); */
}
} /* for loop */
}
}
else {
code = BOZO_ShutdownAll(self);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to shutdown servers (%s)\n", em(code));
BSETCODE(code, buffer);
goto done;
}
}
if (wait) {
code = BOZO_WaitAll(self);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: can't wait for processes to shutdown (%s)\n",
em(code));
BSETCODE(code, buffer);
goto done;
}
}
SETCODE(code);
done:
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
int32
bos_setcellname(self, name)
AFS::BOS self
char *name
PREINIT:
int32 code = 0;
CODE:
{
not_here("AFS::BOS::setcellname");
code = BOZO_SetCellName(self, name);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to set cell (%s)\n", em(code));
BSETCODE(code, buffer);
}
}
OUTPUT:
RETVAL
void
bos_listkeys(self, showkey=0)
AFS::BOS self
int showkey
PREINIT:
afs_int32 i, kvno, code = 0;
struct ktc_encryptionKey tkey;
struct bozo_keyInfo keyInfo;
int everWorked = 0;
char index[5];
HV *list = (HV*)sv_2mortal((SV*)newHV());
PPCODE:
{
for (i = 0;; i++) {
HV *key = (HV *) sv_2mortal((SV *) newHV());
code = BOZO_ListKeys(self, i, &kvno, &tkey, &keyInfo);
if (code)
break;
everWorked = 1;
/* first check if key is returned */
if ((!ka_KeyIsZero((char *) &tkey, sizeof(tkey))) && showkey) {
/* ka_PrintBytes ((char *)&tkey, sizeof(tkey)); */
safe_hv_store(key, "key", 3, newSVpv((char *) &tkey, sizeof(tkey)), 0);
}
else {
if (keyInfo.keyCheckSum == 0) { /* shouldn't happen */
/* printf ("key version is %d\n", kvno); */
}
else {
safe_hv_store(key, "keyCheckSum", 11, newSVuv(keyInfo.keyCheckSum), 0);
}
}
sprintf(index, "%d", kvno);
safe_hv_store(list, index, strlen(index), newRV_inc((SV *) (key)), 0);
} /* for loop */
if (everWorked) {
/* fprintf(stderr, "Keys last changed on %d.\n", keyInfo.mod_sec); */
EXTEND(sp, 2);
PUSHs(sv_2mortal(newSViv(keyInfo.mod_sec)));
PUSHs(newRV_inc((SV *) (list)));
}
if (code != BZDOM) {
char buffer[256];
sprintf(buffer, "AFS::BOS: %s error encountered while listing keys\n", em(code));
BSETCODE(code, buffer);
}
else {
code = 0;
}
if (everWorked) {
XSRETURN(2);
}
else {
XSRETURN_EMPTY;
hv_undef(list);
}
}
int32
bos_getrestricted(self)
AFS::BOS self
CODE:
{
#ifdef BOS_RESTRICTED_MODE
int32 val, code;
RETVAL = 0;
code = BOZO_GetRestrictedMode(self, &val);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to get restricted mode (%s)\n", em(code));
BSETCODE(code, buffer);
}
RETVAL = val;
#else
RETVAL = 0;
not_here("AFS::BOS::getrestricted");
#endif
}
OUTPUT:
RETVAL
int32
bos_setrestricted(self, mode)
AFS::BOS self
char *mode
CODE:
{
#ifdef BOS_RESTRICTED_MODE
int32 val, code;
util_GetInt32(mode, &val);
code = BOZO_SetRestrictedMode(self, val);
if (code) {
char buffer[256];
sprintf(buffer, "AFS::BOS: failed to set restricted mode (%s)\n", em(code));
BSETCODE(code, buffer);
}
RETVAL = (code == 0);
#else
RETVAL = 0;
not_here("AFS::BOS::setrestricted");
#endif
}
OUTPUT:
RETVAL
int32
bos_salvage(self, partition=NULL, volume=NULL, all=0, outName=NULL, showlog=0, parallel=NULL, tmpDir=NULL, orphans=NULL, localauth=0, tmpname=NULL, debug=0, nowrite=0, force=0, oktozap=0, rootfiles=0, salvagedirs=0, blockreads=0, ListResidencies=0, S...
AFS::BOS self
char *partition
char *volume
int32 all
char *outName
int32 showlog
char *parallel
char *tmpDir
char *orphans
int32 localauth
char *tmpname
int32 debug
int32 nowrite
int32 force
int32 oktozap
int32 rootfiles
int32 salvagedirs
int32 blockreads
int32 ListResidencies
int32 SalvageRemote
int32 SalvageArchival
int32 IgnoreCheck
int32 ForceOnLine
int32 UseRootDirACL
int32 TraceBadLinkCounts
int32 DontAskFS
int32 LogLevel
int32 rxdebug
int32 Residencies
PREINIT:
afs_int32 code = 0, rc;
char tname[BOZO_BSSIZE];
afs_int32 newID;
extern struct ubik_client *cstruct;
afs_int32 curGoal, mrafs = 0;
char *tp;
CODE:
{
not_here("AFS::BOS::salvage");
if (partition && strlen(partition) == 0)
partition = NULL;
if (volume && strlen(volume) == 0)
volume = NULL;
if (outName && strlen(outName) == 0)
outName = NULL;
if (parallel && strlen(parallel) == 0)
parallel = NULL;
if (tmpDir && strlen(tmpDir) == 0)
tmpDir = NULL;
if (orphans && strlen(orphans) == 0)
orphans = NULL;
Zero(&mrafsParm, 1, mrafsParm);
/* Find out whether fileserver is running MR-AFS (has a scanner instance) */
}
}
if (rc) {
code = rc;
goto done;
}
}
else {
/* salvage individual volume (don't shutdown fs first), just use
* single-shot cron bnode. Must leave server running when using this
* option, since salvager will ask file server for the volume */
afs_int32 err;
const char *confdir;
confdir = (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH);
code = internal_vsu_ClientInit( /* noauth */ 1, confdir, tmpname,
/* server auth */ 0, &cstruct, (int (*)()) 0);
if (code == 0) {
newID = vsu_GetVolumeID(volume, cstruct, &err);
if (newID == 0) {
char buffer[256];
sprintf(buffer, "AFS::BOS: can't interpret %s as volume name or ID\n",
volume);
BSETCODE(-1, buffer);
goto done;
}
sprintf(tname, "%u", newID);
}
else {
char buffer[256];
sprintf(buffer,
"AFS::BOS: can't initialize volume system client (code %d), trying anyway.\n",
code);
BSETCODE(code, buffer);
strncpy(tname, volume, sizeof(tname));
}
if (volutil_GetPartitionID(partition) < 0) {
/* can't parse volume ID, so complain before shutting down
* file server.
*/
char buffer[256];
sprintf(buffer, "AFS::BOS: can't interpret %s as partition ID.\n", partition);
BSETCODE(-1, buffer);
goto done;
}
/* fprintf(stderr, "Starting salvage of volume %d on partition %s.\n",
newID, partition); */
rc = DoSalvage(self, partition, tname, outName, showlog, parallel, tmpDir, orphans);
if (rc) {
code = rc;
goto done;
}
}
code = 0;
SETCODE(code);
done:
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
MODULE = AFS PACKAGE = AFS::PTS PREFIX = pts_
AFS::PTS
pts__new(class=0, sec=1, cell=0)
char * class
int32 sec
char * cell
PREINIT:
int32 code = -1;
AFS__PTS server;
PPCODE:
{
if (cell && (cell[0] == '\0' || cell[0] == '0'))
cell = NULL;
server = internal_pts_new(&code, sec, cell);
# SETCODE(code); wird tiefer gesetzt...
if (code == 0) {
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "AFS::PTS", (void *) server);
XSRETURN(1);
}
else
XSRETURN_UNDEF;
}
int32
pts__DESTROY(server)
AFS::PTS server
CODE:
{
int32 code;
/* printf("pts DEBUG ubik_ClientDestroy\n"); */
code = ubik_ClientDestroy(server);
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
void
pts_id(server,object,anon=1)
AFS::PTS server
SV * object
int32 anon
PPCODE:
{
if (!SvROK(object)) {
int32 code, id;
char *name;
name = (char *) SvPV(object, PL_na);
code = internal_pr_id(server, name, &id, anon);
ST(0) = sv_newmortal();
SETCODE(code);
if (code == 0)
sv_setiv(ST(0), id);
XSRETURN(1);
}
else if (SvTYPE(SvRV(object)) == SVt_PVAV) {
int32 code, id;
int i, len;
AV *av;
SV *sv;
char *name;
STRLEN namelen;
namelist lnames;
idlist lids;
av = (AV *) SvRV(object);
len = av_len(av);
if (len != -1) {
lnames.namelist_len = len + 1;
lnames.namelist_val = (prname *) safemalloc(PR_MAXNAMELEN * (len + 1));
for (i = 0; i <= len; i++) {
sv = *av_fetch(av, i, 0);
if (sv) {
name = SvPV(sv, namelen);
strncpy(lnames.namelist_val[i], name, PR_MAXNAMELEN);
}
}
lids.idlist_len = 0;
lids.idlist_val = 0;
code = ubik_Call(PR_NameToID, server, 0, &lnames, &lids);
SETCODE(code);
if (code == 0 && lids.idlist_val) {
EXTEND(sp, lids.idlist_len);
for (i = 0; i < lids.idlist_len; i++) {
id = lids.idlist_val[i];
if (id == ANONYMOUSID && !anon) {
PUSHs(sv_newmortal());
}
else {
PUSHs(sv_2mortal(newSViv(id)));
}
}
if (lids.idlist_val)
free(lids.idlist_val);
}
if (lnames.namelist_val)
safefree(lnames.namelist_val);
PUTBACK;
return;
}
}
else if (SvTYPE(SvRV(object)) == SVt_PVHV) {
int32 code = 0, id;
int i, len;
HV *hv;
HE *he;
namelist lnames;
idlist lids;
char *key;
I32 keylen;
hv = (HV *) SvRV(object);
len = 0;
hv_iterinit(hv);
while (hv_iternext(hv))
len++;
if (len != 0) {
lnames.namelist_len = len;
lnames.namelist_val = (prname *) safemalloc(PR_MAXNAMELEN * len);
hv_iterinit(hv);
i = 0;
while ((he = hv_iternext(hv))) {
key = hv_iterkey(he, &keylen);
strncpy(lnames.namelist_val[i], key, PR_MAXNAMELEN);
i++;
}
lids.idlist_len = 0;
lids.idlist_val = 0;
code = ubik_Call(PR_NameToID, server, 0, &lnames, &lids);
SETCODE(code);
if (code == 0 && lids.idlist_val) {
hv_iterinit(hv);
i = 0;
while ((he = hv_iternext(hv))) {
key = hv_iterkey(he, &keylen);
id = lids.idlist_val[i];
if (id == ANONYMOUSID && !anon) {
safe_hv_store(hv, key, keylen, newSVsv(&PL_sv_undef), 0);
}
else {
safe_hv_store(hv, key, keylen, newSViv(id), 0);
}
i++;
}
if (lids.idlist_val)
free(lids.idlist_val);
}
if (lnames.namelist_val)
safefree(lnames.namelist_val);
}
if (code == 0) {
ST(0) = sv_2mortal(newRV_inc((SV *) hv));
}
else {
ST(0) = sv_newmortal();
}
XSRETURN(1);
}
else {
croak("object is not a scaler, ARRAY reference, or HASH reference");
}
}
void
pts_PR_NameToID(server,object)
AFS::PTS server
SV * object
PPCODE:
{
int32 code, id;
int i, len;
AV *av;
SV *sv;
char *name;
STRLEN namelen;
namelist lnames;
idlist lids;
if (!SvROK(object) || SvTYPE(SvRV(object)) != SVt_PVAV) {
croak("object is not an ARRAY reference");
}
av = (AV *) SvRV(object);
len = av_len(av);
if (len != -1) {
lnames.namelist_len = len + 1;
lnames.namelist_val = (prname *) safemalloc(PR_MAXNAMELEN * (len + 1));
for (i = 0; i <= len; i++) {
sv = *av_fetch(av, i, 0);
if (sv) {
name = SvPV(sv, namelen);
strncpy(lnames.namelist_val[i], name, PR_MAXNAMELEN);
}
}
lids.idlist_len = 0;
lids.idlist_val = 0;
code = ubik_Call(PR_NameToID, server, 0, &lnames, &lids);
SETCODE(code);
if (code == 0 && lids.idlist_val) {
EXTEND(sp, lids.idlist_len);
for (i = 0; i < lids.idlist_len; i++) {
id = lids.idlist_val[i];
PUSHs(sv_2mortal(newSViv(id)));
}
if (lids.idlist_val)
free(lids.idlist_val);
}
if (lnames.namelist_val)
safefree(lnames.namelist_val);
PUTBACK;
return;
}
}
void
pts_name(server,object,anon=1)
AFS::PTS server
SV * object
int32 anon
PPCODE:
{
if (!SvROK(object)) {
int32 code, id;
char name[PR_MAXNAMELEN];
id = SvIV(object);
code = internal_pr_name(server, id, name);
SETCODE(code);
ST(0) = sv_newmortal();
if (code == 0) {
if (!anon && check_name_for_id(name, id)) {
/* return undef */
}
else {
sv_setpv(ST(0), name);
}
}
XSRETURN(1);
}
else if (SvTYPE(SvRV(object)) == SVt_PVAV) {
int32 code;
int i, len;
AV *av;
SV *sv;
char *name;
namelist lnames;
idlist lids;
av = (AV *) SvRV(object);
len = av_len(av);
if (len != -1) {
lids.idlist_len = len + 1;
lids.idlist_val = (int32 *) safemalloc(sizeof(int32) * (len + 1));
lnames.namelist_len = 0;
lnames.namelist_val = 0;
for (i = 0; i <= len; i++) {
sv = *av_fetch(av, i, 0);
if (sv) {
lids.idlist_val[i] = SvIV(sv);
}
}
code = ubik_Call(PR_IDToName, server, 0, &lids, &lnames);
SETCODE(code);
if (code == 0 && lnames.namelist_val) {
EXTEND(sp, lnames.namelist_len);
for (i = 0; i < lnames.namelist_len; i++) {
name = lnames.namelist_val[i];
if (!anon && check_name_for_id(name, lids.idlist_val[i])) {
PUSHs(sv_newmortal());
}
else {
PUSHs(sv_2mortal(newSVpv(name, strlen(name))));
}
}
if (lnames.namelist_val)
free(lnames.namelist_val);
}
if (lids.idlist_val)
safefree(lids.idlist_val);
PUTBACK;
return;
}
}
else if (SvTYPE(SvRV(object)) == SVt_PVHV) {
int32 code = 0;
int i, len;
HV *hv;
SV *sv;
HE *he;
char *name;
namelist lnames;
idlist lids;
char *key;
I32 keylen;
hv = (HV *) SvRV(object);
len = 0;
hv_iterinit(hv);
while (hv_iternext(hv))
len++;
if (len != 0) {
lids.idlist_len = len;
lids.idlist_val = (int32 *) safemalloc(sizeof(int32) * len);
lnames.namelist_len = 0;
lnames.namelist_val = 0;
hv_iterinit(hv);
i = 0;
sv = sv_newmortal();
while ((he = hv_iternext(hv))) {
key = hv_iterkey(he, &keylen);
sv_setpvn(sv, key, keylen);
lids.idlist_val[i] = SvIV(sv);
i++;
}
code = ubik_Call(PR_IDToName, server, 0, &lids, &lnames);
SETCODE(code);
if (code == 0 && lnames.namelist_val) {
hv_iterinit(hv);
i = 0;
while ((he = hv_iternext(hv))) {
key = hv_iterkey(he, &keylen);
name = lnames.namelist_val[i];
if (!anon && check_name_for_id(name, lids.idlist_val[i])) {
safe_hv_store(hv, key, keylen, newSVsv(&PL_sv_undef), 0);
}
else {
safe_hv_store(hv, key, keylen, newSVpv(name, strlen(name)), 0);
}
i++;
}
if (lnames.namelist_val)
free(lnames.namelist_val);
}
if (lids.idlist_val)
safefree(lids.idlist_val);
}
if (code == 0) {
ST(0) = sv_2mortal(newRV_inc((SV *) hv));
}
else {
ST(0) = sv_newmortal();
}
XSRETURN(1);
}
else {
croak("object is not a scaler, ARRAY reference, or HASH reference");
}
}
void
pts_PR_IDToName(server,object)
AFS::PTS server
SV * object
PPCODE:
{
int32 code;
int i, len;
AV *av;
SV *sv;
char *name;
namelist lnames;
idlist lids;
if (!SvROK(object) || SvTYPE(SvRV(object)) != SVt_PVAV) {
croak("object is not an ARRAY reference");
}
av = (AV *) SvRV(object);
len = av_len(av);
if (len != -1) {
lids.idlist_len = len + 1;
lids.idlist_val = (int32 *) safemalloc(sizeof(int32) * (len + 1));
lnames.namelist_len = 0;
lnames.namelist_val = 0;
for (i = 0; i <= len; i++) {
sv = *av_fetch(av, i, 0);
if (sv) {
lids.idlist_val[i] = SvIV(sv);
}
}
code = ubik_Call(PR_IDToName, server, 0, &lids, &lnames);
SETCODE(code);
if (code == 0 && lnames.namelist_val) {
EXTEND(sp, lnames.namelist_len);
for (i = 0; i < lnames.namelist_len; i++) {
name = lnames.namelist_val[i];
PUSHs(sv_2mortal(newSVpv(name, strlen(name))));
}
if (lnames.namelist_val)
free(lnames.namelist_val);
}
if (lids.idlist_val)
safefree(lids.idlist_val);
PUTBACK;
return;
}
}
void
pts_members(server,name,convertids=1,over=0)
AFS::PTS server
char * name
int32 convertids
int32 over
PPCODE:
{
int32 code, wentover, id;
int i;
prlist list;
code = internal_pr_id(server, name, &id, 0);
if (code == 0) {
list.prlist_val = 0;
list.prlist_len = 0;
code = ubik_Call(PR_ListElements, server, 0, id, &list, &wentover);
if (items == 4)
sv_setiv(ST(3), (IV) wentover);
if (code == 0) {
if (convertids) {
namelist lnames;
lnames.namelist_len = 0;
lnames.namelist_val = 0;
code = ubik_Call(PR_IDToName, server, 0, &list, &lnames);
if (code == 0 && lnames.namelist_val) {
EXTEND(sp, lnames.namelist_len);
for (i = 0; i < lnames.namelist_len; i++) {
name = lnames.namelist_val[i];
PUSHs(sv_2mortal(newSVpv(name, strlen(name))));
}
if (lnames.namelist_val)
free(lnames.namelist_val);
}
}
else {
EXTEND(sp, list.prlist_len);
for (i = 0; i < list.prlist_len; i++) {
PUSHs(sv_2mortal(newSViv(list.prlist_val[i])));
}
}
}
if (list.prlist_val)
free(list.prlist_val);
}
else {
if (items == 4)
sv_setiv(ST(3), (IV) 0);
}
SETCODE(code);
}
void
pts_PR_ListElements(server,id,over)
AFS::PTS server
code = ubik_Call(PR_SetFieldsEntry, server, 0, id, mask, flags, 0, 0, 0, 0);
}
SETCODE(code);
ST(0) = sv_newmortal();
sv_setiv(ST(0), (code == 0));
XSRETURN(1);
}
void
pts_ismember(server,name,group)
AFS::PTS server
char * name
char * group
PPCODE:
{
int32 code, id, gid, flag;
code = internal_pr_id(server, name, &id, 0);
if (code == 0)
code = internal_pr_id(server, group, &gid, 0);
if (code == 0)
code = ubik_Call(PR_IsAMemberOf, server, 0, id, gid, &flag);
SETCODE(code);
ST(0) = sv_newmortal();
if (code == 0)
sv_setiv(ST(0), (flag != 0));
XSRETURN(1);
}
void
pts_PR_IsAMemberOf(server,uid,gid)
AFS::PTS server
int32 uid
int32 gid
PPCODE:
{
int32 code, flag;
code = ubik_Call(PR_IsAMemberOf, server, 0, uid, gid, &flag);
SETCODE(code);
ST(0) = sv_newmortal();
if (code == 0)
sv_setiv(ST(0), (flag != 0));
XSRETURN(1);
}
MODULE = AFS PACKAGE = AFS::KAS PREFIX = kas_
int32
kas__DESTROY(server)
AFS::KAS server
CODE:
{
int32 code;
code = ubik_ClientDestroy(server);
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
void
kas_KAM_GetEntry(server,user,inst)
AFS::KAS server
char * user
char * inst
PPCODE:
{
int32 code;
struct kaentryinfo entry;
code = ubik_Call(KAM_GetEntry, server, 0, user, inst, KAMAJORVERSION, &entry);
SETCODE(code);
if (code == 0) {
HV *stats = newHV();
if (parse_kaentryinfo(stats, &entry)) {
EXTEND(sp, 1);
PUSHs(sv_2mortal(newRV_noinc((SV *) stats)));
}
else {
hv_undef(stats);
}
}
}
void
kas_KAM_Debug(server,version)
AFS::KAS server
int32 version
PPCODE:
{
int32 code;
struct ka_debugInfo entry;
code = ubik_Call(KAM_Debug, server, 0, version, 0, &entry);
SETCODE(code);
if (code == 0) {
HV *stats = newHV();
if (parse_ka_debugInfo(stats, &entry)) {
EXTEND(sp, 1);
PUSHs(sv_2mortal(newRV_noinc((SV *) stats)));
}
else {
hv_undef(stats);
}
}
}
void
kas_KAM_GetStats(server,version)
AFS::KAS server
int32 version
PPCODE:
{
int32 code;
int32 admin_accounts;
struct kasstats kas;
struct kadstats kad;
SV *st;
EXTEND(sp, 1);
st = sv_newmortal();
sv_setref_pv(st, "AFS::KTC_TOKEN", (void *) t);
PUSHs(st);
if (pwexpires != -1)
sv_setiv(ST(7), (IV) pw);
XSRETURN(1);
}
else {
char buffer[256];
sprintf(buffer, "AFS::KTC_TOKEN: ");
KSETCODE(code, buffer);
safefree(t);
XSRETURN_UNDEF;
}
}
MODULE = AFS PACKAGE = AFS PREFIX = afs_
BOOT:
initialize_bz_error_table();
initialize_vols_error_table();
initialize_vl_error_table();
initialize_u_error_table();
initialize_pt_error_table();
initialize_ka_error_table();
initialize_acfg_error_table();
initialize_ktc_error_table();
initialize_rxk_error_table();
/* initialize_cmd_error_table(); */
/* initialize_budb_error_table(); */
/* initialize_butm_error_table(); */
/* initialize_butc_error_table(); */
void
afs__finalize()
CODE:
{
if (rx_initialized) {
rx_Finalize();
/* printf("AFS DEBUG rx_Finalize\n"); */
}
}
int32
afs_ascii2ptsaccess(access)
char * access
CODE:
{
int32 code, flags;
code = parse_pts_setfields(access, &flags);
SETCODE(code);
if (code != 0)
flags = 0;
RETVAL = flags;
}
OUTPUT:
RETVAL
void
afs_ptsaccess2ascii(flags)
int32 flags
CODE:
{
SETCODE(0);
ST(0) = sv_newmortal();
sv_setpv(ST(0), parse_flags_ptsaccess(flags));
}
void
afs_ka_ParseLoginName(login)
char * login
PPCODE:
{
int32 code;
char name[MAXKTCNAMELEN];
char inst[MAXKTCNAMELEN];
char cell[MAXKTCREALMLEN];
code = ka_ParseLoginName(login, name, inst, cell);
SETCODE(code);
if (code == 0) {
EXTEND(sp, 3);
PUSHs(sv_2mortal(newSVpv(name, strlen(name))));
PUSHs(sv_2mortal(newSVpv(inst, strlen(inst))));
PUSHs(sv_2mortal(newSVpv(cell, strlen(cell))));
}
}
void
afs_ka_StringToKey(str,cell)
char * str
char * cell
PPCODE:
{
struct ktc_encryptionKey *key;
SV *st;
key = (struct ktc_encryptionKey *) safemalloc(sizeof(*key));
ka_StringToKey(str, cell, key);
SETCODE(0);
EXTEND(sp, 1);
st = sv_newmortal();
sv_setref_pv(st, "AFS::KTC_EKEY", (void *) key);
PUSHs(st);
}
void
afs_ka_UserAthenticateGeneral(p,pass,life,flags,pwexpires=-1,reason=0)
AFS::KTC_PRINCIPAL p
char * pass
int32 life
int32 flags
int32 pwexpires
char * reason
if (code == 0) {
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "AFS::KAS", (void *) server);
XSRETURN(1);
}
}
void
afs_ka_SingleServerConn(host,token,service,cell=0)
char * host
AFS::KTC_TOKEN token
int32 service
char * cell
PPCODE:
{
int32 code;
AFS__KAS server;
if (token == &the_null_token)
token = NULL;
code = ka_SingleServerConn(cell, host, service, token, &server);
SETCODE(code);
if (code == 0) {
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), "AFS::KAS", (void *) server);
XSRETURN(1);
}
}
void
afs_ka_des_string_to_key(str)
char * str
PPCODE:
{
struct ktc_encryptionKey *key;
SV *st;
key = (struct ktc_encryptionKey *) safemalloc(sizeof(*key));
des_string_to_key(str, key);
SETCODE(0);
EXTEND(sp, 1);
st = sv_newmortal();
sv_setref_pv(st, "AFS::KTC_EKEY", (void *) key);
PUSHs(st);
}
int32
afs_setpag()
CODE:
{
int32 code;
code = setpag();
SETCODE(code);
RETVAL = (code == 0);
}
OUTPUT:
RETVAL
void
afs_expandcell(cell)
char * cell
PPCODE:
{
int32 code;
struct afsconf_cell info;
if (cell && (cell[0] == '\0' || cell[0] == '0'))
cell = NULL;
code = internal_GetCellInfo(cell, 0, &info);
if (code != 0) {
XSRETURN_UNDEF;
}
else {
SETCODE(code); /* fuer Fehler wird tiefer gesetzt... */
ST(0) = sv_newmortal();
sv_setpv(ST(0), info.name);
XSRETURN(1);
}
}
void
afs_localcell()
PPCODE:
{
int32 code;
char *cell;
cell = internal_GetLocalCell(&code);
if (! code) SETCODE(code); /* fuer Fehler wird tiefer gesetzt... */
ST(0) = sv_newmortal();
sv_setpv(ST(0), cell);
XSRETURN(1);
}
void
afs_getcellinfo(cell=0,ip=0)
char * cell
int32 ip
PPCODE:
{
int32 code;
struct afsconf_cell info;
if (cell && (cell[0] == '\0' || cell[0] == '0'))
cell = NULL;
code = internal_GetCellInfo(cell, 0, &info);
if (code != 0) {
XSRETURN_UNDEF;
}
else {
int i;
char *h;
SETCODE(code); /* fuer Fehler wird tiefer gesetzt... */
XPUSHs(sv_2mortal(newSVpv(info.name, strlen(info.name))));
for (i = 0; i < info.numServers; i++) {
if (ip == 1) {
h = (char *) inet_ntoa(info.hostAddr[i].sin_addr);
}
else {
h = info.hostName[i];
}
XPUSHs(sv_2mortal(newSVpv(h, strlen(h))));
}
XSRETURN(i+1);
}
}
int32
afs_convert_numeric_names(...)
CODE:
{
int32 flag;
if (items > 1)
croak("Usage: AFS::convert_numeric_names(flag)");
if (items == 1) {
flag = (int) SvIV(ST(0));
convert_numeric_names = (flag != 0);
}
RETVAL = convert_numeric_names;
}
OUTPUT:
RETVAL
int32
afs_raise_exception(...)
CODE:
{
int32 flag;
if (items > 1)
croak("Usage: AFS::raise_exception(flag)");
if (items == 1) {
flag = (int) SvIV(ST(0));
raise_exception = (flag != 0);
}
RETVAL = raise_exception;
}
OUTPUT:
RETVAL
void
afs_configdir(...)
PPCODE:
{
char *value;
int32 code;
if (items > 1)
croak("Usage: AFS::configdir(dir)");
if (items == 1) {
STRLEN len;
value = (char *) SvPV(ST(0), len);
if (config_dir != NULL)
safefree(config_dir);
if (cdir != NULL) {
afsconf_Close(cdir);
cdir = NULL;
}
config_dir = (char *) safemalloc(len + 1);
strcpy(config_dir, value);
code = internal_GetConfigDir();
# SETCODE(code); wird tiefer gesetzt...
ST(0) = sv_newmortal();
sv_setiv(ST(0), (code == 0));
XSRETURN(1);
}
else {
code = internal_GetConfigDir();
# SETCODE(code); wird tiefer gesetzt...
if (code == 0) {
ST(0) = sv_newmortal();
sv_setpv(ST(0), config_dir);
XSRETURN(1);
}
else
XSRETURN_UNDEF;
}
}
/* KTC routines */
AFS::KTC_PRINCIPAL
afs_ktc_ListTokens(context)
int32 context
PPCODE:
{
int32 code;
struct ktc_principal *p;
p = (struct ktc_principal *) safemalloc(sizeof(struct ktc_principal));
code = ktc_ListTokens(context, &context, p);
SETCODE(code);
sv_setiv(ST(0), (IV) context);
ST(0) = sv_newmortal();
if (code == 0) {
sv_setref_pv(ST(0), "AFS::KTC_PRINCIPAL", (void *) p);
}
( run in 0.889 second using v1.01-cache-2.11-cpan-39bf76dae61 )