AFS

 view release on metacpan or  search on metacpan

src/AFS.xs  view on Meta::CPAN

      case VL_BADRELLOCKTYPE:
          sprintf(buffer, "VLDB: bad release lock type\n");
          break;
      case VL_RERELEASE:
          sprintf(buffer, "VLDB: status report: last release was aborted\n");
          break;
      case VL_BADSERVERFLAG:
          sprintf(buffer, "VLDB: invalid replication site server flag\n");
          break;
      case VL_PERM:
          sprintf(buffer, "VLDB: no permission access for call\n");
          break;
      case VOLSERREAD_DUMPERROR:
          sprintf(buffer, "VOLSER:  Problems encountered in reading the dump file !\n");
          break;
      case VOLSERDUMPERROR:
          sprintf(buffer, "VOLSER: Problems encountered in doing the dump !\n");
          break;
      case VOLSERATTACH_ERROR:
          sprintf(buffer, "VOLSER: Could not attach the volume\n");
          break;
      case VOLSERDETACH_ERROR:
          sprintf(buffer, "VOLSER: Could not detach the volume\n");
          break;
      case VOLSERILLEGAL_PARTITION:
          sprintf(buffer, "VOLSER: encountered illegal partition number\n");
          break;
      case VOLSERBAD_ACCESS:
          sprintf(buffer, "VOLSER: permission denied, not a super user\n");
          break;
      case VOLSERVLDB_ERROR:
          sprintf(buffer, "VOLSER: error detected in the VLDB\n");
          break;
      case VOLSERBADNAME:
          sprintf(buffer, "VOLSER: error in volume name\n");
          break;
      case VOLSERVOLMOVED:
          sprintf(buffer, "VOLSER: volume has moved\n");
          break;
      case VOLSERBADOP:
          sprintf(buffer, "VOLSER: illegal operation\n");
          break;
      case VOLSERBADRELEASE:
          sprintf(buffer, "VOLSER: release could not be completed\n");
          break;
      case VOLSERVOLBUSY:
          sprintf(buffer, "VOLSER: volume is busy\n");
          break;
      case VOLSERNO_MEMORY:
          sprintf(buffer, "VOLSER: volume server is out of memory\n");
          break;
      case VOLSERNOVOL:
          sprintf(buffer,
                  "VOLSER: no such volume - location specified incorrectly or volume does not exist\n");
          break;
      case VOLSERMULTIRWVOL:
          sprintf(buffer,
                  "VOLSER: multiple RW volumes with same ID, one of which should be deleted\n");
          break;
      case VOLSERFAILEDOP:
          sprintf(buffer, "VOLSER: not all entries were successfully processed\n");
          break;
      default:
          sprintf(buffer, "Unknown ERROR code\n");
          break;
    }
    return 0;
}

#ifdef AFS_PTHREAD_ENV
void IOMGR_Sleep (seconds)
  int seconds;
{
    double i,j;

    croak("DEBUG: IOMGR_Sleep not available ...\nPlease inform the author...");
    j = 0.0;
    i = 1.0/j;
}

void clock_UpdateTime ()
{
    double i,j;

    croak("DEBUG: clock_UpdateTime not available ...\nPlease inform the author..  .");
    j = 0.0;
    i = 1.0/j;
}

int clock_haveCurrentTime ()
{
    double i,j;

    croak("DEBUG: clock_haveCurrentTime not available...\nPlease inform the auth or...");
    j = 0.0;
    i = 1.0/j;
    return 1;
}
#endif /* AFS_PTHREAD_ENV*/

static int32 not_here(s)
    char *s;
{
    croak("%s not implemented on this architecture or under this AFS version", s);
    return -1;
}

int PrintDiagnostics(astring, acode)
    char *astring;
    afs_int32 acode;
{
    if (acode == EACCES) {
        fprintf(STDERR, "You are not authorized to perform the 'vos %s' command (%d)\n",
                astring, acode);
    }
    else {
        fprintf(STDERR, "Error in vos %s command.\n", astring);
        PrintError("", acode);
    }
    return 0;
}

src/AFS.xs  view on Meta::CPAN

{
    register char *bp;

    bp = braslist[i];
    while (*bp++ == *lp++)
	if (bp >= braelist[i])
	    return (1);
    return (0);
}

static int
cclass(register char *set, register char c, int af)
{
    register int n;

    if (c == 0)
	return (0);
    n = *set++;
    while (--n)
	if (*set++ == c)
	    return (af);
    return (!af);
}

