AFS

 view release on metacpan or  search on metacpan

src/AFS.xs  view on Meta::CPAN

          sprintf(buffer, "VLDB: bad incoming vldb entry\n");
          break;
      case VL_BADVOLIDBUMP:
          sprintf(buffer, "VLDB: illegal max volid increment\n");
          break;
      case VL_IDALREADYHASHED:
          sprintf(buffer, "VLDB: (RO/BACK) Id already hashed\n");
          break;
      case VL_ENTRYLOCKED:
          sprintf(buffer, "VLDB: vldb entry is already locked\n");
          break;
      case VL_BADVOLOPER:
          sprintf(buffer, "VLDB: bad volume operation code\n");
          break;
      case VL_BADRELLOCKTYPE:
          sprintf(buffer, "VLDB: bad release lock type\n");
          break;
      case VL_RERELEASE:
          sprintf(buffer, "VLDB: status report: last release was aborted\n");
          break;
      case VL_BADSERVERFLAG:
          sprintf(buffer, "VLDB: invalid replication site server flag\n");
          break;
      case VL_PERM:
          sprintf(buffer, "VLDB: no permission access for call\n");
          break;
      case VOLSERREAD_DUMPERROR:
          sprintf(buffer, "VOLSER:  Problems encountered in reading the dump file !\n");
          break;
      case VOLSERDUMPERROR:
          sprintf(buffer, "VOLSER: Problems encountered in doing the dump !\n");
          break;
      case VOLSERATTACH_ERROR:
          sprintf(buffer, "VOLSER: Could not attach the volume\n");
          break;
      case VOLSERDETACH_ERROR:
          sprintf(buffer, "VOLSER: Could not detach the volume\n");
          break;
      case VOLSERILLEGAL_PARTITION:
          sprintf(buffer, "VOLSER: encountered illegal partition number\n");
          break;
      case VOLSERBAD_ACCESS:
          sprintf(buffer, "VOLSER: permission denied, not a super user\n");
          break;
      case VOLSERVLDB_ERROR:
          sprintf(buffer, "VOLSER: error detected in the VLDB\n");
          break;
      case VOLSERBADNAME:
          sprintf(buffer, "VOLSER: error in volume name\n");
          break;
      case VOLSERVOLMOVED:
          sprintf(buffer, "VOLSER: volume has moved\n");
          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;
}

src/AFS.xs  view on Meta::CPAN

    afs_int32 error = 0, code;
    afs_hyper_t size;
    long blksize;
    int ufdIsOpen = 0;

    /* Open the output file */
    if (!filename || !*filename) {
        usd_StandardOutput(&ufd);
        blksize = 4096;
        ufdIsOpen = 1;
    }
    else {
        code = usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
        if (code == 0) {
            ufdIsOpen = 1;
            hzero(size);
            code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
        }
        if (code == 0) {
            code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
        }
        if (code) {
            char buffer[256];
            sprintf(buffer, "Could not create file '%s'\n", filename);
            VSETCODE(VOLSERBADOP, buffer);
            ERROR_EXIT(VOLSERBADOP);
        }
    }

    code = ReceiveFile(ufd, call, blksize);
    if (code)
        ERROR_EXIT(code);

  error_exit:
    /* Close the output file */
    if (ufdIsOpen) {
        code = USD_CLOSE(ufd);
        if (code) {
            char buffer[256];
            sprintf(buffer, "Could not close dump file %s\n",
                    (filename && *filename) ? filename : "STDIN");
            VSETCODE(code, buffer);
            if (!error)
                error = code;
        }
    }

    return (error);
}

struct tqElem {
    afs_int32 volid;
    struct tqElem *next;
};

struct tqHead {
    afs_int32 count;
    struct tqElem *next;
};

static struct tqHead busyHead, notokHead;

static void qInit(ahead)
    struct tqHead *ahead;
{
    Zero(ahead, 1, struct tqHead);
    return;
}

static void qPut(ahead, volid)
    struct tqHead *ahead;
    afs_int32 volid;
{
    struct tqElem *elem;

    elem = (struct tqElem *) safemalloc(sizeof(struct tqElem));
    elem->next = ahead->next;
    elem->volid = volid;
    ahead->next = elem;
    ahead->count++;
    return;
}

