2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
15 #ifdef IGNORE_SOME_GCC_WARNINGS
16 # pragma GCC diagnostic warning "-Wimplicit-function-declaration"
20 #include <WINNT/afsreg.h>
24 #include <sys/statfs.h>
29 #include <rx/rx_queue.h>
32 #include <rx/rx_globals.h>
34 #include <afs/vlserver.h>
35 #include <afs/cellconfig.h>
37 #include <afs/afsutil.h>
39 #include <afs/afsint.h>
44 #include <afs/ihandle.h>
45 #include <afs/vnode.h>
46 #include <afs/volume.h>
47 #include <afs/com_err.h>
51 #include "volser_internal.h"
52 #include "volser_prototypes.h"
53 #include "vsutils_prototypes.h"
54 #include "lockprocs_prototypes.h"
56 #ifdef HAVE_POSIX_REGEX
60 /* Local Prototypes */
61 int PrintDiagnostics(char *astring, afs_int32 acode);
62 int GetVolumeInfo(afs_uint32 volid, afs_uint32 *server, afs_int32 *part,
63 afs_int32 *voltype, struct nvldbentry *rentry);
75 #define COMMONPARMS cmd_Seek(ts, 12);\
76 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
77 cmd_AddParmAlias(ts, 12, "-c"); /* original -cell option */ \
78 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");\
79 cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
80 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
81 cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
82 cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL, "don't resolve addresses"); \
83 cmd_AddParm(ts, "-config", CMD_SINGLE, CMD_OPTIONAL, "config location"); \
85 #define ERROR_EXIT(code) do { \
91 extern struct ubik_client *cstruct;
94 static struct tqHead busyHead, notokHead;
97 qInit(struct tqHead *ahead)
99 memset(ahead, 0, sizeof(struct tqHead));
105 qPut(struct tqHead *ahead, afs_uint32 volid)
109 elem = malloc(sizeof(struct tqElem));
110 elem->next = ahead->next;
118 qGet(struct tqHead *ahead, afs_uint32 *volid)
122 if (ahead->count <= 0)
124 *volid = ahead->next->volid;
126 ahead->next = tmp->next;
132 /* returns 1 if <filename> exists else 0 */
134 FileExists(char *filename)
140 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
144 code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
152 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
154 VolNameOK(char *name)
159 total = strlen(name);
160 if (!strcmp(&name[total - 9], ".readonly")) {
162 } else if (!strcmp(&name[total - 7], ".backup")) {
169 /* return 1 if name is a number else 0 */
171 IsNumeric(char *name)
180 for (i = 0; i < len; i++) {
181 if (*ptr < '0' || *ptr > '9') {
193 * Parse a server dotted address and return the address in network byte order
196 GetServerNoresolve(char *aname)
202 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
204 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
205 addr = htonl(addr); /* convert to network byte order */
211 * Parse a server name/address and return the address in network byte order
214 GetServer(char *aname)
217 afs_uint32 addr; /* in network byte order */
219 char hostname[MAXHOSTCHARS];
221 if ((addr = GetServerNoresolve(aname)) == 0) {
222 th = gethostbyname(aname);
225 memcpy(&addr, th->h_addr, sizeof(addr));
228 if (rx_IsLoopbackAddr(ntohl(addr))) { /* local host */
229 code = gethostname(hostname, MAXHOSTCHARS);
232 th = gethostbyname(hostname);
235 memcpy(&addr, th->h_addr, sizeof(addr));
242 GetVolumeType(char *aname)
245 if (!strcmp(aname, "ro"))
247 else if (!strcmp(aname, "rw"))
249 else if (!strcmp(aname, "bk"))
256 IsPartValid(afs_int32 partId, afs_uint32 server, afs_int32 *code)
258 struct partList dummyPartList;
264 *code = UV_ListPartitions(server, &dummyPartList, &cnt);
267 for (i = 0; i < cnt; i++) {
268 if (dummyPartList.partFlags[i] & PARTVALID)
269 if (dummyPartList.partId[i] == partId)
277 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
278 * associated with <call> */
280 SendFile(usd_handle_t ufd, struct rx_call *call, long blksize)
282 char *buffer = (char *)0;
286 buffer = malloc(blksize);
288 fprintf(STDERR, "malloc failed\n");
293 #if !defined(AFS_NT40_ENV) && !defined(AFS_PTHREAD_ENV)
294 /* Only for this for non-NT, non-pthread. For NT, we can't select on
295 * non-socket FDs. For pthread environments, we don't need to select at
296 * all, since the following read() will block. */
299 FD_SET((intptr_t)(ufd->handle), &in);
300 /* don't timeout if read blocks */
301 IOMGR_Select(((intptr_t)(ufd->handle)) + 1, &in, 0, 0, 0);
303 error = USD_READ(ufd, buffer, blksize, &nbytes);
305 fprintf(STDERR, "File system read failed: %s\n",
306 afs_error_message(error));
313 if (rx_Write(call, buffer, nbytes) != nbytes) {
323 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
324 * writes it out to the volume. */
326 WriteData(struct rx_call *call, void *rock)
328 char *filename = (char *) rock;
331 afs_int32 error, code;
333 afs_int64 currOffset;
339 if (!filename || !*filename) {
340 usd_StandardInput(&ufd);
344 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
347 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
350 fprintf(STDERR, "Could not access file '%s': %s\n", filename,
351 afs_error_message(code));
355 /* test if we have a valid dump */
356 USD_SEEK(ufd, 0, SEEK_END, &currOffset);
357 USD_SEEK(ufd, currOffset - sizeof(afs_uint32), SEEK_SET, &currOffset);
358 USD_READ(ufd, (char *)&buffer, sizeof(afs_uint32), &got);
359 if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
360 fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
364 USD_SEEK(ufd, 0, SEEK_SET, &currOffset);
366 code = SendFile(ufd, call, blksize);
373 code = USD_CLOSE(ufd);
375 fprintf(STDERR, "Could not close dump file %s\n",
376 (filename && *filename) ? filename : "STDOUT");
384 /* Receive data from <call> stream into file associated
385 * with <fd> <blksize>
388 ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize)
392 afs_uint32 bytesleft, w;
395 buffer = malloc(blksize);
397 fprintf(STDERR, "memory allocation failed\n");
401 while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {
402 for (bytesleft = bytesread; bytesleft; bytesleft -= w) {
403 #if !defined(AFS_NT40_ENV) && !defined(AFS_PTHREAD_ENV)
404 /* Only for this for non-NT, non-pthread. For NT, we can't select
405 * on non-socket FDs. For pthread environments, we don't need to
406 * select at all, since the following write() will block. */
409 FD_SET((intptr_t)(ufd->handle), &out);
410 /* don't timeout if write blocks */
411 IOMGR_Select(((intptr_t)(ufd->handle)) + 1, 0, &out, 0, 0);
414 USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
416 fprintf(STDERR, "File system write failed: %s\n",
417 afs_error_message(error));
430 DumpFunction(struct rx_call *call, void *rock)
432 char *filename = (char *)rock;
433 usd_handle_t ufd; /* default is to stdout */
434 afs_int32 error = 0, code;
439 /* Open the output file */
440 if (!filename || !*filename) {
441 usd_StandardOutput(&ufd);
446 usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
450 code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
453 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
456 fprintf(STDERR, "Could not create file '%s': %s\n", filename,
457 afs_error_message(code));
458 ERROR_EXIT(VOLSERBADOP);
462 code = ReceiveFile(ufd, call, blksize);
467 /* Close the output file */
469 code = USD_CLOSE(ufd);
471 fprintf(STDERR, "Could not close dump file %s\n",
472 (filename && *filename) ? filename : "STDIN");
482 DisplayFormat(volintInfo *pntr, afs_uint32 server, afs_int32 part,
483 int *totalOK, int *totalNotOK, int *totalBusy, int fast,
484 int longlist, int disp)
490 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
491 } else if (longlist) {
492 if (pntr->status == VOK) {
493 fprintf(STDOUT, "%-32s ", pntr->name);
494 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
496 fprintf(STDOUT, "RW ");
498 fprintf(STDOUT, "RO ");
500 fprintf(STDOUT, "BK ");
501 fprintf(STDOUT, "%10d K ", pntr->size);
502 if (pntr->inUse == 1) {
503 fprintf(STDOUT, "On-line");
506 fprintf(STDOUT, "Off-line");
509 if (pntr->needsSalvaged == 1)
510 fprintf(STDOUT, "**needs salvage**");
511 fprintf(STDOUT, "\n");
512 MapPartIdIntoName(part, pname);
513 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
515 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
516 (unsigned long)pntr->parentID,
517 (unsigned long)pntr->cloneID,
518 (unsigned long)pntr->backupID);
519 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
520 t = pntr->creationDate;
521 fprintf(STDOUT, " Creation %s",
524 fprintf(STDOUT, " Copy %s",
527 t = pntr->backupDate;
529 fprintf(STDOUT, " Backup Never\n");
531 fprintf(STDOUT, " Backup %s",
534 t = pntr->accessDate;
536 fprintf(STDOUT, " Last Access %s",
539 t = pntr->updateDate;
541 fprintf(STDOUT, " Last Update Never\n");
543 fprintf(STDOUT, " Last Update %s",
546 " %d accesses in the past day (i.e., vnode references)\n",
548 } else if (pntr->status == VBUSY) {
550 qPut(&busyHead, pntr->volid);
552 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
553 (unsigned long)pntr->volid);
556 qPut(¬okHead, pntr->volid);
558 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
559 (unsigned long)pntr->volid);
561 fprintf(STDOUT, "\n");
562 } else { /* default listing */
563 if (pntr->status == VOK) {
564 fprintf(STDOUT, "%-32s ", pntr->name);
565 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
567 fprintf(STDOUT, "RW ");
569 fprintf(STDOUT, "RO ");
571 fprintf(STDOUT, "BK ");
572 fprintf(STDOUT, "%10d K ", pntr->size);
573 if (pntr->inUse == 1) {
574 fprintf(STDOUT, "On-line");
577 fprintf(STDOUT, "Off-line");
580 if (pntr->needsSalvaged == 1)
581 fprintf(STDOUT, "**needs salvage**");
582 fprintf(STDOUT, "\n");
583 } else if (pntr->status == VBUSY) {
585 qPut(&busyHead, pntr->volid);
587 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
588 (unsigned long)pntr->volid);
591 qPut(¬okHead, pntr->volid);
593 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
594 (unsigned long)pntr->volid);
599 /*------------------------------------------------------------------------
600 * PRIVATE XDisplayFormat
603 * Display the contents of one extended volume info structure.
606 * a_xInfoP : Ptr to extended volume info struct to print.
607 * a_servID : Server ID to print.
608 * a_partID : Partition ID to print.
609 * a_totalOKP : Ptr to total-OK counter.
610 * a_totalNotOKP : Ptr to total-screwed counter.
611 * a_totalBusyP : Ptr to total-busy counter.
612 * a_fast : Fast listing?
613 * a_int32 : Int32 listing?
614 * a_showProblems : Show volume problems?
620 * Nothing interesting.
624 *------------------------------------------------------------------------*/
627 XDisplayFormat(volintXInfo *a_xInfoP, afs_uint32 a_servID, afs_int32 a_partID,
628 int *a_totalOKP, int *a_totalNotOKP, int *a_totalBusyP,
629 int a_fast, int a_int32, int a_showProblems)
630 { /*XDisplayFormat */
638 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
639 } else if (a_int32) {
641 * Fully-detailed listing.
643 if (a_xInfoP->status == VOK) {
645 * Volume's status is OK - all the fields are valid.
647 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
648 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
649 if (a_xInfoP->type == 0)
650 fprintf(STDOUT, "RW ");
651 if (a_xInfoP->type == 1)
652 fprintf(STDOUT, "RO ");
653 if (a_xInfoP->type == 2)
654 fprintf(STDOUT, "BK ");
655 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
656 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
657 if (a_xInfoP->inUse == 1) {
658 fprintf(STDOUT, "On-line");
661 fprintf(STDOUT, "Off-line");
664 fprintf(STDOUT, "\n");
665 MapPartIdIntoName(a_partID, pname);
666 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
668 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
669 (unsigned long)a_xInfoP->parentID,
670 (unsigned long)a_xInfoP->cloneID,
671 (unsigned long)a_xInfoP->backupID);
672 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
674 t = a_xInfoP->creationDate;
675 fprintf(STDOUT, " Creation %s",
678 t = a_xInfoP->copyDate;
679 fprintf(STDOUT, " Copy %s",
682 t = a_xInfoP->backupDate;
684 fprintf(STDOUT, " Backup Never\n");
686 fprintf(STDOUT, " Backup %s",
689 t = a_xInfoP->accessDate;
691 fprintf(STDOUT, " Last Access %s",
694 t = a_xInfoP->updateDate;
696 fprintf(STDOUT, " Last Update Never\n");
698 fprintf(STDOUT, " Last Update %s",
701 " %d accesses in the past day (i.e., vnode references)\n",
705 * Print all the read/write and authorship stats.
707 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
709 " |-------------------------------------------|\n");
711 " | Same Network | Diff Network |\n");
713 " |----------|----------|----------|----------|\n");
715 " | Total | Auth | Total | Auth |\n");
717 " |----------|----------|----------|----------|\n");
718 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
719 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
720 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
721 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
722 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
723 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
724 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
725 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
726 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
727 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
729 " |-------------------------------------------|\n\n");
732 " Writes Affecting Authorship\n");
734 " |-------------------------------------------|\n");
736 " | File Authorship | Directory Authorship|\n");
738 " |----------|----------|----------|----------|\n");
740 " | Same | Diff | Same | Diff |\n");
742 " |----------|----------|----------|----------|\n");
743 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
744 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
745 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
746 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
747 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
748 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
749 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
750 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
751 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
752 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
753 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
754 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
755 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
756 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
757 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
758 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
759 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
760 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
761 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
762 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
763 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
764 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
765 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
766 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
767 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
768 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
769 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
770 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
771 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
772 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
774 " |-------------------------------------------|\n");
775 } /*Volume status OK */
776 else if (a_xInfoP->status == VBUSY) {
778 qPut(&busyHead, a_xInfoP->volid);
780 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
781 (unsigned long)a_xInfoP->volid);
785 qPut(¬okHead, a_xInfoP->volid);
787 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
788 (unsigned long)a_xInfoP->volid);
789 } /*Screwed volume */
790 fprintf(STDOUT, "\n");
796 if (a_xInfoP->status == VOK) {
797 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
798 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
799 if (a_xInfoP->type == 0)
800 fprintf(STDOUT, "RW ");
801 if (a_xInfoP->type == 1)
802 fprintf(STDOUT, "RO ");
803 if (a_xInfoP->type == 2)
804 fprintf(STDOUT, "BK ");
805 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
806 if (a_xInfoP->inUse == 1) {
807 fprintf(STDOUT, "On-line");
810 fprintf(STDOUT, "Off-line");
813 fprintf(STDOUT, "\n");
815 else if (a_xInfoP->status == VBUSY) {
817 qPut(&busyHead, a_xInfoP->volid);
819 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
820 (unsigned long)a_xInfoP->volid);
824 qPut(¬okHead, a_xInfoP->volid);
826 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
827 (unsigned long)a_xInfoP->volid);
828 } /*Screwed volume */
829 } /*Default listing */
830 } /*XDisplayFormat */
832 /*------------------------------------------------------------------------
833 * PRIVATE XDisplayFormat2
836 * Display the formated contents of one extended volume info structure.
839 * a_xInfoP : Ptr to extended volume info struct to print.
840 * a_servID : Server ID to print.
841 * a_partID : Partition ID to print.
842 * a_totalOKP : Ptr to total-OK counter.
843 * a_totalNotOKP : Ptr to total-screwed counter.
844 * a_totalBusyP : Ptr to total-busy counter.
845 * a_fast : Fast listing?
846 * a_int32 : Int32 listing?
847 * a_showProblems : Show volume problems?
853 * Nothing interesting.
857 *------------------------------------------------------------------------*/
860 XDisplayFormat2(volintXInfo *a_xInfoP, afs_uint32 a_servID, afs_int32 a_partID,
861 int *a_totalOKP, int *a_totalNotOKP, int *a_totalBusyP,
862 int a_fast, int a_int32, int a_showProblems)
863 { /*XDisplayFormat */
869 fprintf(STDOUT, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP->volid);
870 } else if (a_int32) {
872 * Fully-detailed listing.
874 if (a_xInfoP->status == VOK) {
876 * Volume's status is OK - all the fields are valid.
879 static long server_cache = -1, partition_cache = -1;
880 static char hostname[256], address[32], pname[16];
881 int i,ai[] = {VOLINT_STATS_TIME_IDX_0,VOLINT_STATS_TIME_IDX_1,VOLINT_STATS_TIME_IDX_2,
882 VOLINT_STATS_TIME_IDX_3,VOLINT_STATS_TIME_IDX_4,VOLINT_STATS_TIME_IDX_5};
884 if (a_servID != server_cache) {
888 strcpy(hostname, hostutil_GetNameByINet(a_servID));
889 strcpy(address, inet_ntoa(s));
890 server_cache = a_servID;
892 if (a_partID != partition_cache) {
893 MapPartIdIntoName(a_partID, pname);
894 partition_cache = a_partID;
897 fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name);
898 fprintf(STDOUT, "id\t\t%lu\n", afs_printable_uint32_lu(a_xInfoP->volid));
899 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
900 fprintf(STDOUT, "part\t\t%s\n", pname);
901 fprintf(STDOUT, "status\t\tOK\n");
902 fprintf(STDOUT, "backupID\t%lu\n",
903 afs_printable_uint32_lu(a_xInfoP->backupID));
904 fprintf(STDOUT, "parentID\t%lu\n",
905 afs_printable_uint32_lu(a_xInfoP->parentID));
906 fprintf(STDOUT, "cloneID\t\t%lu\n",
907 afs_printable_uint32_lu(a_xInfoP->cloneID));
908 fprintf(STDOUT, "inUse\t\t%s\n", a_xInfoP->inUse ? "Y" : "N");
909 switch (a_xInfoP->type) {
911 fprintf(STDOUT, "type\t\tRW\n");
914 fprintf(STDOUT, "type\t\tRO\n");
917 fprintf(STDOUT, "type\t\tBK\n");
920 fprintf(STDOUT, "type\t\t?\n");
923 t = a_xInfoP->creationDate;
924 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
925 afs_printable_uint32_lu(a_xInfoP->creationDate),
928 t = a_xInfoP->accessDate;
929 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
930 afs_printable_uint32_lu(a_xInfoP->accessDate),
933 t = a_xInfoP->updateDate;
934 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
935 afs_printable_uint32_lu(a_xInfoP->updateDate),
938 t = a_xInfoP->backupDate;
939 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
940 afs_printable_uint32_lu(a_xInfoP->backupDate),
943 t = a_xInfoP->copyDate;
944 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
945 afs_printable_uint32_lu(a_xInfoP->copyDate),
948 fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
949 fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
951 fprintf(STDOUT, "filecount\t%u\n", a_xInfoP->filecount);
952 fprintf(STDOUT, "dayUse\t\t%u\n", a_xInfoP->dayUse);
956 fprintf(STDOUT,"reads_same_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]);
957 fprintf(STDOUT,"reads_same_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]);
958 fprintf(STDOUT,"reads_diff_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]);
959 fprintf(STDOUT,"reads_diff_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
961 fprintf(STDOUT,"writes_same_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]);
962 fprintf(STDOUT,"writes_same_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]);
963 fprintf(STDOUT,"writes_diff_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]);
964 fprintf(STDOUT,"writes_diff_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
968 fprintf(STDOUT,"file_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileSameAuthor[ai[i]]);
969 fprintf(STDOUT,"file_diff_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileDiffAuthor[ai[i]]);
970 fprintf(STDOUT,"dir_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirSameAuthor[ai[i]]);
971 fprintf(STDOUT,"dir_dif_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirDiffAuthor[ai[i]]);
974 } /*Volume status OK */
975 else if (a_xInfoP->status == VBUSY) {
977 qPut(&busyHead, a_xInfoP->volid);
979 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
980 (unsigned long)a_xInfoP->volid);
984 qPut(¬okHead, a_xInfoP->volid);
986 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
987 (unsigned long)a_xInfoP->volid);
988 } /*Screwed volume */
994 if (a_xInfoP->status == VOK) {
995 fprintf(STDOUT, "name\t%-32s\n", a_xInfoP->name);
996 fprintf(STDOUT, "volID\t%10lu\n", (unsigned long)a_xInfoP->volid);
997 if (a_xInfoP->type == 0)
998 fprintf(STDOUT, "type\tRW\n");
999 if (a_xInfoP->type == 1)
1000 fprintf(STDOUT, "type\tRO\n");
1001 if (a_xInfoP->type == 2)
1002 fprintf(STDOUT, "type\tBK\n");
1003 fprintf(STDOUT, "size\t%10dK\n", a_xInfoP->size);
1005 fprintf(STDOUT, "inUse\t%d\n",a_xInfoP->inUse);
1006 if (a_xInfoP->inUse == 1)
1012 else if (a_xInfoP->status == VBUSY) {
1014 qPut(&busyHead, a_xInfoP->volid);
1016 fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
1017 (unsigned long)a_xInfoP->volid);
1021 qPut(¬okHead, a_xInfoP->volid);
1023 fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
1024 (unsigned long)a_xInfoP->volid);
1025 } /*Screwed volume */
1026 } /*Default listing */
1027 } /*XDisplayFormat */
1030 DisplayFormat2(long server, long partition, volintInfo *pntr)
1032 static long server_cache = -1, partition_cache = -1;
1033 static char hostname[256], address[32], pname[16];
1036 if (server != server_cache) {
1040 strcpy(hostname, hostutil_GetNameByINet(server));
1041 strcpy(address, inet_ntoa(s));
1042 server_cache = server;
1044 if (partition != partition_cache) {
1045 MapPartIdIntoName(partition, pname);
1046 partition_cache = partition;
1049 if (pntr->status == VOK)
1050 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
1052 fprintf(STDOUT, "id\t\t%lu\n",
1053 afs_printable_uint32_lu(pntr->volid));
1054 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
1055 fprintf(STDOUT, "part\t\t%s\n", pname);
1056 switch (pntr->status) {
1058 fprintf(STDOUT, "status\t\tOK\n");
1061 fprintf(STDOUT, "status\t\tBUSY\n");
1064 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
1067 fprintf(STDOUT, "backupID\t%lu\n",
1068 afs_printable_uint32_lu(pntr->backupID));
1069 fprintf(STDOUT, "parentID\t%lu\n",
1070 afs_printable_uint32_lu(pntr->parentID));
1071 fprintf(STDOUT, "cloneID\t\t%lu\n",
1072 afs_printable_uint32_lu(pntr->cloneID));
1073 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
1074 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
1075 /* 0xD3 is from afs/volume.h since I had trouble including the file */
1076 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
1077 switch (pntr->type) {
1079 fprintf(STDOUT, "type\t\tRW\n");
1082 fprintf(STDOUT, "type\t\tRO\n");
1085 fprintf(STDOUT, "type\t\tBK\n");
1088 fprintf(STDOUT, "type\t\t?\n");
1091 t = pntr->creationDate;
1092 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
1093 afs_printable_uint32_lu(pntr->creationDate),
1096 t = pntr->accessDate;
1097 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
1098 afs_printable_uint32_lu(pntr->accessDate),
1101 t = pntr->updateDate;
1102 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
1103 afs_printable_uint32_lu(pntr->updateDate),
1106 t = pntr->backupDate;
1107 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
1108 afs_printable_uint32_lu(pntr->backupDate),
1112 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
1113 afs_printable_uint32_lu(pntr->copyDate),
1116 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n",
1117 afs_printable_uint32_lu(pntr->flags));
1118 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
1119 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
1120 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n",
1121 afs_printable_uint32_lu(pntr->spare0));
1122 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
1123 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
1124 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n",
1125 afs_printable_uint32_lu(pntr->spare1));
1126 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n",
1127 afs_printable_uint32_lu(pntr->spare2));
1128 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n",
1129 afs_printable_uint32_lu(pntr->spare3));
1134 DisplayVolumes2(long server, long partition, volintInfo *pntr, long count)
1138 for (i = 0; i < count; i++) {
1139 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1140 DisplayFormat2(server, partition, pntr);
1141 fprintf(STDOUT, "END_OF_ENTRY\n\n");
1148 DisplayVolumes(afs_uint32 server, afs_int32 part, volintInfo *pntr,
1149 afs_int32 count, afs_int32 longlist, afs_int32 fast,
1152 int totalOK, totalNotOK, totalBusy, i;
1153 afs_uint32 volid = 0;
1160 for (i = 0; i < count; i++) {
1161 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
1166 while (busyHead.count) {
1167 qGet(&busyHead, &volid);
1168 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1169 (unsigned long)volid);
1173 while (notokHead.count) {
1174 qGet(¬okHead, &volid);
1175 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1176 (unsigned long)volid);
1180 fprintf(STDOUT, "\n");
1183 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
1184 totalOK, totalNotOK, totalBusy);
1188 /*------------------------------------------------------------------------
1189 * PRIVATE XDisplayVolumes
1192 * Display extended volume information.
1195 * a_servID : Pointer to the Rx call we're performing.
1196 * a_partID : Partition for which we want the extended list.
1197 * a_xInfoP : Ptr to extended volume info.
1198 * a_count : Number of volume records contained above.
1199 * a_int32 : Int32 listing generated?
1200 * a_fast : Fast listing generated?
1201 * a_quiet : Quiet listing generated?
1207 * Nothing interesting.
1211 *------------------------------------------------------------------------*/
1214 XDisplayVolumes(afs_uint32 a_servID, afs_int32 a_partID, volintXInfo *a_xInfoP,
1215 afs_int32 a_count, afs_int32 a_int32, afs_int32 a_fast,
1217 { /*XDisplayVolumes */
1219 int totalOK; /*Total OK volumes */
1220 int totalNotOK; /*Total screwed volumes */
1221 int totalBusy; /*Total busy volumes */
1222 int i; /*Loop variable */
1223 afs_uint32 volid = 0; /*Current volume ID */
1226 * Initialize counters and (global!!) queues.
1235 * Display each volume in the list.
1237 for (i = 0; i < a_count; i++) {
1238 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1239 &totalBusy, a_fast, a_int32, 0);
1244 * If any volumes were found to be busy or screwed, display them.
1247 while (busyHead.count) {
1248 qGet(&busyHead, &volid);
1249 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1250 (unsigned long)volid);
1254 while (notokHead.count) {
1255 qGet(¬okHead, &volid);
1256 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1257 (unsigned long)volid);
1262 fprintf(STDOUT, "\n");
1265 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1266 totalOK, totalNotOK, totalBusy);
1270 } /*XDisplayVolumes */
1272 /*------------------------------------------------------------------------
1273 * PRIVATE XDisplayVolumes2
1276 * Display extended formated volume information.
1279 * a_servID : Pointer to the Rx call we're performing.
1280 * a_partID : Partition for which we want the extended list.
1281 * a_xInfoP : Ptr to extended volume info.
1282 * a_count : Number of volume records contained above.
1283 * a_int32 : Int32 listing generated?
1284 * a_fast : Fast listing generated?
1285 * a_quiet : Quiet listing generated?
1291 * Nothing interesting.
1295 *------------------------------------------------------------------------*/
1298 XDisplayVolumes2(afs_uint32 a_servID, afs_int32 a_partID, volintXInfo *a_xInfoP,
1299 afs_int32 a_count, afs_int32 a_int32, afs_int32 a_fast,
1301 { /*XDisplayVolumes */
1303 int totalOK; /*Total OK volumes */
1304 int totalNotOK; /*Total screwed volumes */
1305 int totalBusy; /*Total busy volumes */
1306 int i; /*Loop variable */
1307 afs_uint32 volid = 0; /*Current volume ID */
1310 * Initialize counters and (global!!) queues.
1319 * Display each volume in the list.
1321 for (i = 0; i < a_count; i++) {
1322 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1323 XDisplayFormat2(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1324 &totalBusy, a_fast, a_int32, 0);
1325 fprintf(STDOUT, "END_OF_ENTRY\n");
1330 * If any volumes were found to be busy or screwed, display them.
1333 while (busyHead.count) {
1334 qGet(&busyHead, &volid);
1335 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1336 (unsigned long)volid);
1340 while (notokHead.count) {
1341 qGet(¬okHead, &volid);
1342 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1343 (unsigned long)volid);
1348 fprintf(STDOUT, "\n");
1351 "VOLUMES_ONLINE\t%d\nVOLUMES_OFFLINE\t%d\nVOLUMES_BUSY\t%d\n",
1352 totalOK, totalNotOK, totalBusy);
1356 } /*XDisplayVolumes2 */
1359 /* set <server> and <part> to the correct values depending on
1360 * <voltype> and <entry> */
1362 GetServerAndPart(struct nvldbentry *entry, int voltype, afs_uint32 *server,
1363 afs_int32 *part, int *previdx)
1365 int i, istart, vtype;
1370 /* Doesn't check for non-existance of backup volume */
1371 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1373 istart = 0; /* seach the entire entry */
1376 /* Seach from beginning of entry or pick up where we left off */
1377 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1380 for (i = istart; i < entry->nServers; i++) {
1381 if (entry->serverFlags[i] & vtype) {
1382 *server = entry->serverNumber[i];
1383 *part = entry->serverPartition[i];
1389 /* Didn't find any, return -1 */
1395 PrintLocked(afs_int32 aflags)
1397 afs_int32 flags = aflags & VLOP_ALLOPERS;
1400 fprintf(STDOUT, " Volume is currently LOCKED \n");
1402 if (flags & VLOP_MOVE) {
1403 fprintf(STDOUT, " Volume is locked for a move operation\n");
1405 if (flags & VLOP_RELEASE) {
1406 fprintf(STDOUT, " Volume is locked for a release operation\n");
1408 if (flags & VLOP_BACKUP) {
1409 fprintf(STDOUT, " Volume is locked for a backup operation\n");
1411 if (flags & VLOP_DELETE) {
1412 fprintf(STDOUT, " Volume is locked for a delete/misc operation\n");
1414 if (flags & VLOP_DUMP) {
1415 fprintf(STDOUT, " Volume is locked for a dump/restore operation\n");
1421 PostVolumeStats(struct nvldbentry *entry)
1423 SubEnumerateEntry(entry);
1424 /* Check for VLOP_ALLOPERS */
1425 PrintLocked(entry->flags);
1429 /*------------------------------------------------------------------------
1430 * PRIVATE XVolumeStats
1433 * Display extended volume information.
1436 * a_xInfoP : Ptr to extended volume info.
1437 * a_entryP : Ptr to the volume's VLDB entry.
1438 * a_srvID : Server ID.
1439 * a_partID : Partition ID.
1440 * a_volType : Type of volume to print.
1446 * Nothing interesting.
1450 *------------------------------------------------------------------------*/
1453 XVolumeStats(volintXInfo *a_xInfoP, struct nvldbentry *a_entryP,
1454 afs_int32 a_srvID, afs_int32 a_partID, int a_volType)
1457 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1459 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1460 a_srvID, /*Server ID to print */
1461 a_partID, /*Partition ID to print */
1462 &totalOK, /*Ptr to total-OK counter */
1463 &totalNotOK, /*Ptr to total-screwed counter */
1464 &totalBusy, /*Ptr to total-busy counter */
1465 0, /*Don't do a fast listing */
1466 1, /*Do a long listing */
1467 1); /*Show volume problems */
1473 VolumeStats_int(volintInfo *pntr, struct nvldbentry *entry, afs_uint32 server,
1474 afs_int32 part, int voltype)
1480 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1485 /* command to forcibly remove a volume */
1487 NukeVolume(struct cmd_syndesc *as)
1496 server = GetServer(tp = as->parms[0].items->data);
1498 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1502 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1504 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1508 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1511 PrintError("", err);
1514 "vos: could not parse '%s' as a numeric volume ID", tp);
1519 "vos: forcibly removing all traces of volume %d, please wait...",
1522 code = UV_NukeVolume(server, partID, volID);
1524 fprintf(STDOUT, "done.\n");
1526 fprintf(STDOUT, "failed with code %d.\n", code);
1531 /*------------------------------------------------------------------------
1532 * PRIVATE ExamineVolume
1535 * Routine used to examine a single volume, contacting the VLDB as
1536 * well as the Volume Server.
1539 * as : Ptr to parsed command line arguments.
1542 * 0 for a successful operation,
1543 * Otherwise, one of the ubik or VolServer error values.
1546 * Nothing interesting.
1550 *------------------------------------------------------------------------
1553 ExamineVolume(struct cmd_syndesc *as, void *arock)
1555 struct nvldbentry entry;
1556 afs_int32 vcode = 0;
1557 volintInfo *pntr = (volintInfo *) 0;
1558 volintXInfo *xInfoP = (volintXInfo *) 0;
1560 afs_int32 code, err, error = 0;
1561 int voltype, foundserv = 0, foundentry = 0;
1565 int wantExtendedInfo; /*Do we want extended vol info? */
1566 int isSubEnum=0; /* Keep track whether sub enumerate called. */
1567 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1569 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1572 PrintError("", err);
1574 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1575 as->parms[0].items->data);
1580 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1581 (unsigned long)volid);
1584 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1587 "Could not fetch the entry for volume number %lu from VLDB \n",
1588 (unsigned long)volid);
1592 fprintf(STDOUT, "done\n");
1593 MapHostToNetwork(&entry);
1595 if (entry.volumeId[RWVOL] == volid)
1597 else if (entry.volumeId[BACKVOL] == volid)
1599 else /* (entry.volumeId[ROVOL] == volid) */
1602 do { /* do {...} while (voltype == ROVOL) */
1603 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1604 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1605 * If its a RO vol, get the next RO entry.
1607 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1608 &aserver, &apart, &previdx);
1609 if (previdx == -1) { /* searched all entries */
1611 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1612 as->parms[0].items->data);
1619 /* Get information about the volume from the server */
1621 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1622 hostutil_GetNameByINet(aserver));
1625 if (wantExtendedInfo)
1626 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1628 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1630 fprintf(STDOUT, "done\n");
1634 if (code == ENODEV) {
1635 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1636 /* The VLDB says there is no backup volume and its not on disk */
1637 fprintf(STDERR, "Volume %s does not exist\n",
1638 as->parms[0].items->data);
1642 "Volume does not exist on server %s as indicated by the VLDB\n",
1643 hostutil_GetNameByINet(aserver));
1646 PrintDiagnostics("examine", code);
1648 fprintf(STDOUT, "\n");
1651 if (wantExtendedInfo)
1652 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1653 else if (as->parms[2].items) {
1654 DisplayFormat2(aserver, apart, pntr);
1655 EnumerateEntry(&entry);
1658 VolumeStats_int(pntr, &entry, aserver, apart, voltype);
1660 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1661 /* The VLDB says there is no backup volume yet we found one on disk */
1662 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1663 as->parms[0].items->data);
1672 } while (voltype == ROVOL);
1675 fprintf(STDERR, "Dump only information from VLDB\n\n");
1676 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1680 PostVolumeStats(&entry);
1685 /*------------------------------------------------------------------------
1689 * Routine used to change the status of a single volume.
1692 * as : Ptr to parsed command line arguments.
1695 * 0 for a successful operation,
1696 * Otherwise, one of the ubik or VolServer error values.
1699 * Nothing interesting.
1703 *------------------------------------------------------------------------
1706 SetFields(struct cmd_syndesc *as, void *arock)
1708 struct nvldbentry entry;
1711 afs_int32 code, err;
1717 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1720 PrintError("", err);
1722 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1723 as->parms[0].items->data);
1727 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1730 "Could not fetch the entry for volume number %lu from VLDB \n",
1731 (unsigned long)volid);
1734 MapHostToNetwork(&entry);
1736 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1737 if (previdx == -1) {
1738 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1739 as->parms[0].items->data);
1743 init_volintInfo(&info);
1747 if (as->parms[1].items) {
1750 code = util_GetHumanInt32(as->parms[1].items->data, &info.maxquota);
1752 fprintf(STDERR, "invalid quota value\n");
1756 if (as->parms[2].items) {
1761 if (as->parms[3].items) {
1762 /* -clearVolUpCounter */
1767 fprintf(STDERR,"Nothing to set.\n");
1770 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1773 "Could not update volume info fields for volume number %lu\n",
1774 (unsigned long)volid);
1778 /*------------------------------------------------------------------------
1782 * Brings a volume online.
1785 * as : Ptr to parsed command line arguments.
1788 * 0 for a successful operation,
1791 * Nothing interesting.
1795 *------------------------------------------------------------------------
1798 volOnline(struct cmd_syndesc *as, void *arock)
1801 afs_int32 partition;
1803 afs_int32 code, err = 0;
1805 server = GetServer(as->parms[0].items->data);
1807 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1808 as->parms[0].items->data);
1812 partition = volutil_GetPartitionID(as->parms[1].items->data);
1813 if (partition < 0) {
1814 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1815 as->parms[1].items->data);
1819 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1822 PrintError("", err);
1824 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1825 as->parms[0].items->data);
1829 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1832 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1839 /*------------------------------------------------------------------------
1840 * PRIVATE volOffline
1843 * Brings a volume offline.
1846 * as : Ptr to parsed command line arguments.
1849 * 0 for a successful operation,
1852 * Nothing interesting.
1856 *------------------------------------------------------------------------
1859 volOffline(struct cmd_syndesc *as, void *arock)
1862 afs_int32 partition;
1864 afs_int32 code, err = 0;
1865 afs_int32 transflag, sleeptime, transdone;
1867 server = GetServer(as->parms[0].items->data);
1869 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1870 as->parms[0].items->data);
1874 partition = volutil_GetPartitionID(as->parms[1].items->data);
1875 if (partition < 0) {
1876 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1877 as->parms[1].items->data);
1881 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1884 PrintError("", err);
1886 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1887 as->parms[0].items->data);
1891 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1892 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1893 transdone = ((sleeptime || as->parms[4].items) ? 0 /*online */ : VTOutOfService);
1894 if (as->parms[4].items && !as->parms[3].items) {
1895 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1900 UV_SetVolume(server, partition, volid, transflag, transdone,
1903 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1911 CreateVolume(struct cmd_syndesc *as, void *arock)
1915 afs_uint32 volid = 0, rovolid = 0, bkvolid = 0;
1916 afs_uint32 *arovolid;
1918 struct nvldbentry entry;
1923 arovolid = &rovolid;
1926 tserver = GetServer(as->parms[0].items->data);
1928 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1929 as->parms[0].items->data);
1932 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1934 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1935 as->parms[1].items->data);
1938 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1940 PrintError("", code);
1943 "vos : partition %s does not exist on the server\n",
1944 as->parms[1].items->data);
1947 if (!ISNAMEVALID(as->parms[2].items->data)) {
1949 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1950 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1953 if (!VolNameOK(as->parms[2].items->data)) {
1955 "Illegal volume name %s, should not end in .readonly or .backup\n",
1956 as->parms[2].items->data);
1959 if (IsNumeric(as->parms[2].items->data)) {
1960 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1961 as->parms[2].items->data);
1964 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1966 fprintf(STDERR, "Volume %s already exists\n",
1967 as->parms[2].items->data);
1968 PrintDiagnostics("create", code);
1972 if (as->parms[3].items) {
1973 code = util_GetHumanInt32(as->parms[3].items->data, "a);
1975 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1980 if (as->parms[4].items) {
1981 if (!IsNumeric(as->parms[4].items->data)) {
1982 fprintf(STDERR, "vos: Given volume ID %s should be numeric.\n",
1983 as->parms[4].items->data);
1987 code = util_GetUInt32(as->parms[4].items->data, &volid);
1989 fprintf(STDERR, "vos: bad integer specified for volume ID.\n");
1994 if (as->parms[5].items) {
1995 if (!IsNumeric(as->parms[5].items->data)) {
1996 fprintf(STDERR, "vos: Given RO volume ID %s should be numeric.\n",
1997 as->parms[5].items->data);
2001 code = util_GetUInt32(as->parms[5].items->data, &rovolid);
2003 fprintf(STDERR, "vos: bad integer specified for volume ID.\n");
2013 UV_CreateVolume3(tserver, pnum, as->parms[2].items->data, quota, 0,
2014 0, 0, 0, &volid, arovolid, &bkvolid);
2016 PrintDiagnostics("create", code);
2019 MapPartIdIntoName(pnum, part);
2020 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
2021 (unsigned long)volid, part, as->parms[0].items->data);
2028 DeleteAll(struct nvldbentry *entry)
2031 afs_int32 error, code, curserver, curpart;
2034 MapHostToNetwork(entry);
2036 for (i = 0; i < entry->nServers; i++) {
2037 curserver = entry->serverNumber[i];
2038 curpart = entry->serverPartition[i];
2039 if (entry->serverFlags[i] & ITSROVOL) {
2040 volid = entry->volumeId[ROVOL];
2042 volid = entry->volumeId[RWVOL];
2044 code = UV_DeleteVolume(curserver, curpart, volid);
2053 DeleteVolume(struct cmd_syndesc *as, void *arock)
2055 afs_int32 err, code = 0;
2056 afs_uint32 server = 0;
2057 afs_int32 partition = -1;
2062 if (as->parms[0].items) {
2063 server = GetServer(as->parms[0].items->data);
2065 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2066 as->parms[0].items->data);
2071 if (as->parms[1].items) {
2072 partition = volutil_GetPartitionID(as->parms[1].items->data);
2073 if (partition < 0) {
2074 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2075 as->parms[1].items->data);
2079 /* Check for validity of the partition */
2080 if (!IsPartValid(partition, server, &code)) {
2082 PrintError("", code);
2085 "vos : partition %s does not exist on the server\n",
2086 as->parms[1].items->data);
2092 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2094 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
2095 as->parms[2].items->data);
2097 PrintError("", err);
2101 /* If the server or partition option are not complete, try to fill
2102 * them in from the VLDB entry.
2104 if ((partition == -1) || !server) {
2105 struct nvldbentry entry;
2107 code = VLDB_GetEntryByID(volid, -1, &entry);
2110 "Could not fetch the entry for volume %lu from VLDB\n",
2111 (unsigned long)volid);
2112 PrintError("", code);
2116 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
2117 || ((volid == entry.volumeId[BACKVOL])
2118 && (entry.flags & BACK_EXISTS))) {
2119 idx = Lp_GetRwIndex(&entry);
2120 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2121 || ((partition != -1)
2122 && (partition != entry.serverPartition[idx]))) {
2123 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2124 as->parms[2].items->data);
2127 } else if ((volid == entry.volumeId[ROVOL])
2128 && (entry.flags & RO_EXISTS)) {
2129 for (idx = -1, j = 0; j < entry.nServers; j++) {
2130 if (entry.serverFlags[j] != ITSROVOL)
2133 if (((server == 0) || (server == entry.serverNumber[j]))
2134 && ((partition == -1)
2135 || (partition == entry.serverPartition[j]))) {
2138 "VLDB: Volume '%s' matches more than one RO\n",
2139 as->parms[2].items->data);
2146 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2147 as->parms[2].items->data);
2151 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2152 as->parms[2].items->data);
2156 server = htonl(entry.serverNumber[idx]);
2157 partition = entry.serverPartition[idx];
2161 code = UV_DeleteVolume(server, partition, volid);
2163 PrintDiagnostics("remove", code);
2167 MapPartIdIntoName(partition, pname);
2168 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2169 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2173 #define TESTM 0 /* set for move space tests, clear for production */
2175 MoveVolume(struct cmd_syndesc *as, void *arock)
2179 afs_uint32 fromserver, toserver;
2180 afs_int32 frompart, topart;
2181 afs_int32 flags, code, err;
2182 char fromPartName[10], toPartName[10];
2184 struct diskPartition64 partition; /* for space check */
2187 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2190 PrintError("", err);
2192 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2193 as->parms[0].items->data);
2196 fromserver = GetServer(as->parms[1].items->data);
2197 if (fromserver == 0) {
2198 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2199 as->parms[1].items->data);
2202 toserver = GetServer(as->parms[3].items->data);
2203 if (toserver == 0) {
2204 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2205 as->parms[3].items->data);
2208 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2210 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2211 as->parms[2].items->data);
2214 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2216 PrintError("", code);
2219 "vos : partition %s does not exist on the server\n",
2220 as->parms[2].items->data);
2223 topart = volutil_GetPartitionID(as->parms[4].items->data);
2225 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2226 as->parms[4].items->data);
2229 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2231 PrintError("", code);
2234 "vos : partition %s does not exist on the server\n",
2235 as->parms[4].items->data);
2240 if (as->parms[5].items) flags |= RV_NOCLONE;
2243 * check source partition for space to clone volume
2246 MapPartIdIntoName(topart, toPartName);
2247 MapPartIdIntoName(frompart, fromPartName);
2250 * check target partition for space to move volume
2253 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2255 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2259 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2262 p = (volintInfo *) 0;
2263 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2265 fprintf(STDERR, "vos:cannot access volume %lu\n",
2266 (unsigned long)volid);
2270 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2272 if (partition.free <= p->size) {
2274 "vos: no space on target partition %s to move volume %lu\n",
2275 toPartName, (unsigned long)volid);
2282 fprintf(STDOUT, "size test - don't do move\n");
2286 /* successful move still not guaranteed but shoot for it */
2289 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2291 PrintDiagnostics("move", code);
2294 MapPartIdIntoName(topart, toPartName);
2295 MapPartIdIntoName(frompart, fromPartName);
2296 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2297 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2298 as->parms[3].items->data, toPartName);
2304 CopyVolume(struct cmd_syndesc *as, void *arock)
2307 afs_uint32 fromserver, toserver;
2308 afs_int32 frompart, topart, code, err, flags;
2309 char fromPartName[10], toPartName[10], *tovolume;
2310 struct nvldbentry entry;
2311 struct diskPartition64 partition; /* for space check */
2314 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2317 PrintError("", err);
2319 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2320 as->parms[0].items->data);
2323 fromserver = GetServer(as->parms[1].items->data);
2324 if (fromserver == 0) {
2325 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2326 as->parms[1].items->data);
2330 toserver = GetServer(as->parms[4].items->data);
2331 if (toserver == 0) {
2332 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2333 as->parms[4].items->data);
2337 tovolume = as->parms[3].items->data;
2338 if (!ISNAMEVALID(tovolume)) {
2340 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2341 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2344 if (!VolNameOK(tovolume)) {
2346 "Illegal volume name %s, should not end in .readonly or .backup\n",
2350 if (IsNumeric(tovolume)) {
2351 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2355 code = VLDB_GetEntryByName(tovolume, &entry);
2357 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2358 PrintDiagnostics("copy", code);
2362 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2364 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2365 as->parms[2].items->data);
2368 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2370 PrintError("", code);
2373 "vos : partition %s does not exist on the server\n",
2374 as->parms[2].items->data);
2378 topart = volutil_GetPartitionID(as->parms[5].items->data);
2380 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2381 as->parms[5].items->data);
2384 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2386 PrintError("", code);
2389 "vos : partition %s does not exist on the server\n",
2390 as->parms[5].items->data);
2395 if (as->parms[6].items) flags |= RV_OFFLINE;
2396 if (as->parms[7].items) flags |= RV_RDONLY;
2397 if (as->parms[8].items) flags |= RV_NOCLONE;
2399 MapPartIdIntoName(topart, toPartName);
2400 MapPartIdIntoName(frompart, fromPartName);
2403 * check target partition for space to move volume
2406 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2408 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2412 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2415 p = (volintInfo *) 0;
2416 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2418 fprintf(STDERR, "vos:cannot access volume %lu\n",
2419 (unsigned long)volid);
2423 if (partition.free <= p->size) {
2425 "vos: no space on target partition %s to copy volume %lu\n",
2426 toPartName, (unsigned long)volid);
2432 /* successful copy still not guaranteed but shoot for it */
2435 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2438 PrintDiagnostics("copy", code);
2441 MapPartIdIntoName(topart, toPartName);
2442 MapPartIdIntoName(frompart, fromPartName);
2443 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2444 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2445 tovolume, as->parms[4].items->data, toPartName);
2452 ShadowVolume(struct cmd_syndesc *as, void *arock)
2454 afs_uint32 volid, tovolid;
2455 afs_uint32 fromserver, toserver;
2456 afs_int32 frompart, topart;
2457 afs_int32 code, err, flags;
2458 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2459 struct diskPartition64 partition; /* for space check */
2462 p = (volintInfo *) 0;
2463 q = (volintInfo *) 0;
2465 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2468 PrintError("", err);
2470 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2471 as->parms[0].items->data);
2474 fromserver = GetServer(as->parms[1].items->data);
2475 if (fromserver == 0) {
2476 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2477 as->parms[1].items->data);
2481 toserver = GetServer(as->parms[3].items->data);
2482 if (toserver == 0) {
2483 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2484 as->parms[3].items->data);
2488 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2490 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2491 as->parms[2].items->data);
2494 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2496 PrintError("", code);
2499 "vos : partition %s does not exist on the server\n",
2500 as->parms[2].items->data);
2504 topart = volutil_GetPartitionID(as->parms[4].items->data);
2506 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2507 as->parms[4].items->data);
2510 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2512 PrintError("", code);
2515 "vos : partition %s does not exist on the server\n",
2516 as->parms[4].items->data);
2520 if (as->parms[5].items) {
2521 tovolume = as->parms[5].items->data;
2522 if (!ISNAMEVALID(tovolume)) {
2524 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2525 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2528 if (!VolNameOK(tovolume)) {
2530 "Illegal volume name %s, should not end in .readonly or .backup\n",
2534 if (IsNumeric(tovolume)) {
2536 "Illegal volume name %s, should not be a number\n",
2541 /* use actual name of source volume */
2542 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2544 fprintf(STDERR, "vos:cannot access volume %lu\n",
2545 (unsigned long)volid);
2548 strcpy(toVolName, p->name);
2549 tovolume = toVolName;
2550 /* save p for size checks later */
2553 if (as->parms[6].items) {
2554 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2557 PrintError("", err);
2559 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2560 as->parms[6].items->data);
2566 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2569 PrintError("", err);
2571 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2580 if (as->parms[7].items) flags |= RV_OFFLINE;
2581 if (as->parms[8].items) flags |= RV_RDONLY;
2582 if (as->parms[9].items) flags |= RV_NOCLONE;
2583 if (as->parms[10].items) flags |= RV_CPINCR;
2585 MapPartIdIntoName(topart, toPartName);
2586 MapPartIdIntoName(frompart, fromPartName);
2589 * check target partition for space to move volume
2592 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2594 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2598 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2601 /* Don't do this again if we did it above */
2603 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2605 fprintf(STDERR, "vos:cannot access volume %lu\n",
2606 (unsigned long)volid);
2611 /* OK if this fails */
2612 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2614 /* Treat existing volume size as "free" */
2616 p->size = (q->size < p->size) ? p->size - q->size : 0;
2618 if (partition.free <= p->size) {
2620 "vos: no space on target partition %s to copy volume %lu\n",
2621 toPartName, (unsigned long)volid);
2629 /* successful copy still not guaranteed but shoot for it */
2632 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2633 topart, tovolid, flags);
2635 PrintDiagnostics("shadow", code);
2638 MapPartIdIntoName(topart, toPartName);
2639 MapPartIdIntoName(frompart, fromPartName);
2640 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2641 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2642 as->parms[3].items->data, toPartName);
2649 CloneVolume(struct cmd_syndesc *as, void *arock)
2651 afs_uint32 volid, cloneid;
2653 afs_int32 part, voltype;
2654 char partName[10], *volname;
2655 afs_int32 code, err, flags;
2656 struct nvldbentry entry;
2658 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2661 PrintError("", err);
2663 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2664 as->parms[0].items->data);
2668 if (as->parms[1].items || as->parms[2].items) {
2669 if (!as->parms[1].items || !as->parms[2].items) {
2671 "Must specify both -server and -partition options\n");
2674 server = GetServer(as->parms[1].items->data);
2676 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2677 as->parms[1].items->data);
2680 part = volutil_GetPartitionID(as->parms[2].items->data);
2682 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2683 as->parms[2].items->data);
2686 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2688 PrintError("", code);
2691 "vos : partition %s does not exist on the server\n",
2692 as->parms[2].items->data);
2696 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2702 if (as->parms[3].items) {
2703 volname = as->parms[3].items->data;
2704 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2706 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2707 volname, VOLSER_OLDMAXVOLNAME - 1);
2712 * In order that you be able to make clones of RO or BK, this
2713 * check must be omitted.
2715 if (!VolNameOK(volname)) {
2717 "Illegal volume name %s, should not end in .readonly or .backup\n",
2722 if (IsNumeric(volname)) {
2724 "Illegal volume name %s, should not be a number\n",
2731 if (as->parms[4].items) {
2732 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2735 PrintError("", err);
2737 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2738 as->parms[4].items->data);
2744 if (as->parms[5].items) flags |= RV_OFFLINE;
2745 if (as->parms[6].items && as->parms[7].items) {
2746 fprintf(STDERR, "vos: cannot specify that a volume be -readwrite and -readonly\n");
2749 if (as->parms[6].items) flags |= RV_RDONLY;
2750 if (as->parms[7].items) flags |= RV_RWONLY;
2754 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2757 PrintDiagnostics("clone", code);
2760 MapPartIdIntoName(part, partName);
2761 fprintf(STDOUT, "Created clone for volume %s\n",
2762 as->parms[0].items->data);
2769 BackupVolume(struct cmd_syndesc *as, void *arock)
2773 afs_int32 apart, vtype, code, err;
2774 struct nvldbentry entry;
2777 afs_uint32 buserver;
2778 afs_int32 bupart, butype;
2779 struct nvldbentry buentry;
2781 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2784 PrintError("", err);
2786 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2787 as->parms[0].items->data);
2790 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2794 /* verify this is a readwrite volume */
2796 if (vtype != RWVOL) {
2797 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2801 /* is there a backup volume already? */
2803 if (entry.flags & BACK_EXISTS) {
2804 /* yep, where is it? */
2806 buvolid = entry.volumeId[BACKVOL];
2807 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2812 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2815 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2821 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2822 (unsigned long)buvolid, (unsigned long)buserver);
2827 /* nope, carry on */
2829 code = UV_BackupVolume(aserver, apart, avolid);
2832 PrintDiagnostics("backup", code);
2835 fprintf(STDOUT, "Created backup volume for %s \n",
2836 as->parms[0].items->data);
2841 ReleaseVolume(struct cmd_syndesc *as, void *arock)
2844 struct nvldbentry entry;
2847 afs_int32 apart, vtype, code, err;
2851 if (as->parms[1].items)
2853 if (as->parms[2].items)
2855 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2858 PrintError("", err);
2860 fprintf(STDERR, "vos: can't find volume '%s'\n",
2861 as->parms[0].items->data);
2864 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2868 if (vtype != RWVOL) {
2869 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2873 if (!ISNAMEVALID(entry.name)) {
2875 "Volume name %s is too long, rename before releasing\n",
2880 code = UV_ReleaseVolume(avolid, aserver, apart, force, stayUp);
2883 PrintDiagnostics("release", code);
2886 fprintf(STDOUT, "Released volume %s successfully\n",
2887 as->parms[0].items->data);
2892 DumpVolumeCmd(struct cmd_syndesc *as, void *arock)
2896 afs_int32 apart, voltype, fromdate = 0, code, err, i, flags;
2897 char filename[MAXPATHLEN];
2898 struct nvldbentry entry;
2900 rx_SetRxDeadTime(60 * 10);
2901 for (i = 0; i < MAXSERVERS; i++) {
2902 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2905 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2906 if (rx_ServiceOf(rxConn))
2907 rx_ServiceOf(rxConn)->connDeadTime = rx_connDeadTime;
2910 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2913 PrintError("", err);
2915 fprintf(STDERR, "vos: can't find volume '%s'\n",
2916 as->parms[0].items->data);
2920 if (as->parms[3].items || as->parms[4].items) {
2921 if (!as->parms[3].items || !as->parms[4].items) {
2923 "Must specify both -server and -partition options\n");
2926 aserver = GetServer(as->parms[3].items->data);
2928 fprintf(STDERR, "Invalid server name\n");
2931 apart = volutil_GetPartitionID(as->parms[4].items->data);
2933 fprintf(STDERR, "Invalid partition name\n");
2937 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2942 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2943 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2945 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2946 as->parms[1].items->data, code);
2950 if (as->parms[2].items) {
2951 strcpy(filename, as->parms[2].items->data);
2953 strcpy(filename, "");
2956 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
2958 if (as->parms[5].items) {
2960 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2961 DumpFunction, filename, flags);
2964 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2967 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
2968 flags &= ~VOLDUMPV2_OMITDIRS;
2972 PrintDiagnostics("dump", code);
2975 if (strcmp(filename, ""))
2976 fprintf(STDERR, "Dumped volume %s in file %s\n",
2977 as->parms[0].items->data, filename);
2979 fprintf(STDERR, "Dumped volume %s in stdout \n",
2980 as->parms[0].items->data);
2994 RestoreVolumeCmd(struct cmd_syndesc *as, void *arock)
2996 afs_uint32 avolid, aparentid;
2998 afs_int32 apart, code, vcode, err;
2999 afs_int32 aoverwrite = ASK;
3000 afs_int32 acreation = 0, alastupdate = 0;
3001 int restoreflags = 0;
3002 int readonly = 0, offline = 0, voltype = RWVOL;
3003 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
3004 char volname[VOLSER_MAXVOLNAME + 1];
3005 struct nvldbentry entry;
3008 if (as->parms[4].items) {
3009 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
3012 PrintError("", err);
3014 fprintf(STDERR, "vos: can't find volume '%s'\n",
3015 as->parms[4].items->data);
3021 if (as->parms[5].items) {
3022 if ((strcmp(as->parms[5].items->data, "a") == 0)
3023 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
3025 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
3026 || (strcmp(as->parms[5].items->data, "full") == 0)) {
3028 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
3029 || (strcmp(as->parms[5].items->data, "inc") == 0)
3030 || (strcmp(as->parms[5].items->data, "increment") == 0)
3031 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
3034 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
3035 as->parms[5].items->data);
3039 if (as->parms[6].items)
3041 if (as->parms[7].items) {
3046 if (as->parms[8].items) {
3047 if ((strcmp(as->parms[8].items->data, "d") == 0)
3048 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
3049 acreation = TS_DUMP;
3050 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
3051 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
3052 acreation = TS_KEEP;
3053 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
3054 || (strcmp(as->parms[8].items->data, "new") == 0)) {
3057 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
3058 as->parms[8].items->data);
3063 if (as->parms[9].items) {
3064 if ((strcmp(as->parms[9].items->data, "d") == 0)
3065 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
3066 alastupdate = TS_DUMP;
3067 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
3068 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
3069 alastupdate = TS_KEEP;
3070 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
3071 || (strcmp(as->parms[9].items->data, "new") == 0)) {
3072 alastupdate = TS_NEW;
3074 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
3075 as->parms[9].items->data);
3080 aserver = GetServer(as->parms[0].items->data);
3082 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3083 as->parms[0].items->data);
3086 apart = volutil_GetPartitionID(as->parms[1].items->data);
3088 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3089 as->parms[1].items->data);
3092 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3094 PrintError("", code);
3097 "vos : partition %s does not exist on the server\n",
3098 as->parms[1].items->data);
3101 strcpy(avolname, as->parms[2].items->data);
3102 if (!ISNAMEVALID(avolname)) {
3104 "vos: the name of the volume %s exceeds the size limit\n",
3108 if (!VolNameOK(avolname)) {
3110 "Illegal volume name %s, should not end in .readonly or .backup\n",
3114 if (as->parms[3].items) {
3115 strcpy(afilename, as->parms[3].items->data);
3116 if (!FileExists(afilename)) {
3117 fprintf(STDERR, "Can't access file %s\n", afilename);
3121 strcpy(afilename, "");
3124 /* Check if volume exists or not */
3126 vsu_ExtractName(volname, avolname);
3127 vcode = VLDB_GetEntryByName(volname, &entry);
3128 if (vcode) { /* no volume - do a full restore */
3129 restoreflags = RV_FULLRST;
3130 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3132 "Volume does not exist; Will perform a full restore\n");
3135 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3136 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3137 restoreflags = RV_FULLRST;
3138 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3140 "%s Volume does not exist; Will perform a full restore\n",
3141 readonly ? "RO" : "RW");
3144 avolid = entry.volumeId[voltype];
3145 } else if (entry.volumeId[voltype] != 0
3146 && entry.volumeId[voltype] != avolid) {
3147 avolid = entry.volumeId[voltype];
3149 aparentid = entry.volumeId[RWVOL];
3152 else { /* volume exists - do we do a full incremental or abort */
3154 afs_int32 Opart, Otype, vol_elsewhere = 0;
3155 struct nvldbentry Oentry;
3159 avolid = entry.volumeId[voltype];
3160 } else if (entry.volumeId[voltype] != 0
3161 && entry.volumeId[voltype] != avolid) {
3162 avolid = entry.volumeId[voltype];
3164 aparentid = entry.volumeId[RWVOL];
3166 /* A file name was specified - check if volume is on another partition */
3167 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3171 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3174 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3178 if (!vcode || (Opart != apart))
3181 if (aoverwrite == ASK) {
3182 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3184 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3188 /* Ask what to do */
3189 if (vol_elsewhere) {
3191 "The volume %s %u already exists on a different server/part\n",
3192 volname, entry.volumeId[voltype]);
3194 "Do you want to do a full restore or abort? [fa](a): ");
3197 "The volume %s %u already exists in the VLDB\n",
3198 volname, entry.volumeId[voltype]);
3200 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3203 while (!(dc == EOF || dc == '\n'))
3204 dc = getchar(); /* goto end of line */
3205 if ((c == 'f') || (c == 'F'))
3207 else if ((c == 'i') || (c == 'I'))
3213 if (aoverwrite == ABORT) {
3214 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3216 } else if (aoverwrite == FULL) {
3217 restoreflags = RV_FULLRST;
3219 "Volume exists; Will delete and perform full restore\n");
3220 } else if (aoverwrite == INC) {
3222 if (vol_elsewhere) {
3224 "%s volume %lu already exists on a different server/part; not allowed\n",
3225 readonly ? "RO" : "RW", (unsigned long)avolid);
3231 restoreflags |= RV_OFFLINE;
3233 restoreflags |= RV_RDONLY;
3235 switch (acreation) {
3237 restoreflags |= RV_CRDUMP;
3240 restoreflags |= RV_CRKEEP;
3243 restoreflags |= RV_CRNEW;
3246 if (aoverwrite == FULL)
3247 restoreflags |= RV_CRNEW;
3249 restoreflags |= RV_CRKEEP;
3252 switch (alastupdate) {
3254 restoreflags |= RV_LUDUMP;
3257 restoreflags |= RV_LUKEEP;
3260 restoreflags |= RV_LUNEW;
3263 restoreflags |= RV_LUDUMP;
3265 if (as->parms[10].items) {
3266 restoreflags |= RV_NODEL;
3271 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3272 avolname, restoreflags, WriteData, afilename);
3274 PrintDiagnostics("restore", code);
3277 MapPartIdIntoName(apart, apartName);
3280 * patch typo here - originally "parms[1]", should be "parms[0]"
3283 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3284 as->parms[0].items->data, apartName);
3289 LockReleaseCmd(struct cmd_syndesc *as, void *arock)
3292 afs_int32 code, err;
3294 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3297 PrintError("", err);
3299 fprintf(STDERR, "vos: can't find volume '%s'\n",
3300 as->parms[0].items->data);
3304 code = UV_LockRelease(avolid);
3306 PrintDiagnostics("unlock", code);
3309 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3310 as->parms[0].items->data);
3315 AddSite(struct cmd_syndesc *as, void *arock)
3319 afs_int32 apart, code, err, arovolid, valid = 0;
3320 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3322 vsu_ExtractName(avolname, as->parms[2].items->data);;
3323 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3326 PrintError("", err);
3328 fprintf(STDERR, "vos: can't find volume '%s'\n",
3329 as->parms[2].items->data);
3333 if (as->parms[3].items) {
3334 vsu_ExtractName(avolname, as->parms[3].items->data);
3335 arovolid = vsu_GetVolumeID(avolname, cstruct, &err);
3337 fprintf(STDERR, "vos: invalid ro volume id '%s'\n",
3338 as->parms[3].items->data);
3342 aserver = GetServer(as->parms[0].items->data);
3344 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3345 as->parms[0].items->data);
3348 apart = volutil_GetPartitionID(as->parms[1].items->data);
3350 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3351 as->parms[1].items->data);
3354 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3356 PrintError("", code);
3359 "vos : partition %s does not exist on the server\n",
3360 as->parms[1].items->data);
3363 if (as->parms[4].items) {
3366 code = UV_AddSite2(aserver, apart, avolid, arovolid, valid);
3368 PrintDiagnostics("addsite", code);
3371 MapPartIdIntoName(apart, apartName);
3372 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3373 as->parms[0].items->data, apartName, as->parms[2].items->data);
3378 RemoveSite(struct cmd_syndesc *as, void *arock)
3383 afs_int32 apart, code, err;
3384 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3386 vsu_ExtractName(avolname, as->parms[2].items->data);
3387 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3390 PrintError("", err);
3392 fprintf(STDERR, "vos: can't find volume '%s'\n",
3393 as->parms[2].items->data);
3396 aserver = GetServer(as->parms[0].items->data);
3398 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3399 as->parms[0].items->data);
3402 apart = volutil_GetPartitionID(as->parms[1].items->data);
3404 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3405 as->parms[1].items->data);
3409 *skip the partition validity check, since it is possible that the partition
3410 *has since been decomissioned.
3413 if (!IsPartValid(apart,aserver,&code)){
3414 if(code) PrintError("",code);
3415 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3419 code = UV_RemoveSite(aserver, apart, avolid);
3421 PrintDiagnostics("remsite", code);
3424 MapPartIdIntoName(apart, apartName);
3425 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3426 as->parms[0].items->data, apartName, as->parms[2].items->data);
3431 ChangeLocation(struct cmd_syndesc *as, void *arock)
3435 afs_int32 apart, code, err;
3438 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3441 PrintError("", err);
3443 fprintf(STDERR, "vos: can't find volume '%s'\n",
3444 as->parms[2].items->data);
3447 aserver = GetServer(as->parms[0].items->data);
3449 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3450 as->parms[0].items->data);
3453 apart = volutil_GetPartitionID(as->parms[1].items->data);
3455 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3456 as->parms[1].items->data);
3459 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3461 PrintError("", code);
3464 "vos : partition %s does not exist on the server\n",
3465 as->parms[1].items->data);
3468 code = UV_ChangeLocation(aserver, apart, avolid);
3470 PrintDiagnostics("changeloc", code);
3473 MapPartIdIntoName(apart, apartName);
3474 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3475 as->parms[0].items->data, apartName, as->parms[2].items->data);
3480 ListPartitions(struct cmd_syndesc *as, void *arock)
3484 struct partList dummyPartList;
3489 aserver = GetServer(as->parms[0].items->data);
3491 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3492 as->parms[0].items->data);
3497 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3499 PrintDiagnostics("listpart", code);
3503 fprintf(STDOUT, "The partitions on the server are:\n");
3504 for (i = 0; i < cnt; i++) {
3505 if (dummyPartList.partFlags[i] & PARTVALID) {
3506 memset(pname, 0, sizeof(pname));
3507 MapPartIdIntoName(dummyPartList.partId[i], pname);
3508 fprintf(STDOUT, " %10s ", pname);
3510 if ((i % 5) == 0 && (i != 0))
3511 fprintf(STDOUT, "\n");
3514 fprintf(STDOUT, "\n");
3515 fprintf(STDOUT, "Total: %d\n", total);
3521 CompareVolName(const void *p1, const void *p2)
3523 volintInfo *arg1, *arg2;
3525 arg1 = (volintInfo *) p1;
3526 arg2 = (volintInfo *) p2;
3527 return (strcmp(arg1->name, arg2->name));
3531 /*------------------------------------------------------------------------
3532 * PRIVATE XCompareVolName
3535 * Comparison routine for volume names coming from an extended
3539 * a_obj1P : Char ptr to first extended vol info object
3540 * a_obj1P : Char ptr to second extended vol info object
3543 * The value of strcmp() on the volume names within the passed
3544 * objects (i,e., -1, 0, or 1).
3547 * Passed to qsort() as the designated comparison routine.
3551 *------------------------------------------------------------------------*/
3554 XCompareVolName(const void *a_obj1P, const void *a_obj2P)
3555 { /*XCompareVolName */
3558 (((struct volintXInfo *)(a_obj1P))->name,
3559 ((struct volintXInfo *)(a_obj2P))->name));
3561 } /*XCompareVolName */
3564 CompareVolID(const void *p1, const void *p2)
3566 volintInfo *arg1, *arg2;
3568 arg1 = (volintInfo *) p1;
3569 arg2 = (volintInfo *) p2;
3570 if (arg1->volid == arg2->volid)
3572 if (arg1->volid > arg2->volid)
3579 /*------------------------------------------------------------------------
3580 * PRIVATE XCompareVolID
3583 * Comparison routine for volume IDs coming from an extended
3587 * a_obj1P : Char ptr to first extended vol info object
3588 * a_obj1P : Char ptr to second extended vol info object
3591 * The value of strcmp() on the volume names within the passed
3592 * objects (i,e., -1, 0, or 1).
3595 * Passed to qsort() as the designated comparison routine.
3599 *------------------------------------------------------------------------*/
3602 XCompareVolID(const void *a_obj1P, const void *a_obj2P)
3603 { /*XCompareVolID */
3605 afs_int32 id1, id2; /*Volume IDs we're comparing */
3607 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3608 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3616 } /*XCompareVolID */
3618 /*------------------------------------------------------------------------
3619 * PRIVATE ListVolumes
3622 * Routine used to list volumes, contacting the Volume Server
3623 * directly, bypassing the VLDB.
3626 * as : Ptr to parsed command line arguments.
3629 * 0 Successful operation
3632 * Nothing interesting.
3636 *------------------------------------------------------------------------*/
3639 ListVolumes(struct cmd_syndesc *as, void *arock)
3641 afs_int32 apart, int32list, fast;
3645 volintInfo *oldpntr = NULL;
3649 volintXInfo *xInfoP;
3650 volintXInfo *origxInfoP = NULL; /*Ptr to current/orig extended vol info */
3651 int wantExtendedInfo; /*Do we want extended vol info? */
3654 struct partList dummyPartList;
3662 if (as->parms[3].items)
3664 if (as->parms[4].items)
3668 if (as->parms[2].items)