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>
16 #include <sys/types.h>
26 #include <netinet/in.h>
27 #include <arpa/inet.h>
31 #include <sys/statfs.h>
39 #include <rx/rx_globals.h>
41 #include <afs/vlserver.h>
42 #include <afs/cellconfig.h>
44 #include <afs/afsutil.h>
46 #include <afs/afsint.h>
51 #include <afs/ihandle.h>
52 #include <afs/vnode.h>
53 #include <afs/volume.h>
60 #include "volser_prototypes.h"
62 #ifdef HAVE_POSIX_REGEX
76 #define COMMONPARMS cmd_Seek(ts, 12);\
77 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
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");\
83 #define ERROR_EXIT(code) {error=(code); goto error_exit;}
87 struct rx_connection *tconn;
89 extern struct ubik_client *cstruct;
92 static struct tqHead busyHead, notokHead;
95 qInit(struct tqHead *ahead)
97 memset((char *)ahead, 0, sizeof(struct tqHead));
103 qPut(struct tqHead *ahead, afs_int32 volid)
107 elem = (struct tqElem *)malloc(sizeof(struct tqElem));
108 elem->next = ahead->next;
116 qGet(struct tqHead *ahead, afs_int32 *volid)
120 if (ahead->count <= 0)
122 *volid = ahead->next->volid;
124 ahead->next = tmp->next;
130 /* returns 1 if <filename> exists else 0 */
132 FileExists(char *filename)
138 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
142 code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
150 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
152 VolNameOK(char *name)
157 total = strlen(name);
158 if (!strcmp(&name[total - 9], ".readonly")) {
160 } else if (!strcmp(&name[total - 7], ".backup")) {
167 /* return 1 if name is a number else 0 */
169 IsNumeric(char *name)
177 for (i = 0; i < len; i++) {
178 if (*ptr < '0' || *ptr > '9') {
190 * Parse a server name/address and return the address in HOST BYTE order
193 GetServer(char *aname)
195 register struct hostent *th;
198 register afs_int32 code;
199 char hostname[MAXHOSTCHARS];
201 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
203 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
204 addr = ntohl(addr); /* convert to host order */
206 th = gethostbyname(aname);
209 memcpy(&addr, th->h_addr, sizeof(addr));
212 if (addr == htonl(0x7f000001)) { /* local host */
213 code = gethostname(hostname, MAXHOSTCHARS);
216 th = gethostbyname(hostname); /* returns host byte order */
219 memcpy(&addr, th->h_addr, sizeof(addr));
226 GetVolumeType(char *aname)
229 if (!strcmp(aname, "ro"))
231 else if (!strcmp(aname, "rw"))
233 else if (!strcmp(aname, "bk"))
240 IsPartValid(afs_int32 partId, afs_int32 server, afs_int32 *code)
242 struct partList dummyPartList;
248 *code = UV_ListPartitions(server, &dummyPartList, &cnt);
251 for (i = 0; i < cnt; i++) {
252 if (dummyPartList.partFlags[i] & PARTVALID)
253 if (dummyPartList.partId[i] == partId)
261 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
262 * associated with <call> */
264 SendFile(usd_handle_t ufd, register struct rx_call *call, long blksize)
266 char *buffer = (char *)0;
271 buffer = (char *)malloc(blksize);
273 fprintf(STDERR, "malloc failed\n");
277 while (!error && !done) {
278 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
281 FD_SET((int)(ufd->handle), &in);
282 /* don't timeout if read blocks */
283 IOMGR_Select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
285 error = USD_READ(ufd, buffer, blksize, &nbytes);
287 fprintf(STDERR, "File system read failed\n");
294 if (rx_Write(call, buffer, nbytes) != nbytes) {
304 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
305 * writes it out to the volume. */
307 WriteData(struct rx_call *call, char *rock)
312 afs_int32 error, code;
314 afs_hyper_t filesize, currOffset;
321 if (!filename || !*filename) {
322 usd_StandardInput(&ufd);
326 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
329 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
332 fprintf(STDERR, "Could not access file '%s'\n", filename);
336 /* test if we have a valid dump */
337 hset64(filesize, 0, 0);
338 USD_SEEK(ufd, filesize, SEEK_END, &currOffset);
339 hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32));
340 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
341 USD_READ(ufd, &buffer, sizeof(afs_uint32), &got);
342 if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
343 fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
347 /* rewind, we are done */
348 hset64(filesize, 0, 0);
349 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
351 code = SendFile(ufd, call, blksize);
358 code = USD_CLOSE(ufd);
360 fprintf(STDERR, "Could not close dump file %s\n",
361 (filename && *filename) ? filename : "STDOUT");
369 /* Receive data from <call> stream into file associated
370 * with <fd> <blksize>
373 ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize)
377 afs_uint32 bytesleft, w;
380 buffer = (char *)malloc(blksize);
382 fprintf(STDERR, "memory allocation failed\n");
386 while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {
387 for (bytesleft = bytesread; bytesleft; bytesleft -= w) {
388 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
391 FD_SET((int)(ufd->handle), &out);
392 /* don't timeout if write blocks */
393 IOMGR_Select(((int)(ufd->handle)) + 1, 0, &out, 0, 0);
396 USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
398 fprintf(STDERR, "File system write failed\n");
411 DumpFunction(struct rx_call *call, char *filename)
413 usd_handle_t ufd; /* default is to stdout */
414 afs_int32 error = 0, code;
419 /* Open the output file */
420 if (!filename || !*filename) {
421 usd_StandardOutput(&ufd);
426 usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
430 code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
433 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
436 fprintf(STDERR, "Could not create file '%s'\n", filename);
437 ERROR_EXIT(VOLSERBADOP);
441 code = ReceiveFile(ufd, call, blksize);
446 /* Close the output file */
448 code = USD_CLOSE(ufd);
450 fprintf(STDERR, "Could not close dump file %s\n",
451 (filename && *filename) ? filename : "STDIN");
462 vos_ctime(afs_int32 *timep)
468 #define vos_ctime ctime
472 DisplayFormat(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
475 afs_int32 server, part;
476 int *totalOK, *totalNotOK, *totalBusy;
477 int fast, longlist, disp;
482 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
483 } else if (longlist) {
484 if (pntr->status == VOK) {
485 fprintf(STDOUT, "%-32s ", pntr->name);
486 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
488 fprintf(STDOUT, "RW ");
490 fprintf(STDOUT, "RO ");
492 fprintf(STDOUT, "BK ");
493 fprintf(STDOUT, "%10d K ", pntr->size);
494 if (pntr->inUse == 1) {
495 fprintf(STDOUT, "On-line");
498 fprintf(STDOUT, "Off-line");
501 if (pntr->needsSalvaged == 1)
502 fprintf(STDOUT, "**needs salvage**");
503 fprintf(STDOUT, "\n");
504 MapPartIdIntoName(part, pname);
505 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
507 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
508 (unsigned long)pntr->parentID,
509 (unsigned long)pntr->cloneID,
510 (unsigned long)pntr->backupID);
511 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
512 fprintf(STDOUT, " Creation %s",
513 vos_ctime(& pntr->creationDate));
514 #ifdef FULL_LISTVOL_SWITCH
515 fprintf(STDOUT, " Copy %s",
516 vos_ctime( & pntr->copyDate));
517 if (!pntr->backupDate)
518 fprintf(STDOUT, " Backup Never\n");
520 fprintf(STDOUT, " Backup %s",
521 vos_ctime( & pntr->backupDate));
522 if (pntr->accessDate)
523 fprintf(STDOUT, " Last Access %s",
524 vos_ctime( & pntr->accessDate));
526 if (!pntr->updateDate)
527 fprintf(STDOUT, " Last Update Never\n");
529 fprintf(STDOUT, " Last Update %s",
530 vos_ctime( & pntr->updateDate));
532 " %d accesses in the past day (i.e., vnode references)\n",
535 } else if (pntr->status == VBUSY) {
537 qPut(&busyHead, pntr->volid);
539 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
540 (unsigned long)pntr->volid);
543 qPut(¬okHead, pntr->volid);
545 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
546 (unsigned long)pntr->volid);
548 fprintf(STDOUT, "\n");
549 } else { /* default listing */
550 if (pntr->status == VOK) {
551 fprintf(STDOUT, "%-32s ", pntr->name);
552 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
554 fprintf(STDOUT, "RW ");
556 fprintf(STDOUT, "RO ");
558 fprintf(STDOUT, "BK ");
559 fprintf(STDOUT, "%10d K ", pntr->size);
560 if (pntr->inUse == 1) {
561 fprintf(STDOUT, "On-line");
564 fprintf(STDOUT, "Off-line");
567 if (pntr->needsSalvaged == 1)
568 fprintf(STDOUT, "**needs salvage**");
569 fprintf(STDOUT, "\n");
570 } else if (pntr->status == VBUSY) {
572 qPut(&busyHead, pntr->volid);
574 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
575 (unsigned long)pntr->volid);
578 qPut(¬okHead, pntr->volid);
580 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
581 (unsigned long)pntr->volid);
586 /*------------------------------------------------------------------------
587 * PRIVATE XDisplayFormat
590 * Display the contents of one extended volume info structure.
593 * a_xInfoP : Ptr to extended volume info struct to print.
594 * a_servID : Server ID to print.
595 * a_partID : Partition ID to print.
596 * a_totalOKP : Ptr to total-OK counter.
597 * a_totalNotOKP : Ptr to total-screwed counter.
598 * a_totalBusyP : Ptr to total-busy counter.
599 * a_fast : Fast listing?
600 * a_int32 : Int32 listing?
601 * a_showProblems : Show volume problems?
607 * Nothing interesting.
611 *------------------------------------------------------------------------*/
614 XDisplayFormat(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
615 a_totalBusyP, a_fast, a_int32, a_showProblems)
616 volintXInfo *a_xInfoP;
626 { /*XDisplayFormat */
634 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
635 } else if (a_int32) {
637 * Fully-detailed listing.
639 if (a_xInfoP->status == VOK) {
641 * Volume's status is OK - all the fields are valid.
643 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
644 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
645 if (a_xInfoP->type == 0)
646 fprintf(STDOUT, "RW ");
647 if (a_xInfoP->type == 1)
648 fprintf(STDOUT, "RO ");
649 if (a_xInfoP->type == 2)
650 fprintf(STDOUT, "BK ");
651 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
652 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
653 if (a_xInfoP->inUse == 1) {
654 fprintf(STDOUT, "On-line");
657 fprintf(STDOUT, "Off-line");
660 fprintf(STDOUT, "\n");
661 MapPartIdIntoName(a_partID, pname);
662 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
664 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
665 (unsigned long)a_xInfoP->parentID,
666 (unsigned long)a_xInfoP->cloneID,
667 (unsigned long)a_xInfoP->backupID);
668 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
669 fprintf(STDOUT, " Creation %s",
670 vos_ctime( & a_xInfoP->creationDate));
671 #ifdef FULL_LISTVOL_SWITCH
672 fprintf(STDOUT, " Copy %s",
673 vos_ctime( & a_xInfoP->copyDate));
674 if (!a_xInfoP->backupDate)
675 fprintf(STDOUT, " Backup Never\n");
677 fprintf(STDOUT, " Backup %s",
678 vos_ctime( & a_xInfoP->backupDate));
679 if (a_xInfoP->accessDate)
680 fprintf(STDOUT, " Last Access %s",
681 vos_ctime( & a_xInfoP->accessDate));
683 if (!a_xInfoP->updateDate)
684 fprintf(STDOUT, " Last Update Never\n");
686 fprintf(STDOUT, " Last Update %s",
687 vos_ctime( & a_xInfoP->updateDate));
689 " %d accesses in the past day (i.e., vnode references)\n",
694 * Print all the read/write and authorship stats.
696 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
698 " |-------------------------------------------|\n");
700 " | Same Network | Diff Network |\n");
702 " |----------|----------|----------|----------|\n");
704 " | Total | Auth | Total | Auth |\n");
706 " |----------|----------|----------|----------|\n");
707 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
708 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
709 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
710 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
711 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
712 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
713 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
714 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
715 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
716 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
718 " |-------------------------------------------|\n\n");
721 " Writes Affecting Authorship\n");
723 " |-------------------------------------------|\n");
725 " | File Authorship | Directory Authorship|\n");
727 " |----------|----------|----------|----------|\n");
729 " | Same | Diff | Same | Diff |\n");
731 " |----------|----------|----------|----------|\n");
732 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
733 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
734 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
735 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
736 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
737 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
738 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
739 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
740 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
741 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
742 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
743 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
744 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
745 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
746 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
747 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
748 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
749 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
750 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
751 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
752 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
753 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
754 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
755 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
756 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
757 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
758 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
759 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
760 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
761 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
763 " |-------------------------------------------|\n");
764 } /*Volume status OK */
765 else if (a_xInfoP->status == VBUSY) {
767 qPut(&busyHead, a_xInfoP->volid);
769 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
770 (unsigned long)a_xInfoP->volid);
774 qPut(¬okHead, a_xInfoP->volid);
776 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
777 (unsigned long)a_xInfoP->volid);
778 } /*Screwed volume */
779 fprintf(STDOUT, "\n");
785 if (a_xInfoP->status == VOK) {
786 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
787 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
788 if (a_xInfoP->type == 0)
789 fprintf(STDOUT, "RW ");
790 if (a_xInfoP->type == 1)
791 fprintf(STDOUT, "RO ");
792 if (a_xInfoP->type == 2)
793 fprintf(STDOUT, "BK ");
794 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
795 if (a_xInfoP->inUse == 1) {
796 fprintf(STDOUT, "On-line");
799 fprintf(STDOUT, "Off-line");
802 fprintf(STDOUT, "\n");
804 else if (a_xInfoP->status == VBUSY) {
806 qPut(&busyHead, a_xInfoP->volid);
808 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
809 (unsigned long)a_xInfoP->volid);
813 qPut(¬okHead, a_xInfoP->volid);
815 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
816 (unsigned long)a_xInfoP->volid);
817 } /*Screwed volume */
818 } /*Default listing */
819 } /*XDisplayFormat */
821 #ifdef FULL_LISTVOL_SWITCH
822 /*------------------------------------------------------------------------
823 * PRIVATE XDisplayFormat2
826 * Display the formated contents of one extended volume info structure.
829 * a_xInfoP : Ptr to extended volume info struct to print.
830 * a_servID : Server ID to print.
831 * a_partID : Partition ID to print.
832 * a_totalOKP : Ptr to total-OK counter.
833 * a_totalNotOKP : Ptr to total-screwed counter.
834 * a_totalBusyP : Ptr to total-busy counter.
835 * a_fast : Fast listing?
836 * a_int32 : Int32 listing?
837 * a_showProblems : Show volume problems?
843 * Nothing interesting.
847 *------------------------------------------------------------------------*/
850 XDisplayFormat2(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
851 a_totalBusyP, a_fast, a_int32, a_showProblems)
852 volintXInfo *a_xInfoP;
862 { /*XDisplayFormat */
867 fprintf(STDOUT, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP->volid);
868 } else if (a_int32) {
870 * Fully-detailed listing.
872 if (a_xInfoP->status == VOK) {
874 * Volume's status is OK - all the fields are valid.
877 static long server_cache = -1, partition_cache = -1;
878 static char hostname[256], address[32], pname[16];
879 int i,ai[] = {VOLINT_STATS_TIME_IDX_0,VOLINT_STATS_TIME_IDX_1,VOLINT_STATS_TIME_IDX_2,
880 VOLINT_STATS_TIME_IDX_3,VOLINT_STATS_TIME_IDX_4,VOLINT_STATS_TIME_IDX_5};
882 if (a_servID != server_cache) {
886 strcpy(hostname, hostutil_GetNameByINet(a_servID));
887 strcpy(address, inet_ntoa(s));
888 server_cache = a_servID;
890 if (a_partID != partition_cache) {
891 MapPartIdIntoName(a_partID, pname);
892 partition_cache = a_partID;
895 fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name);
896 fprintf(STDOUT, "id\t\t%lu\n", a_xInfoP->volid);
897 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
898 fprintf(STDOUT, "part\t\t%s\n", pname);
899 switch (a_xInfoP->status) {
901 fprintf(STDOUT, "status\t\tOK\n");
904 fprintf(STDOUT, "status\t\tBUSY\n");
907 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
910 fprintf(STDOUT, "backupID\t%lu\n", a_xInfoP->backupID);
911 fprintf(STDOUT, "parentID\t%lu\n", a_xInfoP->parentID);
912 fprintf(STDOUT, "cloneID\t\t%lu\n", a_xInfoP->cloneID);
913 fprintf(STDOUT, "inUse\t\t%s\n", a_xInfoP->inUse ? "Y" : "N");
914 switch (a_xInfoP->type) {
916 fprintf(STDOUT, "type\t\tRW\n");
919 fprintf(STDOUT, "type\t\tRO\n");
922 fprintf(STDOUT, "type\t\tBK\n");
925 fprintf(STDOUT, "type\t\t?\n");
928 fprintf(STDOUT, "creationDate\t%-9lu\t%s", a_xInfoP->creationDate,
929 vos_ctime(&a_xInfoP->creationDate));
930 fprintf(STDOUT, "accessDate\t%-9lu\t%s", a_xInfoP->accessDate,
931 vos_ctime(&a_xInfoP->accessDate));
932 fprintf(STDOUT, "updateDate\t%-9lu\t%s", a_xInfoP->updateDate,
933 vos_ctime(&a_xInfoP->updateDate));
934 fprintf(STDOUT, "backupDate\t%-9lu\t%s", a_xInfoP->backupDate,
935 vos_ctime(&a_xInfoP->backupDate));
936 fprintf(STDOUT, "copyDate\t%-9lu\t%s", a_xInfoP->copyDate,
937 vos_ctime(&a_xInfoP->copyDate));
939 fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
940 fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
942 fprintf(STDOUT, "filecount\t%u\n", a_xInfoP->filecount);
943 fprintf(STDOUT, "dayUse\t\t%u\n", a_xInfoP->dayUse);
947 fprintf(STDOUT,"reads_same_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]);
948 fprintf(STDOUT,"reads_same_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]);
949 fprintf(STDOUT,"reads_diff_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]);
950 fprintf(STDOUT,"reads_diff_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
952 fprintf(STDOUT,"writes_same_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]);
953 fprintf(STDOUT,"writes_same_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]);
954 fprintf(STDOUT,"writes_diff_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]);
955 fprintf(STDOUT,"writes_diff_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
959 fprintf(STDOUT,"file_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileSameAuthor[ai[i]]);
960 fprintf(STDOUT,"file_diff_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileDiffAuthor[ai[i]]);
961 fprintf(STDOUT,"dir_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirSameAuthor[ai[i]]);
962 fprintf(STDOUT,"dir_dif_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirDiffAuthor[ai[i]]);
965 } /*Volume status OK */
966 else if (a_xInfoP->status == VBUSY) {
968 qPut(&busyHead, a_xInfoP->volid);
970 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
971 (unsigned long)a_xInfoP->volid);
975 qPut(¬okHead, a_xInfoP->volid);
977 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
978 (unsigned long)a_xInfoP->volid);
979 } /*Screwed volume */
985 if (a_xInfoP->status == VOK) {
986 fprintf(STDOUT, "name\t%-32s\n", a_xInfoP->name);
987 fprintf(STDOUT, "volID\t%10lu\n", (unsigned long)a_xInfoP->volid);
988 if (a_xInfoP->type == 0)
989 fprintf(STDOUT, "type\tRW\n");
990 if (a_xInfoP->type == 1)
991 fprintf(STDOUT, "type\tRO\n");
992 if (a_xInfoP->type == 2)
993 fprintf(STDOUT, "type\tBK\n");
994 fprintf(STDOUT, "size\t%10dK\n", a_xInfoP->size);
996 fprintf(STDOUT, "inUse\t%d\n",a_xInfoP->inUse);
997 if (a_xInfoP->inUse == 1)
1003 else if (a_xInfoP->status == VBUSY) {
1005 qPut(&busyHead, a_xInfoP->volid);
1007 fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
1008 (unsigned long)a_xInfoP->volid);
1012 qPut(¬okHead, a_xInfoP->volid);
1014 fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
1015 (unsigned long)a_xInfoP->volid);
1016 } /*Screwed volume */
1017 } /*Default listing */
1018 } /*XDisplayFormat */
1019 #endif /*FULL_LISTVOL_SWITCH*/
1021 #ifdef FULL_LISTVOL_SWITCH
1023 DisplayFormat2(server, partition, pntr)
1024 long server, partition;
1027 static long server_cache = -1, partition_cache = -1;
1028 static char hostname[256], address[32], pname[16];
1030 if (server != server_cache) {
1034 strcpy(hostname, hostutil_GetNameByINet(server));
1035 strcpy(address, inet_ntoa(s));
1036 server_cache = server;
1038 if (partition != partition_cache) {
1039 MapPartIdIntoName(partition, pname);
1040 partition_cache = partition;
1042 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
1043 fprintf(STDOUT, "id\t\t%lu\n", pntr->volid);
1044 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
1045 fprintf(STDOUT, "part\t\t%s\n", pname);
1046 switch (pntr->status) {
1048 fprintf(STDOUT, "status\t\tOK\n");
1051 fprintf(STDOUT, "status\t\tBUSY\n");
1054 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
1057 fprintf(STDOUT, "backupID\t%lu\n", pntr->backupID);
1058 fprintf(STDOUT, "parentID\t%lu\n", pntr->parentID);
1059 fprintf(STDOUT, "cloneID\t\t%lu\n", pntr->cloneID);
1060 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
1061 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
1062 /* 0xD3 is from afs/volume.h since I had trouble including the file */
1063 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
1064 switch (pntr->type) {
1066 fprintf(STDOUT, "type\t\tRW\n");
1069 fprintf(STDOUT, "type\t\tRO\n");
1072 fprintf(STDOUT, "type\t\tBK\n");
1075 fprintf(STDOUT, "type\t\t?\n");
1078 fprintf(STDOUT, "creationDate\t%-9lu\t%s", pntr->creationDate,
1079 vos_ctime(&pntr->creationDate));
1080 fprintf(STDOUT, "accessDate\t%-9lu\t%s", pntr->accessDate,
1081 vos_ctime(&pntr->accessDate));
1082 fprintf(STDOUT, "updateDate\t%-9lu\t%s", pntr->updateDate,
1083 vos_ctime(&pntr->updateDate));
1084 fprintf(STDOUT, "backupDate\t%-9lu\t%s", pntr->backupDate,
1085 vos_ctime(&pntr->backupDate));
1086 fprintf(STDOUT, "copyDate\t%-9lu\t%s", pntr->copyDate,
1087 vos_ctime(&pntr->copyDate));
1088 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n", pntr->flags);
1089 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
1090 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
1091 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n", pntr->spare0);
1092 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
1093 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
1094 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n", pntr->spare1);
1095 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n", pntr->spare2);
1096 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n", pntr->spare3);
1101 DisplayVolumes2(server, partition, pntr, count)
1103 long server, partition, count;
1107 for (i = 0; i < count; i++) {
1108 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1109 DisplayFormat2(server, partition, pntr);
1110 fprintf(STDOUT, "END_OF_ENTRY\n\n");
1115 #endif /* FULL_LISTVOL_SWITCH */
1118 DisplayVolumes(server, part, pntr, count, longlist, fast, quiet)
1119 afs_int32 server, part;
1121 afs_int32 count, longlist, fast;
1124 int totalOK, totalNotOK, totalBusy, i;
1132 for (i = 0; i < count; i++) {
1133 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
1138 while (busyHead.count) {
1139 qGet(&busyHead, &volid);
1140 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1141 (unsigned long)volid);
1145 while (notokHead.count) {
1146 qGet(¬okHead, &volid);
1147 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1148 (unsigned long)volid);
1152 fprintf(STDOUT, "\n");
1155 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
1156 totalOK, totalNotOK, totalBusy);
1160 /*------------------------------------------------------------------------
1161 * PRIVATE XDisplayVolumes
1164 * Display extended volume information.
1167 * a_servID : Pointer to the Rx call we're performing.
1168 * a_partID : Partition for which we want the extended list.
1169 * a_xInfoP : Ptr to extended volume info.
1170 * a_count : Number of volume records contained above.
1171 * a_int32 : Int32 listing generated?
1172 * a_fast : Fast listing generated?
1173 * a_quiet : Quiet listing generated?
1179 * Nothing interesting.
1183 *------------------------------------------------------------------------*/
1186 XDisplayVolumes(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
1190 volintXInfo *a_xInfoP;
1196 { /*XDisplayVolumes */
1198 int totalOK; /*Total OK volumes */
1199 int totalNotOK; /*Total screwed volumes */
1200 int totalBusy; /*Total busy volumes */
1201 int i; /*Loop variable */
1202 afs_int32 volid; /*Current volume ID */
1205 * Initialize counters and (global!!) queues.
1214 * Display each volume in the list.
1216 for (i = 0; i < a_count; i++) {
1217 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1218 &totalBusy, a_fast, a_int32, 0);
1223 * If any volumes were found to be busy or screwed, display them.
1226 while (busyHead.count) {
1227 qGet(&busyHead, &volid);
1228 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1229 (unsigned long)volid);
1233 while (notokHead.count) {
1234 qGet(¬okHead, &volid);
1235 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1236 (unsigned long)volid);
1241 fprintf(STDOUT, "\n");
1244 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1245 totalOK, totalNotOK, totalBusy);
1249 } /*XDisplayVolumes */
1250 #ifdef FULL_LISTVOL_SWITCH
1251 /*------------------------------------------------------------------------
1252 * PRIVATE XDisplayVolumes2
1255 * Display extended formated volume information.
1258 * a_servID : Pointer to the Rx call we're performing.
1259 * a_partID : Partition for which we want the extended list.
1260 * a_xInfoP : Ptr to extended volume info.
1261 * a_count : Number of volume records contained above.
1262 * a_int32 : Int32 listing generated?
1263 * a_fast : Fast listing generated?
1264 * a_quiet : Quiet listing generated?
1270 * Nothing interesting.
1274 *------------------------------------------------------------------------*/
1277 XDisplayVolumes2(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
1281 volintXInfo *a_xInfoP;
1287 { /*XDisplayVolumes */
1289 int totalOK; /*Total OK volumes */
1290 int totalNotOK; /*Total screwed volumes */
1291 int totalBusy; /*Total busy volumes */
1292 int i; /*Loop variable */
1293 afs_int32 volid; /*Current volume ID */
1296 * Initialize counters and (global!!) queues.
1305 * Display each volume in the list.
1307 for (i = 0; i < a_count; i++) {
1308 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1309 XDisplayFormat2(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1310 &totalBusy, a_fast, a_int32, 0);
1311 fprintf(STDOUT, "END_OF_ENTRY\n");
1316 * If any volumes were found to be busy or screwed, display them.
1319 while (busyHead.count) {
1320 qGet(&busyHead, &volid);
1321 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1322 (unsigned long)volid);
1326 while (notokHead.count) {
1327 qGet(¬okHead, &volid);
1328 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1329 (unsigned long)volid);
1334 fprintf(STDOUT, "\n");
1337 "VOLUMES_ONLINE\t%d\nVOLUMES_OFFLINE\t%d\nVOLUMES_BUSY\t%d\n",
1338 totalOK, totalNotOK, totalBusy);
1342 } /*XDisplayVolumes2 */
1343 #endif /* FULL_LISTVOL_SWITCH */
1346 /* set <server> and <part> to the correct values depending on
1347 * <voltype> and <entry> */
1349 GetServerAndPart(entry, voltype, server, part, previdx)
1350 struct nvldbentry *entry;
1351 afs_int32 *server, *part;
1355 int i, istart, vtype;
1360 /* Doesn't check for non-existance of backup volume */
1361 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1363 istart = 0; /* seach the entire entry */
1366 /* Seach from beginning of entry or pick up where we left off */
1367 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1370 for (i = istart; i < entry->nServers; i++) {
1371 if (entry->serverFlags[i] & vtype) {
1372 *server = entry->serverNumber[i];
1373 *part = entry->serverPartition[i];
1379 /* Didn't find any, return -1 */
1385 PostVolumeStats(entry)
1386 struct nvldbentry *entry;
1388 SubEnumerateEntry(entry);
1389 /* Check for VLOP_ALLOPERS */
1390 if (entry->flags & VLOP_ALLOPERS)
1391 fprintf(STDOUT, " Volume is currently LOCKED \n");
1395 /*------------------------------------------------------------------------
1396 * PRIVATE XVolumeStats
1399 * Display extended volume information.
1402 * a_xInfoP : Ptr to extended volume info.
1403 * a_entryP : Ptr to the volume's VLDB entry.
1404 * a_srvID : Server ID.
1405 * a_partID : Partition ID.
1406 * a_volType : Type of volume to print.
1412 * Nothing interesting.
1416 *------------------------------------------------------------------------*/
1419 XVolumeStats(a_xInfoP, a_entryP, a_srvID, a_partID, a_volType)
1420 volintXInfo *a_xInfoP;
1421 struct nvldbentry *a_entryP;
1428 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1430 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1431 a_srvID, /*Server ID to print */
1432 a_partID, /*Partition ID to print */
1433 &totalOK, /*Ptr to total-OK counter */
1434 &totalNotOK, /*Ptr to total-screwed counter */
1435 &totalBusy, /*Ptr to total-busy counter */
1436 0, /*Don't do a fast listing */
1437 1, /*Do a long listing */
1438 1); /*Show volume problems */
1444 VolumeStats(pntr, entry, server, part, voltype)
1446 struct nvldbentry *entry;
1448 afs_int32 server, part;
1450 int totalOK, totalNotOK, totalBusy;
1452 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1457 /* command to forcibly remove a volume */
1459 NukeVolume(register struct cmd_syndesc *as)
1461 register afs_int32 code;
1462 afs_int32 volID, err;
1467 server = GetServer(tp = as->parms[0].items->data);
1469 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1473 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1475 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1479 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1482 PrintError("", err);
1485 "vos: could not parse '%s' as a numeric volume ID", tp);
1490 "vos: forcibly removing all traces of volume %d, please wait...",
1493 code = UV_NukeVolume(server, partID, volID);
1495 fprintf(STDOUT, "done.\n");
1497 fprintf(STDOUT, "failed with code %d.\n", code);
1502 /*------------------------------------------------------------------------
1503 * PRIVATE ExamineVolume
1506 * Routine used to examine a single volume, contacting the VLDB as
1507 * well as the Volume Server.
1510 * as : Ptr to parsed command line arguments.
1513 * 0 for a successful operation,
1514 * Otherwise, one of the ubik or VolServer error values.
1517 * Nothing interesting.
1521 *------------------------------------------------------------------------
1524 ExamineVolume(register struct cmd_syndesc *as, void *arock)
1526 struct nvldbentry entry;
1527 afs_int32 vcode = 0;
1528 volintInfo *pntr = (volintInfo *) 0;
1529 volintXInfo *xInfoP = (volintXInfo *) 0;
1531 afs_int32 code, err, error = 0;
1532 int voltype, foundserv = 0, foundentry = 0;
1533 afs_int32 aserver, apart;
1535 int wantExtendedInfo; /*Do we want extended vol info? */
1537 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1539 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1542 PrintError("", err);
1544 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1545 as->parms[0].items->data);
1550 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1551 (unsigned long)volid);
1554 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1557 "Could not fetch the entry for volume number %lu from VLDB \n",
1558 (unsigned long)volid);
1562 fprintf(STDOUT, "done\n");
1563 MapHostToNetwork(&entry);
1565 if (entry.volumeId[RWVOL] == volid)
1567 else if (entry.volumeId[BACKVOL] == volid)
1569 else /* (entry.volumeId[ROVOL] == volid) */
1572 do { /* do {...} while (voltype == ROVOL) */
1573 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1574 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1575 * If its a RO vol, get the next RO entry.
1577 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1578 &aserver, &apart, &previdx);
1579 if (previdx == -1) { /* searched all entries */
1581 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1582 as->parms[0].items->data);
1589 /* Get information about the volume from the server */
1591 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1592 hostutil_GetNameByINet(aserver));
1595 if (wantExtendedInfo)
1596 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1598 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1600 fprintf(STDOUT, "done\n");
1604 if (code == ENODEV) {
1605 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1606 /* The VLDB says there is no backup volume and its not on disk */
1607 fprintf(STDERR, "Volume %s does not exist\n",
1608 as->parms[0].items->data);
1612 "Volume does not exist on server %s as indicated by the VLDB\n",
1613 hostutil_GetNameByINet(aserver));
1616 PrintDiagnostics("examine", code);
1618 fprintf(STDOUT, "\n");
1621 if (wantExtendedInfo)
1622 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1624 #ifdef FULL_LISTVOL_SWITCH
1625 if (as->parms[2].items) {
1626 DisplayFormat2(aserver, apart, pntr);
1627 EnumerateEntry(&entry);
1629 #endif /* FULL_LISTVOL_SWITCH */
1630 VolumeStats(pntr, &entry, aserver, apart, voltype);
1632 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1633 /* The VLDB says there is no backup volume yet we found one on disk */
1634 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1635 as->parms[0].items->data);
1644 } while (voltype == ROVOL);
1647 fprintf(STDERR, "Dump only information from VLDB\n\n");
1648 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1650 PostVolumeStats(&entry);
1655 /*------------------------------------------------------------------------
1659 * Routine used to change the status of a single volume.
1662 * as : Ptr to parsed command line arguments.
1665 * 0 for a successful operation,
1666 * Otherwise, one of the ubik or VolServer error values.
1669 * Nothing interesting.
1673 *------------------------------------------------------------------------
1676 SetFields(register struct cmd_syndesc *as, void *arock)
1678 struct nvldbentry entry;
1679 afs_int32 vcode = 0;
1682 afs_int32 code, err;
1683 afs_int32 aserver, apart;
1686 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1689 PrintError("", err);
1691 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1692 as->parms[0].items->data);
1696 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1699 "Could not fetch the entry for volume number %lu from VLDB \n",
1700 (unsigned long)volid);
1703 MapHostToNetwork(&entry);
1705 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1706 if (previdx == -1) {
1707 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1708 as->parms[0].items->data);
1712 init_volintInfo(&info);
1716 if (as->parms[1].items) {
1718 code = util_GetInt32(as->parms[1].items->data, &info.maxquota);
1720 fprintf(STDERR, "invalid quota value\n");
1724 if (as->parms[2].items) {
1728 if (as->parms[3].items) {
1729 /* -clearVolUpCounter */
1732 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1735 "Could not update volume info fields for volume number %lu\n",
1736 (unsigned long)volid);
1740 /*------------------------------------------------------------------------
1744 * Brings a volume online.
1747 * as : Ptr to parsed command line arguments.
1750 * 0 for a successful operation,
1753 * Nothing interesting.
1757 *------------------------------------------------------------------------
1760 volOnline(register struct cmd_syndesc *as, void *arock)
1762 afs_int32 server, partition, volid;
1763 afs_int32 code, err = 0;
1765 server = GetServer(as->parms[0].items->data);
1767 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1768 as->parms[0].items->data);
1772 partition = volutil_GetPartitionID(as->parms[1].items->data);
1773 if (partition < 0) {
1774 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1775 as->parms[1].items->data);
1779 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1782 PrintError("", err);
1784 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1785 as->parms[0].items->data);
1789 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1792 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1799 /*------------------------------------------------------------------------
1800 * PRIVATE volOffline
1803 * Brings a volume offline.
1806 * as : Ptr to parsed command line arguments.
1809 * 0 for a successful operation,
1812 * Nothing interesting.
1816 *------------------------------------------------------------------------
1819 volOffline(register struct cmd_syndesc *as, void *arock)
1821 afs_int32 server, partition, volid;
1822 afs_int32 code, err = 0;
1823 afs_int32 transflag, sleeptime, transdone;
1825 server = GetServer(as->parms[0].items->data);
1827 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1828 as->parms[0].items->data);
1832 partition = volutil_GetPartitionID(as->parms[1].items->data);
1833 if (partition < 0) {
1834 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1835 as->parms[1].items->data);
1839 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1842 PrintError("", err);
1844 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1845 as->parms[0].items->data);
1849 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1850 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1851 transdone = (sleeptime ? 0 /*online */ : VTOutOfService);
1852 if (as->parms[4].items && !as->parms[3].items) {
1853 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1858 UV_SetVolume(server, partition, volid, transflag, transdone,
1861 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1869 CreateVolume(register struct cmd_syndesc *as, void *arock)
1873 afs_int32 volid, code;
1874 struct nvldbentry entry;
1879 tserver = GetServer(as->parms[0].items->data);
1881 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1882 as->parms[0].items->data);
1885 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1887 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1888 as->parms[1].items->data);
1891 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1893 PrintError("", code);
1896 "vos : partition %s does not exist on the server\n",
1897 as->parms[1].items->data);
1900 if (!ISNAMEVALID(as->parms[2].items->data)) {
1902 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1903 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1906 if (!VolNameOK(as->parms[2].items->data)) {
1908 "Illegal volume name %s, should not end in .readonly or .backup\n",
1909 as->parms[2].items->data);
1912 if (IsNumeric(as->parms[2].items->data)) {
1913 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1914 as->parms[2].items->data);
1917 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1919 fprintf(STDERR, "Volume %s already exists\n",
1920 as->parms[2].items->data);
1921 PrintDiagnostics("create", code);
1925 if (as->parms[3].items) {
1926 if (!IsNumeric(as->parms[3].items->data)) {
1927 fprintf(STDERR, "Initial quota %s should be numeric.\n",
1928 as->parms[3].items->data);
1932 code = util_GetInt32(as->parms[3].items->data, "a);
1934 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1940 UV_CreateVolume2(tserver, pnum, as->parms[2].items->data, quota, 0,
1943 PrintDiagnostics("create", code);
1946 MapPartIdIntoName(pnum, part);
1947 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
1948 (unsigned long)volid, part, as->parms[0].items->data);
1955 struct nvldbentry *entry;
1958 afs_int32 error, code, curserver, curpart, volid;
1960 MapHostToNetwork(entry);
1962 for (i = 0; i < entry->nServers; i++) {
1963 curserver = entry->serverNumber[i];
1964 curpart = entry->serverPartition[i];
1965 if (entry->serverFlags[i] & ITSROVOL) {
1966 volid = entry->volumeId[ROVOL];
1968 volid = entry->volumeId[RWVOL];
1970 code = UV_DeleteVolume(curserver, curpart, volid);
1978 DeleteVolume(struct cmd_syndesc *as, void *arock)
1980 afs_int32 err, code = 0;
1981 afs_int32 server = 0, partition = -1, volid;
1985 if (as->parms[0].items) {
1986 server = GetServer(as->parms[0].items->data);
1988 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1989 as->parms[0].items->data);
1994 if (as->parms[1].items) {
1995 partition = volutil_GetPartitionID(as->parms[1].items->data);
1996 if (partition < 0) {
1997 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1998 as->parms[1].items->data);
2002 /* Check for validity of the partition */
2003 if (!IsPartValid(partition, server, &code)) {
2005 PrintError("", code);
2008 "vos : partition %s does not exist on the server\n",
2009 as->parms[1].items->data);
2015 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2017 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
2018 as->parms[2].items->data);
2020 PrintError("", err);
2024 /* If the server or partition option are not complete, try to fill
2025 * them in from the VLDB entry.
2027 if ((partition == -1) || !server) {
2028 struct nvldbentry entry;
2030 code = VLDB_GetEntryByID(volid, -1, &entry);
2033 "Could not fetch the entry for volume %lu from VLDB\n",
2034 (unsigned long)volid);
2035 PrintError("", code);
2039 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
2040 || ((volid == entry.volumeId[BACKVOL])
2041 && (entry.flags & BACK_EXISTS))) {
2042 idx = Lp_GetRwIndex(&entry);
2043 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2044 || ((partition != -1)
2045 && (partition != entry.serverPartition[idx]))) {
2046 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2047 as->parms[2].items->data);
2050 } else if ((volid == entry.volumeId[ROVOL])
2051 && (entry.flags & RO_EXISTS)) {
2052 for (idx = -1, j = 0; j < entry.nServers; j++) {
2053 if (entry.serverFlags[j] != ITSROVOL)
2056 if (((server == 0) || (server == entry.serverNumber[j]))
2057 && ((partition == -1)
2058 || (partition == entry.serverPartition[j]))) {
2061 "VLDB: Volume '%s' matches more than one RO\n",
2062 as->parms[2].items->data);
2069 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2070 as->parms[2].items->data);
2074 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2075 as->parms[2].items->data);
2079 server = htonl(entry.serverNumber[idx]);
2080 partition = entry.serverPartition[idx];
2084 code = UV_DeleteVolume(server, partition, volid);
2086 PrintDiagnostics("remove", code);
2090 MapPartIdIntoName(partition, pname);
2091 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2092 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2096 #define TESTM 0 /* set for move space tests, clear for production */
2098 MoveVolume(register struct cmd_syndesc *as, void *arock)
2101 afs_int32 volid, fromserver, toserver, frompart, topart;
2102 afs_int32 flags, code, err;
2103 char fromPartName[10], toPartName[10];
2105 struct diskPartition partition; /* for space check */
2108 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2111 PrintError("", err);
2113 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2114 as->parms[0].items->data);
2117 fromserver = GetServer(as->parms[1].items->data);
2118 if (fromserver == 0) {
2119 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2120 as->parms[1].items->data);
2123 toserver = GetServer(as->parms[3].items->data);
2124 if (toserver == 0) {
2125 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2126 as->parms[3].items->data);
2129 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2131 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2132 as->parms[2].items->data);
2135 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2137 PrintError("", code);
2140 "vos : partition %s does not exist on the server\n",
2141 as->parms[2].items->data);
2144 topart = volutil_GetPartitionID(as->parms[4].items->data);
2146 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2147 as->parms[4].items->data);
2150 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2152 PrintError("", code);
2155 "vos : partition %s does not exist on the server\n",
2156 as->parms[4].items->data);
2161 if (as->parms[5].items) flags |= RV_NOCLONE;
2164 * check source partition for space to clone volume
2167 MapPartIdIntoName(topart, toPartName);
2168 MapPartIdIntoName(frompart, fromPartName);
2171 * check target partition for space to move volume
2174 code = UV_PartitionInfo(toserver, toPartName, &partition);
2176 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2180 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2183 p = (volintInfo *) 0;
2184 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2186 fprintf(STDERR, "vos:cannot access volume %lu\n",
2187 (unsigned long)volid);
2191 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2193 if (partition.free <= p->size) {
2195 "vos: no space on target partition %s to move volume %lu\n",
2196 toPartName, (unsigned long)volid);
2203 fprintf(STDOUT, "size test - don't do move\n");
2207 /* successful move still not guaranteed but shoot for it */
2210 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2212 PrintDiagnostics("move", code);
2215 MapPartIdIntoName(topart, toPartName);
2216 MapPartIdIntoName(frompart, fromPartName);
2217 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2218 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2219 as->parms[3].items->data, toPartName);
2225 CopyVolume(register struct cmd_syndesc *as, void *arock)
2227 afs_int32 volid, fromserver, toserver, frompart, topart, code, err, flags;
2228 char fromPartName[10], toPartName[10], *tovolume;
2229 struct nvldbentry entry;
2230 struct diskPartition partition; /* for space check */
2233 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2236 PrintError("", err);
2238 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2239 as->parms[0].items->data);
2242 fromserver = GetServer(as->parms[1].items->data);
2243 if (fromserver == 0) {
2244 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2245 as->parms[1].items->data);
2249 toserver = GetServer(as->parms[4].items->data);
2250 if (toserver == 0) {
2251 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2252 as->parms[4].items->data);
2256 tovolume = as->parms[3].items->data;
2257 if (!ISNAMEVALID(tovolume)) {
2259 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2260 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2263 if (!VolNameOK(tovolume)) {
2265 "Illegal volume name %s, should not end in .readonly or .backup\n",
2269 if (IsNumeric(tovolume)) {
2270 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2274 code = VLDB_GetEntryByName(tovolume, &entry);
2276 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2277 PrintDiagnostics("copy", code);
2281 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2283 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2284 as->parms[2].items->data);
2287 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2289 PrintError("", code);
2292 "vos : partition %s does not exist on the server\n",
2293 as->parms[2].items->data);
2297 topart = volutil_GetPartitionID(as->parms[5].items->data);
2299 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2300 as->parms[5].items->data);
2303 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2305 PrintError("", code);
2308 "vos : partition %s does not exist on the server\n",
2309 as->parms[5].items->data);
2314 if (as->parms[6].items) flags |= RV_OFFLINE;
2315 if (as->parms[7].items) flags |= RV_RDONLY;
2316 if (as->parms[8].items) flags |= RV_NOCLONE;
2318 MapPartIdIntoName(topart, toPartName);
2319 MapPartIdIntoName(frompart, fromPartName);
2322 * check target partition for space to move volume
2325 code = UV_PartitionInfo(toserver, toPartName, &partition);
2327 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2331 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2334 p = (volintInfo *) 0;
2335 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2337 fprintf(STDERR, "vos:cannot access volume %lu\n",
2338 (unsigned long)volid);
2342 if (partition.free <= p->size) {
2344 "vos: no space on target partition %s to copy volume %lu\n",
2345 toPartName, (unsigned long)volid);
2351 /* successful copy still not guaranteed but shoot for it */
2354 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2357 PrintDiagnostics("copy", code);
2360 MapPartIdIntoName(topart, toPartName);
2361 MapPartIdIntoName(frompart, fromPartName);
2362 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2363 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2364 tovolume, as->parms[4].items->data, toPartName);
2371 ShadowVolume(register struct cmd_syndesc *as, void *arock)
2373 afs_int32 volid, fromserver, toserver, frompart, topart, tovolid;
2374 afs_int32 code, err, flags;
2375 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2376 struct nvldbentry entry;
2377 struct diskPartition partition; /* for space check */
2380 p = (volintInfo *) 0;
2381 q = (volintInfo *) 0;
2383 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2386 PrintError("", err);
2388 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2389 as->parms[0].items->data);
2392 fromserver = GetServer(as->parms[1].items->data);
2393 if (fromserver == 0) {
2394 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2395 as->parms[1].items->data);
2399 toserver = GetServer(as->parms[3].items->data);
2400 if (toserver == 0) {
2401 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2402 as->parms[3].items->data);
2406 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2408 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2409 as->parms[2].items->data);
2412 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2414 PrintError("", code);
2417 "vos : partition %s does not exist on the server\n",
2418 as->parms[2].items->data);
2422 topart = volutil_GetPartitionID(as->parms[4].items->data);
2424 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2425 as->parms[4].items->data);
2428 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2430 PrintError("", code);
2433 "vos : partition %s does not exist on the server\n",
2434 as->parms[4].items->data);
2438 if (as->parms[5].items) {
2439 tovolume = as->parms[5].items->data;
2440 if (!ISNAMEVALID(tovolume)) {
2442 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2443 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2446 if (!VolNameOK(tovolume)) {
2448 "Illegal volume name %s, should not end in .readonly or .backup\n",
2452 if (IsNumeric(tovolume)) {
2454 "Illegal volume name %s, should not be a number\n",
2459 /* use actual name of source volume */
2460 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2462 fprintf(STDERR, "vos:cannot access volume %lu\n",
2463 (unsigned long)volid);
2466 strcpy(toVolName, p->name);
2467 tovolume = toVolName;
2468 /* save p for size checks later */
2471 if (as->parms[6].items) {
2472 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2475 PrintError("", err);
2477 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2478 as->parms[6].items->data);
2484 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2487 PrintError("", err);
2489 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2498 if (as->parms[7].items) flags |= RV_OFFLINE;
2499 if (as->parms[8].items) flags |= RV_RDONLY;
2500 if (as->parms[9].items) flags |= RV_NOCLONE;
2501 if (as->parms[10].items) flags |= RV_CPINCR;
2503 MapPartIdIntoName(topart, toPartName);
2504 MapPartIdIntoName(frompart, fromPartName);
2507 * check target partition for space to move volume
2510 code = UV_PartitionInfo(toserver, toPartName, &partition);
2512 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2516 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2519 /* Don't do this again if we did it above */
2521 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2523 fprintf(STDERR, "vos:cannot access volume %lu\n",
2524 (unsigned long)volid);
2529 /* OK if this fails */
2530 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2532 /* Treat existing volume size as "free" */
2534 p->size = (q->size < p->size) ? p->size - q->size : 0;
2536 if (partition.free <= p->size) {
2538 "vos: no space on target partition %s to copy volume %lu\n",
2539 toPartName, (unsigned long)volid);
2547 /* successful copy still not guaranteed but shoot for it */
2550 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2551 topart, tovolid, flags);
2553 PrintDiagnostics("shadow", code);
2556 MapPartIdIntoName(topart, toPartName);
2557 MapPartIdIntoName(frompart, fromPartName);
2558 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2559 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2560 as->parms[3].items->data, toPartName);
2567 CloneVolume(register struct cmd_syndesc *as, void *arock)
2569 afs_int32 server, part, volid, cloneid, voltype;
2570 char partName[10], *volname;
2571 afs_int32 code, err, flags;
2572 struct nvldbentry entry;
2574 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2577 PrintError("", err);
2579 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2580 as->parms[0].items->data);
2584 if (as->parms[1].items || as->parms[2].items) {
2585 if (!as->parms[1].items || !as->parms[2].items) {
2587 "Must specify both -server and -partition options\n");
2590 server = GetServer(as->parms[1].items->data);
2592 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2593 as->parms[1].items->data);
2596 part = volutil_GetPartitionID(as->parms[2].items->data);
2598 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2599 as->parms[2].items->data);
2602 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2604 PrintError("", code);
2607 "vos : partition %s does not exist on the server\n",
2608 as->parms[2].items->data);
2612 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2618 if (as->parms[3].items) {
2619 volname = as->parms[3].items->data;
2620 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2622 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2623 volname, VOLSER_OLDMAXVOLNAME - 1);
2626 if (!VolNameOK(volname)) {
2628 "Illegal volume name %s, should not end in .readonly or .backup\n",
2632 if (IsNumeric(volname)) {
2634 "Illegal volume name %s, should not be a number\n",
2641 if (as->parms[4].items) {
2642 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2645 PrintError("", err);
2647 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2648 as->parms[4].items->data);
2654 if (as->parms[5].items) flags |= RV_OFFLINE;
2655 if (as->parms[6].items) flags |= RV_RDONLY;
2659 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2662 PrintDiagnostics("clone", code);
2665 MapPartIdIntoName(part, partName);
2666 fprintf(STDOUT, "Created clone for volume %lu\n",
2667 as->parms[0].items->data);
2674 BackupVolume(register struct cmd_syndesc *as, void *arock)
2676 afs_int32 avolid, aserver, apart, vtype, code, err;
2677 struct nvldbentry entry;
2679 afs_int32 buvolid, buserver, bupart, butype;
2680 struct nvldbentry buentry;
2682 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2685 PrintError("", err);
2687 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2688 as->parms[0].items->data);
2691 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2695 /* verify this is a readwrite volume */
2697 if (vtype != RWVOL) {
2698 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2702 /* is there a backup volume already? */
2704 if (entry.flags & BACK_EXISTS) {
2705 /* yep, where is it? */
2707 buvolid = entry.volumeId[BACKVOL];
2708 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2713 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2716 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2722 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2723 (unsigned long)buvolid, (unsigned long)buserver);
2728 /* nope, carry on */
2730 code = UV_BackupVolume(aserver, apart, avolid);
2733 PrintDiagnostics("backup", code);
2736 fprintf(STDOUT, "Created backup volume for %s \n",
2737 as->parms[0].items->data);
2742 ReleaseVolume(register struct cmd_syndesc *as, void *arock)
2745 struct nvldbentry entry;
2746 afs_int32 avolid, aserver, apart, vtype, code, err;
2749 if (as->parms[1].items)
2751 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2754 PrintError("", err);
2756 fprintf(STDERR, "vos: can't find volume '%s'\n",
2757 as->parms[0].items->data);
2760 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2764 if (vtype != RWVOL) {
2765 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2769 if (!ISNAMEVALID(entry.name)) {
2771 "Volume name %s is too long, rename before releasing\n",
2776 code = UV_ReleaseVolume(avolid, aserver, apart, force);
2778 PrintDiagnostics("release", code);
2781 fprintf(STDOUT, "Released volume %s successfully\n",
2782 as->parms[0].items->data);
2787 DumpVolume(register struct cmd_syndesc *as, void *arock)
2789 afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i, flags;
2790 char filename[MAXPATHLEN];
2791 struct nvldbentry entry;
2793 rx_SetRxDeadTime(60 * 10);
2794 for (i = 0; i < MAXSERVERS; i++) {
2795 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2798 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2799 if (rxConn->service)
2800 rxConn->service->connDeadTime = rx_connDeadTime;
2803 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2806 PrintError("", err);
2808 fprintf(STDERR, "vos: can't find volume '%s'\n",
2809 as->parms[0].items->data);
2813 if (as->parms[3].items || as->parms[4].items) {
2814 if (!as->parms[3].items || !as->parms[4].items) {
2816 "Must specify both -server and -partition options\n");
2819 aserver = GetServer(as->parms[3].items->data);
2821 fprintf(STDERR, "Invalid server name\n");
2824 apart = volutil_GetPartitionID(as->parms[4].items->data);
2826 fprintf(STDERR, "Invalid partition name\n");
2830 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2835 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2836 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2838 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2839 as->parms[1].items->data, code);
2843 if (as->parms[2].items) {
2844 strcpy(filename, as->parms[2].items->data);
2846 strcpy(filename, "");
2849 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
2851 if (as->parms[5].items) {
2853 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2854 DumpFunction, filename, flags);
2857 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2860 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
2861 flags &= ~VOLDUMPV2_OMITDIRS;
2865 PrintDiagnostics("dump", code);
2868 if (strcmp(filename, ""))
2869 fprintf(STDERR, "Dumped volume %s in file %s\n",
2870 as->parms[0].items->data, filename);
2872 fprintf(STDERR, "Dumped volume %s in stdout \n",
2873 as->parms[0].items->data);
2887 RestoreVolume(register struct cmd_syndesc *as, void *arock)
2889 afs_int32 avolid, aparentid, aserver, apart, code, vcode, err;
2890 afs_int32 aoverwrite = ASK;
2891 afs_int32 acreation = 0, alastupdate = 0;
2892 int restoreflags, readonly = 0, offline = 0, voltype = RWVOL;
2894 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
2895 char volname[VOLSER_MAXVOLNAME + 1];
2896 struct nvldbentry entry;
2901 if (as->parms[4].items) {
2902 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2905 PrintError("", err);
2907 fprintf(STDERR, "vos: can't find volume '%s'\n",
2908 as->parms[4].items->data);
2914 if (as->parms[5].items) {
2915 if ((strcmp(as->parms[5].items->data, "a") == 0)
2916 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
2918 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
2919 || (strcmp(as->parms[5].items->data, "full") == 0)) {
2921 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
2922 || (strcmp(as->parms[5].items->data, "inc") == 0)
2923 || (strcmp(as->parms[5].items->data, "increment") == 0)
2924 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
2927 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2928 as->parms[5].items->data);
2932 if (as->parms[6].items)
2934 if (as->parms[7].items) {
2939 if (as->parms[8].items) {
2940 if ((strcmp(as->parms[8].items->data, "d") == 0)
2941 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
2942 acreation = TS_DUMP;
2943 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
2944 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
2945 acreation = TS_KEEP;
2946 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
2947 || (strcmp(as->parms[8].items->data, "new") == 0)) {
2950 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
2951 as->parms[8].items->data);
2956 if (as->parms[9].items) {
2957 if ((strcmp(as->parms[9].items->data, "d") == 0)
2958 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
2959 alastupdate = TS_DUMP;
2960 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
2961 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
2962 alastupdate = TS_KEEP;
2963 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
2964 || (strcmp(as->parms[9].items->data, "new") == 0)) {
2965 alastupdate = TS_NEW;
2967 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
2968 as->parms[9].items->data);
2973 aserver = GetServer(as->parms[0].items->data);
2975 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2976 as->parms[0].items->data);
2979 apart = volutil_GetPartitionID(as->parms[1].items->data);
2981 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2982 as->parms[1].items->data);
2985 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
2987 PrintError("", code);
2990 "vos : partition %s does not exist on the server\n",
2991 as->parms[1].items->data);
2994 strcpy(avolname, as->parms[2].items->data);
2995 if (!ISNAMEVALID(avolname)) {
2997 "vos: the name of the volume %s exceeds the size limit\n",
3001 if (!VolNameOK(avolname)) {
3003 "Illegal volume name %s, should not end in .readonly or .backup\n",
3007 if (as->parms[3].items) {
3008 strcpy(afilename, as->parms[3].items->data);
3009 if (!FileExists(afilename)) {
3010 fprintf(STDERR, "Can't access file %s\n", afilename);
3014 strcpy(afilename, "");
3017 /* Check if volume exists or not */
3019 vsu_ExtractName(volname, avolname);
3020 vcode = VLDB_GetEntryByName(volname, &entry);
3021 if (vcode) { /* no volume - do a full restore */
3022 restoreflags = RV_FULLRST;
3023 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3025 "Volume does not exist; Will perform a full restore\n");
3028 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3029 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3030 restoreflags = RV_FULLRST;
3031 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3033 "%s Volume does not exist; Will perform a full restore\n",
3034 readonly ? "RO" : "RW");
3037 avolid = entry.volumeId[voltype];
3038 } else if (entry.volumeId[voltype] != 0
3039 && entry.volumeId[voltype] != avolid) {
3040 avolid = entry.volumeId[voltype];
3042 aparentid = entry.volumeId[RWVOL];
3045 else { /* volume exists - do we do a full incremental or abort */
3046 int Oserver, Opart, Otype, vol_elsewhere = 0;
3047 struct nvldbentry Oentry;
3051 avolid = entry.volumeId[voltype];
3052 } else if (entry.volumeId[voltype] != 0
3053 && entry.volumeId[voltype] != avolid) {
3054 avolid = entry.volumeId[voltype];
3056 aparentid = entry.volumeId[RWVOL];
3058 /* A file name was specified - check if volume is on another partition */
3059 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3063 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3066 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3070 if (!vcode || (Opart != apart))
3073 if (aoverwrite == ASK) {
3074 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3076 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3080 /* Ask what to do */
3081 if (vol_elsewhere) {
3083 "The volume %s %u already exists on a different server/part\n",
3084 volname, entry.volumeId[voltype]);
3086 "Do you want to do a full restore or abort? [fa](a): ");
3089 "The volume %s %u already exists in the VLDB\n",
3090 volname, entry.volumeId[voltype]);
3092 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3095 while (!(dc == EOF || dc == '\n'))
3096 dc = getchar(); /* goto end of line */
3097 if ((c == 'f') || (c == 'F'))
3099 else if ((c == 'i') || (c == 'I'))
3105 if (aoverwrite == ABORT) {
3106 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3108 } else if (aoverwrite == FULL) {
3109 restoreflags = RV_FULLRST;
3111 "Volume exists; Will delete and perform full restore\n");
3112 } else if (aoverwrite == INC) {
3114 if (vol_elsewhere) {
3116 "%s volume %lu already exists on a different server/part; not allowed\n",
3117 readonly ? "RO" : "RW", (unsigned long)avolid);
3123 restoreflags |= RV_OFFLINE;
3125 restoreflags |= RV_RDONLY;
3127 switch (acreation) {
3129 restoreflags |= RV_CRDUMP;
3132 restoreflags |= RV_CRKEEP;
3135 restoreflags |= RV_CRNEW;
3138 if (aoverwrite == FULL)
3139 restoreflags |= RV_CRNEW;
3141 restoreflags |= RV_CRKEEP;
3144 switch (alastupdate) {
3146 restoreflags |= RV_LUDUMP;
3149 restoreflags |= RV_LUKEEP;
3152 restoreflags |= RV_LUNEW;
3155 restoreflags |= RV_LUDUMP;
3159 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3160 avolname, restoreflags, WriteData, afilename);
3162 PrintDiagnostics("restore", code);
3165 MapPartIdIntoName(apart, apartName);
3168 * patch typo here - originally "parms[1]", should be "parms[0]"
3171 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3172 as->parms[0].items->data, apartName);
3177 LockReleaseCmd(register struct cmd_syndesc *as, void *arock)
3179 afs_int32 avolid, code, err;
3181 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3184 PrintError("", err);
3186 fprintf(STDERR, "vos: can't find volume '%s'\n",
3187 as->parms[0].items->data);
3191 code = UV_LockRelease(avolid);
3193 PrintDiagnostics("unlock", code);
3196 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3197 as->parms[0].items->data);
3202 AddSite(register struct cmd_syndesc *as, void *arock)
3204 afs_int32 avolid, aserver, apart, code, err;
3205 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3207 vsu_ExtractName(avolname, as->parms[2].items->data);;
3208 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3211 PrintError("", err);
3213 fprintf(STDERR, "vos: can't find volume '%s'\n",
3214 as->parms[2].items->data);
3217 aserver = GetServer(as->parms[0].items->data);
3219 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3220 as->parms[0].items->data);
3223 apart = volutil_GetPartitionID(as->parms[1].items->data);
3225 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3226 as->parms[1].items->data);
3229 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3231 PrintError("", code);
3234 "vos : partition %s does not exist on the server\n",
3235 as->parms[1].items->data);
3238 code = UV_AddSite(aserver, apart, avolid);
3240 PrintDiagnostics("addsite", code);
3243 MapPartIdIntoName(apart, apartName);
3244 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3245 as->parms[0].items->data, apartName, as->parms[2].items->data);
3250 RemoveSite(register struct cmd_syndesc *as, void *arock)
3253 afs_int32 avolid, aserver, apart, code, err;
3254 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3256 vsu_ExtractName(avolname, as->parms[2].items->data);
3257 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3260 PrintError("", err);
3262 fprintf(STDERR, "vos: can't find volume '%s'\n",
3263 as->parms[2].items->data);
3266 aserver = GetServer(as->parms[0].items->data);
3268 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3269 as->parms[0].items->data);
3272 apart = volutil_GetPartitionID(as->parms[1].items->data);
3274 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3275 as->parms[1].items->data);
3279 *skip the partition validity check, since it is possible that the partition
3280 *has since been decomissioned.
3283 if (!IsPartValid(apart,aserver,&code)){
3284 if(code) PrintError("",code);
3285 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3289 code = UV_RemoveSite(aserver, apart, avolid);
3291 PrintDiagnostics("remsite", code);
3294 MapPartIdIntoName(apart, apartName);
3295 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3296 as->parms[0].items->data, apartName, as->parms[2].items->data);
3301 ChangeLocation(register struct cmd_syndesc *as, void *arock)
3303 afs_int32 avolid, aserver, apart, code, err;
3306 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3309 PrintError("", err);
3311 fprintf(STDERR, "vos: can't find volume '%s'\n",
3312 as->parms[2].items->data);
3315 aserver = GetServer(as->parms[0].items->data);
3317 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3318 as->parms[0].items->data);
3321 apart = volutil_GetPartitionID(as->parms[1].items->data);
3323 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3324 as->parms[1].items->data);
3327 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3329 PrintError("", code);
3332 "vos : partition %s does not exist on the server\n",
3333 as->parms[1].items->data);
3336 code = UV_ChangeLocation(aserver, apart, avolid);
3338 PrintDiagnostics("addsite", code);
3341 MapPartIdIntoName(apart, apartName);
3342 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3343 as->parms[0].items->data, apartName, as->parms[2].items->data);
3348 ListPartitions(register struct cmd_syndesc *as, void *arock)
3350 afs_int32 aserver, code;
3351 struct partList dummyPartList;
3356 aserver = GetServer(as->parms[0].items->data);
3358 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3359 as->parms[0].items->data);
3364 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3366 PrintDiagnostics("listpart", code);
3370 fprintf(STDOUT, "The partitions on the server are:\n");
3371 for (i = 0; i < cnt; i++) {
3372 if (dummyPartList.partFlags[i] & PARTVALID) {
3373 memset(pname, 0, sizeof(pname));
3374 MapPartIdIntoName(dummyPartList.partId[i], pname);
3375 fprintf(STDOUT, " %10s ", pname);
3377 if ((i % 5) == 0 && (i != 0))
3378 fprintf(STDOUT, "\n");
3381 fprintf(STDOUT, "\n");
3382 fprintf(STDOUT, "Total: %d\n", total);
3388 CompareVolName(p1, p2)
3391 volintInfo *arg1, *arg2;
3393 arg1 = (volintInfo *) p1;
3394 arg2 = (volintInfo *) p2;
3395 return (strcmp(arg1->name, arg2->name));
3399 /*------------------------------------------------------------------------
3400 * PRIVATE XCompareVolName
3403 * Comparison routine for volume names coming from an extended
3407 * a_obj1P : Char ptr to first extended vol info object
3408 * a_obj1P : Char ptr to second extended vol info object
3411 * The value of strcmp() on the volume names within the passed
3412 * objects (i,e., -1, 0, or 1).
3415 * Passed to qsort() as the designated comparison routine.
3419 *------------------------------------------------------------------------*/
3422 XCompareVolName(a_obj1P, a_obj2P)
3423 char *a_obj1P, *a_obj2P;
3425 { /*XCompareVolName */
3428 (((struct volintXInfo *)(a_obj1P))->name,
3429 ((struct volintXInfo *)(a_obj2P))->name));
3431 } /*XCompareVolName */
3434 CompareVolID(p1, p2)
3437 volintInfo *arg1, *arg2;
3439 arg1 = (volintInfo *) p1;
3440 arg2 = (volintInfo *) p2;
3441 if (arg1->volid == arg2->volid)
3443 if (arg1->volid > arg2->volid)
3450 /*------------------------------------------------------------------------
3451 * PRIVATE XCompareVolID
3454 * Comparison routine for volume IDs coming from an extended
3458 * a_obj1P : Char ptr to first extended vol info object
3459 * a_obj1P : Char ptr to second extended vol info object
3462 * The value of strcmp() on the volume names within the passed
3463 * objects (i,e., -1, 0, or 1).
3466 * Passed to qsort() as the designated comparison routine.
3470 *------------------------------------------------------------------------*/
3473 XCompareVolID(a_obj1P, a_obj2P)
3474 char *a_obj1P, *a_obj2P;
3476 { /*XCompareVolID */
3478 afs_int32 id1, id2; /*Volume IDs we're comparing */
3480 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3481 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3489 } /*XCompareVolID */
3491 /*------------------------------------------------------------------------
3492 * PRIVATE ListVolumes
3495 * Routine used to list volumes, contacting the Volume Server
3496 * directly, bypassing the VLDB.
3499 * as : Ptr to parsed command line arguments.
3502 * 0 Successful operation
3505 * Nothing interesting.
3509 *------------------------------------------------------------------------*/
3512 ListVolumes(register struct cmd_syndesc *as, void *arock)
3514 afs_int32 apart, int32list, fast;
3515 afs_int32 aserver, code;
3516 volintInfo *pntr, *oldpntr;
3520 volintXInfo *xInfoP, *origxInfoP; /*Ptr to current/orig extended vol info */
3521 int wantExtendedInfo; /*Do we want extended vol info? */
3524 struct partList dummyPartList;
3532 if (as->parms[3].items)
3534 if (as->parms[4].items)
3538 if (as->parms[2].items)
3544 if (as->parms[5].items) {
3546 * We can't coexist with the fast flag.
3550 "vos: Can't use the -fast and -extended flags together\n");
3555 * We need to turn on ``long'' listings to get the full effect.
3557 wantExtendedInfo = 1;
3560 wantExtendedInfo = 0;
3561 if (as->parms[1].items) {
3562 apart = volutil_GetPartitionID(as->parms[1].items->data);
3564 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3565 as->parms[1].items->data);
3568 dummyPartList.partId[0] = apart;
3569 dummyPartList.partFlags[0] = PARTVALID;
3572 aserver = GetServer(as->parms[0].items->data);
3574 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3575 as->parms[0].items->data);
3580 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3582 PrintError("", code);
3585 "vos : partition %s does not exist on the server\n",
3586 as->parms[1].items->data);
3590 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3592 PrintDiagnostics("listvol", code);
3596 for (i = 0; i < cnt; i++) {
3597 if (dummyPartList.partFlags[i] & PARTVALID) {
3598 if (wantExtendedInfo)
3600 UV_XListVolumes(aserver, dummyPartList.partId[i], all,
3604 UV_ListVolumes(aserver, dummyPartList.partId[i], all,
3607 PrintDiagnostics("listvol", code);
3612 if (wantExtendedInfo) {
3613 origxInfoP = xInfoP;
3614 base = (char *)xInfoP;
3617 base = (char *)pntr;
3621 if (wantExtendedInfo)
3622 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
3624 qsort(base, count, sizeof(volintInfo), CompareVolName);
3626 if (wantExtendedInfo)
3627 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
3629 qsort(base, count, sizeof(volintInfo), CompareVolID);
3631 MapPartIdIntoName(dummyPartList.partId[i], pname);
3634 "Total number of volumes on server %s partition %s: %lu \n",
3635 as->parms[0].items->data, pname,
3636 (unsigned long)count);
3637 if (wantExtendedInfo) {
3638 #ifdef FULL_LISTVOL_SWITCH
3639 if (as->parms[6].items)
3640 XDisplayVolumes2(aserver, dummyPartList.partId[i], origxInfoP,
3641 count, int32list, fast, quiet);
3643 #endif /* FULL_LISTVOL_SWITCH */
3644 XDisplayVolumes(aserver, dummyPartList.partId[i], origxInfoP,
3645 count, int32list, fast, quiet);
3648 xInfoP = (volintXInfo *) 0;
3650 #ifdef FULL_LISTVOL_SWITCH
3651 if (as->parms[6].items)
3652 DisplayVolumes2(aserver, dummyPartList.partId[i], oldpntr,
3655 #endif /* FULL_LISTVOL_SWITCH */
3656 DisplayVolumes(aserver, dummyPartList.partId[i], oldpntr,
3657 count, int32list, fast, quiet);
3660 pntr = (volintInfo *) 0;
3668 SyncVldb(register struct cmd_syndesc *as, void *arock)
3670 afs_int32 pnum = 0, code; /* part name */
3676 if (as->parms[0].items) {
3677 tserver = GetServer(as->parms[0].items->data);
3679 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3680 as->parms[0].items->data);
3685 if (as->parms[1].items) {
3686 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3688 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3689 as->parms[1].items->data);
3692 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3694 PrintError("", code);
3697 "vos: partition %s does not exist on the server\n",
3698 as->parms[1].items->data);
3705 "The -partition option requires a -server option\n");
3710 if (as->parms[2].items) {
3711 /* Synchronize an individual volume */
3712 volname = as->parms[2].items->data;
3713 code = UV_SyncVolume(tserver, pnum, volname, flags);
3717 "Without a -volume option, the -server option is required\n");
3720 code = UV_SyncVldb(tserver, pnum, flags, 0 /*unused */ );
3724 PrintDiagnostics("syncvldb", code);
3728 /* Print a summary of what we did */
3730 fprintf(STDOUT, "VLDB volume %s synchronized", volname);
3732 fprintf(STDOUT, "VLDB synchronized");
3734 fprintf(STDOUT, " with state of server %s", as->parms[0].items->data);
3737 MapPartIdIntoName(pnum, part);
3738 fprintf(STDOUT, " partition %s\n", part);
3740 fprintf(STDOUT, "\n");
3746 SyncServer(register struct cmd_syndesc *as, void *arock)
3748 afs_int32 pnum, code; /* part name */
3753 tserver = GetServer(as->parms[0].items->data);
3755 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3756 as->parms[0].items->data);
3759 if (as->parms[1].items) {
3760 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3762 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3763 as->parms[1].items->data);
3766 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3768 PrintError("", code);
3771 "vos : partition %s does not exist on the server\n",
3772 as->parms[1].items->data);
3780 code = UV_SyncServer(tserver, pnum, flags, 0 /*unused */ );
3782 PrintDiagnostics("syncserv", code);
3786 MapPartIdIntoName(pnum, part);
3787 fprintf(STDOUT, "Server %s partition %s synchronized with VLDB\n",
3788 as->parms[0].items->data, part);
3790 fprintf(STDOUT, "Server %s synchronized with VLDB\n",
3791 as->parms[0].items->data);
3800 struct nvldbentry entry;
3803 /* The vlserver will handle names with the .readonly
3804 * and .backup extension as well as volume ids.
3806 vcode = VLDB_GetEntryByName(name, &entry);
3808 PrintError("", vcode);
3811 MapHostToNetwork(&entry);
3812 EnumerateEntry(&entry);
3814 /* Defect #3027: grubby check to handle locked volume.
3815 * If VLOP_ALLOPERS is set, the entry is locked.
3816 * Leave this routine as is, but put in correct check.
3818 if (entry.flags & VLOP_ALLOPERS)
3819 fprintf(STDOUT, " Volume is currently LOCKED \n");
3825 VolumeZap(register struct cmd_syndesc *as, void *arock)
3827 struct nvldbentry entry;
3828 afs_int32 volid, code, server, part, zapbackupid = 0, backupid = 0, err;
3830 if (as->parms[3].items) {
3831 /* force flag is on, use the other version */
3832 return NukeVolume(as);
3835 if (as->parms[4].items) {
3839 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3842 PrintError("", err);
3844 fprintf(STDERR, "vos: can't find volume '%s'\n",
3845 as->parms[2].items->data);
3848 part = volutil_GetPartitionID(as->parms[1].items->data);
3850 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3851 as->parms[1].items->data);
3854 server = GetServer(as->parms[0].items->data);
3856 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3857 as->parms[0].items->data);
3860 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
3862 PrintError("", code);
3865 "vos : partition %s does not exist on the server\n",
3866 as->parms[1].items->data);
3869 code = VLDB_GetEntryByID(volid, -1, &entry);
3871 if (volid == entry.volumeId[RWVOL])
3872 backupid = entry.volumeId[BACKVOL];
3874 "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
3875 (unsigned long)volid);
3878 volintInfo *pntr = (volintInfo *) 0;
3881 code = UV_ListOneVolume(server, part, volid, &pntr);
3883 if (volid == pntr->parentID)
3884 backupid = pntr->backupID;
3890 code = UV_VolumeZap(server, part, backupid);
3892 PrintDiagnostics("zap", code);
3895 fprintf(STDOUT, "Backup Volume %lu deleted\n",
3896 (unsigned long)backupid);
3899 code = UV_VolumeZap(server, part, volid);
3901 PrintDiagnostics("zap", code);
3904 fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
3910 VolserStatus(register struct cmd_syndesc *as, void *arock)
3912 afs_int32 server, code;
3913 transDebugInfo *pntr, *oldpntr;
3918 server = GetServer(as->parms[0].items->data);
3920 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3921 as->parms[0].items->data);
3924 code = UV_VolserStatus(server, &pntr, &count);
3926 PrintDiagnostics("status", code);
3931 fprintf(STDOUT, "No active transactions on %s\n",
3932 as->parms[0].items->data);
3934 fprintf(STDOUT, "Total transactions: %d\n", count);
3936 for (i = 0; i < count; i++) {
3937 /*print out the relevant info */
3938 fprintf(STDOUT, "--------------------------------------\n");
3939 fprintf(STDOUT, "transaction: %lu created: %s",
3940 (unsigned long)pntr->tid, vos_ctime( & pntr->time));
3941 if (pntr->returnCode) {
3942 fprintf(STDOUT, "returnCode: %lu\n",
3943 (unsigned long)pntr->returnCode);
3946 fprintf(STDOUT, "attachFlags: ");
3947 switch (pntr->iflags) {
3949 fprintf(STDOUT, "offline ");
3952 fprintf(STDOUT, "busy ");
3955 fprintf(STDOUT, "readonly ");
3958 fprintf(STDOUT, "create ");
3961 fprintf(STDOUT, "create volid ");
3964 fprintf(STDOUT, "\n");
3967 fprintf(STDOUT, "volumeStatus: ");
3968 switch (pntr->vflags) {
3969 case VTDeleteOnSalvage:
3970 fprintf(STDOUT, "deleteOnSalvage ");
3971 case VTOutOfService:
3972 fprintf(STDOUT, "outOfService ");
3974 fprintf(STDOUT, "deleted ");
3976 fprintf(STDOUT, "\n");
3979 fprintf(STDOUT, "transactionFlags: ");
3980 fprintf(STDOUT, "delete\n");
3982 MapPartIdIntoName(pntr->partition, pname);
3983 fprintf(STDOUT, "volume: %lu partition: %s procedure: %s\n",
3984 (unsigned long)pntr->volid, pname, pntr->lastProcName);
3985 if (pntr->callValid) {
3987 "packetRead: %lu lastReceiveTime: %d packetSend: %lu lastSendTime: %d\n",
3988 (unsigned long)pntr->readNext, pntr->lastReceiveTime,
3989 (unsigned long)pntr->transmitNext, pntr->lastSendTime);
3992 fprintf(STDOUT, "--------------------------------------\n");
3993 fprintf(STDOUT, "\n");
4001 RenameVolume(register struct cmd_syndesc *as, void *arock)
4003 afs_int32 code1, code2, code;
4004 struct nvldbentry entry;
4006 code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
4008 fprintf(STDERR, "vos: Could not find entry for volume %s\n",
4009 as->parms[0].items->data);
4012 code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
4013 if ((!code1) && (!code2)) { /*the newname already exists */
4014 fprintf(STDERR, "vos: volume %s already exists\n",
4015 as->parms[1].items->data);
4019 if (code1 && code2) {
4020 fprintf(STDERR, "vos: Could not find entry for volume %s or %s\n",
4021 as->parms[0].items->data, as->parms[1].items->data);
4024 if (!VolNameOK(as->parms[0].items->data)) {
4026 "Illegal volume name %s, should not end in .readonly or .backup\n",
4027 as->parms[0].items->data);
4030 if (!ISNAMEVALID(as->parms[1].items->data)) {
4032 "vos: the new volume name %s exceeds the size limit of %d\n",
4033 as->parms[1].items->data, VOLSER_OLDMAXVOLNAME - 10);
4036 if (!VolNameOK(as->parms[1].items->data)) {
4038 "Illegal volume name %s, should not end in .readonly or .backup\n",
4039 as->parms[1].items->data);
4042 if (IsNumeric(as->parms[1].items->data)) {
4043 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
4044 as->parms[1].items->data);
4047 MapHostToNetwork(&entry);
4049 UV_RenameVolume(&entry, as->parms[0].items->data,
4050 as->parms[1].items->data);
4052 PrintDiagnostics("rename", code);
4055 fprintf(STDOUT, "Renamed volume %s to %s\n", as->parms[0].items->data,
4056 as->parms[1].items->data);
4060 GetVolumeInfo(volid, server, part, voltype, rentry)
4061 afs_int32 *server, volid, *part, *voltype;
4062 register struct nvldbentry *rentry;
4067 vcode = VLDB_GetEntryByID(volid, -1, rentry);
4070 "Could not fetch the entry for volume %lu from VLDB \n",
4071 (unsigned long)volid);
4072 PrintError("", vcode);
4075 MapHostToNetwork(rentry);
4076 if (volid == rentry->volumeId[ROVOL]) {
4078 for (i = 0; i < rentry->nServers; i++) {
4079 if ((index == -1) && (rentry->serverFlags[i] & ITSROVOL)
4080 && !(rentry->serverFlags[i] & RO_DONTUSE))
4085 "RO volume is not found in VLDB entry for volume %lu\n",
4086 (unsigned long)volid);
4090 *server = rentry->serverNumber[index];
4091 *part = rentry->serverPartition[index];
4095 index = Lp_GetRwIndex(rentry);
4098 "RW Volume is not found in VLDB entry for volume %lu\n",
4099 (unsigned long)volid);
4102 if (volid == rentry->volumeId[RWVOL]) {
4104 *server = rentry->serverNumber[index];
4105 *part = rentry->serverPartition[index];
4108 if (volid == rentry->volumeId[BACKVOL]) {
4110 *server = rentry->serverNumber[index];
4111 *part = rentry->serverPartition[index];
4115 "unexpected volume type for volume %lu\n",
4116 (unsigned long)volid);
4121 DeleteEntry(register struct cmd_syndesc *as, void *arock)
4126 struct VldbListByAttributes attributes;
4127 nbulkentries arrayEntries;
4128 register struct nvldbentry *vllist;
4129 struct cmd_item *itp;
4132 char prefix[VOLSER_MAXVOLNAME + 1];
4134 afs_int32 totalBack = 0, totalFail = 0, err;
4136 if (as->parms[0].items) { /* -id */
4137 if (as->parms[1].items || as->parms[2].items || as->parms[3].items) {
4139 "You cannot use -server, -partition, or -prefix with the -id argument\n");
4142 for (itp = as->parms[0].items; itp; itp = itp->next) {
4143 avolid = vsu_GetVolumeID(itp->data, cstruct, &err);
4146 PrintError("", err);
4148 fprintf(STDERR, "vos: can't find volume '%s'\n",
4152 if (as->parms[4].items) { /* -noexecute */
4153 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4158 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4160 fprintf(STDERR, "Could not delete entry for volume %s\n",
4163 "You must specify a RW volume name or ID "
4164 "(the entire VLDB entry will be deleted)\n");
4165 PrintError("", vcode);
4171 fprintf(STDOUT, "Deleted %d VLDB entries\n", totalBack);
4175 if (!as->parms[1].items && !as->parms[2].items && !as->parms[3].items) {
4176 fprintf(STDERR, "You must specify an option\n");
4180 /* Zero out search attributes */
4181 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4183 if (as->parms[1].items) { /* -prefix */
4184 strncpy(prefix, as->parms[1].items->data, VOLSER_MAXVOLNAME);
4186 if (!as->parms[2].items && !as->parms[3].items) { /* a single entry only */
4188 "You must provide -server with the -prefix argument\n");
4193 if (as->parms[2].items) { /* -server */
4195 aserver = GetServer(as->parms[2].items->data);
4197 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4198 as->parms[2].items->data);
4201 attributes.server = ntohl(aserver);
4202 attributes.Mask |= VLLIST_SERVER;
4205 if (as->parms[3].items) { /* -partition */
4206 if (!as->parms[2].items) {
4208 "You must provide -server with the -partition argument\n");
4211 apart = volutil_GetPartitionID(as->parms[3].items->data);
4213 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4214 as->parms[3].items->data);
4217 attributes.partition = apart;
4218 attributes.Mask |= VLLIST_PARTITION;
4221 /* Print status line of what we are doing */
4222 fprintf(STDOUT, "Deleting VLDB entries for ");
4223 if (as->parms[2].items) {
4224 fprintf(STDOUT, "server %s ", as->parms[2].items->data);
4226 if (as->parms[3].items) {
4228 MapPartIdIntoName(apart, pname);
4229 fprintf(STDOUT, "partition %s ", pname);
4232 fprintf(STDOUT, "which are prefixed with %s ", prefix);
4234 fprintf(STDOUT, "\n");
4237 /* Get all the VLDB entries on a server and/or partition */
4238 memset(&arrayEntries, 0, sizeof(arrayEntries));
4239 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4241 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4242 PrintError("", vcode);
4246 /* Process each entry */
4247 for (j = 0; j < nentries; j++) {
4248 vllist = &arrayEntries.nbulkentries_val[j];
4250 /* It only deletes the RW volumes */
4251 if (strncmp(vllist->name, prefix, strlen(prefix))) {
4254 "Omitting to delete %s due to prefix %s mismatch\n",
4255 vllist->name, prefix);
4262 if (as->parms[4].items) { /* -noexecute */
4263 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4269 /* Only matches the RW volume name */
4270 avolid = vllist->volumeId[RWVOL];
4271 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4273 fprintf(STDOUT, "Could not delete VDLB entry for %s\n",
4276 PrintError("", vcode);
4281 fprintf(STDOUT, "Deleted VLDB entry for %s \n", vllist->name);
4286 fprintf(STDOUT, "----------------------\n");
4288 "Total VLDB entries deleted: %lu; failed to delete: %lu\n",
4289 (unsigned long)totalBack, (unsigned long)totalFail);
4290 if (arrayEntries.nbulkentries_val)
4291 free(arrayEntries.nbulkentries_val);
4297 CompareVldbEntryByName(p1, p2)
4300 struct nvldbentry *arg1, *arg2;
4302 arg1 = (struct nvldbentry *)p1;
4303 arg2 = (struct nvldbentry *)p2;
4304 return (strcmp(arg1->name, arg2->name));
4308 static int CompareVldbEntry(p1,p2)
4311 struct nvldbentry *arg1,*arg2;
4314 char comp1[100],comp2[100];
4315 char temp1[20],temp2[20];
4317 arg1 = (struct nvldbentry *)p1;
4318 arg2 = (struct nvldbentry *)p2;
4322 for(i = 0; i < arg1->nServers; i++)
4323 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
4324 for(i = 0; i < arg2->nServers; i++)
4325 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
4326 if(pos1 == -1 || pos2 == -1){
4330 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
4331 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
4332 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
4333 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
4334 strcat(comp1,temp1);
4335 strcat(comp2,temp2);
4336 strcat(comp1,arg1->name);
4337 strcat(comp1,arg2->name);
4338 return(strcmp(comp1,comp2));
4344 ListVLDB(struct cmd_syndesc *as, void *arock)
4347 afs_int32 aserver, code;
4349 struct VldbListByAttributes attributes;
4350 nbulkentries arrayEntries;
4351 struct nvldbentry *vllist, *tarray = 0, *ttarray;
4352 afs_int32 centries, nentries = 0, tarraysize, parraysize;
4355 int quiet, sort, lock;
4356 afs_int32 thisindex, nextindex;
4361 attributes.Mask = 0;
4362 lock = (as->parms[3].items ? 1 : 0); /* -lock flag */
4363 quiet = (as->parms[4].items ? 1 : 0); /* -quit flag */
4364 sort = (as->parms[5].items ? 0 : 1); /* -nosort flag */
4366 /* If the volume name is given, Use VolumeInfoCmd to look it up
4367 * and not ListAttributes.
4369 if (as->parms[0].items) {
4372 "vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
4375 code = VolumeInfoCmd(as->parms[0].items->data);
4377 PrintError("", code);
4383 /* Server specified */
4384 if (as->parms[1].items) {
4385 aserver = GetServer(as->parms[1].items->data);
4387 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4388 as->parms[1].items->data);
4391 attributes.server = ntohl(aserver);
4392 attributes.Mask |= VLLIST_SERVER;
4395 /* Partition specified */
4396 if (as->parms[2].items) {
4397 apart = volutil_GetPartitionID(as->parms[2].items->data);
4399 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4400 as->parms[2].items->data);
4403 attributes.partition = apart;
4404 attributes.Mask |= VLLIST_PARTITION;
4408 attributes.Mask |= VLLIST_FLAG;
4409 attributes.flag = VLOP_ALLOPERS;
4412 /* Print header information */
4414 MapPartIdIntoName(apart, pname);
4415 fprintf(STDOUT, "VLDB entries for %s %s%s%s %s\n",
4416 (as->parms[1].items ? "server" : "all"),
4417 (as->parms[1].items ? as->parms[1].items->data : "servers"),
4418 (as->parms[2].items ? " partition " : ""),
4419 (as->parms[2].items ? pname : ""),
4420 (lock ? "which are locked:" : ""));
4423 for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
4424 memset(&arrayEntries, 0, sizeof(arrayEntries));
4429 VLDB_ListAttributesN2(&attributes, 0, thisindex, ¢ries,
4430 &arrayEntries, &nextindex);
4431 if (vcode == RXGEN_OPCODE) {
4432 /* Vlserver not running with ListAttributesN2. Fall back */
4434 VLDB_ListAttributes(&attributes, ¢ries, &arrayEntries);
4438 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4439 PrintError("", vcode);
4442 nentries += centries;
4444 /* We don't sort, so just print the entries now */
4446 for (j = 0; j < centries; j++) { /* process each entry */
4447 vllist = &arrayEntries.nbulkentries_val[j];
4448 MapHostToNetwork(vllist);
4449 EnumerateEntry(vllist);
4451 if (vllist->flags & VLOP_ALLOPERS)
4452 fprintf(STDOUT, " Volume is currently LOCKED \n");
4456 /* So we sort. First we must collect all the entries and keep
4459 else if (centries > 0) {
4461 /* steal away the first bulk entries array */
4462 tarray = (struct nvldbentry *)arrayEntries.nbulkentries_val;
4463 tarraysize = centries * sizeof(struct nvldbentry);
4464 arrayEntries.nbulkentries_val = 0;
4466 /* Grow the tarray to keep the extra entries */
4467 parraysize = (centries * sizeof(struct nvldbentry));
4469 (struct nvldbentry *)realloc(tarray,
4470 tarraysize + parraysize);
4473 "Could not allocate enough space for the VLDB entries\n");
4479 memcpy(((char *)tarray) + tarraysize,
4480 (char *)arrayEntries.nbulkentries_val, parraysize);
4481 tarraysize += parraysize;
4485 /* Free the bulk array */
4486 if (arrayEntries.nbulkentries_val) {
4487 free(arrayEntries.nbulkentries_val);
4488 arrayEntries.nbulkentries_val = 0;
4492 /* Here is where we now sort all the entries and print them */
4493 if (sort && (nentries > 0)) {
4494 qsort((char *)tarray, nentries, sizeof(struct nvldbentry),
4495 CompareVldbEntryByName);
4496 for (vllist = tarray, j = 0; j < nentries; j++, vllist++) {
4497 MapHostToNetwork(vllist);
4498 EnumerateEntry(vllist);
4500 if (vllist->flags & VLOP_ALLOPERS)
4501 fprintf(STDOUT, " Volume is currently LOCKED \n");
4507 fprintf(STDOUT, "\nTotal entries: %lu\n", (unsigned long)nentries);
4514 BackSys(register struct cmd_syndesc *as, void *arock)
4516 afs_int32 apart = 0, avolid;
4517 afs_int32 aserver = 0, code, aserver1, apart1;
4519 struct VldbListByAttributes attributes;
4520 nbulkentries arrayEntries;
4521 register struct nvldbentry *vllist;
4525 int seenprefix, seenxprefix, exclude, ex, exp, noaction;
4526 afs_int32 totalBack = 0;
4527 afs_int32 totalFail = 0;
4528 int previdx = -1, error, same;
4530 struct cmd_item *ti;
4534 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4535 attributes.Mask = 0;
4537 seenprefix = (as->parms[0].items ? 1 : 0);
4538 exclude = (as->parms[3].items ? 1 : 0);
4539 seenxprefix = (as->parms[4].items ? 1 : 0);
4540 noaction = (as->parms[5].items ? 1 : 0);
4542 if (as->parms[1].items) { /* -server */
4543 aserver = GetServer(as->parms[1].items->data);
4545 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4546 as->parms[1].items->data);
4549 attributes.server = ntohl(aserver);
4550 attributes.Mask |= VLLIST_SERVER;
4553 if (as->parms[2].items) { /* -partition */
4554 apart = volutil_GetPartitionID(as->parms[2].items->data);
4556 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4557 as->parms[2].items->data);
4560 attributes.partition = apart;
4561 attributes.Mask |= VLLIST_PARTITION;
4564 /* Check to make sure the prefix and xprefix expressions compile ok */
4566 for (ti = as->parms[0].items; ti; ti = ti->next) {
4567 if (strncmp(ti->data, "^", 1) == 0) {
4568 #ifdef HAVE_POSIX_REGEX
4572 code = regcomp(&re, ti->data, REG_NOSUB);
4574 regerror(code, &re, errbuf, sizeof errbuf);
4576 "Unrecognizable -prefix regular expression: '%s': %s\n",
4582 ccode = (char *)re_comp(ti->data);
4585 "Unrecognizable -prefix regular expression: '%s': %s\n",
4594 for (ti = as->parms[4].items; ti; ti = ti->next) {
4595 if (strncmp(ti->data, "^", 1) == 0) {
4596 #ifdef HAVE_POSIX_REGEX
4600 code = regcomp(&re, ti->data, REG_NOSUB);
4602 regerror(code, &re, errbuf, sizeof errbuf);
4604 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4610 ccode = (char *)re_comp(ti->data);
4613 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4622 memset(&arrayEntries, 0, sizeof(arrayEntries)); /* initialize to hint the stub to alloc space */
4623 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4625 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4626 PrintError("", vcode);
4630 if (as->parms[1].items || as->parms[2].items || verbose) {
4631 fprintf(STDOUT, "%s up volumes",
4632 (noaction ? "Would have backed" : "Backing"));
4634 if (as->parms[1].items) {
4635 fprintf(STDOUT, " on server %s", as->parms[1].items->data);
4636 } else if (as->parms[2].items) {
4637 fprintf(STDOUT, " for all servers");
4640 if (as->parms[2].items) {
4641 MapPartIdIntoName(apart, pname);
4642 fprintf(STDOUT, " partition %s", pname);
4645 if (seenprefix || (!seenprefix && seenxprefix)) {
4646 ti = (seenprefix ? as->parms[0].items : as->parms[4].items);
4647 ex = (seenprefix ? exclude : !exclude);
4648 exp = (strncmp(ti->data, "^", 1) == 0);
4649 fprintf(STDOUT, " which %smatch %s '%s'", (ex ? "do not " : ""),
4650 (exp ? "expression" : "prefix"), ti->data);
4651 for (ti = ti->next; ti; ti = ti->next) {
4652 exp = (strncmp(ti->data, "^", 1) == 0);
4653 printf(" %sor %s '%s'", (ex ? "n" : ""),
4654 (exp ? "expression" : "prefix"), ti->data);
4658 if (seenprefix && seenxprefix) {
4659 ti = as->parms[4].items;
4660 exp = (strncmp(ti->data, "^", 1) == 0);
4661 fprintf(STDOUT, " %swhich match %s '%s'",
4662 (exclude ? "adding those " : "removing those "),
4663 (exp ? "expression" : "prefix"), ti->data);
4664 for (ti = ti->next; ti; ti = ti->next) {
4665 exp = (strncmp(ti->data, "^", 1) == 0);
4666 printf(" or %s '%s'", (exp ? "expression" : "prefix"),
4670 fprintf(STDOUT, " .. ");
4672 fprintf(STDOUT, "\n");
4676 for (j = 0; j < nentries; j++) { /* process each vldb entry */
4677 vllist = &arrayEntries.nbulkentries_val[j];
4680 for (ti = as->parms[0].items; ti; ti = ti->next) {
4681 if (strncmp(ti->data, "^", 1) == 0) {
4682 #ifdef HAVE_POSIX_REGEX
4686 /* XXX -- should just do the compile once! */
4687 code = regcomp(&re, ti->data, REG_NOSUB);
4689 regerror(code, &re, errbuf, sizeof errbuf);
4691 "Error in -prefix regular expression: '%s': %s\n",
4695 match = (regexec(&re, vllist->name, 0, NULL, 0) == 0);
4698 ccode = (char *)re_comp(ti->data);
4701 "Error in -prefix regular expression: '%s': %s\n",
4705 match = (re_exec(vllist->name) == 1);
4709 (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4719 /* Without the -exclude flag: If it matches the prefix, then
4720 * check if we want to exclude any from xprefix.
4721 * With the -exclude flag: If it matches the prefix, then
4722 * check if we want to add any from xprefix.
4724 if (match && seenxprefix) {
4725 for (ti = as->parms[4].items; ti; ti = ti->next) {
4726 if (strncmp(ti->data, "^", 1) == 0) {
4727 #ifdef HAVE_POSIX_REGEX
4731 /* XXX -- should just do the compile once! */
4732 code = regcomp(&re, ti->data, REG_NOSUB);
4734 regerror(code, &re, errbuf, sizeof errbuf);
4736 "Error in -xprefix regular expression: '%s': %s\n",
4740 if (regexec(&re, vllist->name, 0, NULL, 0) == 0)
4744 ccode = (char *)re_comp(ti->data);
4747 "Error in -xprefix regular expression: '%s': %s\n",
4751 if (re_exec(vllist->name) == 1) {
4757 if (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4767 match = !match; /* -exclude will reverse the match */
4769 continue; /* Skip if no match */
4771 /* Print list of volumes to backup */
4773 fprintf(STDOUT, " %s\n", vllist->name);
4777 if (!(vllist->flags & RW_EXISTS)) {
4780 "Omitting to backup %s since RW volume does not exist \n",
4782 fprintf(STDOUT, "\n");
4788 avolid = vllist->volumeId[RWVOL];
4789 MapHostToNetwork(vllist);
4790 GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
4791 if (aserver1 == -1 || apart1 == -1) {
4792 fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n",
4798 same = VLDB_IsSameAddrs(aserver, aserver1, &error);
4801 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4807 if ((aserver && !same) || (apart && (apart != apart1))) {
4810 "Omitting to backup %s since the RW is in a different location\n",
4816 time_t now = time(0);
4817 fprintf(STDOUT, "Creating backup volume for %s on %s",
4818 vllist->name, ctime(&now));
4822 code = UV_BackupVolume(aserver1, apart1, avolid);
4824 fprintf(STDOUT, "Could not backup %s\n", vllist->name);
4830 fprintf(STDOUT, "\n");
4832 } /* process each vldb entry */
4833 fprintf(STDOUT, "done\n");
4834 fprintf(STDOUT, "Total volumes backed up: %lu; failed to backup: %lu\n",
4835 (unsigned long)totalBack, (unsigned long)totalFail);
4837 if (arrayEntries.nbulkentries_val)
4838 free(arrayEntries.nbulkentries_val);
4843 UnlockVLDB(register struct cmd_syndesc *as, void *arock)
4846 afs_int32 aserver, code;
4848 struct VldbListByAttributes attributes;
4849 nbulkentries arrayEntries;
4850 register struct nvldbentry *vllist;
4859 attributes.Mask = 0;
4861 if (as->parms[0].items) { /* server specified */
4862 aserver = GetServer(as->parms[0].items->data);
4864 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4865 as->parms[0].items->data);
4868 attributes.server = ntohl(aserver);
4869 attributes.Mask |= VLLIST_SERVER;
4871 if (as->parms[1].items) { /* partition specified */
4872 apart = volutil_GetPartitionID(as->parms[1].items->data);
4874 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4875 as->parms[1].items->data);
4878 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4880 PrintError("", code);
4883 "vos : partition %s does not exist on the server\n",
4884 as->parms[1].items->data);
4887 attributes.partition = apart;
4888 attributes.Mask |= VLLIST_PARTITION;
4890 attributes.flag = VLOP_ALLOPERS;
4891 attributes.Mask |= VLLIST_FLAG;
4892 memset(&arrayEntries, 0, sizeof(arrayEntries)); /*initialize to hint the stub to alloc space */
4893 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4895 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4896 PrintError("", vcode);
4899 for (j = 0; j < nentries; j++) { /* process each entry */
4900 vllist = &arrayEntries.nbulkentries_val[j];
4901 volid = vllist->volumeId[RWVOL];
4903 ubik_VL_ReleaseLock(cstruct, 0, volid, -1,
4904 LOCKREL_OPCODE | LOCKREL_AFSID |
4907 fprintf(STDERR, "Could not unlock entry for volume %s\n",
4909 PrintError("", vcode);
4914 MapPartIdIntoName(apart, pname);
4917 "Could not lock %lu VLDB entries of %lu locked entries\n",
4918 (unsigned long)totalE, (unsigned long)nentries);
4920 if (as->parms[0].items) {
4922 "Unlocked all the VLDB entries for volumes on server %s ",
4923 as->parms[0].items->data);
4924 if (as->parms[1].items) {
4925 MapPartIdIntoName(apart, pname);
4926 fprintf(STDOUT, "partition %s\n", pname);
4928 fprintf(STDOUT, "\n");
4930 } else if (as->parms[1].items) {
4931 MapPartIdIntoName(apart, pname);
4933 "Unlocked all the VLDB entries for volumes on partition %s on all servers\n",
4938 if (arrayEntries.nbulkentries_val)
4939 free(arrayEntries.nbulkentries_val);
4944 PrintInt64Size(afs_uint64 in)
4946 register afs_uint32 hi, lo;
4947 register char * units;
4948 static char output[16];
4950 SplitInt64(in,hi,lo);
4954 } else if (!(hi & 0xFFFFFC00)) {
4956 lo = (hi << 22) | (lo >> 10);
4957 } else if (!(hi & 0xFFF00000)) {
4959 lo = (hi << 12) | (lo >> 20);
4960 } else if (!(hi & 0xC0000000)) {
4962 lo = (hi << 2) | (lo >> 30);
4967 sprintf(output,"%u %s", lo, units);
4972 PartitionInfo(register struct cmd_syndesc *as, void *arock)
4975 afs_int32 aserver, code;
4977 struct diskPartition partition;
4978 struct partList dummyPartList;
4980 int printSummary=0, sumPartitions=0;
4981 afs_uint64 sumFree, sumStorage, tmp;
4984 ZeroInt64(sumStorage);
4986 aserver = GetServer(as->parms[0].items->data);
4988 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4989 as->parms[0].items->data);
4992 if (as->parms[1].items) {
4993 apart = volutil_GetPartitionID(as->parms[1].items->data);
4995 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4996 as->parms[1].items->data);
4999 dummyPartList.partId[0] = apart;
5000 dummyPartList.partFlags[0] = PARTVALID;
5003 if (as->parms[2].items) {
5007 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
5009 PrintError("", code);
5012 "vos : partition %s does not exist on the server\n",
5013 as->parms[1].items->data);
5017 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
5019 PrintDiagnostics("listpart", code);
5023 for (i = 0; i < cnt; i++) {
5024 if (dummyPartList.partFlags[i] & PARTVALID) {
5025 MapPartIdIntoName(dummyPartList.partId[i], pname);
5026 code = UV_PartitionInfo(aserver, pname, &partition);
5028 fprintf(STDERR, "Could not get information on partition %s\n",
5030 PrintError("", code);
5034 "Free space on partition %s: %d K blocks out of total %d\n",
5035 pname, partition.free, partition.minFree);
5037 FillInt64(tmp,0,partition.free);
5038 AddUInt64(sumFree,tmp,&sumFree);
5039 FillInt64(tmp,0,partition.minFree);
5040 AddUInt64(sumStorage,tmp,&sumStorage);
5045 "Summary: %s free out of ",
5046 PrintInt64Size(sumFree));
5048 "%s on %d partitions\n",
5049 PrintInt64Size(sumStorage),
5056 ChangeAddr(register struct cmd_syndesc *as, void *arock)
5058 afs_int32 ip1, ip2, vcode;
5061 ip1 = GetServer(as->parms[0].items->data);
5063 fprintf(STDERR, "vos: invalid host address\n");
5067 if ((as->parms[1].items && as->parms[2].items)
5068 || (!as->parms[1].items && !as->parms[2].items)) {
5070 "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
5074 if (as->parms[1].items) {
5075 ip2 = GetServer(as->parms[1].items->data);
5077 fprintf(STDERR, "vos: invalid host address\n");
5081 /* Play a trick here. If we are removing an address, ip1 will be -1
5082 * and ip2 will be the original address. This switch prevents an
5083 * older revision vlserver from removing the IP address.
5090 vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
5093 fprintf(STDERR, "Could not remove server %s from the VLDB\n",
5094 as->parms[0].items->data);
5095 if (vcode == VL_NOENT) {
5097 "vlserver does not support the remove flag or ");
5100 fprintf(STDERR, "Could not change server %s to server %s\n",
5101 as->parms[0].items->data, as->parms[1].items->data);
5103 PrintError("", vcode);
5108 fprintf(STDOUT, "Removed server %s from the VLDB\n",
5109 as->parms[0].items->data);
5111 fprintf(STDOUT, "Changed server %s to server %s\n",
5112 as->parms[0].items->data, as->parms[1].items->data);
5118 print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
5119 int print, int noresolve)
5123 struct VLCallBack vlcb;
5126 ListAddrByAttributes m_attrs;
5127 afs_int32 m_nentries, *m_addrp;
5128 afs_int32 base, index;
5132 afsUUID_to_string(m_uuid, buf, sizeof(buf));
5133 printf("UUID: %s\n", buf);
5136 /* print out the list of all the server */
5137 addrp = (afs_int32 *) addrs->bulkaddrs_val;
5138 for (i = 0; i < nentries; i++, addrp++) {
5139 /* If it is a multihomed address, then we will need to
5140 * get the addresses for this multihomed server from
5141 * the vlserver and print them.
5143 if (((*addrp & 0xff000000) == 0xff000000) && ((*addrp) & 0xffff)) {
5144 /* Get the list of multihomed fileservers */
5145 base = (*addrp >> 16) & 0xff;
5146 index = (*addrp) & 0xffff;
5148 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
5149 && (index <= VL_MHSRV_PERBLK)) {
5150 m_attrs.Mask = VLADDR_INDEX;
5151 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
5153 m_addrs.bulkaddrs_val = 0;
5154 m_addrs.bulkaddrs_len = 0;
5156 ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, &m_uuid,
5157 &vlcb, &m_nentries, &m_addrs);
5160 "vos: could not list the multi-homed server addresses\n");
5161 PrintError("", vcode);
5164 /* Print the list */
5165 m_addrp = (afs_int32 *) m_addrs.bulkaddrs_val;
5166 for (j = 0; j < m_nentries; j++, m_addrp++) {
5167 *m_addrp = htonl(*m_addrp);
5170 printf("%s ", afs_inet_ntoa_r(*m_addrp, hoststr));
5172 printf("%s ", hostutil_GetNameByINet(*m_addrp));
5176 printf("<unknown>\n");
5185 /* Otherwise, it is a non-multihomed entry and contains
5186 * the IP address of the server - print it.
5188 *addrp = htonl(*addrp);
5191 printf("%s\n", afs_inet_ntoa_r(*addrp, hoststr));
5193 printf("%s\n", hostutil_GetNameByINet(*addrp));
5204 ListAddrs(register struct cmd_syndesc *as, void *arock)
5207 afs_int32 i, noresolve = 0, printuuid = 0;
5208 struct VLCallBack vlcb;
5211 ListAddrByAttributes m_attrs;
5212 afsUUID m_uuid, askuuid;
5213 afs_int32 m_nentries;
5215 memset(&m_attrs, 0, sizeof(struct ListAddrByAttributes));
5216 m_attrs.Mask = VLADDR_INDEX;
5218 memset(&m_addrs, 0, sizeof(bulkaddrs));
5219 memset(&askuuid, 0, sizeof(afsUUID));
5220 if (as->parms[0].items) {
5222 if (afsUUID_from_string(as->parms[0].items->data, &askuuid) < 0) {
5223 fprintf(STDERR, "vos: invalid UUID '%s'\n",
5224 as->parms[0].items->data);
5227 m_attrs.Mask = VLADDR_UUID;
5228 m_attrs.uuid = askuuid;
5230 if (as->parms[1].items) {
5234 he = hostutil_GetHostByName((char *)as->parms[1].items->data);
5236 fprintf(STDERR, "vos: Can't get host info for '%s'\n",
5237 as->parms[1].items->data);
5240 memcpy(&saddr, he->h_addr, 4);
5241 m_attrs.Mask = VLADDR_IPADDR;
5242 m_attrs.ipaddr = ntohl(saddr);
5244 if (as->parms[2].items) {
5247 if (as->parms[3].items) {
5251 m_addrs.bulkaddrs_val = 0;
5252 m_addrs.bulkaddrs_len = 0;
5255 ubik_Call_New(VL_GetAddrs, cstruct, 0, 0, 0, &vlcb, &nentries,
5258 fprintf(STDERR, "vos: could not list the server addresses\n");
5259 PrintError("", vcode);
5264 m_addrs.bulkaddrs_val = 0;
5265 m_addrs.bulkaddrs_len = 0;
5271 ubik_Call_New(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
5272 &vlcb, &m_nentries, &m_addrs);
5274 if (vcode == VL_NOENT) {
5275 if (m_attrs.Mask == VLADDR_UUID) {
5276 fprintf(STDERR, "vos: no entry for UUID '%s' found in VLDB\n",
5277 as->parms[0].items->data);
5279 } else if (m_attrs.Mask == VLADDR_IPADDR) {
5280 fprintf(STDERR, "vos: no entry for host '%s' [0x%08x] found in VLDB\n",
5281 as->parms[1].items->data, m_attrs.ipaddr);
5290 if (vcode == VL_INDEXERANGE) {
5295 fprintf(STDERR, "vos: could not list the server addresses\n");
5296 PrintError("", vcode);
5300 print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid, noresolve);
5303 if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
5311 LockEntry(register struct cmd_syndesc *as, void *arock)
5313 afs_int32 avolid, vcode, err;
5315 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5318 PrintError("", err);
5320 fprintf(STDERR, "vos: can't find volume '%s'\n",
5321 as->parms[0].items->data);
5324 vcode = ubik_VL_SetLock(cstruct, 0, avolid, -1, VLOP_DELETE);
5326 fprintf(STDERR, "Could not lock VLDB entry for volume %s\n",
5327 as->parms[0].items->data);
5328 PrintError("", vcode);
5331 fprintf(STDOUT, "Locked VLDB entry for volume %s\n",
5332 as->parms[0].items->data);
5337 ConvertRO(register struct cmd_syndesc *as, void *arock)
5339 afs_int32 partition = -1;
5340 afs_int32 server, volid, code, i, same;
5341 struct nvldbentry entry, storeEntry;
5344 afs_int32 rwserver = 0;
5345 afs_int32 rwpartition;
5347 afs_int32 roserver = 0;
5348 afs_int32 ropartition;
5350 struct rx_connection *aconn;
5353 server = GetServer(as->parms[0].items->data);
5355 fprintf(STDERR, "vos: host '%s' not found in host table\n",
5356 as->parms[0].items->data);
5359 partition = volutil_GetPartitionID(as->parms[1].items->data);
5360 if (partition < 0) {
5361 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5362 as->parms[1].items->data);
5365 if (!IsPartValid(partition, server, &code)) {
5367 PrintError("", code);
5370 "vos : partition %s does not exist on the server\n",
5371 as->parms[1].items->data);
5374 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &code);
5377 PrintError("", code);
5379 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
5380 as->parms[0].items->data);
5383 if (as->parms[3].items)
5386 vcode = VLDB_GetEntryByID(volid, -1, &entry);
5389 "Could not fetch the entry for volume %lu from VLDB\n",
5390 (unsigned long)volid);
5391 PrintError("convertROtoRW", code);
5395 /* use RO volid even if user specified RW or BK volid */
5397 if (volid != entry.volumeId[ROVOL])
5398 volid = entry.volumeId[ROVOL];
5400 MapHostToNetwork(&entry);
5401 for (i = 0; i < entry.nServers; i++) {
5402 if (entry.serverFlags[i] & ITSRWVOL) {
5404 rwserver = entry.serverNumber[i];
5405 rwpartition = entry.serverPartition[i];
5407 if (entry.serverFlags[i] & ITSROVOL) {
5408 same = VLDB_IsSameAddrs(server, entry.serverNumber[i], &code);
5411 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
5417 roserver = entry.serverNumber[i];
5418 ropartition = entry.serverPartition[i];
5424 fprintf(STDERR, "Warning: RO volume didn't exist in vldb!\n");
5426 if (ropartition != partition) {
5428 "Warning: RO volume should be in partition %d instead of %d (vldb)\n",
5429 ropartition, partition);
5434 "VLDB indicates that a RW volume exists already on %s in partition %s.\n",
5435 hostutil_GetNameByINet(rwserver),
5436 volutil_PartitionName(rwpartition));
5438 fprintf(STDERR, "Overwrite this VLDB entry? [y|n] (n)\n");
5440 while (!(dc == EOF || dc == '\n'))
5441 dc = getchar(); /* goto end of line */
5442 if ((c != 'y') && (c != 'Y')) {
5443 fprintf(STDERR, "aborted.\n");
5450 ubik_VL_SetLock(cstruct, 0, entry.volumeId[RWVOL], RWVOL,
5452 aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
5453 code = AFSVolConvertROtoRWvolume(aconn, partition, volid);
5456 "Converting RO volume %lu to RW volume failed with code %d\n",
5457 (unsigned long)volid, code);
5458 PrintError("convertROtoRW ", code);
5461 entry.serverFlags[roindex] = ITSRWVOL;
5462 entry.flags |= RW_EXISTS;
5463 entry.flags &= ~BACK_EXISTS;
5466 if (rwindex != entry.nServers) {
5467 entry.serverNumber[rwindex] = entry.serverNumber[entry.nServers];
5468 entry.serverPartition[rwindex] =
5469 entry.serverPartition[entry.nServers];
5470 entry.serverFlags[rwindex] = entry.serverFlags[entry.nServers];
5471 entry.serverNumber[entry.nServers] = 0;
5472 entry.serverPartition[entry.nServers] = 0;
5473 entry.serverFlags[entry.nServers] = 0;
5476 entry.flags &= ~RO_EXISTS;
5477 for (i = 0; i < entry.nServers; i++) {
5478 if (entry.serverFlags[i] & ITSROVOL) {
5479 if (!(entry.serverFlags[i] & (RO_DONTUSE | NEW_REPSITE)))
5480 entry.flags |= RO_EXISTS;
5483 MapNetworkToHost(&entry, &storeEntry);
5485 VLDB_ReplaceEntry(entry.volumeId[RWVOL], RWVOL, &storeEntry,
5486 (LOCKREL_OPCODE | LOCKREL_AFSID |
5487 LOCKREL_TIMESTAMP));
5490 "Warning: volume converted, but vldb update failed with code %d!\n",
5493 vcode = UV_LockRelease(entry.volumeId[RWVOL]);
5495 PrintDiagnostics("unlock", vcode);
5501 Sizes(register struct cmd_syndesc *as, void *arock)
5503 afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i;
5504 struct nvldbentry entry;
5505 volintSize vol_size;
5507 rx_SetRxDeadTime(60 * 10);
5508 for (i = 0; i < MAXSERVERS; i++) {
5509 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
5512 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
5513 if (rxConn->service)
5514 rxConn->service->connDeadTime = rx_connDeadTime;
5517 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5520 PrintError("", err);
5522 fprintf(STDERR, "vos: can't find volume '%s'\n",
5523 as->parms[0].items->data);
5527 if (as->parms[1].items || as->parms[2].items) {
5528 if (!as->parms[1].items || !as->parms[2].items) {
5530 "Must specify both -server and -partition options\n");
5533 aserver = GetServer(as->parms[2].items->data);
5535 fprintf(STDERR, "Invalid server name\n");
5538 apart = volutil_GetPartitionID(as->parms[1].items->data);
5540 fprintf(STDERR, "Invalid partition name\n");
5544 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
5551 if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
5552 code = ktime_DateToInt32(as->parms[4].items->data, &fromdate);
5554 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
5555 as->parms[4].items->data, code);
5560 fprintf(STDOUT, "Volume: %s\n", as->parms[0].items->data);
5562 if (as->parms[3].items) { /* do the dump estimate */
5563 #ifdef AFS_64BIT_ENV
5564 vol_size.dump_size = 0;
5566 FillInt64(vol_size.dump_size,0, 1);
5568 code = UV_GetSize(avolid, aserver, apart, fromdate, &vol_size);
5570 PrintDiagnostics("size", code);
5573 /* presumably the size info is now gathered in pntr */
5574 /* now we display it */
5576 fprintf(STDOUT, "dump_size: %llu\n", vol_size.dump_size);
5584 PrintDiagnostics(astring, acode)
5588 if (acode == EACCES) {
5590 "You are not authorized to perform the 'vos %s' command (%d)\n",
5593 fprintf(STDERR, "Error in vos %s command.\n", astring);
5594 PrintError("", acode);
5601 MyBeforeProc(struct cmd_syndesc *as, void *arock)
5603 register char *tcell;
5604 register afs_int32 code;
5605 register afs_int32 sauth;
5607 /* Initialize the ubik_client connection */
5608 rx_SetRxDeadTime(90);
5609 cstruct = (struct ubik_client *)0;
5613 if (as->parms[12].items) /* if -cell specified */
5614 tcell = as->parms[12].items->data;
5615 if (as->parms[14].items) /* -serverauth specified */
5617 if (as->parms[16].items) /* -crypt specified */
5620 vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
5621 &cstruct, UV_SetSecurity))) {
5622 fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
5623 (unsigned long)code);
5627 if (as->parms[15].items) /* -verbose flag set */
5637 /* this sucks but it works for now.
5642 #include "AFS_component_version_number.c"
5648 register afs_int32 code;
5650 register struct cmd_syndesc *ts;
5652 #ifdef AFS_AIX32_ENV
5654 * The following signal action for AIX is necessary so that in case of a
5655 * crash (i.e. core is generated) we can include the user's data section
5656 * in the core dump. Unfortunately, by default, only a partial core is
5657 * generated which, in many cases, isn't too useful.
5659 struct sigaction nsa;
5661 sigemptyset(&nsa.sa_mask);
5662 nsa.sa_handler = SIG_DFL;
5663 nsa.sa_flags = SA_FULLDUMP;
5664 sigaction(SIGSEGV, &nsa, NULL);
5667 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
5669 cmd_SetBeforeProc(MyBeforeProc, NULL);
5671 ts = cmd_CreateSyntax("create", CreateVolume, NULL, "create a new volume");
5672 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5673 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5674 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "volume name");
5675 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL,
5676 "initial quota (KB)");
5678 cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
5682 ts = cmd_CreateSyntax("remove", DeleteVolume, NULL, "delete a volume");
5683 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5684 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5685 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5689 ts = cmd_CreateSyntax("move", MoveVolume, NULL, "move a volume");
5690 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5691 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5692 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5693 "partition name on source");
5694 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5695 "machine name on destination");
5696 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5697 "partition name on destination");
5698 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5699 "copy live volume without cloning");
5702 ts = cmd_CreateSyntax("copy", CopyVolume, NULL, "copy a volume");
5703 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5704 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5705 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5706 "partition name on source");
5707 cmd_AddParm(ts, "-toname", CMD_SINGLE, 0, "volume name on destination");
5708 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5709 "machine name on destination");
5710 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5711 "partition name on destination");
5712 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5713 "leave new volume offline");
5714 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5715 "make new volume read-only");
5716 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5717 "copy live volume without cloning");
5720 ts = cmd_CreateSyntax("shadow", ShadowVolume, NULL,
5721 "make or update a shadow volume");
5722 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5723 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5724 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5725 "partition name on source");
5726 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5727 "machine name on destination");
5728 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5729 "partition name on destination");
5730 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5731 "volume name on destination");
5732 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5733 "volume ID on destination");
5734 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5735 "leave shadow volume offline");
5736 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5737 "make shadow volume read-only");
5738 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5739 "copy live volume without cloning");
5740 cmd_AddParm(ts, "-incremental", CMD_FLAG, CMD_OPTIONAL,
5741 "do incremental update if target exists");
5744 ts = cmd_CreateSyntax("backup", BackupVolume, NULL,
5745 "make backup of a volume");
5746 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5749 ts = cmd_CreateSyntax("clone", CloneVolume, NULL,
5750 "make clone of a volume");
5751 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5752 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5753 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5754 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5755 "volume name on destination");
5756 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5757 "volume ID on destination");
5758 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5759 "leave clone volume offline");
5760 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5761 "make clone volume read-only, not readwrite");
5764 ts = cmd_CreateSyntax("release", ReleaseVolume, NULL, "release a volume");
5765 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5766 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5767 "force a complete release");
5770 ts = cmd_CreateSyntax("dump", DumpVolume, NULL, "dump a volume");
5771 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5772 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5773 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5774 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5775 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5776 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL,
5777 "dump a clone of the volume");
5778 cmd_AddParm(ts, "-omitdirs", CMD_FLAG, CMD_OPTIONAL,
5779 "omit unchanged directories from an incremental dump");
5782 ts = cmd_CreateSyntax("restore", RestoreVolume, NULL, "restore a volume");
5783 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5784 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5785 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of volume to be restored");
5786 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5787 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
5788 cmd_AddParm(ts, "-overwrite", CMD_SINGLE, CMD_OPTIONAL,
5789 "abort | full | incremental");
5790 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5791 "leave restored volume offline");
5792 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5793 "make restored volume read-only");
5794 cmd_AddParm(ts, "-creation", CMD_SINGLE, CMD_OPTIONAL,
5795 "dump | keep | new");
5796 cmd_AddParm(ts, "-lastupdate", CMD_SINGLE, CMD_OPTIONAL,
5797 "dump | keep | new");
5800 ts = cmd_CreateSyntax("unlock", LockReleaseCmd, NULL,
5801 "release lock on VLDB entry for a volume");
5802 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5805 ts = cmd_CreateSyntax("changeloc", ChangeLocation, NULL,
5806 "change an RW volume's location in the VLDB");
5807 cmd_AddParm(ts, "-server", CMD_SINGLE, 0,
5808 "machine name for new location");
5809 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5810 "partition name for new location");
5811 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5814 ts = cmd_CreateSyntax("addsite", AddSite, NULL, "add a replication site");
5815 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new site");
5816 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5817 "partition name for new site");
5818 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5821 ts = cmd_CreateSyntax("remsite", RemoveSite, NULL,
5822 "remove a replication site");
5823 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5824 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5825 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5828 ts = cmd_CreateSyntax("listpart", ListPartitions, NULL, "list partitions");
5829 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5832 ts = cmd_CreateSyntax("listvol", ListVolumes, NULL,
5833 "list volumes on server (bypass VLDB)");
5834 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5835 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5836 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "minimal listing");
5837 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
5838 "list all normal volume fields");
5839 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5840 "generate minimal information");
5841 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5842 "list extended volume fields");
5843 #ifdef FULL_LISTVOL_SWITCH
5844 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5845 "machine readable format");
5846 #endif /* FULL_LISTVOL_SWITCH */
5849 ts = cmd_CreateSyntax("syncvldb", SyncVldb, NULL,
5850 "synchronize VLDB with server");
5851 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5852 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5853 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5856 ts = cmd_CreateSyntax("syncserv", SyncServer, NULL,
5857 "synchronize server with VLDB");
5858 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5859 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5862 ts = cmd_CreateSyntax("examine", ExamineVolume, NULL,
5863 "everything about the volume");
5864 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5865 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5866 "list extended volume fields");
5867 #ifdef FULL_LISTVOL_SWITCH
5868 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5869 "machine readable format");
5870 #endif /* FULL_LISTVOL_SWITCH */
5872 cmd_CreateAlias(ts, "volinfo");
5874 ts = cmd_CreateSyntax("setfields", SetFields, NULL,
5875 "change volume info fields");
5876 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5877 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "quota (KB)");
5878 cmd_AddParm(ts, "-clearuse", CMD_FLAG, CMD_OPTIONAL, "clear dayUse");
5879 cmd_AddParm(ts, "-clearVolUpCounter", CMD_FLAG, CMD_OPTIONAL, "clear volUpdateCounter");
5882 ts = cmd_CreateSyntax("offline", volOffline, NULL, (char *)CMD_HIDDEN);
5883 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5884 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5885 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5886 cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds to sleep");
5887 cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "busy volume");
5890 ts = cmd_CreateSyntax("online", volOnline, NULL, (char *)CMD_HIDDEN);
5891 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5892 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5893 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5896 ts = cmd_CreateSyntax("zap", VolumeZap, NULL,
5897 "delete the volume, don't bother with VLDB");
5898 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5899 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5900 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume ID");
5901 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5902 "force deletion of bad volumes");
5903 cmd_AddParm(ts, "-backup", CMD_FLAG, CMD_OPTIONAL,
5904 "also delete backup volume if one is found");
5907 ts = cmd_CreateSyntax("status", VolserStatus, NULL,
5908 "report on volser status");
5909 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5912 ts = cmd_CreateSyntax("rename", RenameVolume, NULL, "rename a volume");
5913 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old volume name ");
5914 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new volume name ");
5917 ts = cmd_CreateSyntax("listvldb", ListVLDB, NULL,
5918 "list volumes in the VLDB");
5919 cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5920 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5921 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5922 cmd_AddParm(ts, "-locked", CMD_FLAG, CMD_OPTIONAL, "locked volumes only");
5923 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5924 "generate minimal information");
5925 cmd_AddParm(ts, "-nosort", CMD_FLAG, CMD_OPTIONAL,
5926 "do not alphabetically sort the volume names");
5929 ts = cmd_CreateSyntax("backupsys", BackSys, NULL, "en masse backups");
5930 cmd_AddParm(ts, "-prefix", CMD_LIST, CMD_OPTIONAL,
5931 "common prefix on volume(s)");
5932 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5933 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5934 cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL,
5935 "exclude common prefix volumes");
5936 cmd_AddParm(ts, "-xprefix", CMD_LIST, CMD_OPTIONAL,
5937 "negative prefix on volume(s)");
5938 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "no action");
5941 ts = cmd_CreateSyntax("delentry", DeleteEntry, NULL,
5942 "delete VLDB entry for a volume");
5943 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "volume name or ID");
5944 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL,
5945 "prefix of the volume whose VLDB entry is to be deleted");
5946 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5947 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5948 cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE,
5952 ts = cmd_CreateSyntax("partinfo", PartitionInfo, NULL,
5953 "list partition information");
5954 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5955 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5956 cmd_AddParm(ts, "-summary", CMD_FLAG, CMD_OPTIONAL,
5957 "print storage summary");
5960 ts = cmd_CreateSyntax("unlockvldb", UnlockVLDB, NULL,
5961 "unlock all the locked entries in the VLDB");
5962 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5963 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5966 ts = cmd_CreateSyntax("lock", LockEntry, NULL,
5967 "lock VLDB entry for a volume");
5968 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5971 ts = cmd_CreateSyntax("changeaddr", ChangeAddr, NULL,
5972 "change the IP address of a file server");
5973 cmd_AddParm(ts, "-oldaddr", CMD_SINGLE, 0, "original IP address");
5974 cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
5975 cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL,
5976 "remove the IP address from the VLDB");
5979 ts = cmd_CreateSyntax("listaddrs", ListAddrs, NULL,
5980 "list the IP address of all file servers registered in the VLDB");
5981 cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
5982 cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
5983 cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL,
5984 "don't resolve addresses");
5985 cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
5986 "print uuid of hosts");
5989 ts = cmd_CreateSyntax("convertROtoRW", ConvertRO, NULL,
5990 "convert a RO volume into a RW volume (after loss of old RW volume)");
5991 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5992 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5993 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5994 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "don't ask");
5997 ts = cmd_CreateSyntax("size", Sizes, NULL,
5998 "obtain various sizes of the volume.");
5999 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6000 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6001 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6002 cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL,
6003 "Obtain the size of the dump");
6004 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
6007 code = cmd_Dispatch(argc, argv);
6009 /* Shut down the ubik_client and rx connections */
6011 (void)ubik_ClientDestroy(cstruct);
6017 exit((code ? -1 : 0));