/* Kann vielleicht ganz raus ???    */
/* static void qGet(ahead, volid) */
/*     struct tqHead *ahead; */
/*     afs_int32 *volid; */
/* { */
/*     struct tqElem *tmp; */

/*     if (ahead->count <= 0) */
/*         return; */
/*     *volid = ahead->next->volid; */
/*     tmp = ahead->next; */
/*     ahead->next = tmp->next; */
/*     ahead->count--; */
/*     free(tmp); */
/*     return; */
/* } */

static int FileExists(filename)
    char *filename;
{
    usd_handle_t ufd;
    int code;
    afs_hyper_t size;

    code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
    if (code) {
        return 0;
    }
    code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
    USD_CLOSE(ufd);
    if (code) {
        return 0;
    }
    return 1;
}

static void myDisplayFormat(vol, pntr, server, part, totalOK, totalNotOK, totalBusy, fast)
    HV *vol;

src/AFS.xs  view on Meta::CPAN

    int *totalOK, *totalNotOK, *totalBusy;
    int fast;
{
    char pname[10];
    char hostname[256];

    if (fast) {
        safe_hv_store(vol, "volid", 5, newSViv(pntr->volid), 0);
    }
    else {
        safe_hv_store(vol, "status", 6, newSViv(pntr->status), 0);
        safe_hv_store(vol, "volid", 5, newSViv(pntr->volid), 0);

        if (pntr->status == VOK) {
            safe_hv_store(vol, "name", 4,  newSVpv(pntr->name, strlen((char *) pntr->name)), 0);
            if (pntr->type == 0)
                safe_hv_store(vol, "type", 4, newSVpv("RW", 2), 0);
            if (pntr->type == 1)
                safe_hv_store(vol, "type", 4, newSVpv("RO", 2), 0);
            if (pntr->type == 2)
                safe_hv_store(vol, "type", 4, newSVpv("BK", 2), 0);

            safe_hv_store(vol, "size", 4, newSViv(pntr->size), 0);

            if (pntr->inUse == 1) {
                safe_hv_store(vol, "inUse", 5, newSVpv("On-line", 7), 0);
                *totalOK += 1;
            }
            else {
                safe_hv_store(vol, "inUse", 5, newSVpv("Off-line", 8), 0);
                *totalNotOK += 1;
            }

            MapPartIdIntoName(part, pname);
            strcpy(hostname, (char *) hostutil_GetNameByINet(server));
            safe_hv_store(vol, "server", 6, newSVpv(hostname, strlen((char *) hostname)), 0);
            safe_hv_store(vol, "backupID", 8, newSViv(pntr->backupID), 0);
            safe_hv_store(vol, "parentID", 8, newSViv(pntr->parentID), 0);
            safe_hv_store(vol, "cloneID", 7, newSViv(pntr->cloneID), 0);
            safe_hv_store(vol, "maxquota", 8, newSViv(pntr->maxquota), 0);
            safe_hv_store(vol, "creationDate", 12, newSViv(pntr->creationDate), 0);
#ifdef OpenAFS           /* copy taken from <src/volser/vos.c> OpenAFS-1.2.11 FULL_LISTVOL_SWITCH*/
            safe_hv_store(vol, "copyDate", 8, newSViv(pntr->copyDate), 0);
            if (!pntr->backupDate)
                safe_hv_store(vol, "backupDate", 10, newSVpv("Never", 5), 0);
            else
                safe_hv_store(vol, "backupDate", 10, newSViv(pntr->backupDate), 0);
            if (pntr->accessDate)
                safe_hv_store(vol, "accessDate", 10, newSViv(pntr->accessDate), 0);
#endif
            if (!pntr->updateDate)
                safe_hv_store(vol, "updateDate", 10, newSVpv("Never", 5), 0);
            else
                safe_hv_store(vol, "updateDate", 10, newSViv(pntr->updateDate), 0);

            safe_hv_store(vol, "dayUse", 6, newSViv(pntr->dayUse), 0);

        }
        else if (pntr->status == VBUSY) {
            *totalBusy += 1;
            qPut(&busyHead, pntr->volid);
        }
        else {
            *totalNotOK += 1;
            qPut(&notokHead, pntr->volid);
        }
    }
}

