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 fprintf(STDOUT, " Last Update %s",
503 ctime((time_t *) & pntr->updateDate));
505 " %d accesses in the past day (i.e., vnode references)\n",
507 } else if (pntr->status == VBUSY) {
509 qPut(&busyHead, pntr->volid);
511 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
512 (unsigned long)pntr->volid);
515 qPut(¬okHead, pntr->volid);
517 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
518 (unsigned long)pntr->volid);
520 fprintf(STDOUT, "\n");
521 } else { /* default listing */
522 if (pntr->status == VOK) {
523 fprintf(STDOUT, "%-32s ", pntr->name);
524 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
526 fprintf(STDOUT, "RW ");
528 fprintf(STDOUT, "RO ");
530 fprintf(STDOUT, "BK ");
531 fprintf(STDOUT, "%10d K ", pntr->size);
532 if (pntr->inUse == 1) {
533 fprintf(STDOUT, "On-line");
536 fprintf(STDOUT, "Off-line");
539 if (pntr->needsSalvaged == 1)
540 fprintf(STDOUT, "**needs salvage**");
541 fprintf(STDOUT, "\n");
542 } else if (pntr->status == VBUSY) {
544 qPut(&busyHead, pntr->volid);
546 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
547 (unsigned long)pntr->volid);
550 qPut(¬okHead, pntr->volid);
552 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
553 (unsigned long)pntr->volid);
558 /*------------------------------------------------------------------------
559 * PRIVATE XDisplayFormat
562 * Display the contents of one extended volume info structure.
565 * a_xInfoP : Ptr to extended volume info struct to print.
566 * a_servID : Server ID to print.
567 * a_partID : Partition ID to print.
568 * a_totalOKP : Ptr to total-OK counter.
569 * a_totalNotOKP : Ptr to total-screwed counter.
570 * a_totalBusyP : Ptr to total-busy counter.
571 * a_fast : Fast listing?
572 * a_int32 : Int32 listing?
573 * a_showProblems : Show volume problems?
579 * Nothing interesting.
583 *------------------------------------------------------------------------*/
586 XDisplayFormat(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
587 a_totalBusyP, a_fast, a_int32, a_showProblems)
588 volintXInfo *a_xInfoP;
598 { /*XDisplayFormat */
606 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
607 } else if (a_int32) {
609 * Fully-detailed listing.
611 if (a_xInfoP->status == VOK) {
613 * Volume's status is OK - all the fields are valid.
615 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
616 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
617 if (a_xInfoP->type == 0)
618 fprintf(STDOUT, "RW ");
619 if (a_xInfoP->type == 1)
620 fprintf(STDOUT, "RO ");
621 if (a_xInfoP->type == 2)
622 fprintf(STDOUT, "BK ");
623 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
624 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
625 if (a_xInfoP->inUse == 1) {
626 fprintf(STDOUT, "On-line");
629 fprintf(STDOUT, "Off-line");
632 fprintf(STDOUT, "\n");
633 MapPartIdIntoName(a_partID, pname);
634 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
636 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
637 (unsigned long)a_xInfoP->parentID,
638 (unsigned long)a_xInfoP->cloneID,
639 (unsigned long)a_xInfoP->backupID);
640 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
641 fprintf(STDOUT, " Creation %s",
642 ctime((time_t *) & a_xInfoP->creationDate));
643 #ifdef FULL_LISTVOL_SWITCH
644 fprintf(STDOUT, " Copy %s",
645 ctime((time_t *) & a_xInfoP->copyDate));
646 if (!a_xInfoP->backupDate)
647 fprintf(STDOUT, " Backup Never\n");
649 fprintf(STDOUT, " Backup %s",
650 ctime((time_t *) & a_xInfoP->backupDate));
651 if (a_xInfoP->accessDate)
652 fprintf(STDOUT, " Last Access %s",
653 ctime((time_t *) & a_xInfoP->accessDate));
655 fprintf(STDOUT, " Last Update %s",
656 ctime((time_t *) & a_xInfoP->updateDate));
658 " %d accesses in the past day (i.e., vnode references)\n",
662 * Print all the read/write and authorship stats.
664 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
666 " |-------------------------------------------|\n");
668 " | Same Network | Diff Network |\n");
670 " |----------|----------|----------|----------|\n");
672 " | Total | Auth | Total | Auth |\n");
674 " |----------|----------|----------|----------|\n");
675 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
676 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
677 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
678 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
679 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
680 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
681 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
682 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
683 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
684 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
686 " |-------------------------------------------|\n\n");
689 " Writes Affecting Authorship\n");
691 " |-------------------------------------------|\n");
693 " | File Authorship | Directory Authorship|\n");
695 " |----------|----------|----------|----------|\n");
697 " | Same | Diff | Same | Diff |\n");
699 " |----------|----------|----------|----------|\n");
700 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
701 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
702 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
703 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
704 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
705 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
706 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
707 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
708 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
709 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
710 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
711 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
712 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
713 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
714 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
715 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
716 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
717 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
718 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
719 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
720 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
721 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
722 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
723 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
724 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
725 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
726 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
727 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
728 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
729 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
731 " |-------------------------------------------|\n");
732 } /*Volume status OK */
733 else if (a_xInfoP->status == VBUSY) {
735 qPut(&busyHead, a_xInfoP->volid);
737 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
738 (unsigned long)a_xInfoP->volid);
742 qPut(¬okHead, a_xInfoP->volid);
744 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
745 (unsigned long)a_xInfoP->volid);
746 } /*Screwed volume */
747 fprintf(STDOUT, "\n");
753 if (a_xInfoP->status == VOK) {
754 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
755 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
756 if (a_xInfoP->type == 0)
757 fprintf(STDOUT, "RW ");
758 if (a_xInfoP->type == 1)
759 fprintf(STDOUT, "RO ");
760 if (a_xInfoP->type == 2)
761 fprintf(STDOUT, "BK ");
762 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
763 if (a_xInfoP->inUse == 1) {
764 fprintf(STDOUT, "On-line");
767 fprintf(STDOUT, "Off-line");
770 fprintf(STDOUT, "\n");
772 else if (a_xInfoP->status == VBUSY) {
774 qPut(&busyHead, a_xInfoP->volid);
776 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
777 (unsigned long)a_xInfoP->volid);
781 qPut(¬okHead, a_xInfoP->volid);
783 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
784 (unsigned long)a_xInfoP->volid);
785 } /*Screwed volume */
786 } /*Default listing */
787 } /*XDisplayFormat */
789 #ifdef FULL_LISTVOL_SWITCH
791 DisplayFormat2(server, partition, pntr)
792 long server, partition;
795 static long server_cache = -1, partition_cache = -1;
796 static char hostname[256], address[32], pname[16];
798 if (server != server_cache) {
802 strcpy(hostname, hostutil_GetNameByINet(server));
803 strcpy(address, inet_ntoa(s));
804 server_cache = server;
806 if (partition != partition_cache) {
807 MapPartIdIntoName(partition, pname);
808 partition_cache = partition;
812 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
813 fprintf(STDOUT, "id\t\t%lu\n", pntr->volid);
814 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
815 fprintf(STDOUT, "part\t\t%s\n", pname);
816 switch (pntr->status) {
818 fprintf(STDOUT, "status\t\tOK\n");
821 fprintf(STDOUT, "status\t\tBUSY\n");
824 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
827 fprintf(STDOUT, "backupID\t%lu\n", pntr->backupID);
828 fprintf(STDOUT, "parentID\t%lu\n", pntr->parentID);
829 fprintf(STDOUT, "cloneID\t\t%lu\n", pntr->cloneID);
830 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
831 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
832 /* 0xD3 is from afs/volume.h since I had trouble including the file */
833 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
834 switch (pntr->type) {
836 fprintf(STDOUT, "type\t\tRW\n");
839 fprintf(STDOUT, "type\t\tRO\n");
842 fprintf(STDOUT, "type\t\tBK\n");
845 fprintf(STDOUT, "type\t\t?\n");
848 fprintf(STDOUT, "creationDate\t%-9lu\t%s", pntr->creationDate,
849 ctime(&pntr->creationDate));
850 fprintf(STDOUT, "accessDate\t%-9lu\t%s", pntr->accessDate,
851 ctime(&pntr->accessDate));
852 fprintf(STDOUT, "updateDate\t%-9lu\t%s", pntr->updateDate,
853 ctime(&pntr->updateDate));
854 fprintf(STDOUT, "backupDate\t%-9lu\t%s", pntr->backupDate,
855 ctime(&pntr->backupDate));
856 fprintf(STDOUT, "copyDate\t%-9lu\t%s", pntr->copyDate,
857 ctime(&pntr->copyDate));
858 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n", pntr->flags);
859 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
860 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
861 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n", pntr->spare0);
862 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
863 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
864 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n", pntr->spare1);
865 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n", pntr->spare2);
866 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n", pntr->spare3);
871 DisplayVolumes2(server, partition, pntr, count)
873 long server, partition, count;
877 for (i = 0; i < count; i++) {
878 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
879 DisplayFormat2(server, partition, pntr);
880 fprintf(STDOUT, "END_OF_ENTRY\n\n");
885 #endif /* FULL_LISTVOL_SWITCH */
888 DisplayVolumes(server, part, pntr, count, longlist, fast, quiet)
889 afs_int32 server, part;
891 afs_int32 count, longlist, fast;
894 int totalOK, totalNotOK, totalBusy, i;
902 for (i = 0; i < count; i++) {
903 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
908 while (busyHead.count) {
909 qGet(&busyHead, &volid);
910 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
911 (unsigned long)volid);
915 while (notokHead.count) {
916 qGet(¬okHead, &volid);
917 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
918 (unsigned long)volid);
922 fprintf(STDOUT, "\n");
925 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
926 totalOK, totalNotOK, totalBusy);
931 /*------------------------------------------------------------------------
932 * PRIVATE XDisplayVolumes
935 * Display extended volume information.
938 * a_servID : Pointer to the Rx call we're performing.
939 * a_partID : Partition for which we want the extended list.
940 * a_xInfoP : Ptr to extended volume info.
941 * a_count : Number of volume records contained above.
942 * a_int32 : Int32 listing generated?
943 * a_fast : Fast listing generated?
944 * a_quiet : Quiet listing generated?
950 * Nothing interesting.
954 *------------------------------------------------------------------------*/
957 XDisplayVolumes(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
961 volintXInfo *a_xInfoP;
967 { /*XDisplayVolumes */
969 int totalOK; /*Total OK volumes */
970 int totalNotOK; /*Total screwed volumes */
971 int totalBusy; /*Total busy volumes */
972 int i; /*Loop variable */
973 afs_int32 volid; /*Current volume ID */
976 * Initialize counters and (global!!) queues.
985 * Display each volume in the list.
987 for (i = 0; i < a_count; i++) {
988 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
989 &totalBusy, a_fast, a_int32, 0);
994 * If any volumes were found to be busy or screwed, display them.
997 while (busyHead.count) {
998 qGet(&busyHead, &volid);
999 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1000 (unsigned long)volid);
1004 while (notokHead.count) {
1005 qGet(¬okHead, &volid);
1006 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1007 (unsigned long)volid);
1012 fprintf(STDOUT, "\n");
1015 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1016 totalOK, totalNotOK, totalBusy);
1020 } /*XDisplayVolumes */
1022 /* set <server> and <part> to the correct values depending on
1023 * <voltype> and <entry> */
1025 GetServerAndPart(entry, voltype, server, part, previdx)
1026 struct nvldbentry *entry;
1027 afs_int32 *server, *part;
1031 int i, istart, vtype;
1036 /* Doesn't check for non-existance of backup volume */
1037 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1039 istart = 0; /* seach the entire entry */
1042 /* Seach from beginning of entry or pick up where we left off */
1043 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1046 for (i = istart; i < entry->nServers; i++) {
1047 if (entry->serverFlags[i] & vtype) {
1048 *server = entry->serverNumber[i];
1049 *part = entry->serverPartition[i];
1055 /* Didn't find any, return -1 */
1061 PostVolumeStats(entry)
1062 struct nvldbentry *entry;
1064 SubEnumerateEntry(entry);
1065 /* Check for VLOP_ALLOPERS */
1066 if (entry->flags & VLOP_ALLOPERS)
1067 fprintf(STDOUT, " Volume is currently LOCKED \n");
1071 /*------------------------------------------------------------------------
1072 * PRIVATE XVolumeStats
1075 * Display extended volume information.
1078 * a_xInfoP : Ptr to extended volume info.
1079 * a_entryP : Ptr to the volume's VLDB entry.
1080 * a_srvID : Server ID.
1081 * a_partID : Partition ID.
1082 * a_volType : Type of volume to print.
1088 * Nothing interesting.
1092 *------------------------------------------------------------------------*/
1095 XVolumeStats(a_xInfoP, a_entryP, a_srvID, a_partID, a_volType)
1096 volintXInfo *a_xInfoP;
1097 struct nvldbentry *a_entryP;
1104 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1106 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1107 a_srvID, /*Server ID to print */
1108 a_partID, /*Partition ID to print */
1109 &totalOK, /*Ptr to total-OK counter */
1110 &totalNotOK, /*Ptr to total-screwed counter */
1111 &totalBusy, /*Ptr to total-busy counter */
1112 0, /*Don't do a fast listing */
1113 1, /*Do a long listing */
1114 1); /*Show volume problems */
1120 VolumeStats(pntr, entry, server, part, voltype)
1122 struct nvldbentry *entry;
1124 afs_int32 server, part;
1126 int totalOK, totalNotOK, totalBusy;
1128 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1133 /* command to forcibly remove a volume */
1136 register struct cmd_syndesc *as;
1138 register afs_int32 code;
1139 afs_int32 volID, err;
1144 server = GetServer(tp = as->parms[0].items->data);
1146 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1150 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1152 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1156 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1159 PrintError("", err);
1162 "vos: could not parse '%s' as a numeric volume ID", tp);
1167 "vos: forcibly removing all traces of volume %d, please wait...",
1170 code = UV_NukeVolume(server, partID, volID);
1172 fprintf(STDOUT, "done.\n");
1174 fprintf(STDOUT, "failed with code %d.\n", code);
1179 /*------------------------------------------------------------------------
1180 * PRIVATE ExamineVolume
1183 * Routine used to examine a single volume, contacting the VLDB as
1184 * well as the Volume Server.
1187 * as : Ptr to parsed command line arguments.
1190 * 0 for a successful operation,
1191 * Otherwise, one of the ubik or VolServer error values.
1194 * Nothing interesting.
1198 *------------------------------------------------------------------------
1202 register struct cmd_syndesc *as;
1204 struct nvldbentry entry;
1205 afs_int32 vcode = 0;
1206 volintInfo *pntr = (volintInfo *) 0;
1207 volintXInfo *xInfoP = (volintXInfo *) 0;
1209 afs_int32 code, err, error = 0;
1210 int voltype, foundserv = 0, foundentry = 0;
1211 afs_int32 aserver, apart;
1213 int wantExtendedInfo; /*Do we want extended vol info? */
1215 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1217 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1220 PrintError("", err);
1222 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1223 as->parms[0].items->data);
1228 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1229 (unsigned long)volid);
1232 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1235 "Could not fetch the entry for volume number %lu from VLDB \n",
1236 (unsigned long)volid);
1240 fprintf(STDOUT, "done\n");
1241 MapHostToNetwork(&entry);
1243 if (entry.volumeId[RWVOL] == volid)
1245 else if (entry.volumeId[BACKVOL] == volid)
1247 else /* (entry.volumeId[ROVOL] == volid) */
1250 do { /* do {...} while (voltype == ROVOL) */
1251 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1252 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1253 * If its a RO vol, get the next RO entry.
1255 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1256 &aserver, &apart, &previdx);
1257 if (previdx == -1) { /* searched all entries */
1259 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1260 as->parms[0].items->data);
1267 /* Get information about the volume from the server */
1269 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1270 hostutil_GetNameByINet(aserver));
1273 if (wantExtendedInfo)
1274 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1276 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1278 fprintf(STDOUT, "done\n");
1282 if (code == ENODEV) {
1283 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1284 /* The VLDB says there is no backup volume and its not on disk */
1285 fprintf(STDERR, "Volume %s does not exist\n",
1286 as->parms[0].items->data);
1290 "Volume does not exist on server %s as indicated by the VLDB\n",
1291 hostutil_GetNameByINet(aserver));
1294 PrintDiagnostics("examine", code);
1296 fprintf(STDOUT, "\n");
1299 if (wantExtendedInfo)
1300 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1302 #ifdef FULL_LISTVOL_SWITCH
1303 if (as->parms[2].items) {
1304 DisplayFormat2(aserver, apart, pntr);
1305 EnumerateEntry(&entry);
1307 #endif /* FULL_LISTVOL_SWITCH */
1308 VolumeStats(pntr, &entry, aserver, apart, voltype);
1310 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1311 /* The VLDB says there is no backup volume yet we found one on disk */
1312 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1313 as->parms[0].items->data);
1322 } while (voltype == ROVOL);
1325 fprintf(STDERR, "Dump only information from VLDB\n\n");
1326 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1328 PostVolumeStats(&entry);
1333 /*------------------------------------------------------------------------
1337 * Routine used to change the status of a single volume.
1340 * as : Ptr to parsed command line arguments.
1343 * 0 for a successful operation,
1344 * Otherwise, one of the ubik or VolServer error values.
1347 * Nothing interesting.
1351 *------------------------------------------------------------------------
1355 register struct cmd_syndesc *as;
1357 struct nvldbentry entry;
1358 afs_int32 vcode = 0;
1361 afs_int32 code, err;
1362 afs_int32 aserver, apart;
1365 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1368 PrintError("", err);
1370 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1371 as->parms[0].items->data);
1375 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1378 "Could not fetch the entry for volume number %lu from VLDB \n",
1379 (unsigned long)volid);
1382 MapHostToNetwork(&entry);
1384 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1385 if (previdx == -1) {
1386 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1387 as->parms[0].items->data);
1391 memset(&info, 0, sizeof(info));
1402 if (as->parms[1].items) {
1404 code = util_GetInt32(as->parms[1].items->data, &info.maxquota);
1406 fprintf(STDERR, "invalid quota value\n");
1410 if (as->parms[2].items) {
1414 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1417 "Could not update volume info fields for volume number %lu\n",
1418 (unsigned long)volid);
1422 /*------------------------------------------------------------------------
1426 * Brings a volume online.
1429 * as : Ptr to parsed command line arguments.
1432 * 0 for a successful operation,
1435 * Nothing interesting.
1439 *------------------------------------------------------------------------
1443 register struct cmd_syndesc *as;
1445 afs_int32 server, partition, volid;
1446 afs_int32 code, err = 0;
1448 server = GetServer(as->parms[0].items->data);
1450 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1451 as->parms[0].items->data);
1455 partition = volutil_GetPartitionID(as->parms[1].items->data);
1456 if (partition < 0) {
1457 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1458 as->parms[1].items->data);
1462 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1465 PrintError("", err);
1467 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1468 as->parms[0].items->data);
1472 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1475 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1482 /*------------------------------------------------------------------------
1483 * PRIVATE volOffline
1486 * Brings a volume offline.
1489 * as : Ptr to parsed command line arguments.
1492 * 0 for a successful operation,
1495 * Nothing interesting.
1499 *------------------------------------------------------------------------
1502 volOffline(register struct cmd_syndesc *as)
1504 afs_int32 server, partition, volid;
1505 afs_int32 code, err = 0;
1506 afs_int32 transflag, sleeptime, transdone;
1508 server = GetServer(as->parms[0].items->data);
1510 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1511 as->parms[0].items->data);
1515 partition = volutil_GetPartitionID(as->parms[1].items->data);
1516 if (partition < 0) {
1517 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1518 as->parms[1].items->data);
1522 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1525 PrintError("", err);
1527 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1528 as->parms[0].items->data);
1532 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1533 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1534 transdone = (sleeptime ? 0 /*online */ : VTOutOfService);
1535 if (as->parms[4].items && !as->parms[3].items) {
1536 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1541 UV_SetVolume(server, partition, volid, transflag, transdone,
1544 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1552 CreateVolume(register struct cmd_syndesc *as)
1556 afs_int32 volid, code;
1557 struct nvldbentry entry;
1562 tserver = GetServer(as->parms[0].items->data);
1564 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1565 as->parms[0].items->data);
1568 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1570 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1571 as->parms[1].items->data);
1574 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1576 PrintError("", code);
1579 "vos : partition %s does not exist on the server\n",
1580 as->parms[1].items->data);
1583 if (!ISNAMEVALID(as->parms[2].items->data)) {
1585 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1586 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1589 if (!VolNameOK(as->parms[2].items->data)) {
1591 "Illegal volume name %s, should not end in .readonly or .backup\n",
1592 as->parms[2].items->data);
1595 if (IsNumeric(as->parms[2].items->data)) {
1596 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1597 as->parms[2].items->data);
1600 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1602 fprintf(STDERR, "Volume %s already exists\n",
1603 as->parms[2].items->data);
1604 PrintDiagnostics("create", code);
1608 if (as->parms[3].items) {
1609 if (!IsNumeric(as->parms[3].items->data)) {
1610 fprintf(STDERR, "Initial quota %s should be numeric.\n",
1611 as->parms[3].items->data);
1615 code = util_GetInt32(as->parms[3].items->data, "a);
1617 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1623 UV_CreateVolume2(tserver, pnum, as->parms[2].items->data, quota, 0,
1626 PrintDiagnostics("create", code);
1629 MapPartIdIntoName(pnum, part);
1630 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
1631 (unsigned long)volid, part, as->parms[0].items->data);
1638 struct nvldbentry *entry;
1641 afs_int32 error, code, curserver, curpart, volid;
1643 MapHostToNetwork(entry);
1645 for (i = 0; i < entry->nServers; i++) {
1646 curserver = entry->serverNumber[i];
1647 curpart = entry->serverPartition[i];
1648 if (entry->serverFlags[i] & ITSROVOL) {
1649 volid = entry->volumeId[ROVOL];
1651 volid = entry->volumeId[RWVOL];
1653 code = UV_DeleteVolume(curserver, curpart, volid);
1662 struct cmd_syndesc *as;
1664 afs_int32 err, code = 0;
1665 afs_int32 server = 0, partition = -1, volid;
1669 if (as->parms[0].items) {
1670 server = GetServer(as->parms[0].items->data);
1672 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1673 as->parms[0].items->data);
1678 if (as->parms[1].items) {
1679 partition = volutil_GetPartitionID(as->parms[1].items->data);
1680 if (partition < 0) {
1681 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1682 as->parms[1].items->data);
1686 /* Check for validity of the partition */
1687 if (!IsPartValid(partition, server, &code)) {
1689 PrintError("", code);
1692 "vos : partition %s does not exist on the server\n",
1693 as->parms[1].items->data);
1699 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1701 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
1702 as->parms[2].items->data);
1704 PrintError("", err);
1708 /* If the server or partition option are not complete, try to fill
1709 * them in from the VLDB entry.
1711 if ((partition == -1) || !server) {
1712 struct nvldbentry entry;
1714 code = VLDB_GetEntryByID(volid, -1, &entry);
1717 "Could not fetch the entry for volume %lu from VLDB\n",
1718 (unsigned long)volid);
1719 PrintError("", code);
1723 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
1724 || ((volid == entry.volumeId[BACKVOL])
1725 && (entry.flags & BACK_EXISTS))) {
1726 idx = Lp_GetRwIndex(&entry);
1727 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
1728 || ((partition != -1)
1729 && (partition != entry.serverPartition[idx]))) {
1730 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
1731 as->parms[2].items->data);
1734 } else if ((volid == entry.volumeId[ROVOL])
1735 && (entry.flags & RO_EXISTS)) {
1736 for (idx = -1, j = 0; j < entry.nServers; j++) {
1737 if (entry.serverFlags[j] != ITSROVOL)
1740 if (((server == 0) || (server == entry.serverNumber[j]))
1741 && ((partition == -1)
1742 || (partition == entry.serverPartition[j]))) {
1745 "VLDB: Volume '%s' matches more than one RO\n",
1746 as->parms[2].items->data);
1753 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
1754 as->parms[2].items->data);
1758 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
1759 as->parms[2].items->data);
1763 server = htonl(entry.serverNumber[idx]);
1764 partition = entry.serverPartition[idx];
1768 code = UV_DeleteVolume(server, partition, volid);
1770 PrintDiagnostics("remove", code);
1774 MapPartIdIntoName(partition, pname);
1775 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
1776 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
1780 #define TESTM 0 /* set for move space tests, clear for production */
1783 register struct cmd_syndesc *as;
1786 afs_int32 volid, fromserver, toserver, frompart, topart;
1787 afs_int32 flags, code, err;
1788 char fromPartName[10], toPartName[10];
1790 struct diskPartition partition; /* for space check */
1793 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
1796 PrintError("", err);
1798 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
1799 as->parms[0].items->data);
1802 fromserver = GetServer(as->parms[1].items->data);
1803 if (fromserver == 0) {
1804 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1805 as->parms[1].items->data);
1808 toserver = GetServer(as->parms[3].items->data);
1809 if (toserver == 0) {
1810 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1811 as->parms[3].items->data);
1814 frompart = volutil_GetPartitionID(as->parms[2].items->data);
1816 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1817 as->parms[2].items->data);
1820 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
1822 PrintError("", code);
1825 "vos : partition %s does not exist on the server\n",
1826 as->parms[2].items->data);
1829 topart = volutil_GetPartitionID(as->parms[4].items->data);
1831 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1832 as->parms[4].items->data);
1835 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
1837 PrintError("", code);
1840 "vos : partition %s does not exist on the server\n",
1841 as->parms[4].items->data);
1846 if (as->parms[5].items) flags |= RV_NOCLONE;
1849 * check source partition for space to clone volume
1852 MapPartIdIntoName(topart, toPartName);
1853 MapPartIdIntoName(frompart, fromPartName);
1856 * check target partition for space to move volume
1859 code = UV_PartitionInfo(toserver, toPartName, &partition);
1861 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
1865 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
1868 p = (volintInfo *) 0;
1869 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
1871 fprintf(STDERR, "vos:cannot access volume %lu\n",
1872 (unsigned long)volid);
1877 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
1879 if (partition.free <= p->size) {
1881 "vos: no space on target partition %s to move volume %lu\n",
1882 toPartName, (unsigned long)volid);
1889 fprintf(STDOUT, "size test - don't do move\n");
1893 /* successful move still not guaranteed but shoot for it */
1896 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
1898 PrintDiagnostics("move", code);
1901 MapPartIdIntoName(topart, toPartName);
1902 MapPartIdIntoName(frompart, fromPartName);
1903 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
1904 (unsigned long)volid, as->parms[1].items->data, fromPartName,
1905 as->parms[3].items->data, toPartName);
1912 register struct cmd_syndesc *as;
1914 afs_int32 volid, fromserver, toserver, frompart, topart, code, err, flags;
1915 char fromPartName[10], toPartName[10], *tovolume;
1916 struct nvldbentry entry;
1917 struct diskPartition partition; /* for space check */
1920 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
1923 PrintError("", err);
1925 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
1926 as->parms[0].items->data);
1929 fromserver = GetServer(as->parms[1].items->data);
1930 if (fromserver == 0) {
1931 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1932 as->parms[1].items->data);
1936 toserver = GetServer(as->parms[4].items->data);
1937 if (toserver == 0) {
1938 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1939 as->parms[4].items->data);
1943 tovolume = as->parms[3].items->data;
1944 if (!ISNAMEVALID(tovolume)) {
1946 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1947 tovolume, VOLSER_OLDMAXVOLNAME - 10);
1950 if (!VolNameOK(tovolume)) {
1952 "Illegal volume name %s, should not end in .readonly or .backup\n",
1956 if (IsNumeric(tovolume)) {
1957 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1961 code = VLDB_GetEntryByName(tovolume, &entry);
1963 fprintf(STDERR, "Volume %s already exists\n", tovolume);
1964 PrintDiagnostics("copy", code);
1968 frompart = volutil_GetPartitionID(as->parms[2].items->data);
1970 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1971 as->parms[2].items->data);
1974 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
1976 PrintError("", code);
1979 "vos : partition %s does not exist on the server\n",
1980 as->parms[2].items->data);
1984 topart = volutil_GetPartitionID(as->parms[5].items->data);
1986 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1987 as->parms[5].items->data);
1990 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
1992 PrintError("", code);
1995 "vos : partition %s does not exist on the server\n",
1996 as->parms[5].items->data);
2001 if (as->parms[6].items) flags |= RV_OFFLINE;
2002 if (as->parms[7].items) flags |= RV_RDONLY;
2003 if (as->parms[8].items) flags |= RV_NOCLONE;
2005 MapPartIdIntoName(topart, toPartName);
2006 MapPartIdIntoName(frompart, fromPartName);
2009 * check target partition for space to move volume
2012 code = UV_PartitionInfo(toserver, toPartName, &partition);
2014 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2018 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2021 p = (volintInfo *) 0;
2022 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2024 fprintf(STDERR, "vos:cannot access volume %lu\n",
2025 (unsigned long)volid);
2030 if (partition.free <= p->size) {
2032 "vos: no space on target partition %s to copy volume %lu\n",
2033 toPartName, (unsigned long)volid);
2039 /* successful copy still not guaranteed but shoot for it */
2042 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2045 PrintDiagnostics("copy", code);
2048 MapPartIdIntoName(topart, toPartName);
2049 MapPartIdIntoName(frompart, fromPartName);
2050 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2051 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2052 tovolume, as->parms[4].items->data, toPartName);
2060 register struct cmd_syndesc *as;
2062 afs_int32 volid, fromserver, toserver, frompart, topart, tovolid;
2063 afs_int32 code, err, flags;
2064 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2065 struct nvldbentry entry;
2066 struct diskPartition partition; /* for space check */
2069 p = (volintInfo *) 0;
2070 q = (volintInfo *) 0;
2072 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2075 PrintError("", err);
2077 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2078 as->parms[0].items->data);
2081 fromserver = GetServer(as->parms[1].items->data);
2082 if (fromserver == 0) {
2083 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2084 as->parms[1].items->data);
2088 toserver = GetServer(as->parms[3].items->data);
2089 if (toserver == 0) {
2090 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2091 as->parms[3].items->data);
2095 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2097 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2098 as->parms[2].items->data);
2101 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2103 PrintError("", code);
2106 "vos : partition %s does not exist on the server\n",
2107 as->parms[2].items->data);
2111 topart = volutil_GetPartitionID(as->parms[4].items->data);
2113 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2114 as->parms[4].items->data);
2117 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2119 PrintError("", code);
2122 "vos : partition %s does not exist on the server\n",
2123 as->parms[4].items->data);
2127 if (as->parms[5].items) {
2128 tovolume = as->parms[5].items->data;
2129 if (!ISNAMEVALID(tovolume)) {
2131 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2132 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2135 if (!VolNameOK(tovolume)) {
2137 "Illegal volume name %s, should not end in .readonly or .backup\n",
2141 if (IsNumeric(tovolume)) {
2143 "Illegal volume name %s, should not be a number\n",
2148 /* use actual name of source volume */
2149 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2151 fprintf(STDERR, "vos:cannot access volume %lu\n",
2152 (unsigned long)volid);
2155 strcpy(toVolName, p->name);
2156 tovolume = toVolName;
2157 /* save p for size checks later */
2160 if (as->parms[6].items) {
2161 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2164 PrintError("", err);
2166 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2167 as->parms[6].items->data);
2173 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2176 PrintError("", err);
2178 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2187 if (as->parms[7].items) flags |= RV_OFFLINE;
2188 if (as->parms[8].items) flags |= RV_RDONLY;
2189 if (as->parms[9].items) flags |= RV_NOCLONE;
2190 if (as->parms[10].items) flags |= RV_CPINCR;
2192 MapPartIdIntoName(topart, toPartName);
2193 MapPartIdIntoName(frompart, fromPartName);
2196 * check target partition for space to move volume
2199 code = UV_PartitionInfo(toserver, toPartName, &partition);
2201 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2205 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2208 /* Don't do this again if we did it above */
2210 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2212 fprintf(STDERR, "vos:cannot access volume %lu\n",
2213 (unsigned long)volid);
2218 /* OK if this fails */
2219 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2221 /* Treat existing volume size as "free" */
2223 p->size = (q->size < p->size) ? p->size - q->size : 0;
2225 if (partition.free <= p->size) {
2227 "vos: no space on target partition %s to copy volume %lu\n",
2228 toPartName, (unsigned long)volid);
2236 /* successful copy still not guaranteed but shoot for it */
2239 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2240 topart, tovolid, flags);
2242 PrintDiagnostics("shadow", code);
2245 MapPartIdIntoName(topart, toPartName);
2246 MapPartIdIntoName(frompart, fromPartName);
2247 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2248 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2249 as->parms[4].items->data, toPartName);
2257 register struct cmd_syndesc *as;
2259 afs_int32 server, part, volid, cloneid, voltype;
2260 char partName[10], *volname;
2261 afs_int32 code, err, flags;
2262 struct nvldbentry entry;
2264 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2267 PrintError("", err);
2269 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2270 as->parms[0].items->data);
2274 if (as->parms[1].items || as->parms[2].items) {
2275 if (!as->parms[1].items || !as->parms[2].items) {
2277 "Must specify both -server and -partition options\n");
2280 server = GetServer(as->parms[1].items->data);
2282 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2283 as->parms[1].items->data);
2286 part = volutil_GetPartitionID(as->parms[2].items->data);
2288 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2289 as->parms[2].items->data);
2292 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2294 PrintError("", code);
2297 "vos : partition %s does not exist on the server\n",
2298 as->parms[2].items->data);
2302 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2308 if (as->parms[3].items) {
2309 volname = as->parms[3].items->data;
2310 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2312 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2313 volname, VOLSER_OLDMAXVOLNAME - 1);
2316 if (!VolNameOK(volname)) {
2318 "Illegal volume name %s, should not end in .readonly or .backup\n",
2322 if (IsNumeric(volname)) {
2324 "Illegal volume name %s, should not be a number\n",
2331 if (as->parms[4].items) {
2332 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2335 PrintError("", err);
2337 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2338 as->parms[4].items->data);
2344 if (as->parms[5].items) flags |= RV_OFFLINE;
2345 if (as->parms[6].items) flags |= RV_RDONLY;
2349 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2352 PrintDiagnostics("clone", code);
2355 MapPartIdIntoName(part, partName);
2356 fprintf(STDOUT, "Created clone for volume %lu\n",
2357 as->parms[0].items->data);
2365 register struct cmd_syndesc *as;
2367 afs_int32 avolid, aserver, apart, vtype, code, err;
2368 struct nvldbentry entry;
2370 afs_int32 buvolid, buserver, bupart, butype;
2371 struct nvldbentry buentry;
2373 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2376 PrintError("", err);
2378 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2379 as->parms[0].items->data);
2382 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2386 /* verify this is a readwrite volume */
2388 if (vtype != RWVOL) {
2389 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2393 /* is there a backup volume already? */
2395 if (entry.flags & BACK_EXISTS) {
2396 /* yep, where is it? */
2398 buvolid = entry.volumeId[BACKVOL];
2399 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2404 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2407 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2413 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2414 (unsigned long)buvolid, (unsigned long)buserver);
2419 /* nope, carry on */
2421 code = UV_BackupVolume(aserver, apart, avolid);
2424 PrintDiagnostics("backup", code);
2427 fprintf(STDOUT, "Created backup volume for %s \n",
2428 as->parms[0].items->data);
2434 register struct cmd_syndesc *as;
2437 struct nvldbentry entry;
2438 afs_int32 avolid, aserver, apart, vtype, code, err;
2441 if (as->parms[1].items)
2443 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2446 PrintError("", err);
2448 fprintf(STDERR, "vos: can't find volume '%s'\n",
2449 as->parms[0].items->data);
2452 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2456 if (vtype != RWVOL) {
2457 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2461 if (!ISNAMEVALID(entry.name)) {
2463 "Volume name %s is too long, rename before releasing\n",
2468 code = UV_ReleaseVolume(avolid, aserver, apart, force);
2470 PrintDiagnostics("release", code);
2473 fprintf(STDOUT, "Released volume %s successfully\n",
2474 as->parms[0].items->data);
2480 register struct cmd_syndesc *as;
2483 afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i;
2484 char filename[NameLen];
2485 struct nvldbentry entry;
2487 rx_SetRxDeadTime(60 * 10);
2488 for (i = 0; i < MAXSERVERS; i++) {
2489 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2492 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2493 if (rxConn->service)
2494 rxConn->service->connDeadTime = rx_connDeadTime;
2497 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2500 PrintError("", err);
2502 fprintf(STDERR, "vos: can't find volume '%s'\n",
2503 as->parms[0].items->data);
2507 if (as->parms[3].items || as->parms[4].items) {
2508 if (!as->parms[3].items || !as->parms[4].items) {
2510 "Must specify both -server and -partition options\n");
2513 aserver = GetServer(as->parms[3].items->data);
2515 fprintf(STDERR, "Invalid server name\n");
2518 apart = volutil_GetPartitionID(as->parms[4].items->data);
2520 fprintf(STDERR, "Invalid partition name\n");
2524 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2529 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2530 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2532 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2533 as->parms[1].items->data, code);
2537 if (as->parms[2].items) {
2538 strcpy(filename, as->parms[2].items->data);
2540 strcpy(filename, "");
2543 if (as->parms[5].items) {
2545 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2546 DumpFunction, filename);
2549 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2553 PrintDiagnostics("dump", code);
2556 if (strcmp(filename, ""))
2557 fprintf(STDERR, "Dumped volume %s in file %s\n",
2558 as->parms[0].items->data, filename);
2560 fprintf(STDERR, "Dumped volume %s in stdout \n",
2561 as->parms[0].items->data);
2576 register struct cmd_syndesc *as;
2579 afs_int32 avolid, aserver, apart, code, vcode, err;
2580 afs_int32 aoverwrite = ASK;
2581 afs_int32 acreation = 0, alastupdate = 0;
2582 int restoreflags, readonly = 0, offline = 0, voltype = RWVOL;
2584 char afilename[NameLen], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
2585 char volname[VOLSER_MAXVOLNAME + 1];
2586 struct nvldbentry entry;
2590 if (as->parms[4].items) {
2591 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2594 PrintError("", err);
2596 fprintf(STDERR, "vos: can't find volume '%s'\n",
2597 as->parms[4].items->data);
2603 if (as->parms[5].items) {
2604 if ((strcmp(as->parms[5].items->data, "a") == 0)
2605 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
2607 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
2608 || (strcmp(as->parms[5].items->data, "full") == 0)) {
2610 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
2611 || (strcmp(as->parms[5].items->data, "inc") == 0)
2612 || (strcmp(as->parms[5].items->data, "increment") == 0)
2613 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
2616 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2617 as->parms[5].items->data);
2621 if (as->parms[6].items)
2623 if (as->parms[7].items) {
2628 if (as->parms[8].items) {
2629 if ((strcmp(as->parms[8].items->data, "d") == 0)
2630 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
2631 acreation = TS_DUMP;
2632 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
2633 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
2634 acreation = TS_KEEP;
2635 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
2636 || (strcmp(as->parms[8].items->data, "new") == 0)) {
2639 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
2640 as->parms[8].items->data);
2645 if (as->parms[9].items) {
2646 if ((strcmp(as->parms[9].items->data, "d") == 0)
2647 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
2648 alastupdate = TS_DUMP;
2649 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
2650 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
2651 alastupdate = TS_KEEP;
2652 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
2653 || (strcmp(as->parms[9].items->data, "new") == 0)) {
2654 alastupdate = TS_NEW;
2656 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
2657 as->parms[9].items->data);
2662 aserver = GetServer(as->parms[0].items->data);
2664 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2665 as->parms[0].items->data);
2668 apart = volutil_GetPartitionID(as->parms[1].items->data);
2670 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2671 as->parms[1].items->data);
2674 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
2676 PrintError("", code);
2679 "vos : partition %s does not exist on the server\n",
2680 as->parms[1].items->data);
2683 strcpy(avolname, as->parms[2].items->data);
2684 if (!ISNAMEVALID(avolname)) {
2686 "vos: the name of the volume %s exceeds the size limit\n",
2690 if (!VolNameOK(avolname)) {
2692 "Illegal volume name %s, should not end in .readonly or .backup\n",
2696 if (as->parms[3].items) {
2697 strcpy(afilename, as->parms[3].items->data);
2698 if (!FileExists(afilename)) {
2699 fprintf(STDERR, "Can't access file %s\n", afilename);
2703 strcpy(afilename, "");
2706 /* Check if volume exists or not */
2708 vsu_ExtractName(volname, avolname);
2709 vcode = VLDB_GetEntryByName(volname, &entry);
2710 if (vcode) { /* no volume - do a full restore */
2711 restoreflags = RV_FULLRST;
2712 if ((aoverwrite == INC) || (aoverwrite == ABORT))
2714 "Volume does not exist; Will perform a full restore\n");
2717 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
2718 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
2719 restoreflags = RV_FULLRST;
2720 if ((aoverwrite == INC) || (aoverwrite == ABORT))
2722 "%s Volume does not exist; Will perform a full restore\n",
2723 readonly ? "RO" : "RW");
2726 avolid = entry.volumeId[voltype];
2727 } else if (entry.volumeId[voltype] != 0
2728 && entry.volumeId[voltype] != avolid) {
2729 avolid = entry.volumeId[voltype];
2733 else { /* volume exists - do we do a full incremental or abort */
2734 int Oserver, Opart, Otype, vol_elsewhere = 0;
2735 struct nvldbentry Oentry;
2739 avolid = entry.volumeId[voltype];
2740 } else if (entry.volumeId[voltype] != 0
2741 && entry.volumeId[voltype] != avolid) {
2742 avolid = entry.volumeId[voltype];
2745 /* A file name was specified - check if volume is on another partition */
2746 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
2750 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
2753 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
2757 if (!vcode || (Opart != apart))
2760 if (aoverwrite == ASK) {
2761 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
2763 "Volume exists and no -overwrite option specified; Aborting restore command\n");
2767 /* Ask what to do */
2768 if (vol_elsewhere) {
2770 "The volume %s %u already exists on a different server/part\n",
2771 volname, entry.volumeId[voltype]);
2773 "Do you want to do a full restore or abort? [fa](a): ");
2776 "The volume %s %u already exists in the VLDB\n",
2777 volname, entry.volumeId[voltype]);
2779 "Do you want to do a full/incremental restore or abort? [fia](a): ");
2782 while (!(dc == EOF || dc == '\n'))
2783 dc = getchar(); /* goto end of line */
2784 if ((c == 'f') || (c == 'F'))
2786 else if ((c == 'i') || (c == 'I'))
2792 if (aoverwrite == ABORT) {
2793 fprintf(STDERR, "Volume exists; Aborting restore command\n");
2795 } else if (aoverwrite == FULL) {
2796 restoreflags = RV_FULLRST;
2798 "Volume exists; Will delete and perform full restore\n");
2799 } else if (aoverwrite == INC) {
2801 if (vol_elsewhere) {
2803 "%s volume %lu already exists on a different server/part; not allowed\n",
2804 readonly ? "RO" : "RW", (unsigned long)avolid);
2810 restoreflags |= RV_OFFLINE;
2812 restoreflags |= RV_RDONLY;
2814 switch (acreation) {
2816 restoreflags |= RV_CRDUMP;
2819 restoreflags |= RV_CRKEEP;
2822 restoreflags |= RV_CRNEW;
2825 if (aoverwrite == FULL)
2826 restoreflags |= RV_CRNEW;
2828 restoreflags |= RV_CRKEEP;
2831 switch (alastupdate) {
2833 restoreflags |= RV_LUDUMP;
2836 restoreflags |= RV_LUKEEP;
2839 restoreflags |= RV_LUNEW;
2842 restoreflags |= RV_LUKEEP;
2846 UV_RestoreVolume(aserver, apart, avolid, avolname, restoreflags,
2847 WriteData, afilename);
2849 PrintDiagnostics("restore", code);
2852 MapPartIdIntoName(apart, apartName);
2855 * patch typo here - originally "parms[1]", should be "parms[0]"
2858 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
2859 as->parms[0].items->data, apartName);
2865 register struct cmd_syndesc *as;
2868 afs_int32 avolid, code, err;
2870 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2873 PrintError("", err);
2875 fprintf(STDERR, "vos: can't find volume '%s'\n",
2876 as->parms[0].items->data);
2880 code = UV_LockRelease(avolid);
2882 PrintDiagnostics("unlock", code);
2885 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
2886 as->parms[0].items->data);
2892 register struct cmd_syndesc *as;
2894 afs_int32 avolid, aserver, apart, code, err;
2895 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
2897 vsu_ExtractName(avolname, as->parms[2].items->data);;
2898 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
2901 PrintError("", err);
2903 fprintf(STDERR, "vos: can't find volume '%s'\n",
2904 as->parms[2].items->data);
2907 aserver = GetServer(as->parms[0].items->data);
2909 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2910 as->parms[0].items->data);
2913 apart = volutil_GetPartitionID(as->parms[1].items->data);
2915 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2916 as->parms[1].items->data);
2919 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
2921 PrintError("", code);
2924 "vos : partition %s does not exist on the server\n",
2925 as->parms[1].items->data);
2928 code = UV_AddSite(aserver, apart, avolid);
2930 PrintDiagnostics("addsite", code);
2933 MapPartIdIntoName(apart, apartName);
2934 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
2935 as->parms[0].items->data, apartName, as->parms[2].items->data);
2941 register struct cmd_syndesc *as;
2944 afs_int32 avolid, aserver, apart, code, err;
2945 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
2947 vsu_ExtractName(avolname, as->parms[2].items->data);
2948 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
2951 PrintError("", err);
2953 fprintf(STDERR, "vos: can't find volume '%s'\n",
2954 as->parms[2].items->data);
2957 aserver = GetServer(as->parms[0].items->data);
2959 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2960 as->parms[0].items->data);
2963 apart = volutil_GetPartitionID(as->parms[1].items->data);
2965 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2966 as->parms[1].items->data);
2970 *skip the partition validity check, since it is possible that the partition
2971 *has since been decomissioned.
2974 if (!IsPartValid(apart,aserver,&code)){
2975 if(code) PrintError("",code);
2976 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
2980 code = UV_RemoveSite(aserver, apart, avolid);
2982 PrintDiagnostics("remsite", code);
2985 MapPartIdIntoName(apart, apartName);
2986 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
2987 as->parms[0].items->data, apartName, as->parms[2].items->data);
2993 register struct cmd_syndesc *as;
2995 afs_int32 avolid, aserver, apart, code, err;
2998 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3001 PrintError("", err);
3003 fprintf(STDERR, "vos: can't find volume '%s'\n",
3004 as->parms[2].items->data);
3007 aserver = GetServer(as->parms[0].items->data);
3009 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3010 as->parms[0].items->data);
3013 apart = volutil_GetPartitionID(as->parms[1].items->data);
3015 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3016 as->parms[1].items->data);
3019 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3021 PrintError("", code);
3024 "vos : partition %s does not exist on the server\n",
3025 as->parms[1].items->data);
3028 code = UV_ChangeLocation(aserver, apart, avolid);
3030 PrintDiagnostics("addsite", code);
3033 MapPartIdIntoName(apart, apartName);
3034 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3035 as->parms[0].items->data, apartName, as->parms[2].items->data);
3041 register struct cmd_syndesc *as;
3043 afs_int32 aserver, code;
3044 struct partList dummyPartList;
3049 aserver = GetServer(as->parms[0].items->data);
3051 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3052 as->parms[0].items->data);
3057 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3059 PrintDiagnostics("listpart", code);
3063 fprintf(STDOUT, "The partitions on the server are:\n");
3064 for (i = 0; i < cnt; i++) {
3065 if (dummyPartList.partFlags[i] & PARTVALID) {
3066 memset(pname, 0, sizeof(pname));
3067 MapPartIdIntoName(dummyPartList.partId[i], pname);
3068 fprintf(STDOUT, " %10s ", pname);
3070 if ((i % 5) == 0 && (i != 0))
3071 fprintf(STDOUT, "\n");
3074 fprintf(STDOUT, "\n");
3075 fprintf(STDOUT, "Total: %d\n", total);
3081 CompareVolName(p1, p2)
3084 volintInfo *arg1, *arg2;
3086 arg1 = (volintInfo *) p1;
3087 arg2 = (volintInfo *) p2;
3088 return (strcmp(arg1->name, arg2->name));
3092 /*------------------------------------------------------------------------
3093 * PRIVATE XCompareVolName
3096 * Comparison routine for volume names coming from an extended
3100 * a_obj1P : Char ptr to first extended vol info object
3101 * a_obj1P : Char ptr to second extended vol info object
3104 * The value of strcmp() on the volume names within the passed
3105 * objects (i,e., -1, 0, or 1).
3108 * Passed to qsort() as the designated comparison routine.
3112 *------------------------------------------------------------------------*/
3115 XCompareVolName(a_obj1P, a_obj2P)
3116 char *a_obj1P, *a_obj2P;
3118 { /*XCompareVolName */
3121 (((struct volintXInfo *)(a_obj1P))->name,
3122 ((struct volintXInfo *)(a_obj2P))->name));
3124 } /*XCompareVolName */
3127 CompareVolID(p1, p2)
3130 volintInfo *arg1, *arg2;
3132 arg1 = (volintInfo *) p1;
3133 arg2 = (volintInfo *) p2;
3134 if (arg1->volid == arg2->volid)
3136 if (arg1->volid > arg2->volid)
3143 /*------------------------------------------------------------------------
3144 * PRIVATE XCompareVolID
3147 * Comparison routine for volume IDs coming from an extended
3151 * a_obj1P : Char ptr to first extended vol info object
3152 * a_obj1P : Char ptr to second extended vol info object
3155 * The value of strcmp() on the volume names within the passed
3156 * objects (i,e., -1, 0, or 1).
3159 * Passed to qsort() as the designated comparison routine.
3163 *------------------------------------------------------------------------*/
3166 XCompareVolID(a_obj1P, a_obj2P)
3167 char *a_obj1P, *a_obj2P;
3169 { /*XCompareVolID */
3171 afs_int32 id1, id2; /*Volume IDs we're comparing */
3173 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3174 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3182 } /*XCompareVolID */
3184 /*------------------------------------------------------------------------
3185 * PRIVATE ListVolumes
3188 * Routine used to list volumes, contacting the Volume Server
3189 * directly, bypassing the VLDB.
3192 * as : Ptr to parsed command line arguments.
3195 * 0 Successful operation
3198 * Nothing interesting.
3202 *------------------------------------------------------------------------*/
3206 register struct cmd_syndesc *as;
3208 afs_int32 apart, int32list, fast;
3209 afs_int32 aserver, code;
3210 volintInfo *pntr, *oldpntr;
3214 volintXInfo *xInfoP, *origxInfoP; /*Ptr to current/orig extended vol info */
3215 int wantExtendedInfo; /*Do we want extended vol info? */
3218 struct partList dummyPartList;
3226 if (as->parms[3].items)
3228 if (as->parms[4].items)
3232 if (as->parms[2].items)
3238 if (as->parms[5].items) {
3240 * We can't coexist with the fast flag.
3244 "vos: Can't use the -fast and -extended flags together\n");
3249 * We need to turn on ``long'' listings to get the full effect.
3251 wantExtendedInfo = 1;
3254 wantExtendedInfo = 0;
3255 if (as->parms[1].items) {
3256 apart = volutil_GetPartitionID(as->parms[1].items->data);
3258 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3259 as->parms[1].items->data);
3262 dummyPartList.partId[0] = apart;
3263 dummyPartList.partFlags[0] = PARTVALID;
3266 aserver = GetServer(as->parms[0].items->data);
3268 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3269 as->parms[0].items->data);
3274 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3276 PrintError("", code);
3279 "vos : partition %s does not exist on the server\n",
3280 as->parms[1].items->data);
3284 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3286 PrintDiagnostics("listvol", code);
3290 for (i = 0; i < cnt; i++) {
3291 if (dummyPartList.partFlags[i] & PARTVALID) {
3292 if (wantExtendedInfo)
3294 UV_XListVolumes(aserver, dummyPartList.partId[i], all,
3298 UV_ListVolumes(aserver, dummyPartList.partId[i], all,
3301 PrintDiagnostics("listvol", code);
3306 if (wantExtendedInfo) {
3307 origxInfoP = xInfoP;
3308 base = (char *)xInfoP;
3311 base = (char *)pntr;
3315 if (wantExtendedInfo)
3316 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
3318 qsort(base, count, sizeof(volintInfo), CompareVolName);
3320 if (wantExtendedInfo)
3321 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
3323 qsort(base, count, sizeof(volintInfo), CompareVolID);
3325 MapPartIdIntoName(dummyPartList.partId[i], pname);
3328 "Total number of volumes on server %s partition %s: %lu \n",
3329 as->parms[0].items->data, pname,
3330 (unsigned long)count);
3331 if (wantExtendedInfo) {
3332 XDisplayVolumes(aserver, dummyPartList.partId[i], origxInfoP,
3333 count, int32list, fast, quiet);
3336 xInfoP = (volintXInfo *) 0;
3338 #ifdef FULL_LISTVOL_SWITCH
3339 if (as->parms[6].items)
3340 DisplayVolumes2(aserver, dummyPartList.partId[i], oldpntr,
3343 #endif /* FULL_LISTVOL_SWITCH */
3344 DisplayVolumes(aserver, dummyPartList.partId[i], oldpntr,
3345 count, int32list, fast, quiet);
3348 pntr = (volintInfo *) 0;
3357 register struct cmd_syndesc *as;
3359 afs_int32 pnum, code; /* part name */
3365 if (as->parms[0].items) {
3366 tserver = GetServer(as->parms[0].items->data);
3368 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3369 as->parms[0].items->data);
3374 if (as->parms[1].items) {
3375 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3377 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3378 as->parms[1].items->data);
3381 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3383 PrintError("", code);
3386 "vos: partition %s does not exist on the server\n",
3387 as->parms[1].items->data);
3394 "The -partition option requires a -server option\n");
3399 if (as->parms[2].items) {
3400 /* Synchronize an individual volume */
3401 volname = as->parms[2].items->data;
3402 code = UV_SyncVolume(tserver, pnum, volname, flags);
3406 "Without a -volume option, the -server option is required\n");
3409 code = UV_SyncVldb(tserver, pnum, flags, 0 /*unused */ );
3413 PrintDiagnostics("syncvldb", code);
3417 /* Print a summary of what we did */
3419 fprintf(STDOUT, "VLDB volume %s synchronized", volname);
3421 fprintf(STDOUT, "VLDB synchronized");
3423 fprintf(STDOUT, " with state of server %s", as->parms[0].items->data);
3426 MapPartIdIntoName(pnum, part);
3427 fprintf(STDOUT, " partition %s\n", part);
3429 fprintf(STDOUT, "\n");
3436 register struct cmd_syndesc *as;
3439 afs_int32 pnum, code; /* part name */
3444 tserver = GetServer(as->parms[0].items->data);
3446 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3447 as->parms[0].items->data);
3450 if (as->parms[1].items) {
3451 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3453 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3454 as->parms[1].items->data);
3457 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3459 PrintError("", code);
3462 "vos : partition %s does not exist on the server\n",
3463 as->parms[1].items->data);
3471 code = UV_SyncServer(tserver, pnum, flags, 0 /*unused */ );
3473 PrintDiagnostics("syncserv", code);
3477 MapPartIdIntoName(pnum, part);
3478 fprintf(STDOUT, "Server %s partition %s synchronized with VLDB\n",
3479 as->parms[0].items->data, part);
3481 fprintf(STDOUT, "Server %s synchronized with VLDB\n",
3482 as->parms[0].items->data);
3491 struct nvldbentry entry;
3494 /* The vlserver will handle names with the .readonly
3495 * and .backup extension as well as volume ids.
3497 vcode = VLDB_GetEntryByName(name, &entry);
3499 PrintError("", vcode);
3502 MapHostToNetwork(&entry);
3503 EnumerateEntry(&entry);
3505 /* Defect #3027: grubby check to handle locked volume.
3506 * If VLOP_ALLOPERS is set, the entry is locked.
3507 * Leave this routine as is, but put in correct check.
3509 if (entry.flags & VLOP_ALLOPERS)
3510 fprintf(STDOUT, " Volume is currently LOCKED \n");
3517 register struct cmd_syndesc *as;
3520 struct nvldbentry entry;
3521 afs_int32 volid, code, server, part, zapbackupid = 0, backupid = 0, err;
3523 if (as->parms[3].items) {
3524 /* force flag is on, use the other version */
3525 return NukeVolume(as);
3528 if (as->parms[4].items) {
3532 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3535 PrintError("", err);
3537 fprintf(STDERR, "vos: can't find volume '%s'\n",
3538 as->parms[2].items->data);
3541 part = volutil_GetPartitionID(as->parms[1].items->data);
3543 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3544 as->parms[1].items->data);
3547 server = GetServer(as->parms[0].items->data);
3549 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3550 as->parms[0].items->data);
3553 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
3555 PrintError("", code);
3558 "vos : partition %s does not exist on the server\n",
3559 as->parms[1].items->data);
3562 code = VLDB_GetEntryByID(volid, -1, &entry);
3564 if (volid == entry.volumeId[RWVOL])
3565 backupid = entry.volumeId[BACKVOL];
3567 "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
3568 (unsigned long)volid);
3571 volintInfo *pntr = (volintInfo *) 0;
3574 code = UV_ListOneVolume(server, part, volid, &pntr);
3576 if (volid == pntr->parentID)
3577 backupid = pntr->backupID;
3583 code = UV_VolumeZap(server, part, backupid);
3585 PrintDiagnostics("zap", code);
3588 fprintf(STDOUT, "Backup Volume %lu deleted\n",
3589 (unsigned long)backupid);
3592 code = UV_VolumeZap(server, part, volid);
3594 PrintDiagnostics("zap", code);
3597 fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
3604 register struct cmd_syndesc *as;
3607 afs_int32 server, code;
3608 transDebugInfo *pntr, *oldpntr;
3613 server = GetServer(as->parms[0].items->data);
3615 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3616 as->parms[0].items->data);
3619 code = UV_VolserStatus(server, &pntr, &count);
3621 PrintDiagnostics("status", code);
3626 fprintf(STDOUT, "No active transactions on %s\n",
3627 as->parms[0].items->data);
3629 fprintf(STDOUT, "Total transactions: %d\n", count);
3631 for (i = 0; i < count; i++) {
3632 /*print out the relevant info */
3633 fprintf(STDOUT, "--------------------------------------\n");
3634 fprintf(STDOUT, "transaction: %lu created: %s",
3635 (unsigned long)pntr->tid, ctime((time_t *) & pntr->time));
3636 if (pntr->returnCode) {
3637 fprintf(STDOUT, "returnCode: %lu\n",
3638 (unsigned long)pntr->returnCode);
3641 fprintf(STDOUT, "attachFlags: ");
3642 switch (pntr->iflags) {
3644 fprintf(STDOUT, "offline ");
3647 fprintf(STDOUT, "busy ");
3650 fprintf(STDOUT, "readonly ");
3653 fprintf(STDOUT, "create ");
3656 fprintf(STDOUT, "create volid ");
3659 fprintf(STDOUT, "\n");
3662 fprintf(STDOUT, "volumeStatus: ");
3663 switch (pntr->vflags) {
3664 case VTDeleteOnSalvage:
3665 fprintf(STDOUT, "deleteOnSalvage ");
3666 case VTOutOfService:
3667 fprintf(STDOUT, "outOfService ");
3669 fprintf(STDOUT, "deleted ");
3671 fprintf(STDOUT, "\n");
3674 fprintf(STDOUT, "transactionFlags: ");
3675 fprintf(STDOUT, "delete\n");
3677 MapPartIdIntoName(pntr->partition, pname);
3678 fprintf(STDOUT, "volume: %lu partition: %s procedure: %s\n",
3679 (unsigned long)pntr->volid, pname, pntr->lastProcName);
3680 if (pntr->callValid) {
3682 "packetRead: %lu lastReceiveTime: %d packetSend: %lu lastSendTime: %d\n",
3683 (unsigned long)pntr->readNext, pntr->lastReceiveTime,
3684 (unsigned long)pntr->transmitNext, pntr->lastSendTime);
3687 fprintf(STDOUT, "--------------------------------------\n");
3688 fprintf(STDOUT, "\n");
3697 register struct cmd_syndesc *as;
3699 afs_int32 code1, code2, code;
3700 struct nvldbentry entry;
3702 code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
3704 fprintf(STDERR, "vos: Could not find entry for volume %s\n",
3705 as->parms[0].items->data);
3708 code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
3709 if ((!code1) && (!code2)) { /*the newname already exists */
3710 fprintf(STDERR, "vos: volume %s already exists\n",
3711 as->parms[1].items->data);
3715 if (code1 && code2) {
3716 fprintf(STDERR, "vos: Could not find entry for volume %s or %s\n",
3717 as->parms[0].items->data, as->parms[1].items->data);
3720 if (!VolNameOK(as->parms[0].items->data)) {
3722 "Illegal volume name %s, should not end in .readonly or .backup\n",
3723 as->parms[0].items->data);
3726 if (!ISNAMEVALID(as->parms[1].items->data)) {
3728 "vos: the new volume name %s exceeds the size limit of %d\n",
3729 as->parms[1].items->data, VOLSER_OLDMAXVOLNAME - 10);
3732 if (!VolNameOK(as->parms[1].items->data)) {
3734 "Illegal volume name %s, should not end in .readonly or .backup\n",
3735 as->parms[1].items->data);
3738 if (IsNumeric(as->parms[1].items->data)) {
3739 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
3740 as->parms[1].items->data);
3743 MapHostToNetwork(&entry);
3745 UV_RenameVolume(&entry, as->parms[0].items->data,
3746 as->parms[1].items->data);
3748 PrintDiagnostics("rename", code);
3751 fprintf(STDOUT, "Renamed volume %s to %s\n", as->parms[0].items->data,
3752 as->parms[1].items->data);
3756 GetVolumeInfo(volid, server, part, voltype, rentry)
3757 afs_int32 *server, volid, *part, *voltype;
3758 register struct nvldbentry *rentry;
3763 vcode = VLDB_GetEntryByID(volid, -1, rentry);
3766 "Could not fetch the entry for volume %lu from VLDB \n",
3767 (unsigned long)volid);
3768 PrintError("", vcode);
3771 MapHostToNetwork(rentry);
3772 if (volid == rentry->volumeId[ROVOL]) {
3774 for (i = 0; i < rentry->nServers; i++) {
3775 if ((index == -1) && (rentry->serverFlags[i] & ITSROVOL)
3776 && !(rentry->serverFlags[i] & RO_DONTUSE))
3781 "RO volume is not found in VLDB entry for volume %lu\n",
3782 (unsigned long)volid);
3786 *server = rentry->serverNumber[index];
3787 *part = rentry->serverPartition[index];
3791 index = Lp_GetRwIndex(rentry);
3794 "RW Volume is not found in VLDB entry for volume %lu\n",
3795 (unsigned long)volid);
3798 if (volid == rentry->volumeId[RWVOL]) {
3800 *server = rentry->serverNumber[index];
3801 *part = rentry->serverPartition[index];
3804 if (volid == rentry->volumeId[BACKVOL]) {
3806 *server = rentry->serverNumber[index];
3807 *part = rentry->serverPartition[index];
3811 "unexpected volume type for volume %lu\n",
3812 (unsigned long)volid);
3818 register struct cmd_syndesc *as;
3824 struct VldbListByAttributes attributes;
3825 nbulkentries arrayEntries;
3826 register struct nvldbentry *vllist;
3827 struct cmd_item *itp;
3830 char prefix[VOLSER_MAXVOLNAME + 1];
3832 afs_int32 totalBack = 0, totalFail = 0, err;
3834 if (as->parms[0].items) { /* -id */
3835 if (as->parms[1].items || as->parms[2].items || as->parms[3].items) {
3837 "You cannot use -server, -partition, or -prefix with the -id argument\n");
3840 for (itp = as->parms[0].items; itp; itp = itp->next) {
3841 avolid = vsu_GetVolumeID(itp->data, cstruct, &err);
3844 PrintError("", err);
3846 fprintf(STDERR, "vos: can't find volume '%s'\n",
3850 if (as->parms[4].items) { /* -noexecute */
3851 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
3856 vcode = ubik_Call(VL_DeleteEntry, cstruct, 0, avolid, RWVOL);
3858 fprintf(STDERR, "Could not delete entry for volume %s\n",
3861 "You must specify a RW volume name or ID "
3862 "(the entire VLDB entry will be deleted)\n");
3863 PrintError("", vcode);
3869 fprintf(STDOUT, "Deleted %d VLDB entries\n", totalBack);
3873 if (!as->parms[1].items && !as->parms[2].items && !as->parms[3].items) {
3874 fprintf(STDERR, "You must specify an option\n");
3878 /* Zero out search attributes */
3879 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
3881 if (as->parms[1].items) { /* -prefix */
3882 strncpy(prefix, as->parms[1].items->data, VOLSER_MAXVOLNAME);
3884 if (!as->parms[2].items && !as->parms[3].items) { /* a single entry only */
3886 "You must provide -server with the -prefix argument\n");
3891 if (as->parms[2].items) { /* -server */
3893 aserver = GetServer(as->parms[2].items->data);
3895 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3896 as->parms[2].items->data);
3899 attributes.server = ntohl(aserver);
3900 attributes.Mask |= VLLIST_SERVER;
3903 if (as->parms[3].items) { /* -partition */
3904 if (!as->parms[2].items) {
3906 "You must provide -server with the -partition argument\n");
3909 apart = volutil_GetPartitionID(as->parms[3].items->data);
3911 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3912 as->parms[3].items->data);
3915 attributes.partition = apart;
3916 attributes.Mask |= VLLIST_PARTITION;
3919 /* Print status line of what we are doing */
3920 fprintf(STDOUT, "Deleting VLDB entries for ");
3921 if (as->parms[2].items) {
3922 fprintf(STDOUT, "server %s ", as->parms[2].items->data);
3924 if (as->parms[3].items) {
3926 MapPartIdIntoName(apart, pname);
3927 fprintf(STDOUT, "partition %s ", pname);
3930 fprintf(STDOUT, "which are prefixed with %s ", prefix);
3932 fprintf(STDOUT, "\n");
3935 /* Get all the VLDB entries on a server and/or partition */
3936 memset(&arrayEntries, 0, sizeof(arrayEntries));
3937 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
3939 fprintf(STDERR, "Could not access the VLDB for attributes\n");
3940 PrintError("", vcode);
3944 /* Process each entry */
3945 for (j = 0; j < nentries; j++) {
3946 vllist = &arrayEntries.nbulkentries_val[j];
3948 /* It only deletes the RW volumes */
3949 if (strncmp(vllist->name, prefix, strlen(prefix))) {
3952 "Omitting to delete %s due to prefix %s mismatch\n",
3953 vllist->name, prefix);
3960 if (as->parms[4].items) { /* -noexecute */
3961 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
3967 /* Only matches the RW volume name */
3968 avolid = vllist->volumeId[RWVOL];
3969 vcode = ubik_Call(VL_DeleteEntry, cstruct, 0, avolid, RWVOL);
3971 fprintf(STDOUT, "Could not delete VDLB entry for %s\n",
3974 PrintError("", vcode);
3979 fprintf(STDOUT, "Deleted VLDB entry for %s \n", vllist->name);
3984 fprintf(STDOUT, "----------------------\n");
3986 "Total VLDB entries deleted: %lu; failed to delete: %lu\n",
3987 (unsigned long)totalBack, (unsigned long)totalFail);
3988 if (arrayEntries.nbulkentries_val)
3989 free(arrayEntries.nbulkentries_val);
3995 CompareVldbEntryByName(p1, p2)
3998 struct nvldbentry *arg1, *arg2;
4000 arg1 = (struct nvldbentry *)p1;
4001 arg2 = (struct nvldbentry *)p2;
4002 return (strcmp(arg1->name, arg2->name));
4006 static int CompareVldbEntry(p1,p2)
4009 struct nvldbentry *arg1,*arg2;
4012 char comp1[100],comp2[100];
4013 char temp1[20],temp2[20];
4015 arg1 = (struct nvldbentry *)p1;
4016 arg2 = (struct nvldbentry *)p2;
4020 for(i = 0; i < arg1->nServers; i++)
4021 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
4022 for(i = 0; i < arg2->nServers; i++)
4023 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
4024 if(pos1 == -1 || pos2 == -1){
4028 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
4029 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
4030 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
4031 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
4032 strcat(comp1,temp1);
4033 strcat(comp2,temp2);
4034 strcat(comp1,arg1->name);
4035 strcat(comp1,arg2->name);
4036 return(strcmp(comp1,comp2));
4043 struct cmd_syndesc *as;
4046 afs_int32 aserver, code;
4048 struct VldbListByAttributes attributes;
4049 nbulkentries arrayEntries;
4050 struct nvldbentry *vllist, *tarray = 0, *ttarray;
4051 afs_int32 centries, nentries = 0, tarraysize, parraysize;
4054 int quiet, sort, lock;
4055 afs_int32 thisindex, nextindex;
4060 attributes.Mask = 0;
4061 lock = (as->parms[3].items ? 1 : 0); /* -lock flag */
4062 quiet = (as->parms[4].items ? 1 : 0); /* -quit flag */
4063 sort = (as->parms[5].items ? 0 : 1); /* -nosort flag */
4065 /* If the volume name is given, Use VolumeInfoCmd to look it up
4066 * and not ListAttributes.
4068 if (as->parms[0].items) {
4071 "vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
4074 code = VolumeInfoCmd(as->parms[0].items->data);
4076 PrintError("", code);
4082 /* Server specified */
4083 if (as->parms[1].items) {
4084 aserver = GetServer(as->parms[1].items->data);
4086 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4087 as->parms[1].items->data);
4090 attributes.server = ntohl(aserver);
4091 attributes.Mask |= VLLIST_SERVER;
4094 /* Partition specified */
4095 if (as->parms[2].items) {
4096 apart = volutil_GetPartitionID(as->parms[2].items->data);
4098 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4099 as->parms[2].items->data);
4102 attributes.partition = apart;
4103 attributes.Mask |= VLLIST_PARTITION;
4107 attributes.Mask |= VLLIST_FLAG;
4108 attributes.flag = VLOP_ALLOPERS;
4111 /* Print header information */
4113 MapPartIdIntoName(apart, pname);
4114 fprintf(STDOUT, "VLDB entries for %s %s%s%s %s\n",
4115 (as->parms[1].items ? "server" : "all"),
4116 (as->parms[1].items ? as->parms[1].items->data : "servers"),
4117 (as->parms[2].items ? " partition " : ""),
4118 (as->parms[2].items ? pname : ""),
4119 (lock ? "which are locked:" : ""));
4122 for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
4123 memset(&arrayEntries, 0, sizeof(arrayEntries));
4128 VLDB_ListAttributesN2(&attributes, 0, thisindex, ¢ries,
4129 &arrayEntries, &nextindex);
4130 if (vcode == RXGEN_OPCODE) {
4131 /* Vlserver not running with ListAttributesN2. Fall back */
4133 VLDB_ListAttributes(&attributes, ¢ries, &arrayEntries);
4137 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4138 PrintError("", vcode);
4141 nentries += centries;
4143 /* We don't sort, so just print the entries now */
4145 for (j = 0; j < centries; j++) { /* process each entry */
4146 vllist = &arrayEntries.nbulkentries_val[j];
4147 MapHostToNetwork(vllist);
4148 EnumerateEntry(vllist);
4150 if (vllist->flags & VLOP_ALLOPERS)
4151 fprintf(STDOUT, " Volume is currently LOCKED \n");
4155 /* So we sort. First we must collect all the entries and keep
4158 else if (centries > 0) {
4160 /* steal away the first bulk entries array */
4161 tarray = (struct nvldbentry *)arrayEntries.nbulkentries_val;
4162 tarraysize = centries * sizeof(struct nvldbentry);
4163 arrayEntries.nbulkentries_val = 0;
4165 /* Grow the tarray to keep the extra entries */
4166 parraysize = (centries * sizeof(struct nvldbentry));
4168 (struct nvldbentry *)realloc(tarray,
4169 tarraysize + parraysize);
4172 "Could not allocate enough space for the VLDB entries\n");
4178 memcpy(((char *)tarray) + tarraysize,
4179 (char *)arrayEntries.nbulkentries_val, parraysize);
4180 tarraysize += parraysize;
4184 /* Free the bulk array */
4185 if (arrayEntries.nbulkentries_val) {
4186 free(arrayEntries.nbulkentries_val);
4187 arrayEntries.nbulkentries_val = 0;
4191 /* Here is where we now sort all the entries and print them */
4192 if (sort && (nentries > 0)) {
4193 qsort((char *)tarray, nentries, sizeof(struct nvldbentry),
4194 CompareVldbEntryByName);
4195 for (vllist = tarray, j = 0; j < nentries; j++, vllist++) {
4196 MapHostToNetwork(vllist);
4197 EnumerateEntry(vllist);
4199 if (vllist->flags & VLOP_ALLOPERS)
4200 fprintf(STDOUT, " Volume is currently LOCKED \n");
4206 fprintf(STDOUT, "\nTotal entries: %lu\n", (unsigned long)nentries);
4214 register struct cmd_syndesc *as;
4216 afs_int32 apart = 0, avolid;
4217 afs_int32 aserver = 0, code, aserver1, apart1;
4219 struct VldbListByAttributes attributes;
4220 nbulkentries arrayEntries;
4221 register struct nvldbentry *vllist;
4225 int seenprefix, seenxprefix, exclude, ex, exp, noaction;
4226 afs_int32 totalBack = 0;
4227 afs_int32 totalFail = 0;
4228 int previdx = -1, error, same;
4230 struct cmd_item *ti;
4234 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4235 attributes.Mask = 0;
4237 seenprefix = (as->parms[0].items ? 1 : 0);
4238 exclude = (as->parms[3].items ? 1 : 0);
4239 seenxprefix = (as->parms[4].items ? 1 : 0);
4240 noaction = (as->parms[5].items ? 1 : 0);
4242 if (as->parms[1].items) { /* -server */
4243 aserver = GetServer(as->parms[1].items->data);
4245 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4246 as->parms[1].items->data);
4249 attributes.server = ntohl(aserver);
4250 attributes.Mask |= VLLIST_SERVER;
4253 if (as->parms[2].items) { /* -partition */
4254 apart = volutil_GetPartitionID(as->parms[2].items->data);
4256 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4257 as->parms[2].items->data);
4260 attributes.partition = apart;
4261 attributes.Mask |= VLLIST_PARTITION;
4264 /* Check to make sure the prefix and xprefix expressions compile ok */
4266 for (ti = as->parms[0].items; ti; ti = ti->next) {
4267 if (strncmp(ti->data, "^", 1) == 0) {
4268 #ifdef HAVE_POSIX_REGEX
4272 code = regcomp(&re, ti->data, REG_NOSUB);
4274 regerror(code, &re, errbuf, sizeof errbuf);
4276 "Unrecognizable -prefix regular expression: '%s': %s\n",
4282 ccode = (char *)re_comp(ti->data);
4285 "Unrecognizable -prefix regular expression: '%s': %s\n",
4294 for (ti = as->parms[4].items; ti; ti = ti->next) {
4295 if (strncmp(ti->data, "^", 1) == 0) {
4296 #ifdef HAVE_POSIX_REGEX
4300 code = regcomp(&re, ti->data, REG_NOSUB);
4302 regerror(code, &re, errbuf, sizeof errbuf);
4304 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4310 ccode = (char *)re_comp(ti->data);
4313 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4322 memset(&arrayEntries, 0, sizeof(arrayEntries)); /* initialize to hint the stub to alloc space */
4323 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4325 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4326 PrintError("", vcode);
4330 if (as->parms[1].items || as->parms[2].items || verbose) {
4331 fprintf(STDOUT, "%s up volumes",
4332 (noaction ? "Would have backed" : "Backing"));
4334 if (as->parms[1].items) {
4335 fprintf(STDOUT, " on server %s", as->parms[1].items->data);
4336 } else if (as->parms[2].items) {
4337 fprintf(STDOUT, " for all servers");
4340 if (as->parms[2].items) {
4341 MapPartIdIntoName(apart, pname);
4342 fprintf(STDOUT, " partition %s", pname);
4345 if (seenprefix || (!seenprefix && seenxprefix)) {
4346 ti = (seenprefix ? as->parms[0].items : as->parms[4].items);
4347 ex = (seenprefix ? exclude : !exclude);
4348 exp = (strncmp(ti->data, "^", 1) == 0);
4349 fprintf(STDOUT, " which %smatch %s '%s'", (ex ? "do not " : ""),
4350 (exp ? "expression" : "prefix"), ti->data);
4351 for (ti = ti->next; ti; ti = ti->next) {
4352 exp = (strncmp(ti->data, "^", 1) == 0);
4353 printf(" %sor %s '%s'", (ex ? "n" : ""),
4354 (exp ? "expression" : "prefix"), ti->data);
4358 if (seenprefix && seenxprefix) {
4359 ti = as->parms[4].items;
4360 exp = (strncmp(ti->data, "^", 1) == 0);
4361 fprintf(STDOUT, " %swhich match %s '%s'",
4362 (exclude ? "adding those " : "removing those "),
4363 (exp ? "expression" : "prefix"), ti->data);
4364 for (ti = ti->next; ti; ti = ti->next) {
4365 exp = (strncmp(ti->data, "^", 1) == 0);
4366 printf(" or %s '%s'", (exp ? "expression" : "prefix"),
4370 fprintf(STDOUT, " .. ");
4372 fprintf(STDOUT, "\n");
4376 for (j = 0; j < nentries; j++) { /* process each vldb entry */
4377 vllist = &arrayEntries.nbulkentries_val[j];
4380 for (ti = as->parms[0].items; ti; ti = ti->next) {
4381 if (strncmp(ti->data, "^", 1) == 0) {
4382 #ifdef HAVE_POSIX_REGEX
4386 /* XXX -- should just do the compile once! */
4387 code = regcomp(&re, ti->data, REG_NOSUB);
4389 regerror(code, &re, errbuf, sizeof errbuf);
4391 "Error in -prefix regular expression: '%s': %s\n",
4395 match = (regexec(&re, vllist->name, 0, NULL, 0) == 0);
4398 ccode = (char *)re_comp(ti->data);
4401 "Error in -prefix regular expression: '%s': %s\n",
4405 match = (re_exec(vllist->name) == 1);
4409 (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4419 /* Without the -exclude flag: If it matches the prefix, then
4420 * check if we want to exclude any from xprefix.
4421 * With the -exclude flag: If it matches the prefix, then
4422 * check if we want to add any from xprefix.
4424 if (match && seenxprefix) {
4425 for (ti = as->parms[4].items; ti; ti = ti->next) {
4426 if (strncmp(ti->data, "^", 1) == 0) {
4427 #ifdef HAVE_POSIX_REGEX
4431 /* XXX -- should just do the compile once! */
4432 code = regcomp(&re, ti->data, REG_NOSUB);
4434 regerror(code, &re, errbuf, sizeof errbuf);
4436 "Error in -xprefix regular expression: '%s': %s\n",
4440 if (regexec(&re, vllist->name, 0, NULL, 0) == 0)
4444 ccode = (char *)re_comp(ti->data);
4447 "Error in -xprefix regular expression: '%s': %s\n",
4451 if (re_exec(vllist->name) == 1) {
4457 if (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4467 match = !match; /* -exclude will reverse the match */
4469 continue; /* Skip if no match */
4471 /* Print list of volumes to backup */
4473 fprintf(STDOUT, " %s\n", vllist->name);
4477 if (!(vllist->flags & RW_EXISTS)) {
4480 "Omitting to backup %s since RW volume does not exist \n",
4482 fprintf(STDOUT, "\n");
4488 avolid = vllist->volumeId[RWVOL];
4489 MapHostToNetwork(vllist);
4490 GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
4491 if (aserver1 == -1 || apart1 == -1) {
4492 fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n",
4498 same = VLDB_IsSameAddrs(aserver, aserver1, &error);
4501 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4507 if ((aserver && !same) || (apart && (apart != apart1))) {
4510 "Omitting to backup %s since the RW is in a different location\n",
4516 time_t now = time(0);
4517 fprintf(STDOUT, "Creating backup volume for %s on %s",
4518 vllist->name, ctime(&now));
4522 code = UV_BackupVolume(aserver1, apart1, avolid);
4524 fprintf(STDOUT, "Could not backup %s\n", vllist->name);
4530 fprintf(STDOUT, "\n");
4532 } /* process each vldb entry */
4533 fprintf(STDOUT, "done\n");
4534 fprintf(STDOUT, "Total volumes backed up: %lu; failed to backup: %lu\n",
4535 (unsigned long)totalBack, (unsigned long)totalFail);
4537 if (arrayEntries.nbulkentries_val)
4538 free(arrayEntries.nbulkentries_val);
4544 register struct cmd_syndesc *as;
4547 afs_int32 aserver, code;
4549 struct VldbListByAttributes attributes;
4550 nbulkentries arrayEntries;
4551 register struct nvldbentry *vllist;
4560 attributes.Mask = 0;
4562 if (as->parms[0].items) { /* server specified */
4563 aserver = GetServer(as->parms[0].items->data);
4565 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4566 as->parms[0].items->data);
4569 attributes.server = ntohl(aserver);
4570 attributes.Mask |= VLLIST_SERVER;
4572 if (as->parms[1].items) { /* partition specified */
4573 apart = volutil_GetPartitionID(as->parms[1].items->data);
4575 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4576 as->parms[1].items->data);
4579 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4581 PrintError("", code);
4584 "vos : partition %s does not exist on the server\n",
4585 as->parms[1].items->data);
4588 attributes.partition = apart;
4589 attributes.Mask |= VLLIST_PARTITION;
4591 attributes.flag = VLOP_ALLOPERS;
4592 attributes.Mask |= VLLIST_FLAG;
4593 memset(&arrayEntries, 0, sizeof(arrayEntries)); /*initialize to hint the stub to alloc space */
4594 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4596 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4597 PrintError("", vcode);
4600 for (j = 0; j < nentries; j++) { /* process each entry */
4601 vllist = &arrayEntries.nbulkentries_val[j];
4602 volid = vllist->volumeId[RWVOL];
4604 ubik_Call(VL_ReleaseLock, cstruct, 0, volid, -1,
4605 LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
4607 fprintf(STDERR, "Could not unlock entry for volume %s\n",
4609 PrintError("", vcode);
4614 MapPartIdIntoName(apart, pname);
4617 "Could not lock %lu VLDB entries of %lu locked entries\n",
4618 (unsigned long)totalE, (unsigned long)nentries);
4620 if (as->parms[0].items) {
4622 "Unlocked all the VLDB entries for volumes on server %s ",
4623 as->parms[0].items->data);
4624 if (as->parms[1].items) {
4625 MapPartIdIntoName(apart, pname);
4626 fprintf(STDOUT, "partition %s\n", pname);
4628 fprintf(STDOUT, "\n");
4630 } else if (as->parms[1].items) {
4631 MapPartIdIntoName(apart, pname);
4633 "Unlocked all the VLDB entries for volumes on partition %s on all servers\n",
4638 if (arrayEntries.nbulkentries_val)
4639 free(arrayEntries.nbulkentries_val);
4645 register struct cmd_syndesc *as;
4648 afs_int32 aserver, code;
4650 struct diskPartition partition;
4651 struct partList dummyPartList;
4655 aserver = GetServer(as->parms[0].items->data);
4657 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4658 as->parms[0].items->data);
4661 if (as->parms[1].items) {
4662 apart = volutil_GetPartitionID(as->parms[1].items->data);
4664 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4665 as->parms[1].items->data);
4668 dummyPartList.partId[0] = apart;
4669 dummyPartList.partFlags[0] = PARTVALID;
4673 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4675 PrintError("", code);
4678 "vos : partition %s does not exist on the server\n",
4679 as->parms[1].items->data);
4683 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
4685 PrintDiagnostics("listpart", code);
4689 for (i = 0; i < cnt; i++) {
4690 if (dummyPartList.partFlags[i] & PARTVALID) {
4691 MapPartIdIntoName(dummyPartList.partId[i], pname);
4692 code = UV_PartitionInfo(aserver, pname, &partition);
4694 fprintf(STDERR, "Could not get information on partition %s\n",
4696 PrintError("", code);
4700 "Free space on partition %s: %d K blocks out of total %d\n",
4701 pname, partition.free, partition.minFree);
4709 register struct cmd_syndesc *as;
4712 afs_int32 ip1, ip2, vcode;
4715 ip1 = GetServer(as->parms[0].items->data);
4717 fprintf(STDERR, "vos: invalid host address\n");
4721 if ((as->parms[1].items && as->parms[2].items)
4722 || (!as->parms[1].items && !as->parms[2].items)) {
4724 "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
4728 if (as->parms[1].items) {
4729 ip2 = GetServer(as->parms[1].items->data);
4731 fprintf(STDERR, "vos: invalid host address\n");
4735 /* Play a trick here. If we are removing an address, ip1 will be -1
4736 * and ip2 will be the original address. This switch prevents an
4737 * older revision vlserver from removing the IP address.
4744 vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
4747 fprintf(STDERR, "Could not remove server %s from the VLDB\n",
4748 as->parms[0].items->data);
4749 if (vcode == VL_NOENT) {
4751 "vlserver does not support the remove flag or ");
4754 fprintf(STDERR, "Could not change server %s to server %s\n",
4755 as->parms[0].items->data, as->parms[1].items->data);
4757 PrintError("", vcode);
4762 fprintf(STDOUT, "Removed server %s from the VLDB\n",
4763 as->parms[0].items->data);
4765 fprintf(STDOUT, "Changed server %s to server %s\n",
4766 as->parms[0].items->data, as->parms[1].items->data);
4772 print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
4773 int print, int noresolve)
4777 struct VLCallBack vlcb;
4780 ListAddrByAttributes m_attrs;
4781 afs_int32 m_nentries, *m_addrp;
4782 afs_int32 base, index;
4786 afsUUID_to_string(m_uuid, buf, sizeof(buf));
4787 printf("UUID: %s\n", buf);
4790 /* print out the list of all the server */
4791 addrp = (afs_int32 *) addrs->bulkaddrs_val;
4792 for (i = 0; i < nentries; i++, addrp++) {
4793 /* If it is a multihomed address, then we will need to
4794 * get the addresses for this multihomed server from
4795 * the vlserver and print them.
4797 if (((*addrp & 0xff000000) == 0xff000000) && ((*addrp) & 0xffff)) {
4798 /* Get the list of multihomed fileservers */
4799 base = (*addrp >> 16) & 0xff;
4800 index = (*addrp) & 0xffff;
4802 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
4803 && (index <= VL_MHSRV_PERBLK)) {
4804 m_attrs.Mask = VLADDR_INDEX;
4805 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
4807 m_addrs.bulkaddrs_val = 0;
4808 m_addrs.bulkaddrs_len = 0;
4810 ubik_Call(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
4811 &vlcb, &m_nentries, &m_addrs);
4814 "vos: could not list the multi-homed server addresses\n");
4815 PrintError("", vcode);
4818 /* Print the list */
4819 m_addrp = (afs_int32 *) m_addrs.bulkaddrs_val;
4820 for (j = 0; j < m_nentries; j++, m_addrp++) {
4821 *m_addrp = htonl(*m_addrp);
4824 printf("%s ", afs_inet_ntoa_r(*m_addrp, hoststr));
4826 printf("%s ", hostutil_GetNameByINet(*m_addrp));
4830 printf("<unknown>\n");
4839 /* Otherwise, it is a non-multihomed entry and contains
4840 * the IP address of the server - print it.
4842 *addrp = htonl(*addrp);
4845 printf("%s\n", afs_inet_ntoa_r(*addrp, hoststr));
4847 printf("%s\n", hostutil_GetNameByINet(*addrp));
4859 register struct cmd_syndesc *as;
4862 afs_int32 i, noresolve = 0, printuuid = 0;
4863 struct VLCallBack vlcb;
4866 ListAddrByAttributes m_attrs;
4867 afsUUID m_uuid, askuuid;
4868 afs_int32 m_nentries;
4870 memset(&m_attrs, 0, sizeof(struct ListAddrByAttributes));
4871 m_attrs.Mask = VLADDR_INDEX;
4873 memset(&m_addrs, 0, sizeof(bulkaddrs));
4874 memset(&askuuid, 0, sizeof(afsUUID));
4875 if (as->parms[0].items) {
4877 afsUUID_from_string(as->parms[0].items->data, &askuuid);
4878 m_attrs.Mask = VLADDR_UUID;
4879 m_attrs.uuid = askuuid;
4881 if (as->parms[1].items) {
4885 he = hostutil_GetHostByName((char *)as->parms[1].items->data);
4887 fprintf(stderr, "Can't get host info for '%s'\n",
4888 as->parms[1].items->data);
4891 memcpy(&saddr, he->h_addr, 4);
4892 m_attrs.Mask = VLADDR_IPADDR;
4893 m_attrs.ipaddr = ntohl(saddr);
4895 if (as->parms[2].items) {
4898 if (as->parms[3].items) {
4902 m_addrs.bulkaddrs_val = 0;
4903 m_addrs.bulkaddrs_len = 0;
4906 ubik_Call_New(VL_GetAddrs, cstruct, 0, 0, 0, &vlcb, &nentries,
4909 fprintf(STDERR, "vos: could not list the server addresses\n");
4910 PrintError("", vcode);
4915 m_addrs.bulkaddrs_val = 0;
4916 m_addrs.bulkaddrs_len = 0;
4922 ubik_Call_New(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
4923 &vlcb, &m_nentries, &m_addrs);
4924 if (vcode == VL_NOENT) {
4930 if (vcode == VL_INDEXERANGE) {
4935 fprintf(STDERR, "vos: could not list the server addresses\n");
4936 PrintError("", vcode);
4940 print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid, noresolve);
4943 if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
4952 register struct cmd_syndesc *as;
4955 afs_int32 avolid, vcode, err;
4957 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
4960 PrintError("", err);
4962 fprintf(STDERR, "vos: can't find volume '%s'\n",
4963 as->parms[0].items->data);
4966 vcode = ubik_Call(VL_SetLock, cstruct, 0, avolid, -1, VLOP_DELETE);
4968 fprintf(STDERR, "Could not lock VLDB entry for volume %s\n",
4969 as->parms[0].items->data);
4970 PrintError("", vcode);
4973 fprintf(STDOUT, "Locked VLDB entry for volume %s\n",
4974 as->parms[0].items->data);
4980 register struct cmd_syndesc *as;
4983 afs_int32 partition = -1;
4984 afs_int32 server, volid, code, i, same;
4985 struct nvldbentry entry, storeEntry;
4988 afs_int32 rwserver = 0;
4989 afs_int32 rwpartition;
4991 afs_int32 roserver = 0;
4992 afs_int32 ropartition;
4994 struct rx_connection *aconn;
4997 server = GetServer(as->parms[0].items->data);
4999 fprintf(STDERR, "vos: host '%s' not found in host table\n",
5000 as->parms[0].items->data);
5003 partition = volutil_GetPartitionID(as->parms[1].items->data);
5004 if (partition < 0) {
5005 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5006 as->parms[1].items->data);
5009 if (!IsPartValid(partition, server, &code)) {
5011 PrintError("", code);
5014 "vos : partition %s does not exist on the server\n",
5015 as->parms[1].items->data);
5018 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &code);
5021 PrintError("", code);
5023 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
5024 as->parms[0].items->data);
5027 if (as->parms[3].items)
5030 vcode = VLDB_GetEntryByID(volid, -1, &entry);
5033 "Could not fetch the entry for volume %lu from VLDB\n",
5034 (unsigned long)volid);
5035 PrintError("convertROtoRW", code);
5039 /* use RO volid even if user specified RW or BK volid */
5041 if (volid != entry.volumeId[ROVOL])
5042 volid = entry.volumeId[ROVOL];
5044 MapHostToNetwork(&entry);
5045 for (i = 0; i < entry.nServers; i++) {
5046 if (entry.serverFlags[i] & ITSRWVOL) {
5048 rwserver = entry.serverNumber[i];
5049 rwpartition = entry.serverPartition[i];
5051 if (entry.serverFlags[i] & ITSROVOL) {
5052 same = VLDB_IsSameAddrs(server, entry.serverNumber[i], &code);
5055 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
5061 roserver = entry.serverNumber[i];
5062 ropartition = entry.serverPartition[i];
5068 fprintf(STDERR, "Warning: RO volume didn't exist in vldb!\n");
5070 if (ropartition != partition) {
5072 "Warning: RO volume should be in partition %d instead of %d (vldb)\n",
5073 ropartition, partition);
5078 "VLDB indicates that a RW volume exists already on %s in partition %s.\n",
5079 hostutil_GetNameByINet(rwserver),
5080 volutil_PartitionName(rwpartition));
5082 fprintf(STDERR, "Overwrite this VLDB entry? [y|n] (n)\n");
5084 while (!(dc == EOF || dc == '\n'))
5085 dc = getchar(); /* goto end of line */
5086 if ((c != 'y') && (c != 'Y')) {
5087 fprintf(STDERR, "aborted.\n");
5094 ubik_Call(VL_SetLock, cstruct, 0, entry.volumeId[RWVOL], RWVOL,
5096 aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
5097 code = AFSVolConvertROtoRWvolume(aconn, partition, volid);
5100 "Converting RO volume %lu to RW volume failed with code %d\n",
5101 (unsigned long)volid, code);
5102 PrintError("convertROtoRW ", code);
5105 entry.serverFlags[roindex] = ITSRWVOL;
5106 entry.flags |= RW_EXISTS;
5107 entry.flags &= ~BACK_EXISTS;
5110 if (rwindex != entry.nServers) {
5111 entry.serverNumber[rwindex] = entry.serverNumber[entry.nServers];
5112 entry.serverPartition[rwindex] =
5113 entry.serverPartition[entry.nServers];
5114 entry.serverFlags[rwindex] = entry.serverFlags[entry.nServers];
5115 entry.serverNumber[entry.nServers] = 0;
5116 entry.serverPartition[entry.nServers] = 0;
5117 entry.serverFlags[entry.nServers] = 0;
5120 entry.flags &= ~RO_EXISTS;
5121 for (i = 0; i < entry.nServers; i++) {
5122 if (entry.serverFlags[i] & ITSROVOL) {
5123 if (!(entry.serverFlags[i] & (RO_DONTUSE | NEW_REPSITE)))
5124 entry.flags |= RO_EXISTS;
5127 MapNetworkToHost(&entry, &storeEntry);
5129 VLDB_ReplaceEntry(entry.volumeId[RWVOL], RWVOL, &storeEntry,
5130 (LOCKREL_OPCODE | LOCKREL_AFSID |
5131 LOCKREL_TIMESTAMP));
5134 "Warning: volume converted, but vldb update failed with code %d!\n",
5137 vcode = UV_LockRelease(entry.volumeId[RWVOL]);
5139 PrintDiagnostics("unlock", vcode);
5146 register struct cmd_syndesc *as;
5148 afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i;
5149 struct nvldbentry entry;
5150 volintSize vol_size;
5152 rx_SetRxDeadTime(60 * 10);
5153 for (i = 0; i < MAXSERVERS; i++) {
5154 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
5157 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
5158 if (rxConn->service)
5159 rxConn->service->connDeadTime = rx_connDeadTime;
5162 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5165 PrintError("", err);
5167 fprintf(STDERR, "vos: can't find volume '%s'\n",
5168 as->parms[0].items->data);
5172 if (as->parms[1].items || as->parms[2].items) {
5173 if (!as->parms[1].items || !as->parms[2].items) {
5175 "Must specify both -server and -partition options\n");
5178 aserver = GetServer(as->parms[2].items->data);
5180 fprintf(STDERR, "Invalid server name\n");
5183 apart = volutil_GetPartitionID(as->parms[1].items->data);
5185 fprintf(STDERR, "Invalid partition name\n");
5189 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
5196 if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
5197 code = ktime_DateToInt32(as->parms[4].items->data, &fromdate);
5199 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
5200 as->parms[1].items->data, code);
5205 fprintf(STDOUT, "Volume: %s\n", as->parms[0].items->data);
5207 if (as->parms[3].items) { /* do the dump estimate */
5208 #ifdef AFS_64BIT_ENV
5209 vol_size.dump_size = 0;
5211 FillInt64(vol_size.dump_size,0, 1);
5213 code = UV_GetSize(avolid, aserver, apart, fromdate, &vol_size);
5215 PrintDiagnostics("size", code);
5218 /* presumably the size info is now gathered in pntr */
5219 /* now we display it */
5221 fprintf(STDOUT, "dump_size: %llu\n", vol_size.dump_size);
5229 PrintDiagnostics(astring, acode)
5233 if (acode == EACCES) {
5235 "You are not authorized to perform the 'vos %s' command (%d)\n",
5238 fprintf(STDERR, "Error in vos %s command.\n", astring);
5239 PrintError("", acode);
5246 MyBeforeProc(as, arock)
5247 struct cmd_syndesc *as;
5250 register char *tcell;
5251 register afs_int32 code;
5252 register afs_int32 sauth;
5254 /* Initialize the ubik_client connection */
5255 rx_SetRxDeadTime(90);
5256 cstruct = (struct ubik_client *)0;
5260 if (as->parms[12].items) /* if -cell specified */
5261 tcell = as->parms[12].items->data;
5262 if (as->parms[14].items) /* -serverauth specified */
5264 if (as->parms[16].items) /* -crypt specified */
5267 vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
5268 &cstruct, UV_SetSecurity))) {
5269 fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
5270 (unsigned long)code);
5274 if (as->parms[15].items) /* -verbose flag set */
5284 /* this sucks but it works for now.
5289 #include "AFS_component_version_number.c"
5295 register afs_int32 code;
5297 register struct cmd_syndesc *ts;
5299 #ifdef AFS_AIX32_ENV
5301 * The following signal action for AIX is necessary so that in case of a
5302 * crash (i.e. core is generated) we can include the user's data section
5303 * in the core dump. Unfortunately, by default, only a partial core is
5304 * generated which, in many cases, isn't too useful.
5306 struct sigaction nsa;
5308 sigemptyset(&nsa.sa_mask);
5309 nsa.sa_handler = SIG_DFL;
5310 nsa.sa_flags = SA_FULLDUMP;
5311 sigaction(SIGSEGV, &nsa, NULL);
5314 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
5316 cmd_SetBeforeProc(MyBeforeProc, NULL);
5318 ts = cmd_CreateSyntax("create", CreateVolume, 0, "create a new volume");
5319 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5320 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5321 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "volume name");
5322 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL,
5323 "initial quota (KB)");
5325 cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
5329 ts = cmd_CreateSyntax("remove", DeleteVolume, 0, "delete a volume");
5330 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5331 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5332 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5336 ts = cmd_CreateSyntax("move", MoveVolume, 0, "move a volume");
5337 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5338 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5339 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5340 "partition name on source");
5341 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5342 "machine name on destination");
5343 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5344 "partition name on destination");
5345 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5346 "copy live volume without cloning");
5349 ts = cmd_CreateSyntax("copy", CopyVolume, 0, "copy a volume");
5350 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5351 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5352 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5353 "partition name on source");
5354 cmd_AddParm(ts, "-toname", CMD_SINGLE, 0, "volume name on destination");
5355 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5356 "machine name on destination");
5357 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5358 "partition name on destination");
5359 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5360 "leave new volume offline");
5361 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5362 "make new volume read-only");
5363 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5364 "copy live volume without cloning");
5367 ts = cmd_CreateSyntax("shadow", ShadowVolume, 0,
5368 "make or update a shadow volume");
5369 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5370 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5371 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5372 "partition name on source");
5373 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5374 "machine name on destination");
5375 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5376 "partition name on destination");
5377 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5378 "volume name on destination");
5379 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5380 "volume ID on destination");
5381 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5382 "leave shadow volume offline");
5383 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5384 "make shadow volume read-only");
5385 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5386 "copy live volume without cloning");
5387 cmd_AddParm(ts, "-incremental", CMD_FLAG, CMD_OPTIONAL,
5388 "do incremental update if target exists");
5391 ts = cmd_CreateSyntax("backup", BackupVolume, 0,
5392 "make backup of a volume");
5393 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5396 ts = cmd_CreateSyntax("clone", CloneVolume, 0,
5397 "make clone of a volume");
5398 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5399 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5400 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5401 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5402 "volume name on destination");
5403 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5404 "volume ID on destination");
5405 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5406 "leave clone volume offline");
5407 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5408 "make clone volume read-only, not readwrite");
5411 ts = cmd_CreateSyntax("release", ReleaseVolume, 0, "release a volume");
5412 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5413 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5414 "force a complete release");
5417 ts = cmd_CreateSyntax("dump", DumpVolume, 0, "dump a volume");
5418 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5419 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5420 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5421 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5422 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5423 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL,
5424 "dump a clone of the volume");
5427 ts = cmd_CreateSyntax("restore", RestoreVolume, 0, "restore a volume");
5428 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5429 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5430 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of volume to be restored");
5431 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5432 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
5433 cmd_AddParm(ts, "-overwrite", CMD_SINGLE, CMD_OPTIONAL,
5434 "abort | full | incremental");
5435 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5436 "leave restored volume offline");
5437 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5438 "make restored volume read-only");
5439 cmd_AddParm(ts, "-creation", CMD_SINGLE, CMD_OPTIONAL,
5440 "dump | keep | new");
5441 cmd_AddParm(ts, "-lastupdate", CMD_SINGLE, CMD_OPTIONAL,
5442 "dump | keep | new");
5445 ts = cmd_CreateSyntax("unlock", LockReleaseCmd, 0,
5446 "release lock on VLDB entry for a volume");
5447 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5450 ts = cmd_CreateSyntax("changeloc", ChangeLocation, 0,
5451 "change an RW volume's location in the VLDB");
5452 cmd_AddParm(ts, "-server", CMD_SINGLE, 0,
5453 "machine name for new location");
5454 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5455 "partition name for new location");
5456 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5459 ts = cmd_CreateSyntax("addsite", AddSite, 0, "add a replication site");
5460 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new site");
5461 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5462 "partition name for new site");
5463 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5466 ts = cmd_CreateSyntax("remsite", RemoveSite, 0,
5467 "remove a replication site");
5468 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5469 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5470 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5473 ts = cmd_CreateSyntax("listpart", ListPartitions, 0, "list partitions");
5474 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5477 ts = cmd_CreateSyntax("listvol", ListVolumes, 0,
5478 "list volumes on server (bypass VLDB)");
5479 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5480 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5481 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "minimal listing");
5482 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
5483 "list all normal volume fields");
5484 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5485 "generate minimal information");
5486 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5487 "list extended volume fields");
5488 #ifdef FULL_LISTVOL_SWITCH
5489 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5490 "machine readable format");
5491 #endif /* FULL_LISTVOL_SWITCH */
5494 ts = cmd_CreateSyntax("syncvldb", SyncVldb, 0,
5495 "synchronize VLDB with server");
5496 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5497 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5498 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5501 ts = cmd_CreateSyntax("syncserv", SyncServer, 0,
5502 "synchronize server with VLDB");
5503 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5504 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5507 ts = cmd_CreateSyntax("examine", ExamineVolume, 0,
5508 "everything about the volume");
5509 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5510 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5511 "list extended volume fields");
5512 #ifdef FULL_LISTVOL_SWITCH
5513 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5514 "machine readable format");
5515 #endif /* FULL_LISTVOL_SWITCH */
5517 cmd_CreateAlias(ts, "volinfo");
5519 ts = cmd_CreateSyntax("setfields", SetFields, 0,
5520 "change volume info fields");
5521 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5522 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "quota (KB)");
5523 cmd_AddParm(ts, "-clearuse", CMD_FLAG, CMD_OPTIONAL, "clear dayUse");
5526 ts = cmd_CreateSyntax("offline", volOffline, 0, (char *)CMD_HIDDEN);
5527 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5528 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5529 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5530 cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds to sleep");
5531 cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "busy volume");
5534 ts = cmd_CreateSyntax("online", volOnline, 0, (char *)CMD_HIDDEN);
5535 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5536 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5537 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5540 ts = cmd_CreateSyntax("zap", VolumeZap, 0,
5541 "delete the volume, don't bother with VLDB");
5542 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5543 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5544 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume ID");
5545 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5546 "force deletion of bad volumes");
5547 cmd_AddParm(ts, "-backup", CMD_FLAG, CMD_OPTIONAL,
5548 "also delete backup volume if one is found");
5551 ts = cmd_CreateSyntax("status", VolserStatus, 0,
5552 "report on volser status");
5553 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5556 ts = cmd_CreateSyntax("rename", RenameVolume, 0, "rename a volume");
5557 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old volume name ");
5558 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new volume name ");
5561 ts = cmd_CreateSyntax("listvldb", ListVLDB, 0,
5562 "list volumes in the VLDB");
5563 cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5564 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5565 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5566 cmd_AddParm(ts, "-locked", CMD_FLAG, CMD_OPTIONAL, "locked volumes only");
5567 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5568 "generate minimal information");
5569 cmd_AddParm(ts, "-nosort", CMD_FLAG, CMD_OPTIONAL,
5570 "do not alphabetically sort the volume names");
5573 ts = cmd_CreateSyntax("backupsys", BackSys, 0, "en masse backups");
5574 cmd_AddParm(ts, "-prefix", CMD_LIST, CMD_OPTIONAL,
5575 "common prefix on volume(s)");
5576 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5577 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5578 cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL,
5579 "exclude common prefix volumes");
5580 cmd_AddParm(ts, "-xprefix", CMD_LIST, CMD_OPTIONAL,
5581 "negative prefix on volume(s)");
5582 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "no action");
5585 ts = cmd_CreateSyntax("delentry", DeleteEntry, 0,
5586 "delete VLDB entry for a volume");
5587 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "volume name or ID");
5588 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL,
5589 "prefix of the volume whose VLDB entry is to be deleted");
5590 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5591 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5592 cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE,
5596 ts = cmd_CreateSyntax("partinfo", PartitionInfo, 0,
5597 "list partition information");
5598 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5599 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5602 ts = cmd_CreateSyntax("unlockvldb", UnlockVLDB, 0,
5603 "unlock all the locked entries in the VLDB");
5604 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5605 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5608 ts = cmd_CreateSyntax("lock", LockEntry, 0,
5609 "lock VLDB entry for a volume");
5610 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5613 ts = cmd_CreateSyntax("changeaddr", ChangeAddr, 0,
5614 "change the IP address of a file server");
5615 cmd_AddParm(ts, "-oldaddr", CMD_SINGLE, 0, "original IP address");
5616 cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
5617 cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL,
5618 "remove the IP address from the VLDB");
5621 ts = cmd_CreateSyntax("listaddrs", ListAddrs, 0,
5622 "list the IP address of all file servers registered in the VLDB");
5623 cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
5624 cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
5625 cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL,
5626 "don't resolve addresses");
5627 cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
5628 "print uuid of hosts");
5631 ts = cmd_CreateSyntax("convertROtoRW", ConvertRO, 0,
5632 "convert a RO volume into a RW volume (after loss of old RW volume)");
5633 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5634 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5635 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5636 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "don't ask");
5639 ts = cmd_CreateSyntax("size", Sizes, 0,
5640 "obtain various sizes of the volume.");
5641 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5642 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5643 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5644 cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL,
5645 "Obtain the size of the dump");
5646 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5649 code = cmd_Dispatch(argc, argv);
5651 /* Shut down the ubik_client and rx connections */
5653 (void)ubik_ClientDestroy(cstruct);
5659 exit((code ? -1 : 0));