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>
25 #include <netinet/in.h>
26 #include <arpa/inet.h>
30 #include <sys/statfs.h>
46 #include <rx/rx_globals.h>
48 #include <afs/vlserver.h>
50 #include <afs/cellconfig.h>
52 #include <afs/afsutil.h>
54 #include <afs/afsint.h>
64 #include "volser_prototypes.h"
66 #ifdef HAVE_POSIX_REGEX
80 #define COMMONPARMS cmd_Seek(ts, 12);\
81 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
82 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");\
83 cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
84 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
85 cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
87 #define ERROR_EXIT(code) {error=(code); goto error_exit;}
91 struct rx_connection *tconn;
93 extern struct ubik_client *cstruct;
96 static struct tqHead busyHead, notokHead;
99 qInit(struct tqHead *ahead)
101 memset((char *)ahead, 0, sizeof(struct tqHead));
107 qPut(struct tqHead *ahead, afs_int32 volid)
111 elem = (struct tqElem *)malloc(sizeof(struct tqElem));
112 elem->next = ahead->next;
120 qGet(struct tqHead *ahead, afs_int32 *volid)
124 if (ahead->count <= 0)
126 *volid = ahead->next->volid;
128 ahead->next = tmp->next;
134 /* returns 1 if <filename> exists else 0 */
136 FileExists(char *filename)
142 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
146 code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
154 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
156 VolNameOK(char *name)
161 total = strlen(name);
162 if (!strcmp(&name[total - 9], ".readonly")) {
164 } else if (!strcmp(&name[total - 7], ".backup")) {
171 /* return 1 if name is a number else 0 */
173 IsNumeric(char *name)
181 for (i = 0; i < len; i++) {
182 if (*ptr < '0' || *ptr > '9') {
194 * Parse a server name/address and return the address in HOST BYTE order
197 GetServer(char *aname)
199 register struct hostent *th;
202 register afs_int32 code;
203 char hostname[MAXHOSTCHARS];
205 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
207 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
208 addr = ntohl(addr); /* convert to host order */
210 th = gethostbyname(aname);
213 memcpy(&addr, th->h_addr, sizeof(addr));
216 if (addr == htonl(0x7f000001)) { /* local host */
217 code = gethostname(hostname, MAXHOSTCHARS);
220 th = gethostbyname(hostname); /* returns host byte order */
223 memcpy(&addr, th->h_addr, sizeof(addr));
230 GetVolumeType(char *aname)
233 if (!strcmp(aname, "ro"))
235 else if (!strcmp(aname, "rw"))
237 else if (!strcmp(aname, "bk"))
244 IsPartValid(afs_int32 partId, afs_int32 server, afs_int32 *code)
246 struct partList dummyPartList;
252 *code = UV_ListPartitions(server, &dummyPartList, &cnt);
255 for (i = 0; i < cnt; i++) {
256 if (dummyPartList.partFlags[i] & PARTVALID)
257 if (dummyPartList.partId[i] == partId)
265 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
266 * associated with <call> */
268 SendFile(usd_handle_t ufd, register struct rx_call *call, long blksize)
270 char *buffer = (char *)0;
275 buffer = (char *)malloc(blksize);
277 fprintf(STDERR, "malloc failed\n");
281 while (!error && !done) {
282 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
285 FD_SET((int)(ufd->handle), &in);
286 /* don't timeout if read blocks */
287 IOMGR_Select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
289 error = USD_READ(ufd, buffer, blksize, &nbytes);
291 fprintf(STDERR, "File system read failed\n");
298 if (rx_Write(call, buffer, nbytes) != nbytes) {
308 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
309 * writes it out to the volume. */
311 WriteData(struct rx_call *call, char *rock)
316 afs_int32 error, code;
322 if (!filename || !*filename) {
323 usd_StandardInput(&ufd);
327 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
330 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
333 fprintf(STDERR, "Could not access file '%s'\n", filename);
338 code = SendFile(ufd, call, blksize);
345 code = USD_CLOSE(ufd);
347 fprintf(STDERR, "Could not close dump file %s\n",
348 (filename && *filename) ? filename : "STDOUT");
356 /* Receive data from <call> stream into file associated
357 * with <fd> <blksize>
360 ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize)
364 afs_uint32 bytesleft, w;
367 buffer = (char *)malloc(blksize);
369 fprintf(STDERR, "memory allocation failed\n");
373 while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {
374 for (bytesleft = bytesread; bytesleft; bytesleft -= w) {
375 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
378 FD_SET((int)(ufd->handle), &out);
379 /* don't timeout if write blocks */
380 IOMGR_Select(((int)(ufd->handle)) + 1, 0, &out, 0, 0);
383 USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
385 fprintf(STDERR, "File system write failed\n");
398 DumpFunction(struct rx_call *call, char *filename)
400 usd_handle_t ufd; /* default is to stdout */
401 afs_int32 error = 0, code;
406 /* Open the output file */
407 if (!filename || !*filename) {
408 usd_StandardOutput(&ufd);
413 usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
417 code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
420 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
423 fprintf(STDERR, "Could not create file '%s'\n", filename);
424 ERROR_EXIT(VOLSERBADOP);
428 code = ReceiveFile(ufd, call, blksize);
433 /* Close the output file */
435 code = USD_CLOSE(ufd);
437 fprintf(STDERR, "Could not close dump file %s\n",
438 (filename && *filename) ? filename : "STDIN");
448 DisplayFormat(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
451 afs_int32 server, part;
452 int *totalOK, *totalNotOK, *totalBusy;
453 int fast, longlist, disp;
458 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
459 } else if (longlist) {
460 if (pntr->status == VOK) {
461 fprintf(STDOUT, "%-32s ", pntr->name);
462 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
464 fprintf(STDOUT, "RW ");
466 fprintf(STDOUT, "RO ");
468 fprintf(STDOUT, "BK ");
469 fprintf(STDOUT, "%10d K ", pntr->size);
470 if (pntr->inUse == 1) {
471 fprintf(STDOUT, "On-line");
474 fprintf(STDOUT, "Off-line");
477 if (pntr->needsSalvaged == 1)
478 fprintf(STDOUT, "**needs salvage**");
479 fprintf(STDOUT, "\n");
480 MapPartIdIntoName(part, pname);
481 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
483 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
484 (unsigned long)pntr->parentID,
485 (unsigned long)pntr->cloneID,
486 (unsigned long)pntr->backupID);
487 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
488 fprintf(STDOUT, " Creation %s",
489 ctime((time_t *) & pntr->creationDate));
490 #ifdef FULL_LISTVOL_SWITCH
491 fprintf(STDOUT, " Copy %s",
492 ctime((time_t *) & pntr->copyDate));
493 if (!pntr->backupDate)
494 fprintf(STDOUT, " Backup Never\n");
496 fprintf(STDOUT, " Backup %s",
497 ctime((time_t *) & pntr->backupDate));
498 if (pntr->accessDate)
499 fprintf(STDOUT, " Last Access %s",
500 ctime((time_t *) & pntr->accessDate));
502 if (pntr->updateDate < pntr->creationDate)
503 fprintf(STDOUT, " Last Update %s",
504 ctime((time_t *) & pntr->creationDate));
506 fprintf(STDOUT, " Last Update %s",
507 ctime((time_t *) & pntr->updateDate));
509 " %d accesses in the past day (i.e., vnode references)\n",
511 } else if (pntr->status == VBUSY) {
513 qPut(&busyHead, pntr->volid);
515 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
516 (unsigned long)pntr->volid);
519 qPut(¬okHead, pntr->volid);
521 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
522 (unsigned long)pntr->volid);
524 fprintf(STDOUT, "\n");
525 } else { /* default listing */
526 if (pntr->status == VOK) {
527 fprintf(STDOUT, "%-32s ", pntr->name);
528 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
530 fprintf(STDOUT, "RW ");
532 fprintf(STDOUT, "RO ");
534 fprintf(STDOUT, "BK ");
535 fprintf(STDOUT, "%10d K ", pntr->size);
536 if (pntr->inUse == 1) {
537 fprintf(STDOUT, "On-line");
540 fprintf(STDOUT, "Off-line");
543 if (pntr->needsSalvaged == 1)
544 fprintf(STDOUT, "**needs salvage**");
545 fprintf(STDOUT, "\n");
546 } else if (pntr->status == VBUSY) {
548 qPut(&busyHead, pntr->volid);
550 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
551 (unsigned long)pntr->volid);
554 qPut(¬okHead, pntr->volid);
556 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
557 (unsigned long)pntr->volid);
562 /*------------------------------------------------------------------------
563 * PRIVATE XDisplayFormat
566 * Display the contents of one extended volume info structure.
569 * a_xInfoP : Ptr to extended volume info struct to print.
570 * a_servID : Server ID to print.
571 * a_partID : Partition ID to print.
572 * a_totalOKP : Ptr to total-OK counter.
573 * a_totalNotOKP : Ptr to total-screwed counter.
574 * a_totalBusyP : Ptr to total-busy counter.
575 * a_fast : Fast listing?
576 * a_int32 : Int32 listing?
577 * a_showProblems : Show volume problems?
583 * Nothing interesting.
587 *------------------------------------------------------------------------*/
590 XDisplayFormat(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
591 a_totalBusyP, a_fast, a_int32, a_showProblems)
592 volintXInfo *a_xInfoP;
602 { /*XDisplayFormat */
610 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
611 } else if (a_int32) {
613 * Fully-detailed listing.
615 if (a_xInfoP->status == VOK) {
617 * Volume's status is OK - all the fields are valid.
619 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
620 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
621 if (a_xInfoP->type == 0)
622 fprintf(STDOUT, "RW ");
623 if (a_xInfoP->type == 1)
624 fprintf(STDOUT, "RO ");
625 if (a_xInfoP->type == 2)
626 fprintf(STDOUT, "BK ");
627 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
628 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
629 if (a_xInfoP->inUse == 1) {
630 fprintf(STDOUT, "On-line");
633 fprintf(STDOUT, "Off-line");
636 fprintf(STDOUT, "\n");
637 MapPartIdIntoName(a_partID, pname);
638 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
640 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
641 (unsigned long)a_xInfoP->parentID,
642 (unsigned long)a_xInfoP->cloneID,
643 (unsigned long)a_xInfoP->backupID);
644 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
645 fprintf(STDOUT, " Creation %s",
646 ctime((time_t *) & a_xInfoP->creationDate));
647 #ifdef FULL_LISTVOL_SWITCH
648 fprintf(STDOUT, " Copy %s",
649 ctime((time_t *) & a_xInfoP->copyDate));
650 if (!a_xInfoP->backupDate)
651 fprintf(STDOUT, " Backup Never\n");
653 fprintf(STDOUT, " Backup %s",
654 ctime((time_t *) & a_xInfoP->backupDate));
655 if (a_xInfoP->accessDate)
656 fprintf(STDOUT, " Last Access %s",
657 ctime((time_t *) & a_xInfoP->accessDate));
659 if (a_xInfoP->updateDate < a_xInfoP->creationDate)
660 fprintf(STDOUT, " Last Update %s",
661 ctime((time_t *) & a_xInfoP->creationDate));
663 fprintf(STDOUT, " Last Update %s",
664 ctime((time_t *) & a_xInfoP->updateDate));
666 " %d accesses in the past day (i.e., vnode references)\n",
670 * Print all the read/write and authorship stats.
672 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
674 " |-------------------------------------------|\n");
676 " | Same Network | Diff Network |\n");
678 " |----------|----------|----------|----------|\n");
680 " | Total | Auth | Total | Auth |\n");
682 " |----------|----------|----------|----------|\n");
683 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
684 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
685 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
686 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
687 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
688 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
689 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
690 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
691 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
692 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
694 " |-------------------------------------------|\n\n");
697 " Writes Affecting Authorship\n");
699 " |-------------------------------------------|\n");
701 " | File Authorship | Directory Authorship|\n");
703 " |----------|----------|----------|----------|\n");
705 " | Same | Diff | Same | Diff |\n");
707 " |----------|----------|----------|----------|\n");
708 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
709 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
710 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
711 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
712 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
713 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
714 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
715 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
716 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
717 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
718 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
719 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
720 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
721 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
722 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
723 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
724 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
725 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
726 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
727 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
728 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
729 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
730 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
731 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
732 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
733 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
734 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
735 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
736 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
737 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
739 " |-------------------------------------------|\n");
740 } /*Volume status OK */
741 else if (a_xInfoP->status == VBUSY) {
743 qPut(&busyHead, a_xInfoP->volid);
745 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
746 (unsigned long)a_xInfoP->volid);
750 qPut(¬okHead, a_xInfoP->volid);
752 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
753 (unsigned long)a_xInfoP->volid);
754 } /*Screwed volume */
755 fprintf(STDOUT, "\n");
761 if (a_xInfoP->status == VOK) {
762 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
763 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
764 if (a_xInfoP->type == 0)
765 fprintf(STDOUT, "RW ");
766 if (a_xInfoP->type == 1)
767 fprintf(STDOUT, "RO ");
768 if (a_xInfoP->type == 2)
769 fprintf(STDOUT, "BK ");
770 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
771 if (a_xInfoP->inUse == 1) {
772 fprintf(STDOUT, "On-line");
775 fprintf(STDOUT, "Off-line");
778 fprintf(STDOUT, "\n");
780 else if (a_xInfoP->status == VBUSY) {
782 qPut(&busyHead, a_xInfoP->volid);
784 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
785 (unsigned long)a_xInfoP->volid);
789 qPut(¬okHead, a_xInfoP->volid);
791 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
792 (unsigned long)a_xInfoP->volid);
793 } /*Screwed volume */
794 } /*Default listing */
795 } /*XDisplayFormat */
797 #ifdef FULL_LISTVOL_SWITCH
799 DisplayFormat2(server, partition, pntr)
800 long server, partition;
803 static long server_cache = -1, partition_cache = -1;
804 static char hostname[256], address[32], pname[16];
806 if (server != server_cache) {
810 strcpy(hostname, hostutil_GetNameByINet(server));
811 strcpy(address, inet_ntoa(s));
812 server_cache = server;
814 if (partition != partition_cache) {
815 MapPartIdIntoName(partition, pname);
816 partition_cache = partition;
818 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
819 fprintf(STDOUT, "id\t\t%lu\n", pntr->volid);
820 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
821 fprintf(STDOUT, "part\t\t%s\n", pname);
822 switch (pntr->status) {
824 fprintf(STDOUT, "status\t\tOK\n");
827 fprintf(STDOUT, "status\t\tBUSY\n");
830 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
833 fprintf(STDOUT, "backupID\t%lu\n", pntr->backupID);
834 fprintf(STDOUT, "parentID\t%lu\n", pntr->parentID);
835 fprintf(STDOUT, "cloneID\t\t%lu\n", pntr->cloneID);
836 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
837 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
838 /* 0xD3 is from afs/volume.h since I had trouble including the file */
839 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
840 switch (pntr->type) {
842 fprintf(STDOUT, "type\t\tRW\n");
845 fprintf(STDOUT, "type\t\tRO\n");
848 fprintf(STDOUT, "type\t\tBK\n");
851 fprintf(STDOUT, "type\t\t?\n");
854 fprintf(STDOUT, "creationDate\t%-9lu\t%s", pntr->creationDate,
855 ctime(&pntr->creationDate));
856 fprintf(STDOUT, "accessDate\t%-9lu\t%s", pntr->accessDate,
857 ctime(&pntr->accessDate));
858 fprintf(STDOUT, "updateDate\t%-9lu\t%s", pntr->updateDate,
859 ctime(&pntr->updateDate));
860 fprintf(STDOUT, "backupDate\t%-9lu\t%s", pntr->backupDate,
861 ctime(&pntr->backupDate));
862 fprintf(STDOUT, "copyDate\t%-9lu\t%s", pntr->copyDate,
863 ctime(&pntr->copyDate));
864 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n", pntr->flags);
865 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
866 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
867 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n", pntr->spare0);
868 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
869 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
870 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n", pntr->spare1);
871 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n", pntr->spare2);
872 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n", pntr->spare3);
877 DisplayVolumes2(server, partition, pntr, count)
879 long server, partition, count;
883 for (i = 0; i < count; i++) {
884 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
885 DisplayFormat2(server, partition, pntr);
886 fprintf(STDOUT, "END_OF_ENTRY\n\n");
891 #endif /* FULL_LISTVOL_SWITCH */
894 DisplayVolumes(server, part, pntr, count, longlist, fast, quiet)
895 afs_int32 server, part;
897 afs_int32 count, longlist, fast;
900 int totalOK, totalNotOK, totalBusy, i;
908 for (i = 0; i < count; i++) {
909 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
914 while (busyHead.count) {
915 qGet(&busyHead, &volid);
916 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
917 (unsigned long)volid);
921 while (notokHead.count) {
922 qGet(¬okHead, &volid);
923 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
924 (unsigned long)volid);
928 fprintf(STDOUT, "\n");
931 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
932 totalOK, totalNotOK, totalBusy);
937 /*------------------------------------------------------------------------
938 * PRIVATE XDisplayVolumes
941 * Display extended volume information.
944 * a_servID : Pointer to the Rx call we're performing.
945 * a_partID : Partition for which we want the extended list.
946 * a_xInfoP : Ptr to extended volume info.
947 * a_count : Number of volume records contained above.
948 * a_int32 : Int32 listing generated?
949 * a_fast : Fast listing generated?
950 * a_quiet : Quiet listing generated?
956 * Nothing interesting.
960 *------------------------------------------------------------------------*/
963 XDisplayVolumes(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
967 volintXInfo *a_xInfoP;
973 { /*XDisplayVolumes */
975 int totalOK; /*Total OK volumes */
976 int totalNotOK; /*Total screwed volumes */
977 int totalBusy; /*Total busy volumes */
978 int i; /*Loop variable */
979 afs_int32 volid; /*Current volume ID */
982 * Initialize counters and (global!!) queues.
991 * Display each volume in the list.
993 for (i = 0; i < a_count; i++) {
994 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
995 &totalBusy, a_fast, a_int32, 0);
1000 * If any volumes were found to be busy or screwed, display them.
1003 while (busyHead.count) {
1004 qGet(&busyHead, &volid);
1005 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1006 (unsigned long)volid);
1010 while (notokHead.count) {
1011 qGet(¬okHead, &volid);
1012 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1013 (unsigned long)volid);
1018 fprintf(STDOUT, "\n");
1021 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1022 totalOK, totalNotOK, totalBusy);
1026 } /*XDisplayVolumes */
1028 /* set <server> and <part> to the correct values depending on
1029 * <voltype> and <entry> */
1031 GetServerAndPart(entry, voltype, server, part, previdx)
1032 struct nvldbentry *entry;
1033 afs_int32 *server, *part;
1037 int i, istart, vtype;
1042 /* Doesn't check for non-existance of backup volume */
1043 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1045 istart = 0; /* seach the entire entry */
1048 /* Seach from beginning of entry or pick up where we left off */
1049 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1052 for (i = istart; i < entry->nServers; i++) {
1053 if (entry->serverFlags[i] & vtype) {
1054 *server = entry->serverNumber[i];
1055 *part = entry->serverPartition[i];
1061 /* Didn't find any, return -1 */
1067 PostVolumeStats(entry)
1068 struct nvldbentry *entry;
1070 SubEnumerateEntry(entry);
1071 /* Check for VLOP_ALLOPERS */
1072 if (entry->flags & VLOP_ALLOPERS)
1073 fprintf(STDOUT, " Volume is currently LOCKED \n");
1077 /*------------------------------------------------------------------------
1078 * PRIVATE XVolumeStats
1081 * Display extended volume information.
1084 * a_xInfoP : Ptr to extended volume info.
1085 * a_entryP : Ptr to the volume's VLDB entry.
1086 * a_srvID : Server ID.
1087 * a_partID : Partition ID.
1088 * a_volType : Type of volume to print.
1094 * Nothing interesting.
1098 *------------------------------------------------------------------------*/
1101 XVolumeStats(a_xInfoP, a_entryP, a_srvID, a_partID, a_volType)
1102 volintXInfo *a_xInfoP;
1103 struct nvldbentry *a_entryP;
1110 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1112 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1113 a_srvID, /*Server ID to print */
1114 a_partID, /*Partition ID to print */
1115 &totalOK, /*Ptr to total-OK counter */
1116 &totalNotOK, /*Ptr to total-screwed counter */
1117 &totalBusy, /*Ptr to total-busy counter */
1118 0, /*Don't do a fast listing */
1119 1, /*Do a long listing */
1120 1); /*Show volume problems */
1126 VolumeStats(pntr, entry, server, part, voltype)
1128 struct nvldbentry *entry;
1130 afs_int32 server, part;
1132 int totalOK, totalNotOK, totalBusy;
1134 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1139 /* command to forcibly remove a volume */
1142 register struct cmd_syndesc *as;
1144 register afs_int32 code;
1145 afs_int32 volID, err;
1150 server = GetServer(tp = as->parms[0].items->data);
1152 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1156 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1158 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1162 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1165 PrintError("", err);
1168 "vos: could not parse '%s' as a numeric volume ID", tp);
1173 "vos: forcibly removing all traces of volume %d, please wait...",
1176 code = UV_NukeVolume(server, partID, volID);
1178 fprintf(STDOUT, "done.\n");
1180 fprintf(STDOUT, "failed with code %d.\n", code);
1185 /*------------------------------------------------------------------------
1186 * PRIVATE ExamineVolume
1189 * Routine used to examine a single volume, contacting the VLDB as
1190 * well as the Volume Server.
1193 * as : Ptr to parsed command line arguments.
1196 * 0 for a successful operation,
1197 * Otherwise, one of the ubik or VolServer error values.
1200 * Nothing interesting.
1204 *------------------------------------------------------------------------
1208 register struct cmd_syndesc *as;
1210 struct nvldbentry entry;
1211 afs_int32 vcode = 0;
1212 volintInfo *pntr = (volintInfo *) 0;
1213 volintXInfo *xInfoP = (volintXInfo *) 0;
1215 afs_int32 code, err, error = 0;
1216 int voltype, foundserv = 0, foundentry = 0;
1217 afs_int32 aserver, apart;
1219 int wantExtendedInfo; /*Do we want extended vol info? */
1221 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1223 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1226 PrintError("", err);
1228 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1229 as->parms[0].items->data);
1234 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1235 (unsigned long)volid);
1238 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1241 "Could not fetch the entry for volume number %lu from VLDB \n",
1242 (unsigned long)volid);
1246 fprintf(STDOUT, "done\n");
1247 MapHostToNetwork(&entry);
1249 if (entry.volumeId[RWVOL] == volid)
1251 else if (entry.volumeId[BACKVOL] == volid)
1253 else /* (entry.volumeId[ROVOL] == volid) */
1256 do { /* do {...} while (voltype == ROVOL) */
1257 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1258 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1259 * If its a RO vol, get the next RO entry.
1261 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1262 &aserver, &apart, &previdx);
1263 if (previdx == -1) { /* searched all entries */
1265 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1266 as->parms[0].items->data);
1273 /* Get information about the volume from the server */
1275 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1276 hostutil_GetNameByINet(aserver));
1279 if (wantExtendedInfo)
1280 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1282 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1284 fprintf(STDOUT, "done\n");
1288 if (code == ENODEV) {
1289 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1290 /* The VLDB says there is no backup volume and its not on disk */
1291 fprintf(STDERR, "Volume %s does not exist\n",
1292 as->parms[0].items->data);
1296 "Volume does not exist on server %s as indicated by the VLDB\n",
1297 hostutil_GetNameByINet(aserver));
1300 PrintDiagnostics("examine", code);
1302 fprintf(STDOUT, "\n");
1305 if (wantExtendedInfo)
1306 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1308 #ifdef FULL_LISTVOL_SWITCH
1309 if (as->parms[2].items) {
1310 DisplayFormat2(aserver, apart, pntr);
1311 EnumerateEntry(&entry);
1313 #endif /* FULL_LISTVOL_SWITCH */
1314 VolumeStats(pntr, &entry, aserver, apart, voltype);
1316 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1317 /* The VLDB says there is no backup volume yet we found one on disk */
1318 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1319 as->parms[0].items->data);
1328 } while (voltype == ROVOL);
1331 fprintf(STDERR, "Dump only information from VLDB\n\n");
1332 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1334 PostVolumeStats(&entry);
1339 /*------------------------------------------------------------------------
1343 * Routine used to change the status of a single volume.
1346 * as : Ptr to parsed command line arguments.
1349 * 0 for a successful operation,
1350 * Otherwise, one of the ubik or VolServer error values.
1353 * Nothing interesting.
1357 *------------------------------------------------------------------------
1361 register struct cmd_syndesc *as;
1363 struct nvldbentry entry;
1364 afs_int32 vcode = 0;
1367 afs_int32 code, err;
1368 afs_int32 aserver, apart;
1371 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1374 PrintError("", err);
1376 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1377 as->parms[0].items->data);
1381 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1384 "Could not fetch the entry for volume number %lu from VLDB \n",
1385 (unsigned long)volid);
1388 MapHostToNetwork(&entry);
1390 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1391 if (previdx == -1) {
1392 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1393 as->parms[0].items->data);
1397 memset(&info, 0, sizeof(info));
1408 if (as->parms[1].items) {
1410 code = util_GetInt32(as->parms[1].items->data, &info.maxquota);
1412 fprintf(STDERR, "invalid quota value\n");
1416 if (as->parms[2].items) {
1420 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1423 "Could not update volume info fields for volume number %lu\n",
1424 (unsigned long)volid);
1428 /*------------------------------------------------------------------------
1432 * Brings a volume online.
1435 * as : Ptr to parsed command line arguments.
1438 * 0 for a successful operation,
1441 * Nothing interesting.
1445 *------------------------------------------------------------------------
1449 register struct cmd_syndesc *as;
1451 afs_int32 server, partition, volid;
1452 afs_int32 code, err = 0;
1454 server = GetServer(as->parms[0].items->data);
1456 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1457 as->parms[0].items->data);
1461 partition = volutil_GetPartitionID(as->parms[1].items->data);
1462 if (partition < 0) {
1463 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1464 as->parms[1].items->data);
1468 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1471 PrintError("", err);
1473 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1474 as->parms[0].items->data);
1478 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1481 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1488 /*------------------------------------------------------------------------
1489 * PRIVATE volOffline
1492 * Brings a volume offline.
1495 * as : Ptr to parsed command line arguments.
1498 * 0 for a successful operation,
1501 * Nothing interesting.
1505 *------------------------------------------------------------------------
1508 volOffline(register struct cmd_syndesc *as)
1510 afs_int32 server, partition, volid;
1511 afs_int32 code, err = 0;
1512 afs_int32 transflag, sleeptime, transdone;
1514 server = GetServer(as->parms[0].items->data);
1516 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1517 as->parms[0].items->data);
1521 partition = volutil_GetPartitionID(as->parms[1].items->data);
1522 if (partition < 0) {
1523 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1524 as->parms[1].items->data);
1528 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1531 PrintError("", err);
1533 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1534 as->parms[0].items->data);
1538 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1539 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1540 transdone = (sleeptime ? 0 /*online */ : VTOutOfService);
1541 if (as->parms[4].items && !as->parms[3].items) {
1542 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1547 UV_SetVolume(server, partition, volid, transflag, transdone,
1550 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1558 CreateVolume(register struct cmd_syndesc *as)
1562 afs_int32 volid, code;
1563 struct nvldbentry entry;
1568 tserver = GetServer(as->parms[0].items->data);
1570 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1571 as->parms[0].items->data);
1574 pname = volutil_GetPartitionID(as->parms[1].items->data);
1576 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1577 as->parms[1].items->data);
1580 if (!IsPartValid(pname, tserver, &code)) { /*check for validity of the partition */
1582 PrintError("", code);
1585 "vos : partition %s does not exist on the server\n",
1586 as->parms[1].items->data);
1589 if (!ISNAMEVALID(as->parms[2].items->data)) {
1591 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1592 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1595 if (!VolNameOK(as->parms[2].items->data)) {
1597 "Illegal volume name %s, should not end in .readonly or .backup\n",
1598 as->parms[2].items->data);
1601 if (IsNumeric(as->parms[2].items->data)) {
1602 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1603 as->parms[2].items->data);
1606 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1608 fprintf(STDERR, "Volume %s already exists\n",
1609 as->parms[2].items->data);
1610 PrintDiagnostics("create", code);
1614 if (as->parms[3].items) {
1615 if (!IsNumeric(as->parms[3].items->data)) {
1616 fprintf(STDERR, "Initial quota %s should be numeric.\n",
1617 as->parms[3].items->data);
1621 code = util_GetInt32(as->parms[3].items->data, "a);
1623 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1629 UV_CreateVolume2(tserver, pname, as->parms[2].items->data, quota, 0,
1632 PrintDiagnostics("create", code);
1635 MapPartIdIntoName(pname, part);
1636 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
1637 (unsigned long)volid, part, as->parms[0].items->data);
1644 struct nvldbentry *entry;
1647 afs_int32 error, code, curserver, curpart, volid;
1649 MapHostToNetwork(entry);
1651 for (i = 0; i < entry->nServers; i++) {
1652 curserver = entry->serverNumber[i];
1653 curpart = entry->serverPartition[i];
1654 if (entry->serverFlags[i] & ITSROVOL) {
1655 volid = entry->volumeId[ROVOL];
1657 volid = entry->volumeId[RWVOL];
1659 code = UV_DeleteVolume(curserver, curpart, volid);
1668 struct cmd_syndesc *as;
1670 afs_int32 err, code = 0;
1671 afs_int32 server = 0, partition = -1, volid;
1675 if (as->parms[0].items) {
1676 server = GetServer(as->parms[0].items->data);
1678 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1679 as->parms[0].items->data);
1684 if (as->parms[1].items) {
1685 partition = volutil_GetPartitionID(as->parms[1].items->data);
1686 if (partition < 0) {
1687 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1688 as->parms[1].items->data);
1692 /* Check for validity of the partition */
1693 if (!IsPartValid(partition, server, &code)) {
1695 PrintError("", code);
1698 "vos : partition %s does not exist on the server\n",
1699 as->parms[1].items->data);
1705 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1707 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
1708 as->parms[2].items->data);
1710 PrintError("", err);
1714 /* If the server or partition option are not complete, try to fill
1715 * them in from the VLDB entry.
1717 if ((partition == -1) || !server) {
1718 struct nvldbentry entry;
1720 code = VLDB_GetEntryByID(volid, -1, &entry);
1723 "Could not fetch the entry for volume %lu from VLDB\n",
1724 (unsigned long)volid);
1725 PrintError("", code);
1729 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
1730 || ((volid == entry.volumeId[BACKVOL])
1731 && (entry.flags & BACK_EXISTS))) {
1732 idx = Lp_GetRwIndex(&entry);
1733 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
1734 || ((partition != -1)
1735 && (partition != entry.serverPartition[idx]))) {
1736 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
1737 as->parms[2].items->data);
1740 } else if ((volid == entry.volumeId[ROVOL])
1741 && (entry.flags & RO_EXISTS)) {
1742 for (idx = -1, j = 0; j < entry.nServers; j++) {
1743 if (entry.serverFlags[j] != ITSROVOL)
1746 if (((server == 0) || (server == entry.serverNumber[j]))
1747 && ((partition == -1)
1748 || (partition == entry.serverPartition[j]))) {
1751 "VLDB: Volume '%s' matches more than one RO\n",
1752 as->parms[2].items->data);
1759 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
1760 as->parms[2].items->data);
1764 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
1765 as->parms[2].items->data);
1769 server = htonl(entry.serverNumber[idx]);
1770 partition = entry.serverPartition[idx];
1774 code = UV_DeleteVolume(server, partition, volid);
1776 PrintDiagnostics("remove", code);
1780 MapPartIdIntoName(partition, pname);
1781 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
1782 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
1786 #define TESTM 0 /* set for move space tests, clear for production */
1789 register struct cmd_syndesc *as;
1792 afs_int32 volid, fromserver, toserver, frompart, topart;
1793 afs_int32 flags, code, err;
1794 char fromPartName[10], toPartName[10];
1796 struct diskPartition partition; /* for space check */
1799 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
1802 PrintError("", err);
1804 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
1805 as->parms[0].items->data);
1808 fromserver = GetServer(as->parms[1].items->data);
1809 if (fromserver == 0) {
1810 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1811 as->parms[1].items->data);
1814 toserver = GetServer(as->parms[3].items->data);
1815 if (toserver == 0) {
1816 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1817 as->parms[3].items->data);
1820 frompart = volutil_GetPartitionID(as->parms[2].items->data);
1822 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1823 as->parms[2].items->data);
1826 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
1828 PrintError("", code);
1831 "vos : partition %s does not exist on the server\n",
1832 as->parms[2].items->data);
1835 topart = volutil_GetPartitionID(as->parms[4].items->data);
1837 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1838 as->parms[4].items->data);
1841 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
1843 PrintError("", code);
1846 "vos : partition %s does not exist on the server\n",
1847 as->parms[4].items->data);
1852 if (as->parms[5].items) flags |= RV_NOCLONE;
1855 * check source partition for space to clone volume
1858 MapPartIdIntoName(topart, toPartName);
1859 MapPartIdIntoName(frompart, fromPartName);
1862 * check target partition for space to move volume
1865 code = UV_PartitionInfo(toserver, toPartName, &partition);
1867 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
1871 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
1874 p = (volintInfo *) 0;
1875 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
1877 fprintf(STDERR, "vos:cannot access volume %lu\n",
1878 (unsigned long)volid);
1883 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
1885 if (partition.free <= p->size) {
1887 "vos: no space on target partition %s to move volume %lu\n",
1888 toPartName, (unsigned long)volid);
1895 fprintf(STDOUT, "size test - don't do move\n");
1899 /* successful move still not guaranteed but shoot for it */
1902 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
1904 PrintDiagnostics("move", code);
1907 MapPartIdIntoName(topart, toPartName);
1908 MapPartIdIntoName(frompart, fromPartName);
1909 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
1910 (unsigned long)volid, as->parms[1].items->data, fromPartName,
1911 as->parms[3].items->data, toPartName);
1918 register struct cmd_syndesc *as;
1920 afs_int32 volid, fromserver, toserver, frompart, topart, code, err, flags;
1921 char fromPartName[10], toPartName[10], *tovolume;
1922 struct nvldbentry entry;
1923 struct diskPartition partition; /* for space check */
1926 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
1929 PrintError("", err);
1931 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
1932 as->parms[0].items->data);
1935 fromserver = GetServer(as->parms[1].items->data);
1936 if (fromserver == 0) {
1937 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1938 as->parms[1].items->data);
1942 toserver = GetServer(as->parms[4].items->data);
1943 if (toserver == 0) {
1944 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1945 as->parms[4].items->data);
1949 tovolume = as->parms[3].items->data;
1950 if (!ISNAMEVALID(tovolume)) {
1952 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1953 tovolume, VOLSER_OLDMAXVOLNAME - 10);
1956 if (!VolNameOK(tovolume)) {
1958 "Illegal volume name %s, should not end in .readonly or .backup\n",
1962 if (IsNumeric(tovolume)) {
1963 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1967 code = VLDB_GetEntryByName(tovolume, &entry);
1969 fprintf(STDERR, "Volume %s already exists\n", tovolume);
1970 PrintDiagnostics("copy", code);
1974 frompart = volutil_GetPartitionID(as->parms[2].items->data);
1976 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1977 as->parms[2].items->data);
1980 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
1982 PrintError("", code);
1985 "vos : partition %s does not exist on the server\n",
1986 as->parms[2].items->data);
1990 topart = volutil_GetPartitionID(as->parms[5].items->data);
1992 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1993 as->parms[5].items->data);
1996 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
1998 PrintError("", code);
2001 "vos : partition %s does not exist on the server\n",
2002 as->parms[5].items->data);
2007 if (as->parms[6].items) flags |= RV_OFFLINE;
2008 if (as->parms[7].items) flags |= RV_RDONLY;
2009 if (as->parms[8].items) flags |= RV_NOCLONE;
2011 MapPartIdIntoName(topart, toPartName);
2012 MapPartIdIntoName(frompart, fromPartName);
2015 * check target partition for space to move volume
2018 code = UV_PartitionInfo(toserver, toPartName, &partition);
2020 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2024 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2027 p = (volintInfo *) 0;
2028 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2030 fprintf(STDERR, "vos:cannot access volume %lu\n",
2031 (unsigned long)volid);
2036 if (partition.free <= p->size) {
2038 "vos: no space on target partition %s to copy volume %lu\n",
2039 toPartName, (unsigned long)volid);
2045 /* successful copy still not guaranteed but shoot for it */
2048 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2051 PrintDiagnostics("copy", code);
2054 MapPartIdIntoName(topart, toPartName);
2055 MapPartIdIntoName(frompart, fromPartName);
2056 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2057 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2058 tovolume, as->parms[4].items->data, toPartName);
2066 register struct cmd_syndesc *as;
2068 afs_int32 volid, fromserver, toserver, frompart, topart, tovolid;
2069 afs_int32 code, err, flags;
2070 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2071 struct nvldbentry entry;
2072 struct diskPartition partition; /* for space check */
2075 p = (volintInfo *) 0;
2076 q = (volintInfo *) 0;
2078 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2081 PrintError("", err);
2083 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2084 as->parms[0].items->data);
2087 fromserver = GetServer(as->parms[1].items->data);
2088 if (fromserver == 0) {
2089 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2090 as->parms[1].items->data);
2094 toserver = GetServer(as->parms[3].items->data);
2095 if (toserver == 0) {
2096 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2097 as->parms[3].items->data);
2101 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2103 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2104 as->parms[2].items->data);
2107 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2109 PrintError("", code);
2112 "vos : partition %s does not exist on the server\n",
2113 as->parms[2].items->data);
2117 topart = volutil_GetPartitionID(as->parms[4].items->data);
2119 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2120 as->parms[4].items->data);
2123 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2125 PrintError("", code);
2128 "vos : partition %s does not exist on the server\n",
2129 as->parms[4].items->data);
2133 if (as->parms[5].items) {
2134 tovolume = as->parms[5].items->data;
2135 if (!ISNAMEVALID(tovolume)) {
2137 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2138 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2141 if (!VolNameOK(tovolume)) {
2143 "Illegal volume name %s, should not end in .readonly or .backup\n",
2147 if (IsNumeric(tovolume)) {
2149 "Illegal volume name %s, should not be a number\n",
2154 /* use actual name of source volume */
2155 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2157 fprintf(STDERR, "vos:cannot access volume %lu\n",
2158 (unsigned long)volid);
2161 strcpy(toVolName, p->name);
2162 tovolume = toVolName;
2163 /* save p for size checks later */
2166 if (as->parms[6].items) {
2167 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2170 PrintError("", err);
2172 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2173 as->parms[6].items->data);
2179 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2182 PrintError("", err);
2184 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2193 if (as->parms[7].items) flags |= RV_OFFLINE;
2194 if (as->parms[8].items) flags |= RV_RDONLY;
2195 if (as->parms[9].items) flags |= RV_NOCLONE;
2196 if (as->parms[10].items) flags |= RV_CPINCR;
2198 MapPartIdIntoName(topart, toPartName);
2199 MapPartIdIntoName(frompart, fromPartName);
2202 * check target partition for space to move volume
2205 code = UV_PartitionInfo(toserver, toPartName, &partition);
2207 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2211 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2214 /* Don't do this again if we did it above */
2216 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2218 fprintf(STDERR, "vos:cannot access volume %lu\n",
2219 (unsigned long)volid);
2224 /* OK if this fails */
2225 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2227 /* Treat existing volume size as "free" */
2229 p->size = (q->size < p->size) ? p->size - q->size : 0;
2231 if (partition.free <= p->size) {
2233 "vos: no space on target partition %s to copy volume %lu\n",
2234 toPartName, (unsigned long)volid);
2242 /* successful copy still not guaranteed but shoot for it */
2245 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2246 topart, tovolid, flags);
2248 PrintDiagnostics("shadow", code);
2251 MapPartIdIntoName(topart, toPartName);
2252 MapPartIdIntoName(frompart, fromPartName);
2253 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2254 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2255 as->parms[4].items->data, toPartName);
2263 register struct cmd_syndesc *as;
2265 afs_int32 server, part, volid, cloneid, voltype;
2266 char partName[10], *volname;
2267 afs_int32 code, err, flags;
2268 struct nvldbentry entry;
2270 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2273 PrintError("", err);
2275 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2276 as->parms[0].items->data);
2280 if (as->parms[1].items || as->parms[2].items) {
2281 if (!as->parms[1].items || !as->parms[2].items) {
2283 "Must specify both -server and -partition options\n");
2286 server = GetServer(as->parms[1].items->data);
2288 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2289 as->parms[1].items->data);
2292 part = volutil_GetPartitionID(as->parms[2].items->data);
2294 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2295 as->parms[2].items->data);
2298 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2300 PrintError("", code);
2303 "vos : partition %s does not exist on the server\n",
2304 as->parms[2].items->data);
2308 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2314 if (as->parms[3].items) {
2315 volname = as->parms[3].items->data;
2316 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2318 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2319 volname, VOLSER_OLDMAXVOLNAME - 1);
2322 if (!VolNameOK(volname)) {
2324 "Illegal volume name %s, should not end in .readonly or .backup\n",
2328 if (IsNumeric(volname)) {
2330 "Illegal volume name %s, should not be a number\n",
2337 if (as->parms[4].items) {
2338 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2341 PrintError("", err);
2343 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2344 as->parms[4].items->data);
2350 if (as->parms[5].items) flags |= RV_OFFLINE;
2351 if (as->parms[6].items) flags |= RV_RDONLY;
2355 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2358 PrintDiagnostics("clone", code);
2361 MapPartIdIntoName(part, partName);
2362 fprintf(STDOUT, "Created clone for volume %lu\n",
2363 as->parms[0].items->data);
2371 register struct cmd_syndesc *as;
2373 afs_int32 avolid, aserver, apart, vtype, code, err;
2374 struct nvldbentry entry;
2376 afs_int32 buvolid, buserver, bupart, butype;
2377 struct nvldbentry buentry;
2379 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2382 PrintError("", err);
2384 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2385 as->parms[0].items->data);
2388 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2392 /* verify this is a readwrite volume */
2394 if (vtype != RWVOL) {
2395 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2399 /* is there a backup volume already? */
2401 if (entry.flags & BACK_EXISTS) {
2402 /* yep, where is it? */
2404 buvolid = entry.volumeId[BACKVOL];
2405 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2410 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2413 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2419 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2420 (unsigned long)buvolid, (unsigned long)buserver);
2425 /* nope, carry on */
2427 code = UV_BackupVolume(aserver, apart, avolid);
2430 PrintDiagnostics("backup", code);
2433 fprintf(STDOUT, "Created backup volume for %s \n",
2434 as->parms[0].items->data);
2440 register struct cmd_syndesc *as;
2443 struct nvldbentry entry;
2444 afs_int32 avolid, aserver, apart, vtype, code, err;
2447 if (as->parms[1].items)
2449 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2452 PrintError("", err);
2454 fprintf(STDERR, "vos: can't find volume '%s'\n",
2455 as->parms[0].items->data);
2458 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2462 if (vtype != RWVOL) {
2463 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2467 if (!ISNAMEVALID(entry.name)) {
2469 "Volume name %s is too long, rename before releasing\n",
2474 code = UV_ReleaseVolume(avolid, aserver, apart, force);
2476 PrintDiagnostics("release", code);
2479 fprintf(STDOUT, "Released volume %s successfully\n",
2480 as->parms[0].items->data);
2486 register struct cmd_syndesc *as;
2489 afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i;
2490 char filename[NameLen];
2491 struct nvldbentry entry;
2493 rx_SetRxDeadTime(60 * 10);
2494 for (i = 0; i < MAXSERVERS; i++) {
2495 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2498 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2499 if (rxConn->service)
2500 rxConn->service->connDeadTime = rx_connDeadTime;
2503 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2506 PrintError("", err);
2508 fprintf(STDERR, "vos: can't find volume '%s'\n",
2509 as->parms[0].items->data);
2513 if (as->parms[3].items || as->parms[4].items) {
2514 if (!as->parms[3].items || !as->parms[4].items) {
2516 "Must specify both -server and -partition options\n");
2519 aserver = GetServer(as->parms[3].items->data);
2521 fprintf(STDERR, "Invalid server name\n");
2524 apart = volutil_GetPartitionID(as->parms[4].items->data);
2526 fprintf(STDERR, "Invalid partition name\n");
2530 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2535 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2536 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2538 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2539 as->parms[1].items->data, code);
2543 if (as->parms[2].items) {
2544 strcpy(filename, as->parms[2].items->data);
2546 strcpy(filename, "");
2549 if (as->parms[5].items) {
2551 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2552 DumpFunction, filename);
2555 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2559 PrintDiagnostics("dump", code);
2562 if (strcmp(filename, ""))
2563 fprintf(STDERR, "Dumped volume %s in file %s\n",
2564 as->parms[0].items->data, filename);
2566 fprintf(STDERR, "Dumped volume %s in stdout \n",
2567 as->parms[0].items->data);
2578 register struct cmd_syndesc *as;
2581 afs_int32 avolid, aserver, apart, code, vcode, err;
2582 afs_int32 aoverwrite = ASK;
2583 int restoreflags, readonly = 0, offline = 0, voltype = RWVOL;
2585 char afilename[NameLen], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
2586 char volname[VOLSER_MAXVOLNAME + 1];
2587 struct nvldbentry entry;
2591 if (as->parms[4].items) {
2592 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2595 PrintError("", err);
2597 fprintf(STDERR, "vos: can't find volume '%s'\n",
2598 as->parms[4].items->data);
2604 if (as->parms[5].items) {
2605 if ((strcmp(as->parms[5].items->data, "a") == 0)
2606 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
2608 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
2609 || (strcmp(as->parms[5].items->data, "full") == 0)) {
2611 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
2612 || (strcmp(as->parms[5].items->data, "inc") == 0)
2613 || (strcmp(as->parms[5].items->data, "increment") == 0)
2614 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
2617 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2618 as->parms[5].items->data);
2622 if (as->parms[6].items)
2624 if (as->parms[7].items) {
2629 aserver = GetServer(as->parms[0].items->data);
2631 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2632 as->parms[0].items->data);
2635 apart = volutil_GetPartitionID(as->parms[1].items->data);
2637 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2638 as->parms[1].items->data);
2641 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
2643 PrintError("", code);
2646 "vos : partition %s does not exist on the server\n",
2647 as->parms[1].items->data);
2650 strcpy(avolname, as->parms[2].items->data);
2651 if (!ISNAMEVALID(avolname)) {
2653 "vos: the name of the volume %s exceeds the size limit\n",
2657 if (!VolNameOK(avolname)) {
2659 "Illegal volume name %s, should not end in .readonly or .backup\n",
2663 if (as->parms[3].items) {
2664 strcpy(afilename, as->parms[3].items->data);
2665 if (!FileExists(afilename)) {
2666 fprintf(STDERR, "Can't access file %s\n", afilename);
2670 strcpy(afilename, "");
2673 /* Check if volume exists or not */
2675 vsu_ExtractName(volname, avolname);
2676 vcode = VLDB_GetEntryByName(volname, &entry);
2677 if (vcode) { /* no volume - do a full restore */
2678 restoreflags = RV_FULLRST;
2679 if ((aoverwrite == INC) || (aoverwrite == ABORT))
2681 "Volume does not exist; Will perform a full restore\n");
2684 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
2685 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
2686 restoreflags = RV_FULLRST;
2687 if ((aoverwrite == INC) || (aoverwrite == ABORT))
2689 "%s Volume does not exist; Will perform a full restore\n",
2690 readonly ? "RO" : "RW");
2693 avolid = entry.volumeId[voltype];
2694 } else if (entry.volumeId[voltype] != 0
2695 && entry.volumeId[voltype] != avolid) {
2696 avolid = entry.volumeId[voltype];
2700 else { /* volume exists - do we do a full incremental or abort */
2701 int Oserver, Opart, Otype, vol_elsewhere = 0;
2702 struct nvldbentry Oentry;
2706 avolid = entry.volumeId[voltype];
2707 } else if (entry.volumeId[voltype] != 0
2708 && entry.volumeId[voltype] != avolid) {
2709 avolid = entry.volumeId[voltype];
2712 /* A file name was specified - check if volume is on another partition */
2713 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
2717 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
2720 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
2724 if (!vcode || (Opart != apart))
2727 if (aoverwrite == ASK) {
2728 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
2730 "Volume exists and no -overwrite option specified; Aborting restore command\n");
2734 /* Ask what to do */
2735 if (vol_elsewhere) {
2737 "The volume %s %u already exists on a different server/part\n",
2738 volname, entry.volumeId[voltype]);
2740 "Do you want to do a full restore or abort? [fa](a): ");
2743 "The volume %s %u already exists in the VLDB\n",
2744 volname, entry.volumeId[voltype]);
2746 "Do you want to do a full/incremental restore or abort? [fia](a): ");
2749 while (!(dc == EOF || dc == '\n'))
2750 dc = getchar(); /* goto end of line */
2751 if ((c == 'f') || (c == 'F'))
2753 else if ((c == 'i') || (c == 'I'))
2759 if (aoverwrite == ABORT) {
2760 fprintf(STDERR, "Volume exists; Aborting restore command\n");
2762 } else if (aoverwrite == FULL) {
2763 restoreflags = RV_FULLRST;
2765 "Volume exists; Will delete and perform full restore\n");
2766 } else if (aoverwrite == INC) {
2768 if (vol_elsewhere) {
2770 "%s volume %lu already exists on a different server/part; not allowed\n",
2771 readonly ? "RO" : "RW", (unsigned long)avolid);
2777 restoreflags |= RV_OFFLINE;
2779 restoreflags |= RV_RDONLY;
2781 UV_RestoreVolume(aserver, apart, avolid, avolname, restoreflags,
2782 WriteData, afilename);
2784 PrintDiagnostics("restore", code);
2787 MapPartIdIntoName(apart, apartName);
2790 * patch typo here - originally "parms[1]", should be "parms[0]"
2793 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
2794 as->parms[0].items->data, apartName);
2800 register struct cmd_syndesc *as;
2803 afs_int32 avolid, code, err;
2805 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2808 PrintError("", err);
2810 fprintf(STDERR, "vos: can't find volume '%s'\n",
2811 as->parms[0].items->data);
2815 code = UV_LockRelease(avolid);
2817 PrintDiagnostics("unlock", code);
2820 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
2821 as->parms[0].items->data);
2827 register struct cmd_syndesc *as;
2829 afs_int32 avolid, aserver, apart, code, err;
2830 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
2832 vsu_ExtractName(avolname, as->parms[2].items->data);;
2833 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
2836 PrintError("", err);
2838 fprintf(STDERR, "vos: can't find volume '%s'\n",
2839 as->parms[2].items->data);
2842 aserver = GetServer(as->parms[0].items->data);
2844 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2845 as->parms[0].items->data);
2848 apart = volutil_GetPartitionID(as->parms[1].items->data);
2850 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2851 as->parms[1].items->data);
2854 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
2856 PrintError("", code);
2859 "vos : partition %s does not exist on the server\n",
2860 as->parms[1].items->data);
2863 code = UV_AddSite(aserver, apart, avolid);
2865 PrintDiagnostics("addsite", code);
2868 MapPartIdIntoName(apart, apartName);
2869 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
2870 as->parms[0].items->data, apartName, as->parms[2].items->data);
2876 register struct cmd_syndesc *as;
2879 afs_int32 avolid, aserver, apart, code, err;
2880 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
2882 vsu_ExtractName(avolname, as->parms[2].items->data);
2883 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
2886 PrintError("", err);
2888 fprintf(STDERR, "vos: can't find volume '%s'\n",
2889 as->parms[2].items->data);
2892 aserver = GetServer(as->parms[0].items->data);
2894 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2895 as->parms[0].items->data);
2898 apart = volutil_GetPartitionID(as->parms[1].items->data);
2900 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2901 as->parms[1].items->data);
2905 *skip the partition validity check, since it is possible that the partition
2906 *has since been decomissioned.
2909 if (!IsPartValid(apart,aserver,&code)){
2910 if(code) PrintError("",code);
2911 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
2915 code = UV_RemoveSite(aserver, apart, avolid);
2917 PrintDiagnostics("remsite", code);
2920 MapPartIdIntoName(apart, apartName);
2921 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
2922 as->parms[0].items->data, apartName, as->parms[2].items->data);
2928 register struct cmd_syndesc *as;
2930 afs_int32 avolid, aserver, apart, code, err;
2933 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2936 PrintError("", err);
2938 fprintf(STDERR, "vos: can't find volume '%s'\n",
2939 as->parms[2].items->data);
2942 aserver = GetServer(as->parms[0].items->data);
2944 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2945 as->parms[0].items->data);
2948 apart = volutil_GetPartitionID(as->parms[1].items->data);
2950 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2951 as->parms[1].items->data);
2954 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
2956 PrintError("", code);
2959 "vos : partition %s does not exist on the server\n",
2960 as->parms[1].items->data);
2963 code = UV_ChangeLocation(aserver, apart, avolid);
2965 PrintDiagnostics("addsite", code);
2968 MapPartIdIntoName(apart, apartName);
2969 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
2970 as->parms[0].items->data, apartName, as->parms[2].items->data);
2976 register struct cmd_syndesc *as;
2978 afs_int32 aserver, code;
2979 struct partList dummyPartList;
2984 aserver = GetServer(as->parms[0].items->data);
2986 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2987 as->parms[0].items->data);
2992 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
2994 PrintDiagnostics("listpart", code);
2998 fprintf(STDOUT, "The partitions on the server are:\n");
2999 for (i = 0; i < cnt; i++) {
3000 if (dummyPartList.partFlags[i] & PARTVALID) {
3001 memset(pname, 0, sizeof(pname));
3002 MapPartIdIntoName(dummyPartList.partId[i], pname);
3003 fprintf(STDOUT, " %10s ", pname);
3005 if ((i % 5) == 0 && (i != 0))
3006 fprintf(STDOUT, "\n");
3009 fprintf(STDOUT, "\n");
3010 fprintf(STDOUT, "Total: %d\n", total);
3016 CompareVolName(p1, p2)
3019 volintInfo *arg1, *arg2;
3021 arg1 = (volintInfo *) p1;
3022 arg2 = (volintInfo *) p2;
3023 return (strcmp(arg1->name, arg2->name));
3027 /*------------------------------------------------------------------------
3028 * PRIVATE XCompareVolName
3031 * Comparison routine for volume names coming from an extended
3035 * a_obj1P : Char ptr to first extended vol info object
3036 * a_obj1P : Char ptr to second extended vol info object
3039 * The value of strcmp() on the volume names within the passed
3040 * objects (i,e., -1, 0, or 1).
3043 * Passed to qsort() as the designated comparison routine.
3047 *------------------------------------------------------------------------*/
3050 XCompareVolName(a_obj1P, a_obj2P)
3051 char *a_obj1P, *a_obj2P;
3053 { /*XCompareVolName */
3056 (((struct volintXInfo *)(a_obj1P))->name,
3057 ((struct volintXInfo *)(a_obj2P))->name));
3059 } /*XCompareVolName */
3062 CompareVolID(p1, p2)
3065 volintInfo *arg1, *arg2;
3067 arg1 = (volintInfo *) p1;
3068 arg2 = (volintInfo *) p2;
3069 if (arg1->volid == arg2->volid)
3071 if (arg1->volid > arg2->volid)
3078 /*------------------------------------------------------------------------
3079 * PRIVATE XCompareVolID
3082 * Comparison routine for volume IDs coming from an extended
3086 * a_obj1P : Char ptr to first extended vol info object
3087 * a_obj1P : Char ptr to second extended vol info object
3090 * The value of strcmp() on the volume names within the passed
3091 * objects (i,e., -1, 0, or 1).
3094 * Passed to qsort() as the designated comparison routine.
3098 *------------------------------------------------------------------------*/
3101 XCompareVolID(a_obj1P, a_obj2P)
3102 char *a_obj1P, *a_obj2P;
3104 { /*XCompareVolID */
3106 afs_int32 id1, id2; /*Volume IDs we're comparing */
3108 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3109 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3117 } /*XCompareVolID */
3119 /*------------------------------------------------------------------------
3120 * PRIVATE ListVolumes
3123 * Routine used to list volumes, contacting the Volume Server
3124 * directly, bypassing the VLDB.
3127 * as : Ptr to parsed command line arguments.
3130 * 0 Successful operation
3133 * Nothing interesting.
3137 *------------------------------------------------------------------------*/
3141 register struct cmd_syndesc *as;
3143 afs_int32 apart, int32list, fast;
3144 afs_int32 aserver, code;
3145 volintInfo *pntr, *oldpntr;
3149 volintXInfo *xInfoP, *origxInfoP; /*Ptr to current/orig extended vol info */
3150 int wantExtendedInfo; /*Do we want extended vol info? */
3153 struct partList dummyPartList;
3161 if (as->parms[3].items)
3163 if (as->parms[4].items)
3167 if (as->parms[2].items)
3173 if (as->parms[5].items) {
3175 * We can't coexist with the fast flag.
3179 "vos: Can't use the -fast and -extended flags together\n");
3184 * We need to turn on ``long'' listings to get the full effect.
3186 wantExtendedInfo = 1;
3189 wantExtendedInfo = 0;
3190 if (as->parms[1].items) {
3191 apart = volutil_GetPartitionID(as->parms[1].items->data);
3193 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3194 as->parms[1].items->data);
3197 dummyPartList.partId[0] = apart;
3198 dummyPartList.partFlags[0] = PARTVALID;
3201 aserver = GetServer(as->parms[0].items->data);
3203 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3204 as->parms[0].items->data);
3209 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3211 PrintError("", code);
3214 "vos : partition %s does not exist on the server\n",
3215 as->parms[1].items->data);
3219 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3221 PrintDiagnostics("listvol", code);
3225 for (i = 0; i < cnt; i++) {
3226 if (dummyPartList.partFlags[i] & PARTVALID) {
3227 if (wantExtendedInfo)
3229 UV_XListVolumes(aserver, dummyPartList.partId[i], all,
3233 UV_ListVolumes(aserver, dummyPartList.partId[i], all,
3236 PrintDiagnostics("listvol", code);
3241 if (wantExtendedInfo) {
3242 origxInfoP = xInfoP;
3243 base = (char *)xInfoP;
3246 base = (char *)pntr;
3250 if (wantExtendedInfo)
3251 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
3253 qsort(base, count, sizeof(volintInfo), CompareVolName);
3255 if (wantExtendedInfo)
3256 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
3258 qsort(base, count, sizeof(volintInfo), CompareVolID);
3260 MapPartIdIntoName(dummyPartList.partId[i], pname);
3263 "Total number of volumes on server %s partition %s: %lu \n",
3264 as->parms[0].items->data, pname,
3265 (unsigned long)count);
3266 if (wantExtendedInfo) {
3267 XDisplayVolumes(aserver, dummyPartList.partId[i], origxInfoP,
3268 count, int32list, fast, quiet);
3271 xInfoP = (volintXInfo *) 0;
3273 #ifdef FULL_LISTVOL_SWITCH
3274 if (as->parms[6].items)
3275 DisplayVolumes2(aserver, dummyPartList.partId[i], oldpntr,
3278 #endif /* FULL_LISTVOL_SWITCH */
3279 DisplayVolumes(aserver, dummyPartList.partId[i], oldpntr,
3280 count, int32list, fast, quiet);
3283 pntr = (volintInfo *) 0;
3292 register struct cmd_syndesc *as;
3294 afs_int32 pname, code; /* part name */
3300 if (as->parms[0].items) {
3301 tserver = GetServer(as->parms[0].items->data);
3303 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3304 as->parms[0].items->data);
3309 if (as->parms[1].items) {
3310 pname = volutil_GetPartitionID(as->parms[1].items->data);
3312 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3313 as->parms[1].items->data);
3316 if (!IsPartValid(pname, tserver, &code)) { /*check for validity of the partition */
3318 PrintError("", code);
3321 "vos: partition %s does not exist on the server\n",
3322 as->parms[1].items->data);
3329 "The -partition option requires a -server option\n");
3334 if (as->parms[2].items) {
3335 /* Synchronize an individual volume */
3336 volname = as->parms[2].items->data;
3337 code = UV_SyncVolume(tserver, pname, volname, flags);
3341 "Without a -volume option, the -server option is required\n");
3344 code = UV_SyncVldb(tserver, pname, flags, 0 /*unused */ );
3348 PrintDiagnostics("syncvldb", code);
3352 /* Print a summary of what we did */
3354 fprintf(STDOUT, "VLDB volume %s synchronized", volname);
3356 fprintf(STDOUT, "VLDB synchronized");
3358 fprintf(STDOUT, " with state of server %s", as->parms[0].items->data);
3361 MapPartIdIntoName(pname, part);
3362 fprintf(STDOUT, " partition %s\n", part);
3364 fprintf(STDOUT, "\n");
3371 register struct cmd_syndesc *as;
3374 afs_int32 pname, code; /* part name */
3379 tserver = GetServer(as->parms[0].items->data);
3381 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3382 as->parms[0].items->data);
3385 if (as->parms[1].items) {
3386 pname = volutil_GetPartitionID(as->parms[1].items->data);
3388 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3389 as->parms[1].items->data);
3392 if (!IsPartValid(pname, tserver, &code)) { /*check for validity of the partition */
3394 PrintError("", code);
3397 "vos : partition %s does not exist on the server\n",
3398 as->parms[1].items->data);
3404 code = UV_SyncServer(tserver, pname, flags, 0 /*unused */ );
3406 PrintDiagnostics("syncserv", code);
3410 MapPartIdIntoName(pname, part);
3411 fprintf(STDOUT, "Server %s partition %s synchronized with VLDB\n",
3412 as->parms[0].items->data, part);
3414 fprintf(STDOUT, "Server %s synchronized with VLDB\n",
3415 as->parms[0].items->data);
3424 struct nvldbentry entry;
3427 /* The vlserver will handle names with the .readonly
3428 * and .backup extension as well as volume ids.
3430 vcode = VLDB_GetEntryByName(name, &entry);
3432 PrintError("", vcode);
3435 MapHostToNetwork(&entry);
3436 EnumerateEntry(&entry);
3438 /* Defect #3027: grubby check to handle locked volume.
3439 * If VLOP_ALLOPERS is set, the entry is locked.
3440 * Leave this routine as is, but put in correct check.
3442 if (entry.flags & VLOP_ALLOPERS)
3443 fprintf(STDOUT, " Volume is currently LOCKED \n");
3450 register struct cmd_syndesc *as;
3453 struct nvldbentry entry;
3454 afs_int32 volid, code, server, part, zapbackupid = 0, backupid = 0, err;
3456 if (as->parms[3].items) {
3457 /* force flag is on, use the other version */
3458 return NukeVolume(as);
3461 if (as->parms[4].items) {
3465 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3468 PrintError("", err);
3470 fprintf(STDERR, "vos: can't find volume '%s'\n",
3471 as->parms[2].items->data);
3474 part = volutil_GetPartitionID(as->parms[1].items->data);
3476 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3477 as->parms[1].items->data);
3480 server = GetServer(as->parms[0].items->data);
3482 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3483 as->parms[0].items->data);
3486 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
3488 PrintError("", code);
3491 "vos : partition %s does not exist on the server\n",
3492 as->parms[1].items->data);
3495 code = VLDB_GetEntryByID(volid, -1, &entry);
3497 if (volid == entry.volumeId[RWVOL])
3498 backupid = entry.volumeId[BACKVOL];
3500 "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
3501 (unsigned long)volid);
3504 volintInfo *pntr = (volintInfo *) 0;
3507 code = UV_ListOneVolume(server, part, volid, &pntr);
3509 if (volid == pntr->parentID)
3510 backupid = pntr->backupID;
3516 code = UV_VolumeZap(server, part, backupid);
3518 PrintDiagnostics("zap", code);
3521 fprintf(STDOUT, "Backup Volume %lu deleted\n",
3522 (unsigned long)backupid);
3525 code = UV_VolumeZap(server, part, volid);
3527 PrintDiagnostics("zap", code);
3530 fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
3537 register struct cmd_syndesc *as;
3540 afs_int32 server, code;
3541 transDebugInfo *pntr, *oldpntr;
3546 server = GetServer(as->parms[0].items->data);
3548 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3549 as->parms[0].items->data);
3552 code = UV_VolserStatus(server, &pntr, &count);
3554 PrintDiagnostics("status", code);
3559 fprintf(STDOUT, "No active transactions on %s\n",
3560 as->parms[0].items->data);
3562 fprintf(STDOUT, "Total transactions: %d\n", count);
3564 for (i = 0; i < count; i++) {
3565 /*print out the relevant info */
3566 fprintf(STDOUT, "--------------------------------------\n");
3567 fprintf(STDOUT, "transaction: %lu created: %s",
3568 (unsigned long)pntr->tid, ctime((time_t *) & pntr->time));
3569 if (pntr->returnCode) {
3570 fprintf(STDOUT, "returnCode: %lu\n",
3571 (unsigned long)pntr->returnCode);
3574 fprintf(STDOUT, "attachFlags: ");
3575 switch (pntr->iflags) {
3577 fprintf(STDOUT, "offline ");
3580 fprintf(STDOUT, "busy ");
3583 fprintf(STDOUT, "readonly ");
3586 fprintf(STDOUT, "create ");
3589 fprintf(STDOUT, "create volid ");
3592 fprintf(STDOUT, "\n");
3595 fprintf(STDOUT, "volumeStatus: ");
3596 switch (pntr->vflags) {
3597 case VTDeleteOnSalvage:
3598 fprintf(STDOUT, "deleteOnSalvage ");
3599 case VTOutOfService:
3600 fprintf(STDOUT, "outOfService ");
3602 fprintf(STDOUT, "deleted ");
3604 fprintf(STDOUT, "\n");
3607 fprintf(STDOUT, "transactionFlags: ");
3608 fprintf(STDOUT, "delete\n");
3610 MapPartIdIntoName(pntr->partition, pname);
3611 fprintf(STDOUT, "volume: %lu partition: %s procedure: %s\n",
3612 (unsigned long)pntr->volid, pname, pntr->lastProcName);
3613 if (pntr->callValid) {
3615 "packetRead: %lu lastReceiveTime: %d packetSend: %lu lastSendTime: %d\n",
3616 (unsigned long)pntr->readNext, pntr->lastReceiveTime,
3617 (unsigned long)pntr->transmitNext, pntr->lastSendTime);
3620 fprintf(STDOUT, "--------------------------------------\n");
3621 fprintf(STDOUT, "\n");
3630 register struct cmd_syndesc *as;
3632 afs_int32 code1, code2, code;
3633 struct nvldbentry entry;
3635 code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
3637 fprintf(STDERR, "vos: Could not find entry for volume %s\n",
3638 as->parms[0].items->data);
3641 code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
3642 if ((!code1) && (!code2)) { /*the newname already exists */
3643 fprintf(STDERR, "vos: volume %s already exists\n",
3644 as->parms[1].items->data);
3648 if (code1 && code2) {
3649 fprintf(STDERR, "vos: Could not find entry for volume %s or %s\n",
3650 as->parms[0].items->data, as->parms[1].items->data);
3653 if (!VolNameOK(as->parms[0].items->data)) {
3655 "Illegal volume name %s, should not end in .readonly or .backup\n",
3656 as->parms[0].items->data);
3659 if (!ISNAMEVALID(as->parms[1].items->data)) {
3661 "vos: the new volume name %s exceeds the size limit of %d\n",
3662 as->parms[1].items->data, VOLSER_OLDMAXVOLNAME - 10);
3665 if (!VolNameOK(as->parms[1].items->data)) {
3667 "Illegal volume name %s, should not end in .readonly or .backup\n",
3668 as->parms[1].items->data);
3671 if (IsNumeric(as->parms[1].items->data)) {
3672 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
3673 as->parms[1].items->data);
3676 MapHostToNetwork(&entry);
3678 UV_RenameVolume(&entry, as->parms[0].items->data,
3679 as->parms[1].items->data);
3681 PrintDiagnostics("rename", code);
3684 fprintf(STDOUT, "Renamed volume %s to %s\n", as->parms[0].items->data,
3685 as->parms[1].items->data);
3689 GetVolumeInfo(volid, server, part, voltype, rentry)
3690 afs_int32 *server, volid, *part, *voltype;
3691 register struct nvldbentry *rentry;
3696 vcode = VLDB_GetEntryByID(volid, -1, rentry);
3699 "Could not fetch the entry for volume %lu from VLDB \n",
3700 (unsigned long)volid);
3701 PrintError("", vcode);
3704 MapHostToNetwork(rentry);
3705 if (volid == rentry->volumeId[ROVOL]) {
3707 for (i = 0; i < rentry->nServers; i++) {
3708 if ((index == -1) && (rentry->serverFlags[i] & ITSROVOL)
3709 && !(rentry->serverFlags[i] & RO_DONTUSE))
3714 "RO volume is not found in VLDB entry for volume %lu\n",
3715 (unsigned long)volid);
3719 *server = rentry->serverNumber[index];
3720 *part = rentry->serverPartition[index];
3724 index = Lp_GetRwIndex(rentry);
3727 "RW Volume is not found in VLDB entry for volume %lu\n",
3728 (unsigned long)volid);
3731 if (volid == rentry->volumeId[RWVOL]) {
3733 *server = rentry->serverNumber[index];
3734 *part = rentry->serverPartition[index];
3737 if (volid == rentry->volumeId[BACKVOL]) {
3739 *server = rentry->serverNumber[index];
3740 *part = rentry->serverPartition[index];
3744 "unexpected volume type for volume %lu\n",
3745 (unsigned long)volid);
3751 register struct cmd_syndesc *as;
3757 struct VldbListByAttributes attributes;
3758 nbulkentries arrayEntries;
3759 register struct nvldbentry *vllist;
3760 struct cmd_item *itp;
3763 char prefix[VOLSER_MAXVOLNAME + 1];
3765 afs_int32 totalBack = 0, totalFail = 0, err;
3767 if (as->parms[0].items) { /* -id */
3768 if (as->parms[1].items || as->parms[2].items || as->parms[3].items) {
3770 "You cannot use -server, -partition, or -prefix with the -id argument\n");
3773 for (itp = as->parms[0].items; itp; itp = itp->next) {
3774 avolid = vsu_GetVolumeID(itp->data, cstruct, &err);
3777 PrintError("", err);
3779 fprintf(STDERR, "vos: can't find volume '%s'\n",
3783 if (as->parms[4].items) { /* -noexecute */
3784 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
3789 vcode = ubik_Call(VL_DeleteEntry, cstruct, 0, avolid, RWVOL);
3791 fprintf(STDERR, "Could not delete entry for volume %s\n",
3794 "You must specify a RW volume name or ID "
3795 "(the entire VLDB entry will be deleted)\n");
3796 PrintError("", vcode);
3802 fprintf(STDOUT, "Deleted %d VLDB entries\n", totalBack);
3806 if (!as->parms[1].items && !as->parms[2].items && !as->parms[3].items) {
3807 fprintf(STDERR, "You must specify an option\n");
3811 /* Zero out search attributes */
3812 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
3814 if (as->parms[1].items) { /* -prefix */
3815 strncpy(prefix, as->parms[1].items->data, VOLSER_MAXVOLNAME);
3817 if (!as->parms[2].items && !as->parms[3].items) { /* a single entry only */
3819 "You must provide -server with the -prefix argument\n");
3824 if (as->parms[2].items) { /* -server */
3826 aserver = GetServer(as->parms[2].items->data);
3828 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3829 as->parms[2].items->data);
3832 attributes.server = ntohl(aserver);
3833 attributes.Mask |= VLLIST_SERVER;
3836 if (as->parms[3].items) { /* -partition */
3837 if (!as->parms[2].items) {
3839 "You must provide -server with the -partition argument\n");
3842 apart = volutil_GetPartitionID(as->parms[3].items->data);
3844 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3845 as->parms[3].items->data);
3848 attributes.partition = apart;
3849 attributes.Mask |= VLLIST_PARTITION;
3852 /* Print status line of what we are doing */
3853 fprintf(STDOUT, "Deleting VLDB entries for ");
3854 if (as->parms[2].items) {
3855 fprintf(STDOUT, "server %s ", as->parms[2].items->data);
3857 if (as->parms[3].items) {
3859 MapPartIdIntoName(apart, pname);
3860 fprintf(STDOUT, "partition %s ", pname);
3863 fprintf(STDOUT, "which are prefixed with %s ", prefix);
3865 fprintf(STDOUT, "\n");
3868 /* Get all the VLDB entries on a server and/or partition */
3869 memset(&arrayEntries, 0, sizeof(arrayEntries));
3870 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
3872 fprintf(STDERR, "Could not access the VLDB for attributes\n");
3873 PrintError("", vcode);
3877 /* Process each entry */
3878 for (j = 0; j < nentries; j++) {
3879 vllist = &arrayEntries.nbulkentries_val[j];
3881 /* It only deletes the RW volumes */
3882 if (strncmp(vllist->name, prefix, strlen(prefix))) {
3885 "Omitting to delete %s due to prefix %s mismatch\n",
3886 vllist->name, prefix);
3893 if (as->parms[4].items) { /* -noexecute */
3894 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
3900 /* Only matches the RW volume name */
3901 avolid = vllist->volumeId[RWVOL];
3902 vcode = ubik_Call(VL_DeleteEntry, cstruct, 0, avolid, RWVOL);
3904 fprintf(STDOUT, "Could not delete VDLB entry for %s\n",
3907 PrintError("", vcode);
3912 fprintf(STDOUT, "Deleted VLDB entry for %s \n", vllist->name);
3917 fprintf(STDOUT, "----------------------\n");
3919 "Total VLDB entries deleted: %lu; failed to delete: %lu\n",
3920 (unsigned long)totalBack, (unsigned long)totalFail);
3921 if (arrayEntries.nbulkentries_val)
3922 free(arrayEntries.nbulkentries_val);
3928 CompareVldbEntryByName(p1, p2)
3931 struct nvldbentry *arg1, *arg2;
3933 arg1 = (struct nvldbentry *)p1;
3934 arg2 = (struct nvldbentry *)p2;
3935 return (strcmp(arg1->name, arg2->name));
3939 static int CompareVldbEntry(p1,p2)
3942 struct nvldbentry *arg1,*arg2;
3945 char comp1[100],comp2[100];
3946 char temp1[20],temp2[20];
3948 arg1 = (struct nvldbentry *)p1;
3949 arg2 = (struct nvldbentry *)p2;
3953 for(i = 0; i < arg1->nServers; i++)
3954 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
3955 for(i = 0; i < arg2->nServers; i++)
3956 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
3957 if(pos1 == -1 || pos2 == -1){
3961 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
3962 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
3963 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
3964 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
3965 strcat(comp1,temp1);
3966 strcat(comp2,temp2);
3967 strcat(comp1,arg1->name);
3968 strcat(comp1,arg2->name);
3969 return(strcmp(comp1,comp2));
3976 struct cmd_syndesc *as;
3979 afs_int32 aserver, code;
3981 struct VldbListByAttributes attributes;
3982 nbulkentries arrayEntries;
3983 struct nvldbentry *vllist, *tarray = 0, *ttarray;
3984 afs_int32 centries, nentries = 0, tarraysize, parraysize;
3987 int quiet, sort, lock;
3988 afs_int32 thisindex, nextindex;
3993 attributes.Mask = 0;
3994 lock = (as->parms[3].items ? 1 : 0); /* -lock flag */
3995 quiet = (as->parms[4].items ? 1 : 0); /* -quit flag */
3996 sort = (as->parms[5].items ? 0 : 1); /* -nosort flag */
3998 /* If the volume name is given, Use VolumeInfoCmd to look it up
3999 * and not ListAttributes.
4001 if (as->parms[0].items) {
4004 "vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
4007 code = VolumeInfoCmd(as->parms[0].items->data);
4009 PrintError("", code);
4015 /* Server specified */
4016 if (as->parms[1].items) {
4017 aserver = GetServer(as->parms[1].items->data);
4019 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4020 as->parms[1].items->data);
4023 attributes.server = ntohl(aserver);
4024 attributes.Mask |= VLLIST_SERVER;
4027 /* Partition specified */
4028 if (as->parms[2].items) {
4029 apart = volutil_GetPartitionID(as->parms[2].items->data);
4031 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4032 as->parms[2].items->data);
4035 attributes.partition = apart;
4036 attributes.Mask |= VLLIST_PARTITION;
4040 attributes.Mask |= VLLIST_FLAG;
4041 attributes.flag = VLOP_ALLOPERS;
4044 /* Print header information */
4046 MapPartIdIntoName(apart, pname);
4047 fprintf(STDOUT, "VLDB entries for %s %s%s%s %s\n",
4048 (as->parms[1].items ? "server" : "all"),
4049 (as->parms[1].items ? as->parms[1].items->data : "servers"),
4050 (as->parms[2].items ? " partition " : ""),
4051 (as->parms[2].items ? pname : ""),
4052 (lock ? "which are locked:" : ""));
4055 for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
4056 memset(&arrayEntries, 0, sizeof(arrayEntries));
4061 VLDB_ListAttributesN2(&attributes, 0, thisindex, ¢ries,
4062 &arrayEntries, &nextindex);
4063 if (vcode == RXGEN_OPCODE) {
4064 /* Vlserver not running with ListAttributesN2. Fall back */
4066 VLDB_ListAttributes(&attributes, ¢ries, &arrayEntries);
4070 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4071 PrintError("", vcode);
4074 nentries += centries;
4076 /* We don't sort, so just print the entries now */
4078 for (j = 0; j < centries; j++) { /* process each entry */
4079 vllist = &arrayEntries.nbulkentries_val[j];
4080 MapHostToNetwork(vllist);
4081 EnumerateEntry(vllist);
4083 if (vllist->flags & VLOP_ALLOPERS)
4084 fprintf(STDOUT, " Volume is currently LOCKED \n");
4088 /* So we sort. First we must collect all the entries and keep
4091 else if (centries > 0) {
4093 /* steal away the first bulk entries array */
4094 tarray = (struct nvldbentry *)arrayEntries.nbulkentries_val;
4095 tarraysize = centries * sizeof(struct nvldbentry);
4096 arrayEntries.nbulkentries_val = 0;
4098 /* Grow the tarray to keep the extra entries */
4099 parraysize = (centries * sizeof(struct nvldbentry));
4101 (struct nvldbentry *)realloc(tarray,
4102 tarraysize + parraysize);
4105 "Could not allocate enough space for the VLDB entries\n");
4111 memcpy(((char *)tarray) + tarraysize,
4112 (char *)arrayEntries.nbulkentries_val, parraysize);
4113 tarraysize += parraysize;
4117 /* Free the bulk array */
4118 if (arrayEntries.nbulkentries_val) {
4119 free(arrayEntries.nbulkentries_val);
4120 arrayEntries.nbulkentries_val = 0;
4124 /* Here is where we now sort all the entries and print them */
4125 if (sort && (nentries > 0)) {
4126 qsort((char *)tarray, nentries, sizeof(struct nvldbentry),
4127 CompareVldbEntryByName);
4128 for (vllist = tarray, j = 0; j < nentries; j++, vllist++) {
4129 MapHostToNetwork(vllist);
4130 EnumerateEntry(vllist);
4132 if (vllist->flags & VLOP_ALLOPERS)
4133 fprintf(STDOUT, " Volume is currently LOCKED \n");
4139 fprintf(STDOUT, "\nTotal entries: %lu\n", (unsigned long)nentries);
4147 register struct cmd_syndesc *as;
4149 afs_int32 apart = 0, avolid;
4150 afs_int32 aserver = 0, code, aserver1, apart1;
4152 struct VldbListByAttributes attributes;
4153 nbulkentries arrayEntries;
4154 register struct nvldbentry *vllist;
4158 int seenprefix, seenxprefix, exclude, ex, exp, noaction;
4159 afs_int32 totalBack = 0;
4160 afs_int32 totalFail = 0;
4161 int previdx = -1, error, same;
4163 struct cmd_item *ti;
4167 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4168 attributes.Mask = 0;
4170 seenprefix = (as->parms[0].items ? 1 : 0);
4171 exclude = (as->parms[3].items ? 1 : 0);
4172 seenxprefix = (as->parms[4].items ? 1 : 0);
4173 noaction = (as->parms[5].items ? 1 : 0);
4175 if (as->parms[1].items) { /* -server */
4176 aserver = GetServer(as->parms[1].items->data);
4178 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4179 as->parms[1].items->data);
4182 attributes.server = ntohl(aserver);
4183 attributes.Mask |= VLLIST_SERVER;
4186 if (as->parms[2].items) { /* -partition */
4187 apart = volutil_GetPartitionID(as->parms[2].items->data);
4189 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4190 as->parms[2].items->data);
4193 attributes.partition = apart;
4194 attributes.Mask |= VLLIST_PARTITION;
4197 /* Check to make sure the prefix and xprefix expressions compile ok */
4199 for (ti = as->parms[0].items; ti; ti = ti->next) {
4200 if (strncmp(ti->data, "^", 1) == 0) {
4201 #ifdef HAVE_POSIX_REGEX
4205 code = regcomp(&re, ti->data, REG_NOSUB);
4207 regerror(code, &re, errbuf, sizeof errbuf);
4209 "Unrecognizable -prefix regular expression: '%s': %s\n",
4215 ccode = (char *)re_comp(ti->data);
4218 "Unrecognizable -prefix regular expression: '%s': %s\n",
4227 for (ti = as->parms[4].items; ti; ti = ti->next) {
4228 if (strncmp(ti->data, "^", 1) == 0) {
4229 #ifdef HAVE_POSIX_REGEX
4233 code = regcomp(&re, ti->data, REG_NOSUB);
4235 regerror(code, &re, errbuf, sizeof errbuf);
4237 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4243 ccode = (char *)re_comp(ti->data);
4246 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4255 memset(&arrayEntries, 0, sizeof(arrayEntries)); /* initialize to hint the stub to alloc space */
4256 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4258 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4259 PrintError("", vcode);
4263 if (as->parms[1].items || as->parms[2].items || verbose) {
4264 fprintf(STDOUT, "%s up volumes",
4265 (noaction ? "Would have backed" : "Backing"));
4267 if (as->parms[1].items) {
4268 fprintf(STDOUT, " on server %s", as->parms[1].items->data);
4269 } else if (as->parms[2].items) {
4270 fprintf(STDOUT, " for all servers");
4273 if (as->parms[2].items) {
4274 MapPartIdIntoName(apart, pname);
4275 fprintf(STDOUT, " partition %s", pname);
4278 if (seenprefix || (!seenprefix && seenxprefix)) {
4279 ti = (seenprefix ? as->parms[0].items : as->parms[4].items);
4280 ex = (seenprefix ? exclude : !exclude);
4281 exp = (strncmp(ti->data, "^", 1) == 0);
4282 fprintf(STDOUT, " which %smatch %s '%s'", (ex ? "do not " : ""),
4283 (exp ? "expression" : "prefix"), ti->data);
4284 for (ti = ti->next; ti; ti = ti->next) {
4285 exp = (strncmp(ti->data, "^", 1) == 0);
4286 printf(" %sor %s '%s'", (ex ? "n" : ""),
4287 (exp ? "expression" : "prefix"), ti->data);
4291 if (seenprefix && seenxprefix) {
4292 ti = as->parms[4].items;
4293 exp = (strncmp(ti->data, "^", 1) == 0);
4294 fprintf(STDOUT, " %swhich match %s '%s'",
4295 (exclude ? "adding those " : "removing those "),
4296 (exp ? "expression" : "prefix"), ti->data);
4297 for (ti = ti->next; ti; ti = ti->next) {
4298 exp = (strncmp(ti->data, "^", 1) == 0);
4299 printf(" or %s '%s'", (exp ? "expression" : "prefix"),
4303 fprintf(STDOUT, " .. ");
4305 fprintf(STDOUT, "\n");
4309 for (j = 0; j < nentries; j++) { /* process each vldb entry */
4310 vllist = &arrayEntries.nbulkentries_val[j];
4313 for (ti = as->parms[0].items; ti; ti = ti->next) {
4314 if (strncmp(ti->data, "^", 1) == 0) {
4315 #ifdef HAVE_POSIX_REGEX
4319 /* XXX -- should just do the compile once! */
4320 code = regcomp(&re, ti->data, REG_NOSUB);
4322 regerror(code, &re, errbuf, sizeof errbuf);
4324 "Error in -prefix regular expression: '%s': %s\n",
4328 match = (regexec(&re, vllist->name, 0, NULL, 0) == 0);
4331 ccode = (char *)re_comp(ti->data);
4334 "Error in -prefix regular expression: '%s': %s\n",
4338 match = (re_exec(vllist->name) == 1);
4342 (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4352 /* Without the -exclude flag: If it matches the prefix, then
4353 * check if we want to exclude any from xprefix.
4354 * With the -exclude flag: If it matches the prefix, then
4355 * check if we want to add any from xprefix.
4357 if (match && seenxprefix) {
4358 for (ti = as->parms[4].items; ti; ti = ti->next) {
4359 if (strncmp(ti->data, "^", 1) == 0) {
4360 #ifdef HAVE_POSIX_REGEX
4364 /* XXX -- should just do the compile once! */
4365 code = regcomp(&re, ti->data, REG_NOSUB);
4367 regerror(code, &re, errbuf, sizeof errbuf);
4369 "Error in -xprefix regular expression: '%s': %s\n",
4373 if (regexec(&re, vllist->name, 0, NULL, 0) == 0)
4377 ccode = (char *)re_comp(ti->data);
4380 "Error in -xprefix regular expression: '%s': %s\n",
4384 if (re_exec(vllist->name) == 1) {
4390 if (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4400 match = !match; /* -exclude will reverse the match */
4402 continue; /* Skip if no match */
4404 /* Print list of volumes to backup */
4406 fprintf(STDOUT, " %s\n", vllist->name);
4410 if (!(vllist->flags & RW_EXISTS)) {
4413 "Omitting to backup %s since RW volume does not exist \n",
4415 fprintf(STDOUT, "\n");
4421 avolid = vllist->volumeId[RWVOL];
4422 MapHostToNetwork(vllist);
4423 GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
4424 if (aserver1 == -1 || apart1 == -1) {
4425 fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n",
4431 same = VLDB_IsSameAddrs(aserver, aserver1, &error);
4434 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4440 if ((aserver && !same) || (apart && (apart != apart1))) {
4443 "Omitting to backup %s since the RW is in a different location\n",
4449 time_t now = time(0);
4450 fprintf(STDOUT, "Creating backup volume for %s on %s",
4451 vllist->name, ctime(&now));
4455 code = UV_BackupVolume(aserver1, apart1, avolid);
4457 fprintf(STDOUT, "Could not backup %s\n", vllist->name);
4463 fprintf(STDOUT, "\n");
4465 } /* process each vldb entry */
4466 fprintf(STDOUT, "done\n");
4467 fprintf(STDOUT, "Total volumes backed up: %lu; failed to backup: %lu\n",
4468 (unsigned long)totalBack, (unsigned long)totalFail);
4470 if (arrayEntries.nbulkentries_val)
4471 free(arrayEntries.nbulkentries_val);
4477 register struct cmd_syndesc *as;
4480 afs_int32 aserver, code;
4482 struct VldbListByAttributes attributes;
4483 nbulkentries arrayEntries;
4484 register struct nvldbentry *vllist;
4493 attributes.Mask = 0;
4495 if (as->parms[0].items) { /* server specified */
4496 aserver = GetServer(as->parms[0].items->data);
4498 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4499 as->parms[0].items->data);
4502 attributes.server = ntohl(aserver);
4503 attributes.Mask |= VLLIST_SERVER;
4505 if (as->parms[1].items) { /* partition specified */
4506 apart = volutil_GetPartitionID(as->parms[1].items->data);
4508 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4509 as->parms[1].items->data);
4512 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4514 PrintError("", code);
4517 "vos : partition %s does not exist on the server\n",
4518 as->parms[1].items->data);
4521 attributes.partition = apart;
4522 attributes.Mask |= VLLIST_PARTITION;
4524 attributes.flag = VLOP_ALLOPERS;
4525 attributes.Mask |= VLLIST_FLAG;
4526 memset(&arrayEntries, 0, sizeof(arrayEntries)); /*initialize to hint the stub to alloc space */
4527 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4529 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4530 PrintError("", vcode);
4533 for (j = 0; j < nentries; j++) { /* process each entry */
4534 vllist = &arrayEntries.nbulkentries_val[j];
4535 volid = vllist->volumeId[RWVOL];
4537 ubik_Call(VL_ReleaseLock, cstruct, 0, volid, -1,
4538 LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
4540 fprintf(STDERR, "Could not unlock entry for volume %s\n",
4542 PrintError("", vcode);
4547 MapPartIdIntoName(apart, pname);
4550 "Could not lock %lu VLDB entries of %lu locked entries\n",
4551 (unsigned long)totalE, (unsigned long)nentries);
4553 if (as->parms[0].items) {
4555 "Unlocked all the VLDB entries for volumes on server %s ",
4556 as->parms[0].items->data);
4557 if (as->parms[1].items) {
4558 MapPartIdIntoName(apart, pname);
4559 fprintf(STDOUT, "partition %s\n", pname);
4561 fprintf(STDOUT, "\n");
4563 } else if (as->parms[1].items) {
4564 MapPartIdIntoName(apart, pname);
4566 "Unlocked all the VLDB entries for volumes on partition %s on all servers\n",
4571 if (arrayEntries.nbulkentries_val)
4572 free(arrayEntries.nbulkentries_val);
4578 register struct cmd_syndesc *as;
4581 afs_int32 aserver, code;
4583 struct diskPartition partition;
4584 struct partList dummyPartList;
4588 aserver = GetServer(as->parms[0].items->data);
4590 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4591 as->parms[0].items->data);
4594 if (as->parms[1].items) {
4595 apart = volutil_GetPartitionID(as->parms[1].items->data);
4597 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4598 as->parms[1].items->data);
4601 dummyPartList.partId[0] = apart;
4602 dummyPartList.partFlags[0] = PARTVALID;
4606 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4608 PrintError("", code);
4611 "vos : partition %s does not exist on the server\n",
4612 as->parms[1].items->data);
4616 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
4618 PrintDiagnostics("listpart", code);
4622 for (i = 0; i < cnt; i++) {
4623 if (dummyPartList.partFlags[i] & PARTVALID) {
4624 MapPartIdIntoName(dummyPartList.partId[i], pname);
4625 code = UV_PartitionInfo(aserver, pname, &partition);
4627 fprintf(STDERR, "Could not get information on partition %s\n",
4629 PrintError("", code);
4633 "Free space on partition %s: %d K blocks out of total %d\n",
4634 pname, partition.free, partition.minFree);
4642 register struct cmd_syndesc *as;
4645 afs_int32 ip1, ip2, vcode;
4648 ip1 = GetServer(as->parms[0].items->data);
4650 fprintf(STDERR, "vos: invalid host address\n");
4654 if ((as->parms[1].items && as->parms[2].items)
4655 || (!as->parms[1].items && !as->parms[2].items)) {
4657 "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
4661 if (as->parms[1].items) {
4662 ip2 = GetServer(as->parms[1].items->data);
4664 fprintf(STDERR, "vos: invalid host address\n");
4668 /* Play a trick here. If we are removing an address, ip1 will be -1
4669 * and ip2 will be the original address. This switch prevents an
4670 * older revision vlserver from removing the IP address.
4677 vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
4680 fprintf(STDERR, "Could not remove server %s from the VLDB\n",
4681 as->parms[0].items->data);
4682 if (vcode == VL_NOENT) {
4684 "vlserver does not support the remove flag or ");
4687 fprintf(STDERR, "Could not change server %s to server %s\n",
4688 as->parms[0].items->data, as->parms[1].items->data);
4690 PrintError("", vcode);
4695 fprintf(STDOUT, "Removed server %s from the VLDB\n",
4696 as->parms[0].items->data);
4698 fprintf(STDOUT, "Changed server %s to server %s\n",
4699 as->parms[0].items->data, as->parms[1].items->data);
4705 print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
4706 int print, int noresolve)
4712 ListAddrByAttributes m_attrs;
4713 afs_int32 m_unique, m_nentries, *m_addrp;
4714 afs_int32 base, index;
4718 afsUUID_to_string(m_uuid, buf, sizeof(buf));
4719 printf("UUID: %s\n", buf);
4722 /* print out the list of all the server */
4723 addrp = (afs_int32 *) addrs->bulkaddrs_val;
4724 for (i = 0; i < nentries; i++, addrp++) {
4725 /* If it is a multihomed address, then we will need to
4726 * get the addresses for this multihomed server from
4727 * the vlserver and print them.
4729 if (((*addrp & 0xff000000) == 0xff000000) && ((*addrp) & 0xffff)) {
4730 /* Get the list of multihomed fileservers */
4731 base = (*addrp >> 16) & 0xff;
4732 index = (*addrp) & 0xffff;
4734 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
4735 && (index <= VL_MHSRV_PERBLK)) {
4736 m_attrs.Mask = VLADDR_INDEX;
4737 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
4739 m_addrs.bulkaddrs_val = 0;
4740 m_addrs.bulkaddrs_len = 0;
4742 ubik_Call(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
4743 &m_unique, &m_nentries, &m_addrs);
4746 "vos: could not list the multi-homed server addresses\n");
4747 PrintError("", vcode);
4750 /* Print the list */
4751 m_addrp = (afs_int32 *) m_addrs.bulkaddrs_val;
4752 for (j = 0; j < m_nentries; j++, m_addrp++) {
4753 *m_addrp = htonl(*m_addrp);
4756 printf("%s ", afs_inet_ntoa_r(*m_addrp, hoststr));
4758 printf("%s ", hostutil_GetNameByINet(*m_addrp));
4762 printf("<unknown>\n");
4771 /* Otherwise, it is a non-multihomed entry and contains
4772 * the IP address of the server - print it.
4774 *addrp = htonl(*addrp);
4777 printf("%s\n", afs_inet_ntoa_r(*addrp, hoststr));
4779 printf("%s\n", hostutil_GetNameByINet(*addrp));
4791 register struct cmd_syndesc *as;
4794 afs_int32 i, noresolve = 0, printuuid = 0;
4797 ListAddrByAttributes m_attrs;
4798 afsUUID m_uuid, askuuid;
4799 afs_int32 m_unique, m_nentries;
4801 memset(&m_attrs, 0, sizeof(struct ListAddrByAttributes));
4802 m_attrs.Mask = VLADDR_INDEX;
4804 memset(&m_addrs, 0, sizeof(bulkaddrs));
4805 memset(&askuuid, 0, sizeof(afsUUID));
4806 if (as->parms[0].items) {
4808 afsUUID_from_string(as->parms[0].items->data, &askuuid);
4809 m_attrs.Mask = VLADDR_UUID;
4810 m_attrs.uuid = askuuid;
4812 if (as->parms[1].items) {
4816 he = hostutil_GetHostByName((char *)as->parms[1].items->data);
4818 fprintf(stderr, "Can't get host info for '%s'\n",
4819 as->parms[1].items->data);
4822 memcpy(&saddr, he->h_addr, 4);
4823 m_attrs.Mask = VLADDR_IPADDR;
4824 m_attrs.ipaddr = ntohl(saddr);
4826 if (as->parms[2].items) {
4829 if (as->parms[3].items) {
4833 m_addrs.bulkaddrs_val = 0;
4834 m_addrs.bulkaddrs_len = 0;
4837 ubik_Call_New(VL_GetAddrs, cstruct, 0, 0, 0, &m_unique, &nentries,
4840 fprintf(STDERR, "vos: could not list the server addresses\n");
4841 PrintError("", vcode);
4846 m_addrs.bulkaddrs_val = 0;
4847 m_addrs.bulkaddrs_len = 0;
4853 ubik_Call_New(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
4854 &m_unique, &m_nentries, &m_addrs);
4855 if (vcode == VL_NOENT) {
4861 if (vcode == VL_INDEXERANGE) {
4866 fprintf(STDERR, "vos: could not list the server addresses\n");
4867 PrintError("", vcode);
4871 print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid, noresolve);
4874 if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
4883 register struct cmd_syndesc *as;
4886 afs_int32 avolid, vcode, err;
4888 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
4891 PrintError("", err);
4893 fprintf(STDERR, "vos: can't find volume '%s'\n",
4894 as->parms[0].items->data);
4897 vcode = ubik_Call(VL_SetLock, cstruct, 0, avolid, -1, VLOP_DELETE);
4899 fprintf(STDERR, "Could not lock VLDB entry for volume %s\n",
4900 as->parms[0].items->data);
4901 PrintError("", vcode);
4904 fprintf(STDOUT, "Locked VLDB entry for volume %s\n",
4905 as->parms[0].items->data);
4911 register struct cmd_syndesc *as;
4914 afs_int32 partition = -1;
4915 afs_int32 server, volid, code, i, same;
4916 struct nvldbentry entry, storeEntry;
4919 afs_int32 rwserver = 0;
4920 afs_int32 rwpartition;
4922 afs_int32 roserver = 0;
4923 afs_int32 ropartition;
4925 struct rx_connection *aconn;
4928 server = GetServer(as->parms[0].items->data);
4930 fprintf(STDERR, "vos: host '%s' not found in host table\n",
4931 as->parms[0].items->data);
4934 partition = volutil_GetPartitionID(as->parms[1].items->data);
4935 if (partition < 0) {
4936 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4937 as->parms[1].items->data);
4940 if (!IsPartValid(partition, server, &code)) {
4942 PrintError("", code);
4945 "vos : partition %s does not exist on the server\n",
4946 as->parms[1].items->data);
4949 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &code);
4952 PrintError("", code);
4954 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
4955 as->parms[0].items->data);
4958 if (as->parms[3].items)
4961 vcode = VLDB_GetEntryByID(volid, -1, &entry);
4964 "Could not fetch the entry for volume %lu from VLDB\n",
4965 (unsigned long)volid);
4966 PrintError("convertROtoRW", code);
4970 /* use RO volid even if user specified RW or BK volid */
4972 if (volid != entry.volumeId[ROVOL])
4973 volid = entry.volumeId[ROVOL];
4975 MapHostToNetwork(&entry);
4976 for (i = 0; i < entry.nServers; i++) {
4977 if (entry.serverFlags[i] & ITSRWVOL) {
4979 rwserver = entry.serverNumber[i];
4980 rwpartition = entry.serverPartition[i];
4982 if (entry.serverFlags[i] & ITSROVOL) {
4983 same = VLDB_IsSameAddrs(server, entry.serverNumber[i], &code);
4986 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4992 roserver = entry.serverNumber[i];
4993 ropartition = entry.serverPartition[i];
4999 fprintf(STDERR, "Warning: RO volume didn't exist in vldb!\n");
5001 if (ropartition != partition) {
5003 "Warning: RO volume should be in partition %d instead of %d (vldb)\n",
5004 ropartition, partition);
5009 "VLDB indicates that a RW volume exists already on %s in partition %s.\n",
5010 hostutil_GetNameByINet(rwserver),
5011 volutil_PartitionName(rwpartition));
5013 fprintf(STDERR, "Overwrite this VLDB entry? [y|n] (n)\n");
5015 while (!(dc == EOF || dc == '\n'))
5016 dc = getchar(); /* goto end of line */
5017 if ((c != 'y') && (c != 'Y')) {
5018 fprintf(STDERR, "aborted.\n");
5025 ubik_Call(VL_SetLock, cstruct, 0, entry.volumeId[RWVOL], RWVOL,
5027 aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
5028 code = AFSVolConvertROtoRWvolume(aconn, partition, volid);
5031 "Converting RO volume %lu to RW volume failed with code %d\n",
5032 (unsigned long)volid, code);
5033 PrintError("convertROtoRW ", code);
5036 entry.serverFlags[roindex] = ITSRWVOL;
5037 entry.flags |= RW_EXISTS;
5038 entry.flags &= ~BACK_EXISTS;
5041 if (rwindex != entry.nServers) {
5042 entry.serverNumber[rwindex] = entry.serverNumber[entry.nServers];
5043 entry.serverPartition[rwindex] =
5044 entry.serverPartition[entry.nServers];
5045 entry.serverFlags[rwindex] = entry.serverFlags[entry.nServers];
5046 entry.serverNumber[entry.nServers] = 0;
5047 entry.serverPartition[entry.nServers] = 0;
5048 entry.serverFlags[entry.nServers] = 0;
5051 entry.flags &= ~RO_EXISTS;
5052 for (i = 0; i < entry.nServers; i++) {
5053 if (entry.serverFlags[i] & ITSROVOL) {
5054 if (!(entry.serverFlags[i] & (RO_DONTUSE | NEW_REPSITE)))
5055 entry.flags |= RO_EXISTS;
5058 MapNetworkToHost(&entry, &storeEntry);
5060 VLDB_ReplaceEntry(entry.volumeId[RWVOL], RWVOL, &storeEntry,
5061 (LOCKREL_OPCODE | LOCKREL_AFSID |
5062 LOCKREL_TIMESTAMP));
5065 "Warning: volume converted, but vldb update failed with code %d!\n",
5068 vcode = UV_LockRelease(entry.volumeId[RWVOL]);
5070 PrintDiagnostics("unlock", vcode);
5077 register struct cmd_syndesc *as;
5079 afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i;
5080 struct nvldbentry entry;
5081 volintSize vol_size;
5083 rx_SetRxDeadTime(60 * 10);
5084 for (i = 0; i < MAXSERVERS; i++) {
5085 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
5088 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
5089 if (rxConn->service)
5090 rxConn->service->connDeadTime = rx_connDeadTime;
5093 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5096 PrintError("", err);
5098 fprintf(STDERR, "vos: can't find volume '%s'\n",
5099 as->parms[0].items->data);
5103 if (as->parms[1].items || as->parms[2].items) {
5104 if (!as->parms[1].items || !as->parms[2].items) {
5106 "Must specify both -server and -partition options\n");
5109 aserver = GetServer(as->parms[2].items->data);
5111 fprintf(STDERR, "Invalid server name\n");
5114 apart = volutil_GetPartitionID(as->parms[1].items->data);
5116 fprintf(STDERR, "Invalid partition name\n");
5120 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
5127 if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
5128 code = ktime_DateToInt32(as->parms[4].items->data, &fromdate);
5130 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
5131 as->parms[1].items->data, code);
5136 fprintf(STDOUT, "Volume: %s\n", as->parms[0].items->data);
5138 if (as->parms[3].items) { /* do the dump estimate */
5139 #ifdef AFS_64BIT_ENV
5140 vol_size.dump_size = 0;
5142 FillInt64(vol_size.dump_size,0, 1);
5144 code = UV_GetSize(avolid, aserver, apart, fromdate, &vol_size);
5146 PrintDiagnostics("size", code);
5149 /* presumably the size info is now gathered in pntr */
5150 /* now we display it */
5152 fprintf(STDOUT, "dump_size: %llu\n", vol_size.dump_size);
5160 PrintDiagnostics(astring, acode)
5164 if (acode == EACCES) {
5166 "You are not authorized to perform the 'vos %s' command (%d)\n",
5169 fprintf(STDERR, "Error in vos %s command.\n", astring);
5170 PrintError("", acode);
5177 MyBeforeProc(as, arock)
5178 struct cmd_syndesc *as;
5181 register char *tcell;
5182 register afs_int32 code;
5183 register afs_int32 sauth;
5185 /* Initialize the ubik_client connection */
5186 rx_SetRxDeadTime(90);
5187 cstruct = (struct ubik_client *)0;
5191 if (as->parms[12].items) /* if -cell specified */
5192 tcell = as->parms[12].items->data;
5193 if (as->parms[14].items) /* -serverauth specified */
5195 if (as->parms[16].items) /* -crypt specified */
5198 vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
5199 &cstruct, UV_SetSecurity))) {
5200 fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
5201 (unsigned long)code);
5205 if (as->parms[15].items) /* -verbose flag set */
5215 /* this sucks but it works for now.
5220 #include "AFS_component_version_number.c"
5226 register afs_int32 code;
5228 register struct cmd_syndesc *ts;
5230 #ifdef AFS_AIX32_ENV
5232 * The following signal action for AIX is necessary so that in case of a
5233 * crash (i.e. core is generated) we can include the user's data section
5234 * in the core dump. Unfortunately, by default, only a partial core is
5235 * generated which, in many cases, isn't too useful.
5237 struct sigaction nsa;
5239 sigemptyset(&nsa.sa_mask);
5240 nsa.sa_handler = SIG_DFL;
5241 nsa.sa_flags = SA_FULLDUMP;
5242 sigaction(SIGSEGV, &nsa, NULL);
5245 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
5247 cmd_SetBeforeProc(MyBeforeProc, NULL);
5249 ts = cmd_CreateSyntax("create", CreateVolume, 0, "create a new volume");
5250 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5251 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5252 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "volume name");
5253 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL,
5254 "initial quota (KB)");
5256 cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
5260 ts = cmd_CreateSyntax("remove", DeleteVolume, 0, "delete a volume");
5261 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5262 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5263 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5267 ts = cmd_CreateSyntax("move", MoveVolume, 0, "move a volume");
5268 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5269 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5270 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5271 "partition name on source");
5272 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5273 "machine name on destination");
5274 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5275 "partition name on destination");
5276 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5277 "copy live volume without cloning");
5280 ts = cmd_CreateSyntax("copy", CopyVolume, 0, "copy a volume");
5281 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5282 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5283 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5284 "partition name on source");
5285 cmd_AddParm(ts, "-toname", CMD_SINGLE, 0, "volume name on destination");
5286 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5287 "machine name on destination");
5288 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5289 "partition name on destination");
5290 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5291 "leave new volume offline");
5292 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5293 "make new volume read-only");
5294 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5295 "copy live volume without cloning");
5298 ts = cmd_CreateSyntax("shadow", ShadowVolume, 0,
5299 "make or update a shadow volume");
5300 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5301 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5302 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5303 "partition name on source");
5304 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5305 "machine name on destination");
5306 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5307 "partition name on destination");
5308 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5309 "volume name on destination");
5310 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5311 "volume ID on destination");
5312 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5313 "leave shadow volume offline");
5314 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5315 "make shadow volume read-only");
5316 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5317 "copy live volume without cloning");
5318 cmd_AddParm(ts, "-incremental", CMD_FLAG, CMD_OPTIONAL,
5319 "do incremental update if target exists");
5322 ts = cmd_CreateSyntax("backup", BackupVolume, 0,
5323 "make backup of a volume");
5324 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5327 ts = cmd_CreateSyntax("clone", CloneVolume, 0,
5328 "make clone of a volume");
5329 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5330 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5331 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5332 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5333 "volume name on destination");
5334 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5335 "volume ID on destination");
5336 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5337 "leave clone volume offline");
5338 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5339 "make clone volume read-only, not readwrite");
5342 ts = cmd_CreateSyntax("release", ReleaseVolume, 0, "release a volume");
5343 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5344 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5345 "force a complete release");
5348 ts = cmd_CreateSyntax("dump", DumpVolume, 0, "dump a volume");
5349 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5350 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5351 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5352 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5353 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5354 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL,
5355 "dump a clone of the volume");
5358 ts = cmd_CreateSyntax("restore", RestoreVolume, 0, "restore a volume");
5359 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5360 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5361 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of volume to be restored");
5362 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5363 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
5364 cmd_AddParm(ts, "-overwrite", CMD_SINGLE, CMD_OPTIONAL,
5365 "abort | full | incremental");
5366 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5367 "leave restored volume offline");
5368 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5369 "make restored volume read-only");
5372 ts = cmd_CreateSyntax("unlock", LockReleaseCmd, 0,
5373 "release lock on VLDB entry for a volume");
5374 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5377 ts = cmd_CreateSyntax("changeloc", ChangeLocation, 0,
5378 "change an RW volume's location in the VLDB");
5379 cmd_AddParm(ts, "-server", CMD_SINGLE, 0,
5380 "machine name for new location");
5381 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5382 "partition name for new location");
5383 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5386 ts = cmd_CreateSyntax("addsite", AddSite, 0, "add a replication site");
5387 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new site");
5388 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5389 "partition name for new site");
5390 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5393 ts = cmd_CreateSyntax("remsite", RemoveSite, 0,
5394 "remove a replication site");
5395 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5396 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5397 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5400 ts = cmd_CreateSyntax("listpart", ListPartitions, 0, "list partitions");
5401 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5404 ts = cmd_CreateSyntax("listvol", ListVolumes, 0,
5405 "list volumes on server (bypass VLDB)");
5406 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5407 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5408 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "minimal listing");
5409 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
5410 "list all normal volume fields");
5411 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5412 "generate minimal information");
5413 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5414 "list extended volume fields");
5415 #ifdef FULL_LISTVOL_SWITCH
5416 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5417 "machine readable format");
5418 #endif /* FULL_LISTVOL_SWITCH */
5421 ts = cmd_CreateSyntax("syncvldb", SyncVldb, 0,
5422 "synchronize VLDB with server");
5423 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5424 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5425 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5428 ts = cmd_CreateSyntax("syncserv", SyncServer, 0,
5429 "synchronize server with VLDB");
5430 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5431 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5434 ts = cmd_CreateSyntax("examine", ExamineVolume, 0,
5435 "everything about the volume");
5436 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5437 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5438 "list extended volume fields");
5439 #ifdef FULL_LISTVOL_SWITCH
5440 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5441 "machine readable format");
5442 #endif /* FULL_LISTVOL_SWITCH */
5444 cmd_CreateAlias(ts, "volinfo");
5446 ts = cmd_CreateSyntax("setfields", SetFields, 0,
5447 "change volume info fields");
5448 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5449 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "quota (KB)");
5450 cmd_AddParm(ts, "-clearuse", CMD_FLAG, CMD_OPTIONAL, "clear dayUse");
5453 ts = cmd_CreateSyntax("offline", volOffline, 0, (char *)CMD_HIDDEN);
5454 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5455 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5456 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5457 cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds to sleep");
5458 cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "busy volume");
5461 ts = cmd_CreateSyntax("online", volOnline, 0, (char *)CMD_HIDDEN);
5462 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5463 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5464 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5467 ts = cmd_CreateSyntax("zap", VolumeZap, 0,
5468 "delete the volume, don't bother with VLDB");
5469 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5470 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5471 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume ID");
5472 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5473 "force deletion of bad volumes");
5474 cmd_AddParm(ts, "-backup", CMD_FLAG, CMD_OPTIONAL,
5475 "also delete backup volume if one is found");
5478 ts = cmd_CreateSyntax("status", VolserStatus, 0,
5479 "report on volser status");
5480 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5483 ts = cmd_CreateSyntax("rename", RenameVolume, 0, "rename a volume");
5484 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old volume name ");
5485 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new volume name ");
5488 ts = cmd_CreateSyntax("listvldb", ListVLDB, 0,
5489 "list volumes in the VLDB");
5490 cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5491 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5492 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5493 cmd_AddParm(ts, "-locked", CMD_FLAG, CMD_OPTIONAL, "locked volumes only");
5494 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5495 "generate minimal information");
5496 cmd_AddParm(ts, "-nosort", CMD_FLAG, CMD_OPTIONAL,
5497 "do not alphabetically sort the volume names");
5500 ts = cmd_CreateSyntax("backupsys", BackSys, 0, "en masse backups");
5501 cmd_AddParm(ts, "-prefix", CMD_LIST, CMD_OPTIONAL,
5502 "common prefix on volume(s)");
5503 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5504 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5505 cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL,
5506 "exclude common prefix volumes");
5507 cmd_AddParm(ts, "-xprefix", CMD_LIST, CMD_OPTIONAL,
5508 "negative prefix on volume(s)");
5509 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "no action");
5512 ts = cmd_CreateSyntax("delentry", DeleteEntry, 0,
5513 "delete VLDB entry for a volume");
5514 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "volume name or ID");
5515 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL,
5516 "prefix of the volume whose VLDB entry is to be deleted");
5517 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5518 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5519 cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE,
5523 ts = cmd_CreateSyntax("partinfo", PartitionInfo, 0,
5524 "list partition information");
5525 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5526 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5529 ts = cmd_CreateSyntax("unlockvldb", UnlockVLDB, 0,
5530 "unlock all the locked entries in the VLDB");
5531 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5532 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5535 ts = cmd_CreateSyntax("lock", LockEntry, 0,
5536 "lock VLDB entry for a volume");
5537 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5540 ts = cmd_CreateSyntax("changeaddr", ChangeAddr, 0,
5541 "change the IP address of a file server");
5542 cmd_AddParm(ts, "-oldaddr", CMD_SINGLE, 0, "original IP address");
5543 cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
5544 cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL,
5545 "remove the IP address from the VLDB");
5548 ts = cmd_CreateSyntax("listaddrs", ListAddrs, 0,
5549 "list the IP address of all file servers registered in the VLDB");
5550 cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
5551 cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
5552 cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL,
5553 "don't resolve addresses");
5554 cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
5555 "print uuid of hosts");
5558 ts = cmd_CreateSyntax("convertROtoRW", ConvertRO, 0,
5559 "convert a RO volume into a RW volume (after loss of old RW volume)");
5560 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5561 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5562 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5563 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "don't ask");
5566 ts = cmd_CreateSyntax("size", Sizes, 0,
5567 "obtain various sizes of the volume.");
5568 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5569 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5570 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5571 cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL,
5572 "Obtain the size of the dump");
5573 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5576 code = cmd_Dispatch(argc, argv);
5578 /* Shut down the ubik_client and rx connections */
5580 (void)ubik_ClientDestroy(cstruct);
5586 exit((code ? -1 : 0));