static void myXDisplayFormat(stats, a_xInfoP, a_servID, a_partID, a_totalOKP,
                             a_totalNotOKP, a_totalBusyP)
    HV *stats;
    volintXInfo *a_xInfoP;
    afs_int32 a_servID;
    afs_int32 a_partID;
    int *a_totalOKP;
    int *a_totalNotOKP;
    int *a_totalBusyP;

{                               /*XDisplayFormat */
    char hostname[256];
    char pname[10];

    HV *stat1 = (HV *) sv_2mortal((SV *) newHV());
    HV *stat2 = (HV *) sv_2mortal((SV *) newHV());
    HV *stat3 = (HV *) sv_2mortal((SV *) newHV());
    HV *stat4 = (HV *) sv_2mortal((SV *) newHV());
    HV *stat5 = (HV *) sv_2mortal((SV *) newHV());
    HV *stat6 = (HV *) sv_2mortal((SV *) newHV());
    HV *stat7 = (HV *) sv_2mortal((SV *) newHV());
    HV *stat8 = (HV *) sv_2mortal((SV *) newHV());

    /* Fully-detailed listing. */
    safe_hv_store(stats, "status", 6, newSViv(a_xInfoP->status), 0);
    safe_hv_store(stats, "volid", 5, newSViv(a_xInfoP->volid), 0);
    if (a_xInfoP->status == VOK) {
        /* Volume's status is OK - all the fields are valid. */

        if (a_xInfoP->type == 0)
            safe_hv_store(stats, "type", 4, newSVpv("RW", 2), 0);
        if (a_xInfoP->type == 1)
            safe_hv_store(stats, "type", 4, newSVpv("RO", 2), 0);
        if (a_xInfoP->type == 2)
            safe_hv_store(stats, "type", 4, newSVpv("BK", 2), 0);

        safe_hv_store(stats, "size", 4, newSViv(a_xInfoP->size), 0);
        safe_hv_store(stats, "filecount", 9, newSViv(a_xInfoP->filecount), 0);

        if (a_xInfoP->inUse == 1) {
            safe_hv_store(stats, "inUse", 5, newSVpv("On-line", 7), 0);
            (*a_totalOKP)++;
        }
        else {
            safe_hv_store(stats, "inUse", 5, newSVpv("Off-line", 8), 0);
            (*a_totalNotOKP)++;
        }

        MapPartIdIntoName(a_partID, pname);
        strcpy(hostname, (char *) hostutil_GetNameByINet(a_servID));
        safe_hv_store(stats, "server", 6, newSVpv(hostname, strlen((char *) hostname)), 0);
        safe_hv_store(stats, "partition", 9, newSVpv(pname, strlen(pname)), 0);

src/AFS.xs  view on Meta::CPAN

        safe_hv_store(stat3, "fileDiffAuthor", 12,
                 newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0]), 0);
        safe_hv_store(stat3, "dirSameAuthor", 11,
                 newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0]), 0);
        safe_hv_store(stat3, "dirDiffAuthor", 11,
                 newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]), 0);
        safe_hv_store(stats, "0-60sec", 7, newRV_inc((SV *) (stat3)), 0);

        safe_hv_store(stat4, "fileSameAuthor", 12,
                 newSViv(a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1]), 0);
        safe_hv_store(stat4, "fileDiffAuthor", 12,
                 newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1]), 0);
        safe_hv_store(stat4, "dirSameAuthor", 11,
                 newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1]), 0);
        safe_hv_store(stat4, "dirDiffAuthor", 11,
                 newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]), 0);
        safe_hv_store(stats, "1-10min", 7, newRV_inc((SV *) (stat4)), 0);

        safe_hv_store(stat5, "fileSameAuthor", 12,
                 newSViv(a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2]), 0);
        safe_hv_store(stat5, "fileDiffAuthor", 12,
                 newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2]), 0);
        safe_hv_store(stat5, "dirSameAuthor", 11,
                 newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2]), 0);
        safe_hv_store(stat5, "dirDiffAuthor", 11,
                 newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]), 0);
        safe_hv_store(stats, "10min-1hr", 9, newRV_inc((SV *) (stat5)), 0);

        safe_hv_store(stat6, "fileSameAuthor", 12,
                 newSViv(a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3]), 0);
        safe_hv_store(stat6, "fileDiffAuthor", 12,
                 newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3]), 0);
        safe_hv_store(stat6, "dirSameAuthor", 11,
                 newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3]), 0);
        safe_hv_store(stat6, "dirDiffAuthor", 11,
                 newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]), 0);
        safe_hv_store(stats, "1hr-1day", 8, newRV_inc((SV *) (stat6)), 0);

        safe_hv_store(stat7, "fileSameAuthor", 12,
                 newSViv(a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4]), 0);
        safe_hv_store(stat7, "fileDiffAuthor", 12,
                 newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4]), 0);
        safe_hv_store(stat7, "dirSameAuthor", 11,
                 newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4]), 0);
        safe_hv_store(stat7, "dirDiffAuthor", 11,
                 newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]), 0);
        safe_hv_store(stats, "1day-1wk", 8, newRV_inc((SV *) (stat7)), 0);

        safe_hv_store(stat8, "fileSameAuthor", 12,
                 newSViv(a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5]), 0);
        safe_hv_store(stat8, "fileDiffAuthor", 12,
                 newSViv(a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5]), 0);
        safe_hv_store(stat8, "dirSameAuthor", 11,
                 newSViv(a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5]), 0);
        safe_hv_store(stat8, "dirDiffAuthor", 11,
                 newSViv(a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]), 0);
        safe_hv_store(stats, ">1wk", 4, newRV_inc((SV *) (stat8)), 0);
    }                       /*Volume status OK */
    else if (a_xInfoP->status == VBUSY) {
        (*a_totalBusyP)++;
        qPut(&busyHead, a_xInfoP->volid);
    }                       /*Busy volume */
    else {
        (*a_totalNotOKP)++;
        qPut(&notokHead, a_xInfoP->volid);
    }                       /*Screwed volume */
}                           /*myXDisplayFormat */