/* copy taken from <src/ubik/uinit.c> OpenAFS-1.4.14.1 */
static afs_int32
internal_ugen_ClientInit(int noAuthFlag, const char *confDir, char *cellName, afs_int32 sauth,
	       struct ubik_client **uclientp, int (*secproc) (),
	       char *funcName, afs_int32 gen_rxkad_level,
	       afs_int32 maxservers, char *serviceid, afs_int32 deadtime,
	       afs_uint32 server, afs_uint32 port, afs_int32 usrvid)
{
    afs_int32 code, scIndex, i;
    struct afsconf_cell info;
    struct afsconf_dir *tdir;
    struct ktc_principal sname;
    struct ktc_token ttoken;
    struct rx_securityClass *sc;
    /* This must change if VLDB_MAXSERVERS becomes larger than MAXSERVERS */
    static struct rx_connection *serverconns[MAXSERVERS];
    char cellstr[64];

    if (!rx_initialized) {
        /* printf("ugen DEBUG rx_Init\n"); */
        code = rx_Init(0);
        if (code) {
            char buffer[256];
            sprintf(buffer, "%s: could not initialize rx.\n", funcName);
            VSETCODE(code, buffer);
            return (code);
        }
        rx_initialized = 1;
    }
    rx_SetRxDeadTime(deadtime);

    if (sauth) {		/* -localauth */
	tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
	if (!tdir) {
            char buffer[256];
            sprintf(buffer,
		    "%s: Could not process files in configuration directory (%s).\n",
		    funcName, AFSDIR_SERVER_ETC_DIRPATH);
	    code = -1;
            VSETCODE(code, buffer);
            return (code);
	}
	code = afsconf_ClientAuth(tdir, &sc, &scIndex);	/* sets sc,scIndex */
	if (code) {
	    afsconf_Close(tdir);
            char buffer[256];
            sprintf(buffer,
		    "%s: Could not get security object for -localAuth\n",
		    funcName);
            VSETCODE(code, buffer);
            return (code);
	}
	code = afsconf_GetCellInfo(tdir, tdir->cellName, serviceid, &info);
	if (code) {
	    afsconf_Close(tdir);
            char buffer[256];
            sprintf(buffer,
		    "%s: can't find cell %s's hosts in %s/%s\n",
		    funcName, cellName, AFSDIR_SERVER_ETC_DIRPATH,
		    AFSDIR_CELLSERVDB_FILE);
            VSETCODE(code, buffer);
            return (code);
	}
    } else {			/* not -localauth */
	tdir = afsconf_Open(confDir);
	if (!tdir) {
            char buffer[256];
            sprintf(buffer,
		    "%s: Could not process files in configuration directory (%s).\n",
		    funcName, confDir);
	    code = -1;
            VSETCODE(code, buffer);
            return (code);
	}

	if (!cellName) {
	    code = afsconf_GetLocalCell(tdir, cellstr, sizeof(cellstr));
	    if (code) {
                char buffer[256];
                sprintf(buffer,
			"%s: can't get local cellname, check %s/%s\n",
			funcName, confDir, AFSDIR_THISCELL_FILE);
                VSETCODE(code, buffer);
                return (code);
	    }
	    cellName = cellstr;
	}

	code = afsconf_GetCellInfo(tdir, cellName, serviceid, &info);
	if (code) {
            char buffer[256];
            sprintf(buffer,
		    "%s: can't find cell %s's hosts in %s/%s\n",
		    funcName, cellName, confDir, AFSDIR_CELLSERVDB_FILE);
            VSETCODE(code, buffer);
            return (code);
	}
	if (noAuthFlag)		/* -noauth */
	    scIndex = 0;
	else {			/* not -noauth */
	    strcpy(sname.cell, info.name);
	    sname.instance[0] = 0;
	    strcpy(sname.name, "afs");
	    code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL);
	    if (code) {		/* did not get ticket */
		fprintf(stderr,
			"%s: Could not get afs tokens, running unauthenticated.\n",
			funcName);
		scIndex = 0;
	    } else {		/* got a ticket */
		scIndex = 2;
		if ((ttoken.kvno < 0) || (ttoken.kvno > 256)) {
		    fprintf(stderr,
			    "%s: funny kvno (%d) in ticket, proceeding\n",
			    funcName, ttoken.kvno);
		}
	    }
	}

        char buffer[256];
	switch (scIndex) {
	case 0:
	    sc = rxnull_NewClientSecurityObject();
	    break;
	case 2:
	    sc = rxkad_NewClientSecurityObject(gen_rxkad_level,
					       &ttoken.sessionKey,
					       ttoken.kvno, ttoken.ticketLen,
					       ttoken.ticket);

src/AFS.xs  view on Meta::CPAN

                    itp = SvPV_nolen(regex);
                    if (strncmp(itp, "^", 1) == 0) {
                        ccode = (char *) re_comp(itp);
                        if (ccode) {
                            char buffer[256];
                            sprintf(buffer,
                                    "Unrecognizable PREFIX regular expression: '%s': %s\n", itp,
                                    ccode);
                            VSETCODE(ccode, buffer);
                            XSRETURN_UNDEF;
                        }
                    }
                }                       /*for loop */
            /* printf("vos-backupsys DEBUG-8 RE %s \n", itp); */
            }
        }

        /* printf("vos-backupsys DEBUG-9\n"); */
        if (seenxprefix && (prfxlength = sv_len(seenxprefix)) == 0)
            seenxprefix = NULL;
        /* printf("vos-backupsys DEBUG-10\n"); */

        if (seenxprefix && (! (SvTYPE(SvRV(seenxprefix)) == SVt_PVAV))) {
            VSETCODE(-1, "AFS::VOS: XPREFIX not an array reference");
            XSRETURN_UNDEF;
        }
        if (seenxprefix) {
            /* printf("vos-backupsys DEBUG-11\n"); */
            av = (AV *) SvRV(seenxprefix);
            len = av_len(av);
            if (len != -1) {
                for (j = 0; j <= len; j++) {
                    regex = *av_fetch(av, j, 0);
                    itp = SvPV_nolen(regex);
                    if (strncmp(itp, "^", 1) == 0) {
                        ccode = (char *) re_comp(itp);
                        if (ccode) {
                            char buffer[256];
                            sprintf(buffer,
                                    "Unrecognizable XPREFIX regular expression: '%s': %s\n", itp,
                                    ccode);
                            VSETCODE(ccode, buffer);
                            XSRETURN_UNDEF;
                        }
                    }
                }                       /*for */
            }
        }

        /* printf("vos-backupsys DEBUG-12\n"); */
        Zero(&arrayEntries, 1, nbulkentries);   /* initialize to hint the stub to alloc space */
        vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
        if (vcode) {
            VSETCODE(vcode, "Could not access the VLDB for attributes");
            XSRETURN_UNDEF;
        }

            /* a bunch of output generation code deleted. A.W. */

        /* printf("vos-backupsys DEBUG-13\n"); */
        for (j = 0; j < nentries; j++) {        /* process each vldb entry */
            vllist = &arrayEntries.nbulkentries_val[j];
            /* printf("vos-backupsys DEBUG-13-1 Name %s\n", vllist->name); */

            if (seenprefix) {
                av = (AV *) SvRV(seenprefix);
                len = av_len(av);
                /* printf("vos-backupsys DEBUG-14 Len %d\n", len); */
                for (i = 0; i <= len; i++) {
                    regex = *av_fetch(av, i, 0);
                    itp = SvPV_nolen(regex);
                    /* printf("vos-backupsys DEBUG-14-1 RE %s \n", itp); */
                    if (strncmp(itp, "^", 1) == 0) {
                        ccode = (char *) re_comp(itp);
                        if (ccode) {
                            char buffer[256];
                            sprintf(buffer, "Error in PREFIX regular expression: '%s': %s\n",
                                    itp, ccode);
                            VSETCODE(ccode, buffer);
                            XSRETURN_UNDEF;
                        }
                        match = (re_exec(vllist->name) == 1);
                    }
                    else {
                        match = (strncmp(vllist->name, itp, strlen(itp)) == 0);
                    }
                    if (match)
                        break;
                }
            }
            else {
                match = 1;
                /* printf("vos-backupsys DEBUG-15 MATCH %d\n", match); */
            }

            /* Without the -exclude flag: If it matches the prefix, then
             *    check if we want to exclude any from xprefix.
             * With the -exclude flag: If it matches the prefix, then
             *    check if we want to add any from xprefix.
             */
            if (match && seenxprefix) {
                av = (AV *) SvRV(seenxprefix);
                len = av_len(av);
                for (i = 0; i <= len; i++) {
                    regex = *av_fetch(av, i, 0);
                    itp = SvPV_nolen(regex);
                    if (strncmp(itp, "^", 1) == 0) {
                        ccode = (char *) re_comp(itp);
                        if (ccode) {
                            char buffer[256];
                            sprintf(buffer, "Error in PREFIX regular expression: '%s': %s\n",
                                    itp, ccode);
                            VSETCODE(ccode, buffer);
                            XSRETURN_UNDEF;
                        }
                        if (re_exec(vllist->name) == 1) {
                            match = 0;
                            break;
                        }
                    }
                    else {

src/AFS.xs  view on Meta::CPAN


            /* printf("vos-backupsys DEBUG-17\n"); */
            if (!(vllist->flags & RW_EXISTS)) {
                if (verbose) {
                    fprintf(STDOUT, "Omitting to backup %s since RW volume does not exist \n",
                            vllist->name);
                    fprintf(STDOUT, "\n");
                }
                fflush(STDOUT);
                continue;
            }

            /* printf("vos-backupsys DEBUG-18\n"); */
            avolid = vllist->volumeId[RWVOL];
            MapHostToNetwork(vllist);
            GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
            if (aserver1 == -1 || apart1 == -1) {
                av_push(av2, newSVpv(vllist->name, strlen(vllist->name)));
                fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n", vllist->name);
                totalFail++;
                continue;
            }
            /* printf("vos-backupsys DEBUG-19\n"); */
            if (aserver) {
                same = VLDB_IsSameAddrs(aserver, aserver1, &error);
                if (error) {
                    av_push(av2, newSVpv(vllist->name, strlen(vllist->name)));
                    fprintf(stderr,
                            "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
                            aserver, error);
                    totalFail++;
                    continue;
                }
            }
            /* printf("vos-backupsys DEBUG-20\n"); */
            if ((aserver && !same) || (apart && (apart != apart1))) {
                if (verbose) {
                    fprintf(STDOUT,
                            "Omitting to backup %s since the RW is in a different location\n",
                            vllist->name);
                }
                continue;
            }
            if (verbose) {
                time_t now = time(0);
                fprintf(STDOUT, "Creating backup volume for %s on %s", vllist->name, ctime(&now));
                fflush(STDOUT);
            }

            /* printf("vos-backupsys DEBUG-21\n"); */
            code = UV_BackupVolume(aserver1, apart1, avolid);
            if (code) {
                av_push(av2, newSVpv(vllist->name, strlen(vllist->name)));
                fprintf(STDOUT, "Could not backup %s\n", vllist->name);
                totalFail++;
            }
            else {
                av_push(av1, newSVpv(vllist->name, strlen(vllist->name)));
                totalBack++;
            }
        }                               /* process each vldb entry */

        /* printf("vos-backupsys DEBUG-22: Succ %d   Fail %d\n", totalBack, totalFail); */
        if (arrayEntries.nbulkentries_val)
            free(arrayEntries.nbulkentries_val);

        SETCODE(0);
        XPUSHs(sv_2mortal(newRV_inc((SV *) (av1))));
        XPUSHs(sv_2mortal(newRV_inc((SV *) (av2))));
        XSRETURN(2);
    }

void
vos_listpart(cstruct, server)
        AFS::VOS cstruct
        char *server
    PREINIT:
        int32 aserver, code;
        struct partList dummyPartList;
        int i, total, cnt;
        char pname[10];
    PPCODE:
    {
        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;
        }
        code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
        if (code) {
            PrintDiagnostics("listpart", code);
            XSRETURN_UNDEF;
        }
        total = 0;
        for (i = 0; i < cnt; i++) {
            if (dummyPartList.partFlags[i] & PARTVALID) {
                Zero(pname, 10, char);
                MapPartIdIntoName(dummyPartList.partId[i], pname);
                XPUSHs(sv_2mortal(newSVpv(pname, strlen(pname))));
                total++;
            }
        }

        SETCODE(0);
        XSRETURN(total);
    }

void
vos_listvolume(cstruct, name)
        AFS::VOS cstruct
        char *name
    PREINIT:
        struct nvldbentry entry;
        afs_int32 vcode = 0;
        volintInfo *pntr = (volintInfo *)0;
        afs_int32 volid;
        afs_int32 code, err;
        int voltype, foundserv = 0, foundentry = 0;
        afs_int32 aserver, apart;

src/AFS.xs  view on Meta::CPAN

                char buffer[256];
                sprintf(buffer, "AFS::VLDB: server '%s' not found in host table\n", servername);
                VSETCODE(-1, buffer);
                XSRETURN_UNDEF;
            }
            attributes.server = ntohl(aserver);
            attributes.Mask |= VLLIST_SERVER;
        }

            /* Partition specified */
        /* printf("DEBUG-8 \n"); */
        if (parti) {
            /* printf("DEBUG-9 \n"); */
            apart = volutil_GetPartitionID(parti);
            if (apart < 0) {
                char buffer[256];
                sprintf(buffer, "AFS::VLDB: could not interpret partition name '%s'\n", parti);
                VSETCODE(-1, buffer);
                XSRETURN_UNDEF;
            }
            attributes.partition = apart;
            attributes.Mask |= VLLIST_PARTITION;
        }

        /* printf("DEBUG-10 \n"); */
        if (lock) {
            /* printf("DEBUG-11 \n"); */
            attributes.Mask |= VLLIST_FLAG;
            attributes.flag = VLOP_ALLOPERS;
        }

        /* printf("DEBUG-12 \n"); */
        for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
             /* printf("DEBUG-13 \n"); */
            /* memset(&arrayEntries, 0, sizeof(arrayEntries)); */
            /* Zero(&arrayEntries, sizeof(arrayEntries), nbulkentries);  ??? nog ???  */
            Zero(&arrayEntries, 1, nbulkentries);
            /* printf("DEBUG-14 \n"); */
            centries = 0;
            nextindex = -1;

            vcode = VLDB_ListAttributesN2(&attributes, 0, thisindex,
                                          &centries, &arrayEntries, &nextindex);
            /* printf("DEBUG-15 \n"); */
            if (vcode == RXGEN_OPCODE) {
                /* Vlserver not running with ListAttributesN2. Fall back */
                vcode = VLDB_ListAttributes(&attributes, &centries, &arrayEntries);
                nextindex = -1;
            }
            /* printf("DEBUG-16 \n"); */
            if (vcode) {
                char buffer[256];
                sprintf(buffer, "Could not access the VLDB for attributes\n");
                VSETCODE(vcode, buffer);
                XSRETURN_UNDEF;
            }
            nentries += centries;

            /* We don't sort, so just print the entries now */
            /* printf("DEBUG-17 \n"); */
            for (j = 0; j < centries; j++) {    /* process each entry */
                /* printf("DEBUG-18 \n"); */
                vllist = &arrayEntries.nbulkentries_val[j];
                MapHostToNetwork(vllist);
                stats = newHV();
                myEnumerateEntry(stats, vllist);
                safe_hv_store(status, vllist->name, strlen(vllist->name), newRV_inc((SV *) (stats)),
                         0);
            }
            if (arrayEntries.nbulkentries_val)
                free(arrayEntries.nbulkentries_val);
        }

        finish:
        /* printf("DEBUG-19 \n"); */
        SETCODE(0);
        ST(0) = sv_2mortal(newRV_inc((SV *) status));
        XSRETURN(1);
    }