static void VolumeStats(volinfo, pntr, entry, server, part, voltype)
    HV *volinfo;
    volintInfo *pntr;
    struct nvldbentry *entry;
    int voltype;
    afs_int32 server, part;
{
    int totalOK, totalNotOK, totalBusy;

    myDisplayFormat(volinfo, pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0);
    return;
}

static void DisplayVolumes(partition, server, part, pntr, count, fast)
    HV *partition;
    afs_int32 server, part;
    volintInfo *pntr;
    afs_int32 count, fast;
{
    int totalOK, totalNotOK, totalBusy, i;
    char buff[32];

    totalOK = 0;
    totalNotOK = 0;
    totalBusy = 0;
    qInit(&busyHead);
    qInit(&notokHead);
    for (i = 0; i < count; i++) {
        HV *vol = (HV *) sv_2mortal((SV *) newHV());
        myDisplayFormat(vol, pntr, server, part, &totalOK, &totalNotOK, &totalBusy, fast);
        if (pntr->status == VOK) {
            safe_hv_store(partition, pntr->name, strlen(pntr->name), newRV_inc((SV *) (vol)), 0);
        }
        else if (pntr->status == VBUSY) {
            sprintf(buff, "volume_busy_%d", i);
            safe_hv_store(partition, buff, strlen(buff), newRV_inc((SV *) (vol)), 0);
            /* fprintf(STDERR, "DEBUG-1: %s %d\n", buff, strlen(buff)); */
        }
        else {
            sprintf(buff, "volume_notok_%d", i);
            safe_hv_store(partition, buff, strlen(buff), newRV_inc((SV *) (vol)), 0);
            /* fprintf(STDERR, "DEBUG-2: %s %d\n", buff, strlen(buff)); */
        }
        pntr++;
    }
    if (!fast) {
        safe_hv_store(partition, " totalOK", 8, newSViv(totalOK), 0);
        safe_hv_store(partition, " totalBusy", 10, newSViv(totalBusy), 0);
        safe_hv_store(partition, " totalNotOK", 11, newSViv(totalNotOK), 0);
    }
}

static void XDisplayVolumes(part, a_servID, a_partID, a_xInfoP, a_count)
    HV *part;
    afs_int32 a_servID;
    afs_int32 a_partID;
    volintXInfo *a_xInfoP;
    afs_int32 a_count;

{                               /*XDisplayVolumes */

    int totalOK;                /*Total OK volumes */
    int totalNotOK;             /*Total screwed volumes */
    int totalBusy;              /*Total busy volumes */
    int i;                      /*Loop variable */
    char buff[32];

    /* Initialize counters and (global!!) queues.*/
    totalOK = 0;
    totalNotOK = 0;
    totalBusy = 0;
    qInit(&busyHead);
    qInit(&notokHead);

    /* Display each volume in the list.*/
    for (i = 0; i < a_count; i++) {
        HV *vol = (HV *) sv_2mortal((SV *) newHV());
        myXDisplayFormat(vol,
                         a_xInfoP,
                         a_servID,
                         a_partID, &totalOK, &totalNotOK, &totalBusy);
        if (a_xInfoP->status == VOK) {
            safe_hv_store(part, a_xInfoP->name, strlen(a_xInfoP->name), newRV_inc((SV *) (vol)), 0);
        }
        else if (a_xInfoP->status == VBUSY) {
            sprintf(buff, "volume_busy_%d", i);
            safe_hv_store(part, buff, strlen(buff), newRV_inc((SV *) (vol)), 0);
            /* fprintf(STDERR, "DEBUG-1: %s %d\n", buff, strlen(buff)); */
        }
        else {
            sprintf(buff, "volume_notok_%d", i);
            safe_hv_store(part, buff, strlen(buff), newRV_inc((SV *) (vol)), 0);
            /* fprintf(STDERR, "DEBUG-2: %s %d\n", buff, strlen(buff)); */
        }
        a_xInfoP++;
    }

    /* If any volumes were found to be busy or screwed, display them.*/
    safe_hv_store(part, " totalOK", 8, newSViv(totalOK), 0);
    safe_hv_store(part, " totalBusy", 10, newSViv(totalBusy), 0);
    safe_hv_store(part, " totalNotOK", 11, newSViv(totalNotOK), 0);
}                               /*XDisplayVolumes */
/* end of helper functions for VOS class */


/* helper functions for VLDB class: */

void myEnumerateEntry(stats, entry)
    HV *stats;
    struct nvldbentry *entry;
{
    int i;
    char pname[10];
    char hostname[256];
    int isMixed = 0;
    AV *av = (AV *) sv_2mortal((SV *) newAV());

    if (entry->flags & RW_EXISTS)
        safe_hv_store(stats, "RWrite", 6, newSViv(entry->volumeId[RWVOL]), 0);
    if (entry->flags & RO_EXISTS)
        safe_hv_store(stats, "ROnly", 5, newSViv(entry->volumeId[ROVOL]), 0);
    if (entry->flags & BACK_EXISTS)
        safe_hv_store(stats, "Backup", 6, newSViv(entry->volumeId[BACKVOL]), 0);
    if ((entry->cloneId != 0) && (entry->flags & RO_EXISTS))
        safe_hv_store(stats, "cloneId", 7, newSViv(entry->cloneId), 0);

    safe_hv_store(stats, "nServers", 8, newSViv(entry->nServers), 0);

    for (i = 0; i < entry->nServers; i++) {
        if (entry->serverFlags[i] & NEW_REPSITE)
            isMixed = 1;
    }

    for (i = 0; i < entry->nServers; i++) {
        HV *server = (HV *) sv_2mortal((SV *) newHV());
        MapPartIdIntoName(entry->serverPartition[i], pname);
        strcpy(hostname, (char *) hostutil_GetNameByINet(entry->serverNumber[i]));
        safe_hv_store(server, "name", 4, newSVpv(hostname, strlen((char *) hostname)), 0);
        safe_hv_store(server, "partition", 9, newSVpv(pname, strlen((char *) pname)), 0);

        safe_hv_store(server, "serverFlags", 11, newSViv(entry->serverFlags[i]), 0);

        if (entry->serverFlags[i] & ITSRWVOL)
            safe_hv_store(server, "type", 4, newSVpv("RW", 2), 0);
        else
            safe_hv_store(server, "type", 4, newSVpv("RO", 2), 0);

        if (isMixed) {
            if (entry->serverFlags[i] & NEW_REPSITE)
                safe_hv_store(server, "release", 7, newSVpv("New release", 11), 0);
            else
                safe_hv_store(server, "release", 7, newSVpv("Old release", 11), 0);
        }
        else {
            if (entry->serverFlags[i] & RO_DONTUSE)
                safe_hv_store(server, "release", 7, newSVpv("Not released", 12), 0);
        }
        av_push(av, newRV_inc((SV *) (server)));

src/AFS.xs  view on Meta::CPAN

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



( run in 1.668 second using v1.01-cache-2.11-cpan-98e64b0badf )