void
vldb_listaddrs(cstruct, host=NULL, uuid=NULL, noresolve=0, printuuid=0)
        AFS::VLDB cstruct
        char *host
        char *uuid
        int noresolve
        int printuuid
    PREINIT:
        afs_int32 vcode;
        afs_int32 i, j;
        afs_int32            nentries;
        bulkaddrs            m_addrs;
        ListAddrByAttributes m_attrs;
        afsUUID              m_uuid, askuuid;
        afs_int32            m_unique, m_nentries;
    PPCODE:
    {
        Zero(&m_attrs, 1, ListAddrByAttributes);
        m_attrs.Mask = VLADDR_INDEX;

        Zero(&m_addrs, 1, bulkaddrs);
        Zero(&askuuid, 1, afsUUID);
#ifdef OpenAFS
        if (uuid && strlen(uuid) != 0) {
            /* -uuid */
            afsUUID_from_string(uuid, &askuuid);
            m_attrs.Mask = VLADDR_UUID;
            m_attrs.uuid = askuuid;
        }
        else
#endif
            uuid = NULL;

        if (host && strlen(host) != 0) {
            /* -host */
            struct hostent *he;
            afs_int32 saddr;
            he = (struct hostent *) hostutil_GetHostByName(host);
            if (he == (struct hostent *) 0) {
                char buffer[256];
                sprintf(buffer, "Can't get host info for '%s'\n", host);

src/AFS.xs  view on Meta::CPAN

    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);

src/AFS.xs  view on Meta::CPAN

            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

src/AFS.xs  view on Meta::CPAN


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); */
                }



( run in 0.365 second using v1.01-cache-2.11-cpan-39bf76dae61 )