2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
16 #include <sys/types.h>
26 #include <netinet/in.h>
27 #include <arpa/inet.h>
31 #include <sys/statfs.h>
39 #include <rx/rx_globals.h>
41 #include <afs/vlserver.h>
42 #include <afs/cellconfig.h>
44 #include <afs/afsutil.h>
46 #include <afs/afsint.h>
51 #include <afs/ihandle.h>
52 #include <afs/vnode.h>
53 #include <afs/volume.h>
60 #include "volser_prototypes.h"
62 #ifdef HAVE_POSIX_REGEX
76 #define COMMONPARMS cmd_Seek(ts, 12);\
77 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
78 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");\
79 cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
80 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
81 cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
83 #define ERROR_EXIT(code) {error=(code); goto error_exit;}
87 struct rx_connection *tconn;
89 extern struct ubik_client *cstruct;
92 static struct tqHead busyHead, notokHead;
95 qInit(struct tqHead *ahead)
97 memset((char *)ahead, 0, sizeof(struct tqHead));
103 qPut(struct tqHead *ahead, afs_int32 volid)
107 elem = (struct tqElem *)malloc(sizeof(struct tqElem));
108 elem->next = ahead->next;
116 qGet(struct tqHead *ahead, afs_int32 *volid)
120 if (ahead->count <= 0)
122 *volid = ahead->next->volid;
124 ahead->next = tmp->next;
130 /* returns 1 if <filename> exists else 0 */
132 FileExists(char *filename)
138 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
142 code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
150 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
152 VolNameOK(char *name)
157 total = strlen(name);
158 if (!strcmp(&name[total - 9], ".readonly")) {
160 } else if (!strcmp(&name[total - 7], ".backup")) {
167 /* return 1 if name is a number else 0 */
169 IsNumeric(char *name)
177 for (i = 0; i < len; i++) {
178 if (*ptr < '0' || *ptr > '9') {
190 * Parse a server name/address and return the address in HOST BYTE order
193 GetServer(char *aname)
195 register struct hostent *th;
198 register afs_int32 code;
199 char hostname[MAXHOSTCHARS];
201 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
203 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
204 addr = ntohl(addr); /* convert to host order */
206 th = gethostbyname(aname);
209 memcpy(&addr, th->h_addr, sizeof(addr));
212 if (addr == htonl(0x7f000001)) { /* local host */
213 code = gethostname(hostname, MAXHOSTCHARS);
216 th = gethostbyname(hostname); /* returns host byte order */
219 memcpy(&addr, th->h_addr, sizeof(addr));
226 GetVolumeType(char *aname)
229 if (!strcmp(aname, "ro"))
231 else if (!strcmp(aname, "rw"))
233 else if (!strcmp(aname, "bk"))
240 IsPartValid(afs_int32 partId, afs_int32 server, afs_int32 *code)
242 struct partList dummyPartList;
248 *code = UV_ListPartitions(server, &dummyPartList, &cnt);
251 for (i = 0; i < cnt; i++) {
252 if (dummyPartList.partFlags[i] & PARTVALID)
253 if (dummyPartList.partId[i] == partId)
261 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
262 * associated with <call> */
264 SendFile(usd_handle_t ufd, register struct rx_call *call, long blksize)
266 char *buffer = (char *)0;
271 buffer = (char *)malloc(blksize);
273 fprintf(STDERR, "malloc failed\n");
277 while (!error && !done) {
278 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
281 FD_SET((int)(ufd->handle), &in);
282 /* don't timeout if read blocks */
283 IOMGR_Select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
285 error = USD_READ(ufd, buffer, blksize, &nbytes);
287 fprintf(STDERR, "File system read failed\n");
294 if (rx_Write(call, buffer, nbytes) != nbytes) {
304 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
305 * writes it out to the volume. */
307 WriteData(struct rx_call *call, char *rock)
312 afs_int32 error, code;
314 afs_hyper_t filesize, currOffset;
321 if (!filename || !*filename) {
322 usd_StandardInput(&ufd);
326 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
329 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
332 fprintf(STDERR, "Could not access file '%s'\n", filename);
336 /* test if we have a valid dump */
337 hset64(filesize, 0, 0);
338 USD_SEEK(ufd, filesize, SEEK_END, &currOffset);
339 hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32));
340 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
341 USD_READ(ufd, &buffer, sizeof(afs_uint32), &got);
342 if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
343 fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
347 /* rewind, we are done */
348 hset64(filesize, 0, 0);
349 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
351 code = SendFile(ufd, call, blksize);
358 code = USD_CLOSE(ufd);
360 fprintf(STDERR, "Could not close dump file %s\n",
361 (filename && *filename) ? filename : "STDOUT");
369 /* Receive data from <call> stream into file associated
370 * with <fd> <blksize>
373 ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize)
377 afs_uint32 bytesleft, w;
380 buffer = (char *)malloc(blksize);
382 fprintf(STDERR, "memory allocation failed\n");
386 while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {
387 for (bytesleft = bytesread; bytesleft; bytesleft -= w) {
388 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
391 FD_SET((int)(ufd->handle), &out);
392 /* don't timeout if write blocks */
393 IOMGR_Select(((int)(ufd->handle)) + 1, 0, &out, 0, 0);
396 USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
398 fprintf(STDERR, "File system write failed\n");
411 DumpFunction(struct rx_call *call, char *filename)
413 usd_handle_t ufd; /* default is to stdout */
414 afs_int32 error = 0, code;
419 /* Open the output file */
420 if (!filename || !*filename) {
421 usd_StandardOutput(&ufd);
426 usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
430 code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
433 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
436 fprintf(STDERR, "Could not create file '%s'\n", filename);
437 ERROR_EXIT(VOLSERBADOP);
441 code = ReceiveFile(ufd, call, blksize);
446 /* Close the output file */
448 code = USD_CLOSE(ufd);
450 fprintf(STDERR, "Could not close dump file %s\n",
451 (filename && *filename) ? filename : "STDIN");
462 vos_ctime(afs_int32 *timep)
468 #define vos_ctime ctime
472 DisplayFormat(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
475 afs_int32 server, part;
476 int *totalOK, *totalNotOK, *totalBusy;
477 int fast, longlist, disp;
482 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
483 } else if (longlist) {
484 if (pntr->status == VOK) {
485 fprintf(STDOUT, "%-32s ", pntr->name);
486 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
488 fprintf(STDOUT, "RW ");
490 fprintf(STDOUT, "RO ");
492 fprintf(STDOUT, "BK ");
493 fprintf(STDOUT, "%10d K ", pntr->size);
494 if (pntr->inUse == 1) {
495 fprintf(STDOUT, "On-line");
498 fprintf(STDOUT, "Off-line");
501 if (pntr->needsSalvaged == 1)
502 fprintf(STDOUT, "**needs salvage**");
503 fprintf(STDOUT, "\n");
504 MapPartIdIntoName(part, pname);
505 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
507 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
508 (unsigned long)pntr->parentID,
509 (unsigned long)pntr->cloneID,
510 (unsigned long)pntr->backupID);
511 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
512 fprintf(STDOUT, " Creation %s",
513 vos_ctime(& pntr->creationDate));
514 #ifdef FULL_LISTVOL_SWITCH
515 fprintf(STDOUT, " Copy %s",
516 vos_ctime( & pntr->copyDate));
517 if (!pntr->backupDate)
518 fprintf(STDOUT, " Backup Never\n");
520 fprintf(STDOUT, " Backup %s",
521 vos_ctime( & pntr->backupDate));
522 if (pntr->accessDate)
523 fprintf(STDOUT, " Last Access %s",
524 vos_ctime( & pntr->accessDate));
526 if (!pntr->updateDate)
527 fprintf(STDOUT, " Last Update Never\n");
529 fprintf(STDOUT, " Last Update %s",
530 vos_ctime( & pntr->updateDate));
532 " %d accesses in the past day (i.e., vnode references)\n",
535 } else if (pntr->status == VBUSY) {
537 qPut(&busyHead, pntr->volid);
539 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
540 (unsigned long)pntr->volid);
543 qPut(¬okHead, pntr->volid);
545 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
546 (unsigned long)pntr->volid);
548 fprintf(STDOUT, "\n");
549 } else { /* default listing */
550 if (pntr->status == VOK) {
551 fprintf(STDOUT, "%-32s ", pntr->name);
552 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
554 fprintf(STDOUT, "RW ");
556 fprintf(STDOUT, "RO ");
558 fprintf(STDOUT, "BK ");
559 fprintf(STDOUT, "%10d K ", pntr->size);
560 if (pntr->inUse == 1) {
561 fprintf(STDOUT, "On-line");
564 fprintf(STDOUT, "Off-line");
567 if (pntr->needsSalvaged == 1)
568 fprintf(STDOUT, "**needs salvage**");
569 fprintf(STDOUT, "\n");
570 } else if (pntr->status == VBUSY) {
572 qPut(&busyHead, pntr->volid);
574 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
575 (unsigned long)pntr->volid);
578 qPut(¬okHead, pntr->volid);
580 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
581 (unsigned long)pntr->volid);
586 /*------------------------------------------------------------------------
587 * PRIVATE XDisplayFormat
590 * Display the contents of one extended volume info structure.
593 * a_xInfoP : Ptr to extended volume info struct to print.
594 * a_servID : Server ID to print.
595 * a_partID : Partition ID to print.
596 * a_totalOKP : Ptr to total-OK counter.
597 * a_totalNotOKP : Ptr to total-screwed counter.
598 * a_totalBusyP : Ptr to total-busy counter.
599 * a_fast : Fast listing?
600 * a_int32 : Int32 listing?
601 * a_showProblems : Show volume problems?
607 * Nothing interesting.
611 *------------------------------------------------------------------------*/
614 XDisplayFormat(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
615 a_totalBusyP, a_fast, a_int32, a_showProblems)
616 volintXInfo *a_xInfoP;
626 { /*XDisplayFormat */
634 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
635 } else if (a_int32) {
637 * Fully-detailed listing.
639 if (a_xInfoP->status == VOK) {
641 * Volume's status is OK - all the fields are valid.
643 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
644 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
645 if (a_xInfoP->type == 0)
646 fprintf(STDOUT, "RW ");
647 if (a_xInfoP->type == 1)
648 fprintf(STDOUT, "RO ");
649 if (a_xInfoP->type == 2)
650 fprintf(STDOUT, "BK ");
651 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
652 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
653 if (a_xInfoP->inUse == 1) {
654 fprintf(STDOUT, "On-line");
657 fprintf(STDOUT, "Off-line");
660 fprintf(STDOUT, "\n");
661 MapPartIdIntoName(a_partID, pname);
662 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
664 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
665 (unsigned long)a_xInfoP->parentID,
666 (unsigned long)a_xInfoP->cloneID,
667 (unsigned long)a_xInfoP->backupID);
668 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
669 fprintf(STDOUT, " Creation %s",
670 vos_ctime( & a_xInfoP->creationDate));
671 #ifdef FULL_LISTVOL_SWITCH
672 fprintf(STDOUT, " Copy %s",
673 vos_ctime( & a_xInfoP->copyDate));
674 if (!a_xInfoP->backupDate)
675 fprintf(STDOUT, " Backup Never\n");
677 fprintf(STDOUT, " Backup %s",
678 vos_ctime( & a_xInfoP->backupDate));
679 if (a_xInfoP->accessDate)
680 fprintf(STDOUT, " Last Access %s",
681 vos_ctime( & a_xInfoP->accessDate));
683 if (!a_xInfoP->updateDate)
684 fprintf(STDOUT, " Last Update Never\n");
686 fprintf(STDOUT, " Last Update %s",
687 vos_ctime( & a_xInfoP->updateDate));
689 " %d accesses in the past day (i.e., vnode references)\n",
694 * Print all the read/write and authorship stats.
696 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
698 " |-------------------------------------------|\n");
700 " | Same Network | Diff Network |\n");
702 " |----------|----------|----------|----------|\n");
704 " | Total | Auth | Total | Auth |\n");
706 " |----------|----------|----------|----------|\n");
707 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
708 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
709 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
710 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
711 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
712 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
713 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
714 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
715 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
716 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
718 " |-------------------------------------------|\n\n");
721 " Writes Affecting Authorship\n");
723 " |-------------------------------------------|\n");
725 " | File Authorship | Directory Authorship|\n");
727 " |----------|----------|----------|----------|\n");
729 " | Same | Diff | Same | Diff |\n");
731 " |----------|----------|----------|----------|\n");
732 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
733 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
734 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
735 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
736 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
737 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
738 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
739 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
740 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
741 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
742 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
743 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
744 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
745 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
746 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
747 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
748 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
749 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
750 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
751 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
752 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
753 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
754 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
755 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
756 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
757 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
758 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
759 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
760 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
761 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
763 " |-------------------------------------------|\n");
764 } /*Volume status OK */
765 else if (a_xInfoP->status == VBUSY) {
767 qPut(&busyHead, a_xInfoP->volid);
769 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
770 (unsigned long)a_xInfoP->volid);
774 qPut(¬okHead, a_xInfoP->volid);
776 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
777 (unsigned long)a_xInfoP->volid);
778 } /*Screwed volume */
779 fprintf(STDOUT, "\n");
785 if (a_xInfoP->status == VOK) {
786 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
787 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
788 if (a_xInfoP->type == 0)
789 fprintf(STDOUT, "RW ");
790 if (a_xInfoP->type == 1)
791 fprintf(STDOUT, "RO ");
792 if (a_xInfoP->type == 2)
793 fprintf(STDOUT, "BK ");
794 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
795 if (a_xInfoP->inUse == 1) {
796 fprintf(STDOUT, "On-line");
799 fprintf(STDOUT, "Off-line");
802 fprintf(STDOUT, "\n");
804 else if (a_xInfoP->status == VBUSY) {
806 qPut(&busyHead, a_xInfoP->volid);
808 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
809 (unsigned long)a_xInfoP->volid);
813 qPut(¬okHead, a_xInfoP->volid);
815 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
816 (unsigned long)a_xInfoP->volid);
817 } /*Screwed volume */
818 } /*Default listing */
819 } /*XDisplayFormat */
821 #ifdef FULL_LISTVOL_SWITCH
822 /*------------------------------------------------------------------------
823 * PRIVATE XDisplayFormat2
826 * Display the formated contents of one extended volume info structure.
829 * a_xInfoP : Ptr to extended volume info struct to print.
830 * a_servID : Server ID to print.
831 * a_partID : Partition ID to print.
832 * a_totalOKP : Ptr to total-OK counter.
833 * a_totalNotOKP : Ptr to total-screwed counter.
834 * a_totalBusyP : Ptr to total-busy counter.
835 * a_fast : Fast listing?
836 * a_int32 : Int32 listing?
837 * a_showProblems : Show volume problems?
843 * Nothing interesting.
847 *------------------------------------------------------------------------*/
850 XDisplayFormat2(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
851 a_totalBusyP, a_fast, a_int32, a_showProblems)
852 volintXInfo *a_xInfoP;
862 { /*XDisplayFormat */
867 fprintf(STDOUT, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP->volid);
868 } else if (a_int32) {
870 * Fully-detailed listing.
872 if (a_xInfoP->status == VOK) {
874 * Volume's status is OK - all the fields are valid.
877 static long server_cache = -1, partition_cache = -1;
878 static char hostname[256], address[32], pname[16];
879 int i,ai[] = {VOLINT_STATS_TIME_IDX_0,VOLINT_STATS_TIME_IDX_1,VOLINT_STATS_TIME_IDX_2,
880 VOLINT_STATS_TIME_IDX_3,VOLINT_STATS_TIME_IDX_4,VOLINT_STATS_TIME_IDX_5};
882 if (a_servID != server_cache) {
886 strcpy(hostname, hostutil_GetNameByINet(a_servID));
887 strcpy(address, inet_ntoa(s));
888 server_cache = a_servID;
890 if (a_partID != partition_cache) {
891 MapPartIdIntoName(a_partID, pname);
892 partition_cache = a_partID;
895 fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name);
896 fprintf(STDOUT, "id\t\t%lu\n", a_xInfoP->volid);
897 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
898 fprintf(STDOUT, "part\t\t%s\n", pname);
899 switch (a_xInfoP->status) {
901 fprintf(STDOUT, "status\t\tOK\n");
904 fprintf(STDOUT, "status\t\tBUSY\n");
907 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
910 fprintf(STDOUT, "backupID\t%lu\n", a_xInfoP->backupID);
911 fprintf(STDOUT, "parentID\t%lu\n", a_xInfoP->parentID);
912 fprintf(STDOUT, "cloneID\t\t%lu\n", a_xInfoP->cloneID);
913 fprintf(STDOUT, "inUse\t\t%s\n", a_xInfoP->inUse ? "Y" : "N");
914 switch (a_xInfoP->type) {
916 fprintf(STDOUT, "type\t\tRW\n");
919 fprintf(STDOUT, "type\t\tRO\n");
922 fprintf(STDOUT, "type\t\tBK\n");
925 fprintf(STDOUT, "type\t\t?\n");
928 fprintf(STDOUT, "creationDate\t%-9lu\t%s", a_xInfoP->creationDate,
929 vos_ctime(&a_xInfoP->creationDate));
930 fprintf(STDOUT, "accessDate\t%-9lu\t%s", a_xInfoP->accessDate,
931 vos_ctime(&a_xInfoP->accessDate));
932 fprintf(STDOUT, "updateDate\t%-9lu\t%s", a_xInfoP->updateDate,
933 vos_ctime(&a_xInfoP->updateDate));
934 fprintf(STDOUT, "backupDate\t%-9lu\t%s", a_xInfoP->backupDate,
935 vos_ctime(&a_xInfoP->backupDate));
936 fprintf(STDOUT, "copyDate\t%-9lu\t%s", a_xInfoP->copyDate,
937 vos_ctime(&a_xInfoP->copyDate));
939 fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
940 fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
942 fprintf(STDOUT, "filecount\t%u\n", a_xInfoP->filecount);
943 fprintf(STDOUT, "dayUse\t\t%u\n", a_xInfoP->dayUse);
947 fprintf(STDOUT,"reads_same_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]);
948 fprintf(STDOUT,"reads_same_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]);
949 fprintf(STDOUT,"reads_diff_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]);
950 fprintf(STDOUT,"reads_diff_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
952 fprintf(STDOUT,"writes_same_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]);
953 fprintf(STDOUT,"writes_same_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]);
954 fprintf(STDOUT,"writes_diff_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]);
955 fprintf(STDOUT,"writes_diff_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
959 fprintf(STDOUT,"file_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileSameAuthor[ai[i]]);
960 fprintf(STDOUT,"file_diff_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileDiffAuthor[ai[i]]);
961 fprintf(STDOUT,"dir_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirSameAuthor[ai[i]]);
962 fprintf(STDOUT,"dir_dif_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirDiffAuthor[ai[i]]);
965 } /*Volume status OK */
966 else if (a_xInfoP->status == VBUSY) {
968 qPut(&busyHead, a_xInfoP->volid);
970 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
971 (unsigned long)a_xInfoP->volid);
975 qPut(¬okHead, a_xInfoP->volid);
977 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
978 (unsigned long)a_xInfoP->volid);
979 } /*Screwed volume */
985 if (a_xInfoP->status == VOK) {
986 fprintf(STDOUT, "name\t%-32s\n", a_xInfoP->name);
987 fprintf(STDOUT, "volID\t%10lu\n", (unsigned long)a_xInfoP->volid);
988 if (a_xInfoP->type == 0)
989 fprintf(STDOUT, "type\tRW\n");
990 if (a_xInfoP->type == 1)
991 fprintf(STDOUT, "type\tRO\n");
992 if (a_xInfoP->type == 2)
993 fprintf(STDOUT, "type\tBK\n");
994 fprintf(STDOUT, "size\t%10dK\n", a_xInfoP->size);
996 fprintf(STDOUT, "inUse\t%d\n",a_xInfoP->inUse);
997 if (a_xInfoP->inUse == 1)
1003 else if (a_xInfoP->status == VBUSY) {
1005 qPut(&busyHead, a_xInfoP->volid);
1007 fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
1008 (unsigned long)a_xInfoP->volid);
1012 qPut(¬okHead, a_xInfoP->volid);
1014 fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
1015 (unsigned long)a_xInfoP->volid);
1016 } /*Screwed volume */
1017 } /*Default listing */
1018 } /*XDisplayFormat */
1019 #endif /*FULL_LISTVOL_SWITCH*/
1021 #ifdef FULL_LISTVOL_SWITCH
1023 DisplayFormat2(server, partition, pntr)
1024 long server, partition;
1027 static long server_cache = -1, partition_cache = -1;
1028 static char hostname[256], address[32], pname[16];
1030 if (server != server_cache) {
1034 strcpy(hostname, hostutil_GetNameByINet(server));
1035 strcpy(address, inet_ntoa(s));
1036 server_cache = server;
1038 if (partition != partition_cache) {
1039 MapPartIdIntoName(partition, pname);
1040 partition_cache = partition;
1042 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
1043 fprintf(STDOUT, "id\t\t%lu\n", pntr->volid);
1044 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
1045 fprintf(STDOUT, "part\t\t%s\n", pname);
1046 switch (pntr->status) {
1048 fprintf(STDOUT, "status\t\tOK\n");
1051 fprintf(STDOUT, "status\t\tBUSY\n");
1054 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
1057 fprintf(STDOUT, "backupID\t%lu\n", pntr->backupID);
1058 fprintf(STDOUT, "parentID\t%lu\n", pntr->parentID);
1059 fprintf(STDOUT, "cloneID\t\t%lu\n", pntr->cloneID);
1060 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
1061 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
1062 /* 0xD3 is from afs/volume.h since I had trouble including the file */
1063 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
1064 switch (pntr->type) {
1066 fprintf(STDOUT, "type\t\tRW\n");
1069 fprintf(STDOUT, "type\t\tRO\n");
1072 fprintf(STDOUT, "type\t\tBK\n");
1075 fprintf(STDOUT, "type\t\t?\n");
1078 fprintf(STDOUT, "creationDate\t%-9lu\t%s", pntr->creationDate,
1079 vos_ctime(&pntr->creationDate));
1080 fprintf(STDOUT, "accessDate\t%-9lu\t%s", pntr->accessDate,
1081 vos_ctime(&pntr->accessDate));
1082 fprintf(STDOUT, "updateDate\t%-9lu\t%s", pntr->updateDate,
1083 vos_ctime(&pntr->updateDate));
1084 fprintf(STDOUT, "backupDate\t%-9lu\t%s", pntr->backupDate,
1085 vos_ctime(&pntr->backupDate));
1086 fprintf(STDOUT, "copyDate\t%-9lu\t%s", pntr->copyDate,
1087 vos_ctime(&pntr->copyDate));
1088 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n", pntr->flags);
1089 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
1090 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
1091 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n", pntr->spare0);
1092 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
1093 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
1094 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n", pntr->spare1);
1095 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n", pntr->spare2);
1096 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n", pntr->spare3);
1101 DisplayVolumes2(server, partition, pntr, count)
1103 long server, partition, count;
1107 for (i = 0; i < count; i++) {
1108 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1109 DisplayFormat2(server, partition, pntr);
1110 fprintf(STDOUT, "END_OF_ENTRY\n\n");
1115 #endif /* FULL_LISTVOL_SWITCH */
1118 DisplayVolumes(server, part, pntr, count, longlist, fast, quiet)
1119 afs_int32 server, part;
1121 afs_int32 count, longlist, fast;
1124 int totalOK, totalNotOK, totalBusy, i;
1132 for (i = 0; i < count; i++) {
1133 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
1138 while (busyHead.count) {
1139 qGet(&busyHead, &volid);
1140 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1141 (unsigned long)volid);
1145 while (notokHead.count) {
1146 qGet(¬okHead, &volid);
1147 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1148 (unsigned long)volid);
1152 fprintf(STDOUT, "\n");
1155 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
1156 totalOK, totalNotOK, totalBusy);
1160 /*------------------------------------------------------------------------
1161 * PRIVATE XDisplayVolumes
1164 * Display extended volume information.
1167 * a_servID : Pointer to the Rx call we're performing.
1168 * a_partID : Partition for which we want the extended list.
1169 * a_xInfoP : Ptr to extended volume info.
1170 * a_count : Number of volume records contained above.
1171 * a_int32 : Int32 listing generated?
1172 * a_fast : Fast listing generated?
1173 * a_quiet : Quiet listing generated?
1179 * Nothing interesting.
1183 *------------------------------------------------------------------------*/
1186 XDisplayVolumes(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
1190 volintXInfo *a_xInfoP;
1196 { /*XDisplayVolumes */
1198 int totalOK; /*Total OK volumes */
1199 int totalNotOK; /*Total screwed volumes */
1200 int totalBusy; /*Total busy volumes */
1201 int i; /*Loop variable */
1202 afs_int32 volid; /*Current volume ID */
1205 * Initialize counters and (global!!) queues.
1214 * Display each volume in the list.
1216 for (i = 0; i < a_count; i++) {
1217 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1218 &totalBusy, a_fast, a_int32, 0);
1223 * If any volumes were found to be busy or screwed, display them.
1226 while (busyHead.count) {
1227 qGet(&busyHead, &volid);
1228 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1229 (unsigned long)volid);
1233 while (notokHead.count) {
1234 qGet(¬okHead, &volid);
1235 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1236 (unsigned long)volid);
1241 fprintf(STDOUT, "\n");
1244 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1245 totalOK, totalNotOK, totalBusy);
1249 } /*XDisplayVolumes */
1250 #ifdef FULL_LISTVOL_SWITCH
1251 /*------------------------------------------------------------------------
1252 * PRIVATE XDisplayVolumes2
1255 * Display extended formated volume information.
1258 * a_servID : Pointer to the Rx call we're performing.
1259 * a_partID : Partition for which we want the extended list.
1260 * a_xInfoP : Ptr to extended volume info.
1261 * a_count : Number of volume records contained above.
1262 * a_int32 : Int32 listing generated?
1263 * a_fast : Fast listing generated?
1264 * a_quiet : Quiet listing generated?
1270 * Nothing interesting.
1274 *------------------------------------------------------------------------*/
1277 XDisplayVolumes2(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
1281 volintXInfo *a_xInfoP;
1287 { /*XDisplayVolumes */
1289 int totalOK; /*Total OK volumes */
1290 int totalNotOK; /*Total screwed volumes */
1291 int totalBusy; /*Total busy volumes */
1292 int i; /*Loop variable */
1293 afs_int32 volid; /*Current volume ID */
1296 * Initialize counters and (global!!) queues.
1305 * Display each volume in the list.
1307 for (i = 0; i < a_count; i++) {
1308 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1309 XDisplayFormat2(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1310 &totalBusy, a_fast, a_int32, 0);
1311 fprintf(STDOUT, "END_OF_ENTRY\n");
1316 * If any volumes were found to be busy or screwed, display them.
1319 while (busyHead.count) {
1320 qGet(&busyHead, &volid);
1321 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1322 (unsigned long)volid);
1326 while (notokHead.count) {
1327 qGet(¬okHead, &volid);
1328 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1329 (unsigned long)volid);
1334 fprintf(STDOUT, "\n");
1337 "VOLUMES_ONLINE\t%d\nVOLUMES_OFFLINE\t%d\nVOLUMES_BUSY\t%d\n",
1338 totalOK, totalNotOK, totalBusy);
1342 } /*XDisplayVolumes2 */
1343 #endif /* FULL_LISTVOL_SWITCH */
1346 /* set <server> and <part> to the correct values depending on
1347 * <voltype> and <entry> */
1349 GetServerAndPart(entry, voltype, server, part, previdx)
1350 struct nvldbentry *entry;
1351 afs_int32 *server, *part;
1355 int i, istart, vtype;
1360 /* Doesn't check for non-existance of backup volume */
1361 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1363 istart = 0; /* seach the entire entry */
1366 /* Seach from beginning of entry or pick up where we left off */
1367 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1370 for (i = istart; i < entry->nServers; i++) {
1371 if (entry->serverFlags[i] & vtype) {
1372 *server = entry->serverNumber[i];
1373 *part = entry->serverPartition[i];
1379 /* Didn't find any, return -1 */
1385 PostVolumeStats(entry)
1386 struct nvldbentry *entry;
1388 SubEnumerateEntry(entry);
1389 /* Check for VLOP_ALLOPERS */
1390 if (entry->flags & VLOP_ALLOPERS)
1391 fprintf(STDOUT, " Volume is currently LOCKED \n");
1395 /*------------------------------------------------------------------------
1396 * PRIVATE XVolumeStats
1399 * Display extended volume information.
1402 * a_xInfoP : Ptr to extended volume info.
1403 * a_entryP : Ptr to the volume's VLDB entry.
1404 * a_srvID : Server ID.
1405 * a_partID : Partition ID.
1406 * a_volType : Type of volume to print.
1412 * Nothing interesting.
1416 *------------------------------------------------------------------------*/
1419 XVolumeStats(a_xInfoP, a_entryP, a_srvID, a_partID, a_volType)
1420 volintXInfo *a_xInfoP;
1421 struct nvldbentry *a_entryP;
1428 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1430 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1431 a_srvID, /*Server ID to print */
1432 a_partID, /*Partition ID to print */
1433 &totalOK, /*Ptr to total-OK counter */
1434 &totalNotOK, /*Ptr to total-screwed counter */
1435 &totalBusy, /*Ptr to total-busy counter */
1436 0, /*Don't do a fast listing */
1437 1, /*Do a long listing */
1438 1); /*Show volume problems */
1444 VolumeStats(pntr, entry, server, part, voltype)
1446 struct nvldbentry *entry;
1448 afs_int32 server, part;
1450 int totalOK, totalNotOK, totalBusy;
1452 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1457 /* command to forcibly remove a volume */
1459 NukeVolume(register struct cmd_syndesc *as)
1461 register afs_int32 code;
1462 afs_int32 volID, err;
1467 server = GetServer(tp = as->parms[0].items->data);
1469 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1473 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1475 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1479 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1482 PrintError("", err);
1485 "vos: could not parse '%s' as a numeric volume ID", tp);
1490 "vos: forcibly removing all traces of volume %d, please wait...",
1493 code = UV_NukeVolume(server, partID, volID);
1495 fprintf(STDOUT, "done.\n");
1497 fprintf(STDOUT, "failed with code %d.\n", code);
1502 /*------------------------------------------------------------------------
1503 * PRIVATE ExamineVolume
1506 * Routine used to examine a single volume, contacting the VLDB as
1507 * well as the Volume Server.
1510 * as : Ptr to parsed command line arguments.
1513 * 0 for a successful operation,
1514 * Otherwise, one of the ubik or VolServer error values.
1517 * Nothing interesting.
1521 *------------------------------------------------------------------------
1524 ExamineVolume(register struct cmd_syndesc *as, void *arock)
1526 struct nvldbentry entry;
1527 afs_int32 vcode = 0;
1528 volintInfo *pntr = (volintInfo *) 0;
1529 volintXInfo *xInfoP = (volintXInfo *) 0;
1531 afs_int32 code, err, error = 0;
1532 int voltype, foundserv = 0, foundentry = 0;
1533 afs_int32 aserver, apart;
1535 int wantExtendedInfo; /*Do we want extended vol info? */
1537 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1539 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1542 PrintError("", err);
1544 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1545 as->parms[0].items->data);
1550 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1551 (unsigned long)volid);
1554 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1557 "Could not fetch the entry for volume number %lu from VLDB \n",
1558 (unsigned long)volid);
1562 fprintf(STDOUT, "done\n");
1563 MapHostToNetwork(&entry);
1565 if (entry.volumeId[RWVOL] == volid)
1567 else if (entry.volumeId[BACKVOL] == volid)
1569 else /* (entry.volumeId[ROVOL] == volid) */
1572 do { /* do {...} while (voltype == ROVOL) */
1573 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1574 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1575 * If its a RO vol, get the next RO entry.
1577 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1578 &aserver, &apart, &previdx);
1579 if (previdx == -1) { /* searched all entries */
1581 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1582 as->parms[0].items->data);
1589 /* Get information about the volume from the server */
1591 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1592 hostutil_GetNameByINet(aserver));
1595 if (wantExtendedInfo)
1596 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1598 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1600 fprintf(STDOUT, "done\n");
1604 if (code == ENODEV) {
1605 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1606 /* The VLDB says there is no backup volume and its not on disk */
1607 fprintf(STDERR, "Volume %s does not exist\n",
1608 as->parms[0].items->data);
1612 "Volume does not exist on server %s as indicated by the VLDB\n",
1613 hostutil_GetNameByINet(aserver));
1616 PrintDiagnostics("examine", code);
1618 fprintf(STDOUT, "\n");
1621 if (wantExtendedInfo)
1622 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1624 #ifdef FULL_LISTVOL_SWITCH
1625 if (as->parms[2].items) {
1626 DisplayFormat2(aserver, apart, pntr);
1627 EnumerateEntry(&entry);
1629 #endif /* FULL_LISTVOL_SWITCH */
1630 VolumeStats(pntr, &entry, aserver, apart, voltype);
1632 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1633 /* The VLDB says there is no backup volume yet we found one on disk */
1634 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1635 as->parms[0].items->data);
1644 } while (voltype == ROVOL);
1647 fprintf(STDERR, "Dump only information from VLDB\n\n");
1648 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1650 PostVolumeStats(&entry);
1655 /*------------------------------------------------------------------------
1659 * Routine used to change the status of a single volume.
1662 * as : Ptr to parsed command line arguments.
1665 * 0 for a successful operation,
1666 * Otherwise, one of the ubik or VolServer error values.
1669 * Nothing interesting.
1673 *------------------------------------------------------------------------
1676 SetFields(register struct cmd_syndesc *as, void *arock)
1678 struct nvldbentry entry;
1679 afs_int32 vcode = 0;
1682 afs_int32 code, err;
1683 afs_int32 aserver, apart;
1686 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1689 PrintError("", err);
1691 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1692 as->parms[0].items->data);
1696 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1699 "Could not fetch the entry for volume number %lu from VLDB \n",
1700 (unsigned long)volid);
1703 MapHostToNetwork(&entry);
1705 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1706 if (previdx == -1) {
1707 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1708 as->parms[0].items->data);
1712 init_volintInfo(&info);
1716 if (as->parms[1].items) {
1718 code = util_GetInt32(as->parms[1].items->data, &info.maxquota);
1720 fprintf(STDERR, "invalid quota value\n");
1724 if (as->parms[2].items) {
1728 if (as->parms[3].items) {
1729 /* -clearVolUpCounter */
1732 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1735 "Could not update volume info fields for volume number %lu\n",
1736 (unsigned long)volid);
1740 /*------------------------------------------------------------------------
1744 * Brings a volume online.
1747 * as : Ptr to parsed command line arguments.
1750 * 0 for a successful operation,
1753 * Nothing interesting.
1757 *------------------------------------------------------------------------
1760 volOnline(register struct cmd_syndesc *as, void *arock)
1762 afs_int32 server, partition, volid;
1763 afs_int32 code, err = 0;
1765 server = GetServer(as->parms[0].items->data);
1767 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1768 as->parms[0].items->data);
1772 partition = volutil_GetPartitionID(as->parms[1].items->data);
1773 if (partition < 0) {
1774 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1775 as->parms[1].items->data);
1779 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1782 PrintError("", err);
1784 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1785 as->parms[0].items->data);
1789 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1792 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1799 /*------------------------------------------------------------------------
1800 * PRIVATE volOffline
1803 * Brings a volume offline.
1806 * as : Ptr to parsed command line arguments.
1809 * 0 for a successful operation,
1812 * Nothing interesting.
1816 *------------------------------------------------------------------------
1819 volOffline(register struct cmd_syndesc *as, void *arock)
1821 afs_int32 server, partition, volid;
1822 afs_int32 code, err = 0;
1823 afs_int32 transflag, sleeptime, transdone;
1825 server = GetServer(as->parms[0].items->data);
1827 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1828 as->parms[0].items->data);
1832 partition = volutil_GetPartitionID(as->parms[1].items->data);
1833 if (partition < 0) {
1834 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1835 as->parms[1].items->data);
1839 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1842 PrintError("", err);
1844 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1845 as->parms[0].items->data);
1849 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1850 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1851 transdone = (sleeptime ? 0 /*online */ : VTOutOfService);
1852 if (as->parms[4].items && !as->parms[3].items) {
1853 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1858 UV_SetVolume(server, partition, volid, transflag, transdone,
1861 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1869 CreateVolume(register struct cmd_syndesc *as, void *arock)
1873 afs_int32 volid, code;
1874 struct nvldbentry entry;
1879 tserver = GetServer(as->parms[0].items->data);
1881 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1882 as->parms[0].items->data);
1885 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1887 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1888 as->parms[1].items->data);
1891 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1893 PrintError("", code);
1896 "vos : partition %s does not exist on the server\n",
1897 as->parms[1].items->data);
1900 if (!ISNAMEVALID(as->parms[2].items->data)) {
1902 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1903 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1906 if (!VolNameOK(as->parms[2].items->data)) {
1908 "Illegal volume name %s, should not end in .readonly or .backup\n",
1909 as->parms[2].items->data);
1912 if (IsNumeric(as->parms[2].items->data)) {
1913 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1914 as->parms[2].items->data);
1917 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1919 fprintf(STDERR, "Volume %s already exists\n",
1920 as->parms[2].items->data);
1921 PrintDiagnostics("create", code);
1925 if (as->parms[3].items) {
1926 if (!IsNumeric(as->parms[3].items->data)) {
1927 fprintf(STDERR, "Initial quota %s should be numeric.\n",
1928 as->parms[3].items->data);
1932 code = util_GetInt32(as->parms[3].items->data, "a);
1934 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1940 UV_CreateVolume2(tserver, pnum, as->parms[2].items->data, quota, 0,
1943 PrintDiagnostics("create", code);
1946 MapPartIdIntoName(pnum, part);
1947 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
1948 (unsigned long)volid, part, as->parms[0].items->data);
1955 struct nvldbentry *entry;
1958 afs_int32 error, code, curserver, curpart, volid;
1960 MapHostToNetwork(entry);
1962 for (i = 0; i < entry->nServers; i++) {
1963 curserver = entry->serverNumber[i];
1964 curpart = entry->serverPartition[i];
1965 if (entry->serverFlags[i] & ITSROVOL) {
1966 volid = entry->volumeId[ROVOL];
1968 volid = entry->volumeId[RWVOL];
1970 code = UV_DeleteVolume(curserver, curpart, volid);
1978 DeleteVolume(struct cmd_syndesc *as, void *arock)
1980 afs_int32 err, code = 0;
1981 afs_int32 server = 0, partition = -1, volid;
1985 if (as->parms[0].items) {
1986 server = GetServer(as->parms[0].items->data);
1988 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1989 as->parms[0].items->data);
1994 if (as->parms[1].items) {
1995 partition = volutil_GetPartitionID(as->parms[1].items->data);
1996 if (partition < 0) {
1997 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1998 as->parms[1].items->data);
2002 /* Check for validity of the partition */
2003 if (!IsPartValid(partition, server, &code)) {
2005 PrintError("", code);
2008 "vos : partition %s does not exist on the server\n",
2009 as->parms[1].items->data);
2015 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2017 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
2018 as->parms[2].items->data);
2020 PrintError("", err);
2024 /* If the server or partition option are not complete, try to fill
2025 * them in from the VLDB entry.
2027 if ((partition == -1) || !server) {
2028 struct nvldbentry entry;
2030 code = VLDB_GetEntryByID(volid, -1, &entry);
2033 "Could not fetch the entry for volume %lu from VLDB\n",
2034 (unsigned long)volid);
2035 PrintError("", code);
2039 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
2040 || ((volid == entry.volumeId[BACKVOL])
2041 && (entry.flags & BACK_EXISTS))) {
2042 idx = Lp_GetRwIndex(&entry);
2043 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2044 || ((partition != -1)
2045 && (partition != entry.serverPartition[idx]))) {
2046 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2047 as->parms[2].items->data);
2050 } else if ((volid == entry.volumeId[ROVOL])
2051 && (entry.flags & RO_EXISTS)) {
2052 for (idx = -1, j = 0; j < entry.nServers; j++) {
2053 if (entry.serverFlags[j] != ITSROVOL)
2056 if (((server == 0) || (server == entry.serverNumber[j]))
2057 && ((partition == -1)
2058 || (partition == entry.serverPartition[j]))) {
2061 "VLDB: Volume '%s' matches more than one RO\n",
2062 as->parms[2].items->data);
2069 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2070 as->parms[2].items->data);
2074 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2075 as->parms[2].items->data);
2079 server = htonl(entry.serverNumber[idx]);
2080 partition = entry.serverPartition[idx];
2084 code = UV_DeleteVolume(server, partition, volid);
2086 PrintDiagnostics("remove", code);
2090 MapPartIdIntoName(partition, pname);
2091 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2092 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2096 #define TESTM 0 /* set for move space tests, clear for production */
2098 MoveVolume(register struct cmd_syndesc *as, void *arock)
2101 afs_int32 volid, fromserver, toserver, frompart, topart;
2102 afs_int32 flags, code, err;
2103 char fromPartName[10], toPartName[10];
2105 struct diskPartition partition; /* for space check */
2108 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2111 PrintError("", err);
2113 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2114 as->parms[0].items->data);
2117 fromserver = GetServer(as->parms[1].items->data);
2118 if (fromserver == 0) {
2119 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2120 as->parms[1].items->data);
2123 toserver = GetServer(as->parms[3].items->data);
2124 if (toserver == 0) {
2125 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2126 as->parms[3].items->data);
2129 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2131 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2132 as->parms[2].items->data);
2135 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2137 PrintError("", code);
2140 "vos : partition %s does not exist on the server\n",
2141 as->parms[2].items->data);
2144 topart = volutil_GetPartitionID(as->parms[4].items->data);
2146 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2147 as->parms[4].items->data);
2150 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2152 PrintError("", code);
2155 "vos : partition %s does not exist on the server\n",
2156 as->parms[4].items->data);
2161 if (as->parms[5].items) flags |= RV_NOCLONE;
2164 * check source partition for space to clone volume
2167 MapPartIdIntoName(topart, toPartName);
2168 MapPartIdIntoName(frompart, fromPartName);
2171 * check target partition for space to move volume
2174 code = UV_PartitionInfo(toserver, toPartName, &partition);
2176 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2180 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2183 p = (volintInfo *) 0;
2184 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2186 fprintf(STDERR, "vos:cannot access volume %lu\n",
2187 (unsigned long)volid);
2191 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2193 if (partition.free <= p->size) {
2195 "vos: no space on target partition %s to move volume %lu\n",
2196 toPartName, (unsigned long)volid);
2203 fprintf(STDOUT, "size test - don't do move\n");
2207 /* successful move still not guaranteed but shoot for it */
2210 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2212 PrintDiagnostics("move", code);
2215 MapPartIdIntoName(topart, toPartName);
2216 MapPartIdIntoName(frompart, fromPartName);
2217 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2218 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2219 as->parms[3].items->data, toPartName);
2225 CopyVolume(register struct cmd_syndesc *as, void *arock)
2227 afs_int32 volid, fromserver, toserver, frompart, topart, code, err, flags;
2228 char fromPartName[10], toPartName[10], *tovolume;
2229 struct nvldbentry entry;
2230 struct diskPartition partition; /* for space check */
2233 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2236 PrintError("", err);
2238 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2239 as->parms[0].items->data);
2242 fromserver = GetServer(as->parms[1].items->data);
2243 if (fromserver == 0) {
2244 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2245 as->parms[1].items->data);
2249 toserver = GetServer(as->parms[4].items->data);
2250 if (toserver == 0) {
2251 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2252 as->parms[4].items->data);
2256 tovolume = as->parms[3].items->data;
2257 if (!ISNAMEVALID(tovolume)) {
2259 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2260 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2263 if (!VolNameOK(tovolume)) {
2265 "Illegal volume name %s, should not end in .readonly or .backup\n",
2269 if (IsNumeric(tovolume)) {
2270 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2274 code = VLDB_GetEntryByName(tovolume, &entry);
2276 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2277 PrintDiagnostics("copy", code);
2281 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2283 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2284 as->parms[2].items->data);
2287 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2289 PrintError("", code);
2292 "vos : partition %s does not exist on the server\n",
2293 as->parms[2].items->data);
2297 topart = volutil_GetPartitionID(as->parms[5].items->data);
2299 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2300 as->parms[5].items->data);
2303 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2305 PrintError("", code);
2308 "vos : partition %s does not exist on the server\n",
2309 as->parms[5].items->data);
2314 if (as->parms[6].items) flags |= RV_OFFLINE;
2315 if (as->parms[7].items) flags |= RV_RDONLY;
2316 if (as->parms[8].items) flags |= RV_NOCLONE;
2318 MapPartIdIntoName(topart, toPartName);
2319 MapPartIdIntoName(frompart, fromPartName);
2322 * check target partition for space to move volume
2325 code = UV_PartitionInfo(toserver, toPartName, &partition);
2327 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2331 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2334 p = (volintInfo *) 0;
2335 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2337 fprintf(STDERR, "vos:cannot access volume %lu\n",
2338 (unsigned long)volid);
2342 if (partition.free <= p->size) {
2344 "vos: no space on target partition %s to copy volume %lu\n",
2345 toPartName, (unsigned long)volid);
2351 /* successful copy still not guaranteed but shoot for it */
2354 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2357 PrintDiagnostics("copy", code);
2360 MapPartIdIntoName(topart, toPartName);
2361 MapPartIdIntoName(frompart, fromPartName);
2362 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2363 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2364 tovolume, as->parms[4].items->data, toPartName);
2371 ShadowVolume(register struct cmd_syndesc *as, void *arock)
2373 afs_int32 volid, fromserver, toserver, frompart, topart, tovolid;
2374 afs_int32 code, err, flags;
2375 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2376 struct nvldbentry entry;
2377 struct diskPartition partition; /* for space check */
2380 p = (volintInfo *) 0;
2381 q = (volintInfo *) 0;
2383 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2386 PrintError("", err);
2388 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2389 as->parms[0].items->data);
2392 fromserver = GetServer(as->parms[1].items->data);
2393 if (fromserver == 0) {
2394 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2395 as->parms[1].items->data);
2399 toserver = GetServer(as->parms[3].items->data);
2400 if (toserver == 0) {
2401 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2402 as->parms[3].items->data);
2406 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2408 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2409 as->parms[2].items->data);
2412 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2414 PrintError("", code);
2417 "vos : partition %s does not exist on the server\n",
2418 as->parms[2].items->data);
2422 topart = volutil_GetPartitionID(as->parms[4].items->data);
2424 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2425 as->parms[4].items->data);
2428 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2430 PrintError("", code);
2433 "vos : partition %s does not exist on the server\n",
2434 as->parms[4].items->data);
2438 if (as->parms[5].items) {
2439 tovolume = as->parms[5].items->data;
2440 if (!ISNAMEVALID(tovolume)) {
2442 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2443 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2446 if (!VolNameOK(tovolume)) {
2448 "Illegal volume name %s, should not end in .readonly or .backup\n",
2452 if (IsNumeric(tovolume)) {
2454 "Illegal volume name %s, should not be a number\n",
2459 /* use actual name of source volume */
2460 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2462 fprintf(STDERR, "vos:cannot access volume %lu\n",
2463 (unsigned long)volid);
2466 strcpy(toVolName, p->name);
2467 tovolume = toVolName;
2468 /* save p for size checks later */
2471 if (as->parms[6].items) {
2472 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2475 PrintError("", err);
2477 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2478 as->parms[6].items->data);
2484 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2487 PrintError("", err);
2489 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2498 if (as->parms[7].items) flags |= RV_OFFLINE;
2499 if (as->parms[8].items) flags |= RV_RDONLY;
2500 if (as->parms[9].items) flags |= RV_NOCLONE;
2501 if (as->parms[10].items) flags |= RV_CPINCR;
2503 MapPartIdIntoName(topart, toPartName);
2504 MapPartIdIntoName(frompart, fromPartName);
2507 * check target partition for space to move volume
2510 code = UV_PartitionInfo(toserver, toPartName, &partition);
2512 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2516 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2519 /* Don't do this again if we did it above */
2521 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2523 fprintf(STDERR, "vos:cannot access volume %lu\n",
2524 (unsigned long)volid);
2529 /* OK if this fails */
2530 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2532 /* Treat existing volume size as "free" */
2534 p->size = (q->size < p->size) ? p->size - q->size : 0;
2536 if (partition.free <= p->size) {
2538 "vos: no space on target partition %s to copy volume %lu\n",
2539 toPartName, (unsigned long)volid);
2547 /* successful copy still not guaranteed but shoot for it */
2550 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2551 topart, tovolid, flags);
2553 PrintDiagnostics("shadow", code);
2556 MapPartIdIntoName(topart, toPartName);
2557 MapPartIdIntoName(frompart, fromPartName);
2558 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2559 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2560 as->parms[3].items->data, toPartName);
2567 CloneVolume(register struct cmd_syndesc *as, void *arock)
2569 afs_int32 server, part, volid, cloneid, voltype;
2570 char partName[10], *volname;
2571 afs_int32 code, err, flags;
2572 struct nvldbentry entry;
2574 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2577 PrintError("", err);
2579 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2580 as->parms[0].items->data);
2584 if (as->parms[1].items || as->parms[2].items) {
2585 if (!as->parms[1].items || !as->parms[2].items) {
2587 "Must specify both -server and -partition options\n");
2590 server = GetServer(as->parms[1].items->data);
2592 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2593 as->parms[1].items->data);
2596 part = volutil_GetPartitionID(as->parms[2].items->data);
2598 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2599 as->parms[2].items->data);
2602 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2604 PrintError("", code);
2607 "vos : partition %s does not exist on the server\n",
2608 as->parms[2].items->data);
2612 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2618 if (as->parms[3].items) {
2619 volname = as->parms[3].items->data;
2620 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2622 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2623 volname, VOLSER_OLDMAXVOLNAME - 1);
2628 * In order that you be able to make clones of RO or BK, this
2629 * check must be omitted.
2631 if (!VolNameOK(volname)) {
2633 "Illegal volume name %s, should not end in .readonly or .backup\n",
2638 if (IsNumeric(volname)) {
2640 "Illegal volume name %s, should not be a number\n",
2647 if (as->parms[4].items) {
2648 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2651 PrintError("", err);
2653 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2654 as->parms[4].items->data);
2660 if (as->parms[5].items) flags |= RV_OFFLINE;
2661 if (as->parms[6].items) flags |= RV_RDONLY;
2665 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2668 PrintDiagnostics("clone", code);
2671 MapPartIdIntoName(part, partName);
2672 fprintf(STDOUT, "Created clone for volume %s\n",
2673 as->parms[0].items->data);
2680 BackupVolume(register struct cmd_syndesc *as, void *arock)
2682 afs_int32 avolid, aserver, apart, vtype, code, err;
2683 struct nvldbentry entry;
2685 afs_int32 buvolid, buserver, bupart, butype;
2686 struct nvldbentry buentry;
2688 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2691 PrintError("", err);
2693 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2694 as->parms[0].items->data);
2697 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2701 /* verify this is a readwrite volume */
2703 if (vtype != RWVOL) {
2704 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2708 /* is there a backup volume already? */
2710 if (entry.flags & BACK_EXISTS) {
2711 /* yep, where is it? */
2713 buvolid = entry.volumeId[BACKVOL];
2714 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2719 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2722 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2728 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2729 (unsigned long)buvolid, (unsigned long)buserver);
2734 /* nope, carry on */
2736 code = UV_BackupVolume(aserver, apart, avolid);
2739 PrintDiagnostics("backup", code);
2742 fprintf(STDOUT, "Created backup volume for %s \n",
2743 as->parms[0].items->data);
2748 ReleaseVolume(register struct cmd_syndesc *as, void *arock)
2751 struct nvldbentry entry;
2752 afs_int32 avolid, aserver, apart, vtype, code, err;
2755 if (as->parms[1].items)
2757 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2760 PrintError("", err);
2762 fprintf(STDERR, "vos: can't find volume '%s'\n",
2763 as->parms[0].items->data);
2766 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2770 if (vtype != RWVOL) {
2771 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2775 if (!ISNAMEVALID(entry.name)) {
2777 "Volume name %s is too long, rename before releasing\n",
2782 code = UV_ReleaseVolume(avolid, aserver, apart, force);
2784 PrintDiagnostics("release", code);
2787 fprintf(STDOUT, "Released volume %s successfully\n",
2788 as->parms[0].items->data);
2793 DumpVolume(register struct cmd_syndesc *as, void *arock)
2795 afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i, flags;
2796 char filename[MAXPATHLEN];
2797 struct nvldbentry entry;
2799 rx_SetRxDeadTime(60 * 10);
2800 for (i = 0; i < MAXSERVERS; i++) {
2801 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2804 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2805 if (rxConn->service)
2806 rxConn->service->connDeadTime = rx_connDeadTime;
2809 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2812 PrintError("", err);
2814 fprintf(STDERR, "vos: can't find volume '%s'\n",
2815 as->parms[0].items->data);
2819 if (as->parms[3].items || as->parms[4].items) {
2820 if (!as->parms[3].items || !as->parms[4].items) {
2822 "Must specify both -server and -partition options\n");
2825 aserver = GetServer(as->parms[3].items->data);
2827 fprintf(STDERR, "Invalid server name\n");
2830 apart = volutil_GetPartitionID(as->parms[4].items->data);
2832 fprintf(STDERR, "Invalid partition name\n");
2836 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2841 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2842 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2844 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2845 as->parms[1].items->data, code);
2849 if (as->parms[2].items) {
2850 strcpy(filename, as->parms[2].items->data);
2852 strcpy(filename, "");
2855 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
2857 if (as->parms[5].items) {
2859 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2860 DumpFunction, filename, flags);
2863 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2866 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
2867 flags &= ~VOLDUMPV2_OMITDIRS;
2871 PrintDiagnostics("dump", code);
2874 if (strcmp(filename, ""))
2875 fprintf(STDERR, "Dumped volume %s in file %s\n",
2876 as->parms[0].items->data, filename);
2878 fprintf(STDERR, "Dumped volume %s in stdout \n",
2879 as->parms[0].items->data);
2893 RestoreVolume(register struct cmd_syndesc *as, void *arock)
2895 afs_int32 avolid, aparentid, aserver, apart, code, vcode, err;
2896 afs_int32 aoverwrite = ASK;
2897 afs_int32 acreation = 0, alastupdate = 0;
2898 int restoreflags, readonly = 0, offline = 0, voltype = RWVOL;
2900 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
2901 char volname[VOLSER_MAXVOLNAME + 1];
2902 struct nvldbentry entry;
2907 if (as->parms[4].items) {
2908 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2911 PrintError("", err);
2913 fprintf(STDERR, "vos: can't find volume '%s'\n",
2914 as->parms[4].items->data);
2920 if (as->parms[5].items) {
2921 if ((strcmp(as->parms[5].items->data, "a") == 0)
2922 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
2924 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
2925 || (strcmp(as->parms[5].items->data, "full") == 0)) {
2927 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
2928 || (strcmp(as->parms[5].items->data, "inc") == 0)
2929 || (strcmp(as->parms[5].items->data, "increment") == 0)
2930 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
2933 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2934 as->parms[5].items->data);
2938 if (as->parms[6].items)
2940 if (as->parms[7].items) {
2945 if (as->parms[8].items) {
2946 if ((strcmp(as->parms[8].items->data, "d") == 0)
2947 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
2948 acreation = TS_DUMP;
2949 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
2950 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
2951 acreation = TS_KEEP;
2952 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
2953 || (strcmp(as->parms[8].items->data, "new") == 0)) {
2956 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
2957 as->parms[8].items->data);
2962 if (as->parms[9].items) {
2963 if ((strcmp(as->parms[9].items->data, "d") == 0)
2964 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
2965 alastupdate = TS_DUMP;
2966 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
2967 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
2968 alastupdate = TS_KEEP;
2969 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
2970 || (strcmp(as->parms[9].items->data, "new") == 0)) {
2971 alastupdate = TS_NEW;
2973 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
2974 as->parms[9].items->data);
2979 aserver = GetServer(as->parms[0].items->data);
2981 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2982 as->parms[0].items->data);
2985 apart = volutil_GetPartitionID(as->parms[1].items->data);
2987 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2988 as->parms[1].items->data);
2991 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
2993 PrintError("", code);
2996 "vos : partition %s does not exist on the server\n",
2997 as->parms[1].items->data);
3000 strcpy(avolname, as->parms[2].items->data);
3001 if (!ISNAMEVALID(avolname)) {
3003 "vos: the name of the volume %s exceeds the size limit\n",
3007 if (!VolNameOK(avolname)) {
3009 "Illegal volume name %s, should not end in .readonly or .backup\n",
3013 if (as->parms[3].items) {
3014 strcpy(afilename, as->parms[3].items->data);
3015 if (!FileExists(afilename)) {
3016 fprintf(STDERR, "Can't access file %s\n", afilename);
3020 strcpy(afilename, "");
3023 /* Check if volume exists or not */
3025 vsu_ExtractName(volname, avolname);
3026 vcode = VLDB_GetEntryByName(volname, &entry);
3027 if (vcode) { /* no volume - do a full restore */
3028 restoreflags = RV_FULLRST;
3029 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3031 "Volume does not exist; Will perform a full restore\n");
3034 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3035 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3036 restoreflags = RV_FULLRST;
3037 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3039 "%s Volume does not exist; Will perform a full restore\n",
3040 readonly ? "RO" : "RW");
3043 avolid = entry.volumeId[voltype];
3044 } else if (entry.volumeId[voltype] != 0
3045 && entry.volumeId[voltype] != avolid) {
3046 avolid = entry.volumeId[voltype];
3048 aparentid = entry.volumeId[RWVOL];
3051 else { /* volume exists - do we do a full incremental or abort */
3052 int Oserver, Opart, Otype, vol_elsewhere = 0;
3053 struct nvldbentry Oentry;
3057 avolid = entry.volumeId[voltype];
3058 } else if (entry.volumeId[voltype] != 0
3059 && entry.volumeId[voltype] != avolid) {
3060 avolid = entry.volumeId[voltype];
3062 aparentid = entry.volumeId[RWVOL];
3064 /* A file name was specified - check if volume is on another partition */
3065 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3069 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3072 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3076 if (!vcode || (Opart != apart))
3079 if (aoverwrite == ASK) {
3080 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3082 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3086 /* Ask what to do */
3087 if (vol_elsewhere) {
3089 "The volume %s %u already exists on a different server/part\n",
3090 volname, entry.volumeId[voltype]);
3092 "Do you want to do a full restore or abort? [fa](a): ");
3095 "The volume %s %u already exists in the VLDB\n",
3096 volname, entry.volumeId[voltype]);
3098 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3101 while (!(dc == EOF || dc == '\n'))
3102 dc = getchar(); /* goto end of line */
3103 if ((c == 'f') || (c == 'F'))
3105 else if ((c == 'i') || (c == 'I'))
3111 if (aoverwrite == ABORT) {
3112 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3114 } else if (aoverwrite == FULL) {
3115 restoreflags = RV_FULLRST;
3117 "Volume exists; Will delete and perform full restore\n");
3118 } else if (aoverwrite == INC) {
3120 if (vol_elsewhere) {
3122 "%s volume %lu already exists on a different server/part; not allowed\n",
3123 readonly ? "RO" : "RW", (unsigned long)avolid);
3129 restoreflags |= RV_OFFLINE;
3131 restoreflags |= RV_RDONLY;
3133 switch (acreation) {
3135 restoreflags |= RV_CRDUMP;
3138 restoreflags |= RV_CRKEEP;
3141 restoreflags |= RV_CRNEW;
3144 if (aoverwrite == FULL)
3145 restoreflags |= RV_CRNEW;
3147 restoreflags |= RV_CRKEEP;
3150 switch (alastupdate) {
3152 restoreflags |= RV_LUDUMP;
3155 restoreflags |= RV_LUKEEP;
3158 restoreflags |= RV_LUNEW;
3161 restoreflags |= RV_LUDUMP;
3163 if (as->parms[10].items) {
3164 restoreflags |= RV_NODEL;
3169 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3170 avolname, restoreflags, WriteData, afilename);
3172 PrintDiagnostics("restore", code);
3175 MapPartIdIntoName(apart, apartName);
3178 * patch typo here - originally "parms[1]", should be "parms[0]"
3181 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3182 as->parms[0].items->data, apartName);
3187 LockReleaseCmd(register struct cmd_syndesc *as, void *arock)
3189 afs_int32 avolid, code, err;
3191 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3194 PrintError("", err);
3196 fprintf(STDERR, "vos: can't find volume '%s'\n",
3197 as->parms[0].items->data);
3201 code = UV_LockRelease(avolid);
3203 PrintDiagnostics("unlock", code);
3206 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3207 as->parms[0].items->data);
3212 AddSite(register struct cmd_syndesc *as, void *arock)
3214 afs_int32 avolid, aserver, apart, code, err, valid = 0;
3215 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3217 vsu_ExtractName(avolname, as->parms[2].items->data);;
3218 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3221 PrintError("", err);
3223 fprintf(STDERR, "vos: can't find volume '%s'\n",
3224 as->parms[2].items->data);
3227 aserver = GetServer(as->parms[0].items->data);
3229 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3230 as->parms[0].items->data);
3233 apart = volutil_GetPartitionID(as->parms[1].items->data);
3235 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3236 as->parms[1].items->data);
3239 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3241 PrintError("", code);
3244 "vos : partition %s does not exist on the server\n",
3245 as->parms[1].items->data);
3248 if (as->parms[3].items) {
3251 code = UV_AddSite(aserver, apart, avolid, valid);
3253 PrintDiagnostics("addsite", code);
3256 MapPartIdIntoName(apart, apartName);
3257 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3258 as->parms[0].items->data, apartName, as->parms[2].items->data);
3263 RemoveSite(register struct cmd_syndesc *as, void *arock)
3266 afs_int32 avolid, aserver, apart, code, err;
3267 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3269 vsu_ExtractName(avolname, as->parms[2].items->data);
3270 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3273 PrintError("", err);
3275 fprintf(STDERR, "vos: can't find volume '%s'\n",
3276 as->parms[2].items->data);
3279 aserver = GetServer(as->parms[0].items->data);
3281 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3282 as->parms[0].items->data);
3285 apart = volutil_GetPartitionID(as->parms[1].items->data);
3287 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3288 as->parms[1].items->data);
3292 *skip the partition validity check, since it is possible that the partition
3293 *has since been decomissioned.
3296 if (!IsPartValid(apart,aserver,&code)){
3297 if(code) PrintError("",code);
3298 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3302 code = UV_RemoveSite(aserver, apart, avolid);
3304 PrintDiagnostics("remsite", code);
3307 MapPartIdIntoName(apart, apartName);
3308 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3309 as->parms[0].items->data, apartName, as->parms[2].items->data);
3314 ChangeLocation(register struct cmd_syndesc *as, void *arock)
3316 afs_int32 avolid, aserver, apart, code, err;
3319 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3322 PrintError("", err);
3324 fprintf(STDERR, "vos: can't find volume '%s'\n",
3325 as->parms[2].items->data);
3328 aserver = GetServer(as->parms[0].items->data);
3330 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3331 as->parms[0].items->data);
3334 apart = volutil_GetPartitionID(as->parms[1].items->data);
3336 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3337 as->parms[1].items->data);
3340 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3342 PrintError("", code);
3345 "vos : partition %s does not exist on the server\n",
3346 as->parms[1].items->data);
3349 code = UV_ChangeLocation(aserver, apart, avolid);
3351 PrintDiagnostics("addsite", code);
3354 MapPartIdIntoName(apart, apartName);
3355 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3356 as->parms[0].items->data, apartName, as->parms[2].items->data);
3361 ListPartitions(register struct cmd_syndesc *as, void *arock)
3363 afs_int32 aserver, code;
3364 struct partList dummyPartList;
3369 aserver = GetServer(as->parms[0].items->data);
3371 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3372 as->parms[0].items->data);
3377 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3379 PrintDiagnostics("listpart", code);
3383 fprintf(STDOUT, "The partitions on the server are:\n");
3384 for (i = 0; i < cnt; i++) {
3385 if (dummyPartList.partFlags[i] & PARTVALID) {
3386 memset(pname, 0, sizeof(pname));
3387 MapPartIdIntoName(dummyPartList.partId[i], pname);
3388 fprintf(STDOUT, " %10s ", pname);
3390 if ((i % 5) == 0 && (i != 0))
3391 fprintf(STDOUT, "\n");
3394 fprintf(STDOUT, "\n");
3395 fprintf(STDOUT, "Total: %d\n", total);
3401 CompareVolName(p1, p2)
3404 volintInfo *arg1, *arg2;
3406 arg1 = (volintInfo *) p1;
3407 arg2 = (volintInfo *) p2;
3408 return (strcmp(arg1->name, arg2->name));
3412 /*------------------------------------------------------------------------
3413 * PRIVATE XCompareVolName
3416 * Comparison routine for volume names coming from an extended
3420 * a_obj1P : Char ptr to first extended vol info object
3421 * a_obj1P : Char ptr to second extended vol info object
3424 * The value of strcmp() on the volume names within the passed
3425 * objects (i,e., -1, 0, or 1).
3428 * Passed to qsort() as the designated comparison routine.
3432 *------------------------------------------------------------------------*/
3435 XCompareVolName(a_obj1P, a_obj2P)
3436 char *a_obj1P, *a_obj2P;
3438 { /*XCompareVolName */
3441 (((struct volintXInfo *)(a_obj1P))->name,
3442 ((struct volintXInfo *)(a_obj2P))->name));
3444 } /*XCompareVolName */
3447 CompareVolID(p1, p2)
3450 volintInfo *arg1, *arg2;
3452 arg1 = (volintInfo *) p1;
3453 arg2 = (volintInfo *) p2;
3454 if (arg1->volid == arg2->volid)
3456 if (arg1->volid > arg2->volid)
3463 /*------------------------------------------------------------------------
3464 * PRIVATE XCompareVolID
3467 * Comparison routine for volume IDs coming from an extended
3471 * a_obj1P : Char ptr to first extended vol info object
3472 * a_obj1P : Char ptr to second extended vol info object
3475 * The value of strcmp() on the volume names within the passed
3476 * objects (i,e., -1, 0, or 1).
3479 * Passed to qsort() as the designated comparison routine.
3483 *------------------------------------------------------------------------*/
3486 XCompareVolID(a_obj1P, a_obj2P)
3487 char *a_obj1P, *a_obj2P;
3489 { /*XCompareVolID */
3491 afs_int32 id1, id2; /*Volume IDs we're comparing */
3493 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3494 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3502 } /*XCompareVolID */
3504 /*------------------------------------------------------------------------
3505 * PRIVATE ListVolumes
3508 * Routine used to list volumes, contacting the Volume Server
3509 * directly, bypassing the VLDB.
3512 * as : Ptr to parsed command line arguments.
3515 * 0 Successful operation
3518 * Nothing interesting.
3522 *------------------------------------------------------------------------*/
3525 ListVolumes(register struct cmd_syndesc *as, void *arock)
3527 afs_int32 apart, int32list, fast;
3528 afs_int32 aserver, code;
3529 volintInfo *pntr, *oldpntr;
3533 volintXInfo *xInfoP, *origxInfoP; /*Ptr to current/orig extended vol info */
3534 int wantExtendedInfo; /*Do we want extended vol info? */
3537 struct partList dummyPartList;
3545 if (as->parms[3].items)
3547 if (as->parms[4].items)
3551 if (as->parms[2].items)
3557 if (as->parms[5].items) {
3559 * We can't coexist with the fast flag.
3563 "vos: Can't use the -fast and -extended flags together\n");
3568 * We need to turn on ``long'' listings to get the full effect.
3570 wantExtendedInfo = 1;
3573 wantExtendedInfo = 0;
3574 if (as->parms[1].items) {
3575 apart = volutil_GetPartitionID(as->parms[1].items->data);
3577 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3578 as->parms[1].items->data);
3581 dummyPartList.partId[0] = apart;
3582 dummyPartList.partFlags[0] = PARTVALID;
3585 aserver = GetServer(as->parms[0].items->data);
3587 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3588 as->parms[0].items->data);
3593 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3595 PrintError("", code);
3598 "vos : partition %s does not exist on the server\n",
3599 as->parms[1].items->data);
3603 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3605 PrintDiagnostics("listvol", code);
3609 for (i = 0; i < cnt; i++) {
3610 if (dummyPartList.partFlags[i] & PARTVALID) {
3611 if (wantExtendedInfo)
3613 UV_XListVolumes(aserver, dummyPartList.partId[i], all,
3617 UV_ListVolumes(aserver, dummyPartList.partId[i], all,
3620 PrintDiagnostics("listvol", code);
3625 if (wantExtendedInfo) {
3626 origxInfoP = xInfoP;
3627 base = (char *)xInfoP;
3630 base = (char *)pntr;
3634 if (wantExtendedInfo)
3635 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
3637 qsort(base, count, sizeof(volintInfo), CompareVolName);
3639 if (wantExtendedInfo)
3640 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
3642 qsort(base, count, sizeof(volintInfo), CompareVolID);
3644 MapPartIdIntoName(dummyPartList.partId[i], pname);
3647 "Total number of volumes on server %s partition %s: %lu \n",
3648 as->parms[0].items->data, pname,
3649 (unsigned long)count);
3650 if (wantExtendedInfo) {
3651 #ifdef FULL_LISTVOL_SWITCH
3652 if (as->parms[6].items)
3653 XDisplayVolumes2(aserver, dummyPartList.partId[i], origxInfoP,
3654 count, int32list, fast, quiet);
3656 #endif /* FULL_LISTVOL_SWITCH */
3657 XDisplayVolumes(aserver, dummyPartList.partId[i], origxInfoP,
3658 count, int32list, fast, quiet);
3661 xInfoP = (volintXInfo *) 0;
3663 #ifdef FULL_LISTVOL_SWITCH
3664 if (as->parms[6].items)
3665 DisplayVolumes2(aserver, dummyPartList.partId[i], oldpntr,
3668 #endif /* FULL_LISTVOL_SWITCH */
3669 DisplayVolumes(aserver, dummyPartList.partId[i], oldpntr,
3670 count, int32list, fast, quiet);
3673 pntr = (volintInfo *) 0;
3681 SyncVldb(register struct cmd_syndesc *as, void *arock)
3683 afs_int32 pnum = 0, code; /* part name */
3689 if (as->parms[0].items) {
3690 tserver = GetServer(as->parms[0].items->data);
3692 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3693 as->parms[0].items->data);
3698 if (as->parms[1].items) {
3699 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3701 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3702 as->parms[1].items->data);
3705 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3707 PrintError("", code);
3710 "vos: partition %s does not exist on the server\n",
3711 as->parms[1].items->data);
3718 "The -partition option requires a -server option\n");
3723 if (as->parms[2].items) {
3724 /* Synchronize an individual volume */
3725 volname = as->parms[2].items->data;
3726 code = UV_SyncVolume(tserver, pnum, volname, flags);
3730 "Without a -volume option, the -server option is required\n");
3733 code = UV_SyncVldb(tserver, pnum, flags, 0 /*unused */ );
3737 PrintDiagnostics("syncvldb", code);
3741 /* Print a summary of what we did */
3743 fprintf(STDOUT, "VLDB volume %s synchronized", volname);
3745 fprintf(STDOUT, "VLDB synchronized");
3747 fprintf(STDOUT, " with state of server %s", as->parms[0].items->data);
3750 MapPartIdIntoName(pnum, part);
3751 fprintf(STDOUT, " partition %s\n", part);
3753 fprintf(STDOUT, "\n");
3759 SyncServer(register struct cmd_syndesc *as, void *arock)
3761 afs_int32 pnum, code; /* part name */
3766 tserver = GetServer(as->parms[0].items->data);
3768 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3769 as->parms[0].items->data);
3772 if (as->parms[1].items) {
3773 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3775 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3776 as->parms[1].items->data);
3779 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3781 PrintError("", code);
3784 "vos : partition %s does not exist on the server\n",
3785 as->parms[1].items->data);
3793 code = UV_SyncServer(tserver, pnum, flags, 0 /*unused */ );
3795 PrintDiagnostics("syncserv", code);
3799 MapPartIdIntoName(pnum, part);
3800 fprintf(STDOUT, "Server %s partition %s synchronized with VLDB\n",
3801 as->parms[0].items->data, part);
3803 fprintf(STDOUT, "Server %s synchronized with VLDB\n",
3804 as->parms[0].items->data);
3813 struct nvldbentry entry;
3816 /* The vlserver will handle names with the .readonly
3817 * and .backup extension as well as volume ids.
3819 vcode = VLDB_GetEntryByName(name, &entry);
3821 PrintError("", vcode);
3824 MapHostToNetwork(&entry);
3825 EnumerateEntry(&entry);
3827 /* Defect #3027: grubby check to handle locked volume.
3828 * If VLOP_ALLOPERS is set, the entry is locked.
3829 * Leave this routine as is, but put in correct check.
3831 if (entry.flags & VLOP_ALLOPERS)
3832 fprintf(STDOUT, " Volume is currently LOCKED \n");
3838 VolumeZap(register struct cmd_syndesc *as, void *arock)
3840 struct nvldbentry entry;
3841 afs_int32 volid, code, server, part, zapbackupid = 0, backupid = 0, err;
3843 if (as->parms[3].items) {
3844 /* force flag is on, use the other version */
3845 return NukeVolume(as);
3848 if (as->parms[4].items) {
3852 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3855 PrintError("", err);
3857 fprintf(STDERR, "vos: can't find volume '%s'\n",
3858 as->parms[2].items->data);
3861 part = volutil_GetPartitionID(as->parms[1].items->data);
3863 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3864 as->parms[1].items->data);
3867 server = GetServer(as->parms[0].items->data);
3869 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3870 as->parms[0].items->data);
3873 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
3875 PrintError("", code);
3878 "vos : partition %s does not exist on the server\n",
3879 as->parms[1].items->data);
3882 code = VLDB_GetEntryByID(volid, -1, &entry);
3884 if (volid == entry.volumeId[RWVOL])
3885 backupid = entry.volumeId[BACKVOL];
3887 "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
3888 (unsigned long)volid);
3891 volintInfo *pntr = (volintInfo *) 0;
3894 code = UV_ListOneVolume(server, part, volid, &pntr);
3896 if (volid == pntr->parentID)
3897 backupid = pntr->backupID;
3903 code = UV_VolumeZap(server, part, backupid);
3905 PrintDiagnostics("zap", code);
3908 fprintf(STDOUT, "Backup Volume %lu deleted\n",
3909 (unsigned long)backupid);
3912 code = UV_VolumeZap(server, part, volid);
3914 PrintDiagnostics("zap", code);
3917 fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
3923 VolserStatus(register struct cmd_syndesc *as, void *arock)
3925 afs_int32 server, code;
3926 transDebugInfo *pntr, *oldpntr;
3931 server = GetServer(as->parms[0].items->data);
3933 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3934 as->parms[0].items->data);
3937 code = UV_VolserStatus(server, &pntr, &count);
3939 PrintDiagnostics("status", code);
3944 fprintf(STDOUT, "No active transactions on %s\n",
3945 as->parms[0].items->data);
3947 fprintf(STDOUT, "Total transactions: %d\n", count);
3949 for (i = 0; i < count; i++) {
3950 /*print out the relevant info */
3951 fprintf(STDOUT, "--------------------------------------\n");
3952 fprintf(STDOUT, "transaction: %lu created: %s",
3953 (unsigned long)pntr->tid, vos_ctime( & pntr->time));
3954 if (pntr->returnCode) {
3955 fprintf(STDOUT, "returnCode: %lu\n",
3956 (unsigned long)pntr->returnCode);
3959 fprintf(STDOUT, "attachFlags: ");
3960 switch (pntr->iflags) {
3962 fprintf(STDOUT, "offline ");
3965 fprintf(STDOUT, "busy ");
3968 fprintf(STDOUT, "readonly ");
3971 fprintf(STDOUT, "create ");
3974 fprintf(STDOUT, "create volid ");
3977 fprintf(STDOUT, "\n");
3980 fprintf(STDOUT, "volumeStatus: ");
3981 switch (pntr->vflags) {
3982 case VTDeleteOnSalvage:
3983 fprintf(STDOUT, "deleteOnSalvage ");
3984 case VTOutOfService:
3985 fprintf(STDOUT, "outOfService ");
3987 fprintf(STDOUT, "deleted ");
3989 fprintf(STDOUT, "\n");
3992 fprintf(STDOUT, "transactionFlags: ");
3993 fprintf(STDOUT, "delete\n");
3995 MapPartIdIntoName(pntr->partition, pname);
3996 fprintf(STDOUT, "volume: %lu partition: %s procedure: %s\n",
3997 (unsigned long)pntr->volid, pname, pntr->lastProcName);
3998 if (pntr->callValid) {
4000 "packetRead: %lu lastReceiveTime: %d packetSend: %lu lastSendTime: %d\n",
4001 (unsigned long)pntr->readNext, pntr->lastReceiveTime,
4002 (unsigned long)pntr->transmitNext, pntr->lastSendTime);
4005 fprintf(STDOUT, "--------------------------------------\n");
4006 fprintf(STDOUT, "\n");
4014 RenameVolume(register struct cmd_syndesc *as, void *arock)
4016 afs_int32 code1, code2, code;
4017 struct nvldbentry entry;
4019 code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
4021 fprintf(STDERR, "vos: Could not find entry for volume %s\n",
4022 as->parms[0].items->data);
4025 code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
4026 if ((!code1) && (!code2)) { /*the newname already exists */
4027 fprintf(STDERR, "vos: volume %s already exists\n",
4028 as->parms[1].items->data);
4032 if (code1 && code2) {
4033 fprintf(STDERR, "vos: Could not find entry for volume %s or %s\n",
4034 as->parms[0].items->data, as->parms[1].items->data);
4037 if (!VolNameOK(as->parms[0].items->data)) {
4039 "Illegal volume name %s, should not end in .readonly or .backup\n",
4040 as->parms[0].items->data);
4043 if (!ISNAMEVALID(as->parms[1].items->data)) {
4045 "vos: the new volume name %s exceeds the size limit of %d\n",
4046 as->parms[1].items->data, VOLSER_OLDMAXVOLNAME - 10);
4049 if (!VolNameOK(as->parms[1].items->data)) {
4051 "Illegal volume name %s, should not end in .readonly or .backup\n",
4052 as->parms[1].items->data);
4055 if (IsNumeric(as->parms[1].items->data)) {
4056 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
4057 as->parms[1].items->data);
4060 MapHostToNetwork(&entry);
4062 UV_RenameVolume(&entry, as->parms[0].items->data,
4063 as->parms[1].items->data);
4065 PrintDiagnostics("rename", code);
4068 fprintf(STDOUT, "Renamed volume %s to %s\n", as->parms[0].items->data,
4069 as->parms[1].items->data);
4073 GetVolumeInfo(volid, server, part, voltype, rentry)
4074 afs_int32 *server, volid, *part, *voltype;
4075 register struct nvldbentry *rentry;
4080 vcode = VLDB_GetEntryByID(volid, -1, rentry);
4083 "Could not fetch the entry for volume %lu from VLDB \n",
4084 (unsigned long)volid);
4085 PrintError("", vcode);
4088 MapHostToNetwork(rentry);
4089 if (volid == rentry->volumeId[ROVOL]) {
4091 for (i = 0; i < rentry->nServers; i++) {
4092 if ((index == -1) && (rentry->serverFlags[i] & ITSROVOL)
4093 && !(rentry->serverFlags[i] & RO_DONTUSE))
4098 "RO volume is not found in VLDB entry for volume %lu\n",
4099 (unsigned long)volid);
4103 *server = rentry->serverNumber[index];
4104 *part = rentry->serverPartition[index];
4108 index = Lp_GetRwIndex(rentry);
4111 "RW Volume is not found in VLDB entry for volume %lu\n",
4112 (unsigned long)volid);
4115 if (volid == rentry->volumeId[RWVOL]) {
4117 *server = rentry->serverNumber[index];
4118 *part = rentry->serverPartition[index];
4121 if (volid == rentry->volumeId[BACKVOL]) {
4123 *server = rentry->serverNumber[index];
4124 *part = rentry->serverPartition[index];
4128 "unexpected volume type for volume %lu\n",
4129 (unsigned long)volid);
4134 DeleteEntry(register struct cmd_syndesc *as, void *arock)
4139 struct VldbListByAttributes attributes;
4140 nbulkentries arrayEntries;
4141 register struct nvldbentry *vllist;
4142 struct cmd_item *itp;
4145 char prefix[VOLSER_MAXVOLNAME + 1];
4147 afs_int32 totalBack = 0, totalFail = 0, err;
4149 if (as->parms[0].items) { /* -id */
4150 if (as->parms[1].items || as->parms[2].items || as->parms[3].items) {
4152 "You cannot use -server, -partition, or -prefix with the -id argument\n");
4155 for (itp = as->parms[0].items; itp; itp = itp->next) {
4156 avolid = vsu_GetVolumeID(itp->data, cstruct, &err);
4159 PrintError("", err);
4161 fprintf(STDERR, "vos: can't find volume '%s'\n",
4165 if (as->parms[4].items) { /* -noexecute */
4166 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4171 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4173 fprintf(STDERR, "Could not delete entry for volume %s\n",
4176 "You must specify a RW volume name or ID "
4177 "(the entire VLDB entry will be deleted)\n");
4178 PrintError("", vcode);
4184 fprintf(STDOUT, "Deleted %d VLDB entries\n", totalBack);
4188 if (!as->parms[1].items && !as->parms[2].items && !as->parms[3].items) {
4189 fprintf(STDERR, "You must specify an option\n");
4193 /* Zero out search attributes */
4194 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4196 if (as->parms[1].items) { /* -prefix */
4197 strncpy(prefix, as->parms[1].items->data, VOLSER_MAXVOLNAME);
4199 if (!as->parms[2].items && !as->parms[3].items) { /* a single entry only */
4201 "You must provide -server with the -prefix argument\n");
4206 if (as->parms[2].items) { /* -server */
4208 aserver = GetServer(as->parms[2].items->data);
4210 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4211 as->parms[2].items->data);
4214 attributes.server = ntohl(aserver);
4215 attributes.Mask |= VLLIST_SERVER;
4218 if (as->parms[3].items) { /* -partition */
4219 if (!as->parms[2].items) {
4221 "You must provide -server with the -partition argument\n");
4224 apart = volutil_GetPartitionID(as->parms[3].items->data);
4226 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4227 as->parms[3].items->data);
4230 attributes.partition = apart;
4231 attributes.Mask |= VLLIST_PARTITION;
4234 /* Print status line of what we are doing */
4235 fprintf(STDOUT, "Deleting VLDB entries for ");
4236 if (as->parms[2].items) {
4237 fprintf(STDOUT, "server %s ", as->parms[2].items->data);
4239 if (as->parms[3].items) {
4241 MapPartIdIntoName(apart, pname);
4242 fprintf(STDOUT, "partition %s ", pname);
4245 fprintf(STDOUT, "which are prefixed with %s ", prefix);
4247 fprintf(STDOUT, "\n");
4250 /* Get all the VLDB entries on a server and/or partition */
4251 memset(&arrayEntries, 0, sizeof(arrayEntries));
4252 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4254 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4255 PrintError("", vcode);
4259 /* Process each entry */
4260 for (j = 0; j < nentries; j++) {
4261 vllist = &arrayEntries.nbulkentries_val[j];
4263 /* It only deletes the RW volumes */
4264 if (strncmp(vllist->name, prefix, strlen(prefix))) {
4267 "Omitting to delete %s due to prefix %s mismatch\n",
4268 vllist->name, prefix);
4275 if (as->parms[4].items) { /* -noexecute */
4276 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4282 /* Only matches the RW volume name */
4283 avolid = vllist->volumeId[RWVOL];
4284 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4286 fprintf(STDOUT, "Could not delete VDLB entry for %s\n",
4289 PrintError("", vcode);
4294 fprintf(STDOUT, "Deleted VLDB entry for %s \n", vllist->name);
4299 fprintf(STDOUT, "----------------------\n");
4301 "Total VLDB entries deleted: %lu; failed to delete: %lu\n",
4302 (unsigned long)totalBack, (unsigned long)totalFail);
4303 if (arrayEntries.nbulkentries_val)
4304 free(arrayEntries.nbulkentries_val);
4310 CompareVldbEntryByName(p1, p2)
4313 struct nvldbentry *arg1, *arg2;
4315 arg1 = (struct nvldbentry *)p1;
4316 arg2 = (struct nvldbentry *)p2;
4317 return (strcmp(arg1->name, arg2->name));
4321 static int CompareVldbEntry(p1,p2)
4324 struct nvldbentry *arg1,*arg2;
4327 char comp1[100],comp2[100];
4328 char temp1[20],temp2[20];
4330 arg1 = (struct nvldbentry *)p1;
4331 arg2 = (struct nvldbentry *)p2;
4335 for(i = 0; i < arg1->nServers; i++)
4336 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
4337 for(i = 0; i < arg2->nServers; i++)
4338 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
4339 if(pos1 == -1 || pos2 == -1){
4343 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
4344 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
4345 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
4346 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
4347 strcat(comp1,temp1);
4348 strcat(comp2,temp2);
4349 strcat(comp1,arg1->name);
4350 strcat(comp1,arg2->name);
4351 return(strcmp(comp1,comp2));
4357 ListVLDB(struct cmd_syndesc *as, void *arock)
4360 afs_int32 aserver, code;
4362 struct VldbListByAttributes attributes;
4363 nbulkentries arrayEntries;
4364 struct nvldbentry *vllist, *tarray = 0, *ttarray;
4365 afs_int32 centries, nentries = 0, tarraysize, parraysize;
4368 int quiet, sort, lock;
4369 afs_int32 thisindex, nextindex;
4374 attributes.Mask = 0;
4375 lock = (as->parms[3].items ? 1 : 0); /* -lock flag */
4376 quiet = (as->parms[4].items ? 1 : 0); /* -quit flag */
4377 sort = (as->parms[5].items ? 0 : 1); /* -nosort flag */
4379 /* If the volume name is given, Use VolumeInfoCmd to look it up
4380 * and not ListAttributes.
4382 if (as->parms[0].items) {
4385 "vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
4388 code = VolumeInfoCmd(as->parms[0].items->data);
4390 PrintError("", code);
4396 /* Server specified */
4397 if (as->parms[1].items) {
4398 aserver = GetServer(as->parms[1].items->data);
4400 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4401 as->parms[1].items->data);
4404 attributes.server = ntohl(aserver);
4405 attributes.Mask |= VLLIST_SERVER;
4408 /* Partition specified */
4409 if (as->parms[2].items) {
4410 apart = volutil_GetPartitionID(as->parms[2].items->data);
4412 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4413 as->parms[2].items->data);
4416 attributes.partition = apart;
4417 attributes.Mask |= VLLIST_PARTITION;
4421 attributes.Mask |= VLLIST_FLAG;
4422 attributes.flag = VLOP_ALLOPERS;
4425 /* Print header information */
4427 MapPartIdIntoName(apart, pname);
4428 fprintf(STDOUT, "VLDB entries for %s %s%s%s %s\n",
4429 (as->parms[1].items ? "server" : "all"),
4430 (as->parms[1].items ? as->parms[1].items->data : "servers"),
4431 (as->parms[2].items ? " partition " : ""),
4432 (as->parms[2].items ? pname : ""),
4433 (lock ? "which are locked:" : ""));
4436 for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
4437 memset(&arrayEntries, 0, sizeof(arrayEntries));
4442 VLDB_ListAttributesN2(&attributes, 0, thisindex, ¢ries,
4443 &arrayEntries, &nextindex);
4444 if (vcode == RXGEN_OPCODE) {
4445 /* Vlserver not running with ListAttributesN2. Fall back */
4447 VLDB_ListAttributes(&attributes, ¢ries, &arrayEntries);
4451 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4452 PrintError("", vcode);
4455 nentries += centries;
4457 /* We don't sort, so just print the entries now */
4459 for (j = 0; j < centries; j++) { /* process each entry */
4460 vllist = &arrayEntries.nbulkentries_val[j];
4461 MapHostToNetwork(vllist);
4462 EnumerateEntry(vllist);
4464 if (vllist->flags & VLOP_ALLOPERS)
4465 fprintf(STDOUT, " Volume is currently LOCKED \n");
4469 /* So we sort. First we must collect all the entries and keep
4472 else if (centries > 0) {
4474 /* steal away the first bulk entries array */
4475 tarray = (struct nvldbentry *)arrayEntries.nbulkentries_val;
4476 tarraysize = centries * sizeof(struct nvldbentry);
4477 arrayEntries.nbulkentries_val = 0;
4479 /* Grow the tarray to keep the extra entries */
4480 parraysize = (centries * sizeof(struct nvldbentry));
4482 (struct nvldbentry *)realloc(tarray,
4483 tarraysize + parraysize);
4486 "Could not allocate enough space for the VLDB entries\n");
4492 memcpy(((char *)tarray) + tarraysize,
4493 (char *)arrayEntries.nbulkentries_val, parraysize);
4494 tarraysize += parraysize;
4498 /* Free the bulk array */
4499 if (arrayEntries.nbulkentries_val) {
4500 free(arrayEntries.nbulkentries_val);
4501 arrayEntries.nbulkentries_val = 0;
4505 /* Here is where we now sort all the entries and print them */
4506 if (sort && (nentries > 0)) {
4507 qsort((char *)tarray, nentries, sizeof(struct nvldbentry),
4508 CompareVldbEntryByName);
4509 for (vllist = tarray, j = 0; j < nentries; j++, vllist++) {
4510 MapHostToNetwork(vllist);
4511 EnumerateEntry(vllist);
4513 if (vllist->flags & VLOP_ALLOPERS)
4514 fprintf(STDOUT, " Volume is currently LOCKED \n");
4520 fprintf(STDOUT, "\nTotal entries: %lu\n", (unsigned long)nentries);
4527 BackSys(register struct cmd_syndesc *as, void *arock)
4529 afs_int32 apart = 0, avolid;
4530 afs_int32 aserver = 0, code, aserver1, apart1;
4532 struct VldbListByAttributes attributes;
4533 nbulkentries arrayEntries;
4534 register struct nvldbentry *vllist;
4538 int seenprefix, seenxprefix, exclude, ex, exp, noaction;
4539 afs_int32 totalBack = 0;
4540 afs_int32 totalFail = 0;
4541 int previdx = -1, error, same;
4543 struct cmd_item *ti;
4547 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4548 attributes.Mask = 0;
4550 seenprefix = (as->parms[0].items ? 1 : 0);
4551 exclude = (as->parms[3].items ? 1 : 0);
4552 seenxprefix = (as->parms[4].items ? 1 : 0);
4553 noaction = (as->parms[5].items ? 1 : 0);
4555 if (as->parms[1].items) { /* -server */
4556 aserver = GetServer(as->parms[1].items->data);
4558 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4559 as->parms[1].items->data);
4562 attributes.server = ntohl(aserver);
4563 attributes.Mask |= VLLIST_SERVER;
4566 if (as->parms[2].items) { /* -partition */
4567 apart = volutil_GetPartitionID(as->parms[2].items->data);
4569 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4570 as->parms[2].items->data);
4573 attributes.partition = apart;
4574 attributes.Mask |= VLLIST_PARTITION;
4577 /* Check to make sure the prefix and xprefix expressions compile ok */
4579 for (ti = as->parms[0].items; ti; ti = ti->next) {
4580 if (strncmp(ti->data, "^", 1) == 0) {
4581 #ifdef HAVE_POSIX_REGEX
4585 code = regcomp(&re, ti->data, REG_NOSUB);
4587 regerror(code, &re, errbuf, sizeof errbuf);
4589 "Unrecognizable -prefix regular expression: '%s': %s\n",
4595 ccode = (char *)re_comp(ti->data);
4598 "Unrecognizable -prefix regular expression: '%s': %s\n",
4607 for (ti = as->parms[4].items; ti; ti = ti->next) {
4608 if (strncmp(ti->data, "^", 1) == 0) {
4609 #ifdef HAVE_POSIX_REGEX
4613 code = regcomp(&re, ti->data, REG_NOSUB);
4615 regerror(code, &re, errbuf, sizeof errbuf);
4617 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4623 ccode = (char *)re_comp(ti->data);
4626 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4635 memset(&arrayEntries, 0, sizeof(arrayEntries)); /* initialize to hint the stub to alloc space */
4636 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4638 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4639 PrintError("", vcode);
4643 if (as->parms[1].items || as->parms[2].items || verbose) {
4644 fprintf(STDOUT, "%s up volumes",
4645 (noaction ? "Would have backed" : "Backing"));
4647 if (as->parms[1].items) {
4648 fprintf(STDOUT, " on server %s", as->parms[1].items->data);
4649 } else if (as->parms[2].items) {
4650 fprintf(STDOUT, " for all servers");
4653 if (as->parms[2].items) {
4654 MapPartIdIntoName(apart, pname);
4655 fprintf(STDOUT, " partition %s", pname);
4658 if (seenprefix || (!seenprefix && seenxprefix)) {
4659 ti = (seenprefix ? as->parms[0].items : as->parms[4].items);
4660 ex = (seenprefix ? exclude : !exclude);
4661 exp = (strncmp(ti->data, "^", 1) == 0);
4662 fprintf(STDOUT, " which %smatch %s '%s'", (ex ? "do not " : ""),
4663 (exp ? "expression" : "prefix"), ti->data);
4664 for (ti = ti->next; ti; ti = ti->next) {
4665 exp = (strncmp(ti->data, "^", 1) == 0);
4666 printf(" %sor %s '%s'", (ex ? "n" : ""),
4667 (exp ? "expression" : "prefix"), ti->data);
4671 if (seenprefix && seenxprefix) {
4672 ti = as->parms[4].items;
4673 exp = (strncmp(ti->data, "^", 1) == 0);
4674 fprintf(STDOUT, " %swhich match %s '%s'",
4675 (exclude ? "adding those " : "removing those "),
4676 (exp ? "expression" : "prefix"), ti->data);
4677 for (ti = ti->next; ti; ti = ti->next) {
4678 exp = (strncmp(ti->data, "^", 1) == 0);
4679 printf(" or %s '%s'", (exp ? "expression" : "prefix"),
4683 fprintf(STDOUT, " .. ");
4685 fprintf(STDOUT, "\n");
4689 for (j = 0; j < nentries; j++) { /* process each vldb entry */
4690 vllist = &arrayEntries.nbulkentries_val[j];
4693 for (ti = as->parms[0].items; ti; ti = ti->next) {
4694 if (strncmp(ti->data, "^", 1) == 0) {
4695 #ifdef HAVE_POSIX_REGEX
4699 /* XXX -- should just do the compile once! */
4700 code = regcomp(&re, ti->data, REG_NOSUB);
4702 regerror(code, &re, errbuf, sizeof errbuf);
4704 "Error in -prefix regular expression: '%s': %s\n",
4708 match = (regexec(&re, vllist->name, 0, NULL, 0) == 0);
4711 ccode = (char *)re_comp(ti->data);
4714 "Error in -prefix regular expression: '%s': %s\n",
4718 match = (re_exec(vllist->name) == 1);
4722 (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4732 /* Without the -exclude flag: If it matches the prefix, then
4733 * check if we want to exclude any from xprefix.
4734 * With the -exclude flag: If it matches the prefix, then
4735 * check if we want to add any from xprefix.
4737 if (match && seenxprefix) {
4738 for (ti = as->parms[4].items; ti; ti = ti->next) {
4739 if (strncmp(ti->data, "^", 1) == 0) {
4740 #ifdef HAVE_POSIX_REGEX
4744 /* XXX -- should just do the compile once! */
4745 code = regcomp(&re, ti->data, REG_NOSUB);
4747 regerror(code, &re, errbuf, sizeof errbuf);
4749 "Error in -xprefix regular expression: '%s': %s\n",
4753 if (regexec(&re, vllist->name, 0, NULL, 0) == 0)
4757 ccode = (char *)re_comp(ti->data);
4760 "Error in -xprefix regular expression: '%s': %s\n",
4764 if (re_exec(vllist->name) == 1) {
4770 if (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4780 match = !match; /* -exclude will reverse the match */
4782 continue; /* Skip if no match */
4784 /* Print list of volumes to backup */
4786 fprintf(STDOUT, " %s\n", vllist->name);
4790 if (!(vllist->flags & RW_EXISTS)) {
4793 "Omitting to backup %s since RW volume does not exist \n",
4795 fprintf(STDOUT, "\n");
4801 avolid = vllist->volumeId[RWVOL];
4802 MapHostToNetwork(vllist);
4803 GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
4804 if (aserver1 == -1 || apart1 == -1) {
4805 fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n",
4811 same = VLDB_IsSameAddrs(aserver, aserver1, &error);
4814 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4820 if ((aserver && !same) || (apart && (apart != apart1))) {
4823 "Omitting to backup %s since the RW is in a different location\n",
4829 time_t now = time(0);
4830 fprintf(STDOUT, "Creating backup volume for %s on %s",
4831 vllist->name, ctime(&now));
4835 code = UV_BackupVolume(aserver1, apart1, avolid);
4837 fprintf(STDOUT, "Could not backup %s\n", vllist->name);
4843 fprintf(STDOUT, "\n");
4845 } /* process each vldb entry */
4846 fprintf(STDOUT, "done\n");
4847 fprintf(STDOUT, "Total volumes backed up: %lu; failed to backup: %lu\n",
4848 (unsigned long)totalBack, (unsigned long)totalFail);
4850 if (arrayEntries.nbulkentries_val)
4851 free(arrayEntries.nbulkentries_val);
4856 UnlockVLDB(register struct cmd_syndesc *as, void *arock)
4859 afs_int32 aserver, code;
4861 struct VldbListByAttributes attributes;
4862 nbulkentries arrayEntries;
4863 register struct nvldbentry *vllist;
4872 attributes.Mask = 0;
4874 if (as->parms[0].items) { /* server specified */
4875 aserver = GetServer(as->parms[0].items->data);
4877 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4878 as->parms[0].items->data);
4881 attributes.server = ntohl(aserver);
4882 attributes.Mask |= VLLIST_SERVER;
4884 if (as->parms[1].items) { /* partition specified */
4885 apart = volutil_GetPartitionID(as->parms[1].items->data);
4887 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4888 as->parms[1].items->data);
4891 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4893 PrintError("", code);
4896 "vos : partition %s does not exist on the server\n",
4897 as->parms[1].items->data);
4900 attributes.partition = apart;
4901 attributes.Mask |= VLLIST_PARTITION;
4903 attributes.flag = VLOP_ALLOPERS;
4904 attributes.Mask |= VLLIST_FLAG;
4905 memset(&arrayEntries, 0, sizeof(arrayEntries)); /*initialize to hint the stub to alloc space */
4906 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4908 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4909 PrintError("", vcode);
4912 for (j = 0; j < nentries; j++) { /* process each entry */
4913 vllist = &arrayEntries.nbulkentries_val[j];
4914 volid = vllist->volumeId[RWVOL];
4916 ubik_VL_ReleaseLock(cstruct, 0, volid, -1,
4917 LOCKREL_OPCODE | LOCKREL_AFSID |
4920 fprintf(STDERR, "Could not unlock entry for volume %s\n",
4922 PrintError("", vcode);
4927 MapPartIdIntoName(apart, pname);
4930 "Could not lock %lu VLDB entries of %lu locked entries\n",
4931 (unsigned long)totalE, (unsigned long)nentries);
4933 if (as->parms[0].items) {
4935 "Unlocked all the VLDB entries for volumes on server %s ",
4936 as->parms[0].items->data);
4937 if (as->parms[1].items) {
4938 MapPartIdIntoName(apart, pname);
4939 fprintf(STDOUT, "partition %s\n", pname);
4941 fprintf(STDOUT, "\n");
4943 } else if (as->parms[1].items) {
4944 MapPartIdIntoName(apart, pname);
4946 "Unlocked all the VLDB entries for volumes on partition %s on all servers\n",
4951 if (arrayEntries.nbulkentries_val)
4952 free(arrayEntries.nbulkentries_val);
4957 PrintInt64Size(afs_uint64 in)
4959 register afs_uint32 hi, lo;
4960 register char * units;
4961 static char output[16];
4963 SplitInt64(in,hi,lo);
4967 } else if (!(hi & 0xFFFFFC00)) {
4969 lo = (hi << 22) | (lo >> 10);
4970 } else if (!(hi & 0xFFF00000)) {
4972 lo = (hi << 12) | (lo >> 20);
4973 } else if (!(hi & 0xC0000000)) {
4975 lo = (hi << 2) | (lo >> 30);
4980 sprintf(output,"%u %s", lo, units);
4985 PartitionInfo(register struct cmd_syndesc *as, void *arock)
4988 afs_int32 aserver, code;
4990 struct diskPartition partition;
4991 struct partList dummyPartList;
4993 int printSummary=0, sumPartitions=0;
4994 afs_uint64 sumFree, sumStorage, tmp;
4997 ZeroInt64(sumStorage);
4999 aserver = GetServer(as->parms[0].items->data);
5001 fprintf(STDERR, "vos: server '%s' not found in host table\n",
5002 as->parms[0].items->data);
5005 if (as->parms[1].items) {
5006 apart = volutil_GetPartitionID(as->parms[1].items->data);
5008 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5009 as->parms[1].items->data);
5012 dummyPartList.partId[0] = apart;
5013 dummyPartList.partFlags[0] = PARTVALID;
5016 if (as->parms[2].items) {
5020 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
5022 PrintError("", code);
5025 "vos : partition %s does not exist on the server\n",
5026 as->parms[1].items->data);
5030 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
5032 PrintDiagnostics("listpart", code);
5036 for (i = 0; i < cnt; i++) {
5037 if (dummyPartList.partFlags[i] & PARTVALID) {
5038 MapPartIdIntoName(dummyPartList.partId[i], pname);
5039 code = UV_PartitionInfo(aserver, pname, &partition);
5041 fprintf(STDERR, "Could not get information on partition %s\n",
5043 PrintError("", code);
5047 "Free space on partition %s: %d K blocks out of total %d\n",
5048 pname, partition.free, partition.minFree);
5050 FillInt64(tmp,0,partition.free);
5051 AddUInt64(sumFree,tmp,&sumFree);
5052 FillInt64(tmp,0,partition.minFree);
5053 AddUInt64(sumStorage,tmp,&sumStorage);
5058 "Summary: %s free out of ",
5059 PrintInt64Size(sumFree));
5061 "%s on %d partitions\n",
5062 PrintInt64Size(sumStorage),
5069 ChangeAddr(register struct cmd_syndesc *as, void *arock)
5071 afs_int32 ip1, ip2, vcode;
5074 ip1 = GetServer(as->parms[0].items->data);
5076 fprintf(STDERR, "vos: invalid host address\n");
5080 if ((as->parms[1].items && as->parms[2].items)
5081 || (!as->parms[1].items && !as->parms[2].items)) {
5083 "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
5087 if (as->parms[1].items) {
5088 ip2 = GetServer(as->parms[1].items->data);
5090 fprintf(STDERR, "vos: invalid host address\n");
5094 /* Play a trick here. If we are removing an address, ip1 will be -1
5095 * and ip2 will be the original address. This switch prevents an
5096 * older revision vlserver from removing the IP address.
5103 vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
5106 fprintf(STDERR, "Could not remove server %s from the VLDB\n",
5107 as->parms[0].items->data);
5108 if (vcode == VL_NOENT) {
5110 "vlserver does not support the remove flag or ");
5113 fprintf(STDERR, "Could not change server %s to server %s\n",
5114 as->parms[0].items->data, as->parms[1].items->data);
5116 PrintError("", vcode);
5121 fprintf(STDOUT, "Removed server %s from the VLDB\n",
5122 as->parms[0].items->data);
5124 fprintf(STDOUT, "Changed server %s to server %s\n",
5125 as->parms[0].items->data, as->parms[1].items->data);
5131 print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
5132 int print, int noresolve)
5136 struct VLCallBack vlcb;
5139 ListAddrByAttributes m_attrs;
5140 afs_int32 m_nentries, *m_addrp;
5141 afs_int32 base, index;
5145 afsUUID_to_string(m_uuid, buf, sizeof(buf));
5146 printf("UUID: %s\n", buf);
5149 /* print out the list of all the server */
5150 addrp = (afs_int32 *) addrs->bulkaddrs_val;
5151 for (i = 0; i < nentries; i++, addrp++) {
5152 /* If it is a multihomed address, then we will need to
5153 * get the addresses for this multihomed server from
5154 * the vlserver and print them.
5156 if (((*addrp & 0xff000000) == 0xff000000) && ((*addrp) & 0xffff)) {
5157 /* Get the list of multihomed fileservers */
5158 base = (*addrp >> 16) & 0xff;
5159 index = (*addrp) & 0xffff;
5161 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
5162 && (index <= VL_MHSRV_PERBLK)) {
5163 m_attrs.Mask = VLADDR_INDEX;
5164 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
5166 m_addrs.bulkaddrs_val = 0;
5167 m_addrs.bulkaddrs_len = 0;
5169 ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, &m_uuid,
5170 &vlcb, &m_nentries, &m_addrs);
5173 "vos: could not list the multi-homed server addresses\n");
5174 PrintError("", vcode);
5177 /* Print the list */
5178 m_addrp = (afs_int32 *) m_addrs.bulkaddrs_val;
5179 for (j = 0; j < m_nentries; j++, m_addrp++) {
5180 *m_addrp = htonl(*m_addrp);
5183 printf("%s ", afs_inet_ntoa_r(*m_addrp, hoststr));
5185 printf("%s ", hostutil_GetNameByINet(*m_addrp));
5189 printf("<unknown>\n");
5198 /* Otherwise, it is a non-multihomed entry and contains
5199 * the IP address of the server - print it.
5201 *addrp = htonl(*addrp);
5204 printf("%s\n", afs_inet_ntoa_r(*addrp, hoststr));
5206 printf("%s\n", hostutil_GetNameByINet(*addrp));
5217 ListAddrs(register struct cmd_syndesc *as, void *arock)
5220 afs_int32 i, noresolve = 0, printuuid = 0;
5221 struct VLCallBack vlcb;
5224 ListAddrByAttributes m_attrs;
5225 afsUUID m_uuid, askuuid;
5226 afs_int32 m_nentries;
5228 memset(&m_attrs, 0, sizeof(struct ListAddrByAttributes));
5229 m_attrs.Mask = VLADDR_INDEX;
5231 memset(&m_addrs, 0, sizeof(bulkaddrs));
5232 memset(&askuuid, 0, sizeof(afsUUID));
5233 if (as->parms[0].items) {
5235 if (afsUUID_from_string(as->parms[0].items->data, &askuuid) < 0) {
5236 fprintf(STDERR, "vos: invalid UUID '%s'\n",
5237 as->parms[0].items->data);
5240 m_attrs.Mask = VLADDR_UUID;
5241 m_attrs.uuid = askuuid;
5243 if (as->parms[1].items) {
5247 he = hostutil_GetHostByName((char *)as->parms[1].items->data);
5249 fprintf(STDERR, "vos: Can't get host info for '%s'\n",
5250 as->parms[1].items->data);
5253 memcpy(&saddr, he->h_addr, 4);
5254 m_attrs.Mask = VLADDR_IPADDR;
5255 m_attrs.ipaddr = ntohl(saddr);
5257 if (as->parms[2].items) {
5260 if (as->parms[3].items) {
5264 m_addrs.bulkaddrs_val = 0;
5265 m_addrs.bulkaddrs_len = 0;
5268 ubik_Call_New(VL_GetAddrs, cstruct, 0, 0, 0, &vlcb, &nentries,
5271 fprintf(STDERR, "vos: could not list the server addresses\n");
5272 PrintError("", vcode);
5277 m_addrs.bulkaddrs_val = 0;
5278 m_addrs.bulkaddrs_len = 0;
5284 ubik_Call_New(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
5285 &vlcb, &m_nentries, &m_addrs);
5287 if (vcode == VL_NOENT) {
5288 if (m_attrs.Mask == VLADDR_UUID) {
5289 fprintf(STDERR, "vos: no entry for UUID '%s' found in VLDB\n",
5290 as->parms[0].items->data);
5292 } else if (m_attrs.Mask == VLADDR_IPADDR) {
5293 fprintf(STDERR, "vos: no entry for host '%s' [0x%08x] found in VLDB\n",
5294 as->parms[1].items->data, m_attrs.ipaddr);
5303 if (vcode == VL_INDEXERANGE) {
5308 fprintf(STDERR, "vos: could not list the server addresses\n");
5309 PrintError("", vcode);
5313 print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid, noresolve);
5316 if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
5324 LockEntry(register struct cmd_syndesc *as, void *arock)
5326 afs_int32 avolid, vcode, err;
5328 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5331 PrintError("", err);
5333 fprintf(STDERR, "vos: can't find volume '%s'\n",
5334 as->parms[0].items->data);
5337 vcode = ubik_VL_SetLock(cstruct, 0, avolid, -1, VLOP_DELETE);
5339 fprintf(STDERR, "Could not lock VLDB entry for volume %s\n",
5340 as->parms[0].items->data);
5341 PrintError("", vcode);
5344 fprintf(STDOUT, "Locked VLDB entry for volume %s\n",
5345 as->parms[0].items->data);
5350 ConvertRO(register struct cmd_syndesc *as, void *arock)
5352 afs_int32 partition = -1;
5353 afs_int32 server, volid, code, i, same;
5354 struct nvldbentry entry, storeEntry;
5357 afs_int32 rwserver = 0;
5358 afs_int32 rwpartition;
5360 afs_int32 roserver = 0;
5361 afs_int32 ropartition;
5363 struct rx_connection *aconn;
5366 server = GetServer(as->parms[0].items->data);
5368 fprintf(STDERR, "vos: host '%s' not found in host table\n",
5369 as->parms[0].items->data);
5372 partition = volutil_GetPartitionID(as->parms[1].items->data);
5373 if (partition < 0) {
5374 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5375 as->parms[1].items->data);
5378 if (!IsPartValid(partition, server, &code)) {
5380 PrintError("", code);
5383 "vos : partition %s does not exist on the server\n",
5384 as->parms[1].items->data);
5387 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &code);
5390 PrintError("", code);
5392 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
5393 as->parms[0].items->data);
5396 if (as->parms[3].items)
5399 vcode = VLDB_GetEntryByID(volid, -1, &entry);
5402 "Could not fetch the entry for volume %lu from VLDB\n",
5403 (unsigned long)volid);
5404 PrintError("convertROtoRW", code);
5408 /* use RO volid even if user specified RW or BK volid */
5410 if (volid != entry.volumeId[ROVOL])
5411 volid = entry.volumeId[ROVOL];
5413 MapHostToNetwork(&entry);
5414 for (i = 0; i < entry.nServers; i++) {
5415 if (entry.serverFlags[i] & ITSRWVOL) {
5417 rwserver = entry.serverNumber[i];
5418 rwpartition = entry.serverPartition[i];
5420 if (entry.serverFlags[i] & ITSROVOL) {
5421 same = VLDB_IsSameAddrs(server, entry.serverNumber[i], &code);
5424 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
5430 roserver = entry.serverNumber[i];
5431 ropartition = entry.serverPartition[i];
5437 fprintf(STDERR, "Warning: RO volume didn't exist in vldb!\n");
5439 if (ropartition != partition) {
5441 "Warning: RO volume should be in partition %d instead of %d (vldb)\n",
5442 ropartition, partition);
5447 "VLDB indicates that a RW volume exists already on %s in partition %s.\n",
5448 hostutil_GetNameByINet(rwserver),
5449 volutil_PartitionName(rwpartition));
5451 fprintf(STDERR, "Overwrite this VLDB entry? [y|n] (n)\n");
5453 while (!(dc == EOF || dc == '\n'))
5454 dc = getchar(); /* goto end of line */
5455 if ((c != 'y') && (c != 'Y')) {
5456 fprintf(STDERR, "aborted.\n");
5463 ubik_VL_SetLock(cstruct, 0, entry.volumeId[RWVOL], RWVOL,
5465 aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
5466 code = AFSVolConvertROtoRWvolume(aconn, partition, volid);
5469 "Converting RO volume %lu to RW volume failed with code %d\n",
5470 (unsigned long)volid, code);
5471 PrintError("convertROtoRW ", code);
5474 entry.serverFlags[roindex] = ITSRWVOL;
5475 entry.flags |= RW_EXISTS;
5476 entry.flags &= ~BACK_EXISTS;
5479 if (rwindex != entry.nServers) {
5480 entry.serverNumber[rwindex] = entry.serverNumber[entry.nServers];
5481 entry.serverPartition[rwindex] =
5482 entry.serverPartition[entry.nServers];
5483 entry.serverFlags[rwindex] = entry.serverFlags[entry.nServers];
5484 entry.serverNumber[entry.nServers] = 0;
5485 entry.serverPartition[entry.nServers] = 0;
5486 entry.serverFlags[entry.nServers] = 0;
5489 entry.flags &= ~RO_EXISTS;
5490 for (i = 0; i < entry.nServers; i++) {
5491 if (entry.serverFlags[i] & ITSROVOL) {
5492 if (!(entry.serverFlags[i] & (RO_DONTUSE | NEW_REPSITE)))
5493 entry.flags |= RO_EXISTS;
5496 MapNetworkToHost(&entry, &storeEntry);
5498 VLDB_ReplaceEntry(entry.volumeId[RWVOL], RWVOL, &storeEntry,
5499 (LOCKREL_OPCODE | LOCKREL_AFSID |
5500 LOCKREL_TIMESTAMP));
5503 "Warning: volume converted, but vldb update failed with code %d!\n",
5506 vcode = UV_LockRelease(entry.volumeId[RWVOL]);
5508 PrintDiagnostics("unlock", vcode);
5514 Sizes(register struct cmd_syndesc *as, void *arock)
5516 afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i;
5517 struct nvldbentry entry;
5518 volintSize vol_size;
5520 rx_SetRxDeadTime(60 * 10);
5521 for (i = 0; i < MAXSERVERS; i++) {
5522 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
5525 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
5526 if (rxConn->service)
5527 rxConn->service->connDeadTime = rx_connDeadTime;
5530 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5533 PrintError("", err);
5535 fprintf(STDERR, "vos: can't find volume '%s'\n",
5536 as->parms[0].items->data);
5540 if (as->parms[1].items || as->parms[2].items) {
5541 if (!as->parms[1].items || !as->parms[2].items) {
5543 "Must specify both -server and -partition options\n");
5546 aserver = GetServer(as->parms[2].items->data);
5548 fprintf(STDERR, "Invalid server name\n");
5551 apart = volutil_GetPartitionID(as->parms[1].items->data);
5553 fprintf(STDERR, "Invalid partition name\n");
5557 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
5564 if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
5565 code = ktime_DateToInt32(as->parms[4].items->data, &fromdate);
5567 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
5568 as->parms[4].items->data, code);
5573 fprintf(STDOUT, "Volume: %s\n", as->parms[0].items->data);
5575 if (as->parms[3].items) { /* do the dump estimate */
5576 #ifdef AFS_64BIT_ENV
5577 vol_size.dump_size = 0;
5579 FillInt64(vol_size.dump_size,0, 1);
5581 code = UV_GetSize(avolid, aserver, apart, fromdate, &vol_size);
5583 PrintDiagnostics("size", code);
5586 /* presumably the size info is now gathered in pntr */
5587 /* now we display it */
5589 fprintf(STDOUT, "dump_size: %llu\n", vol_size.dump_size);
5597 PrintDiagnostics(astring, acode)
5601 if (acode == EACCES) {
5603 "You are not authorized to perform the 'vos %s' command (%d)\n",
5606 fprintf(STDERR, "Error in vos %s command.\n", astring);
5607 PrintError("", acode);
5614 MyBeforeProc(struct cmd_syndesc *as, void *arock)
5616 register char *tcell;
5617 register afs_int32 code;
5618 register afs_int32 sauth;
5620 /* Initialize the ubik_client connection */
5621 rx_SetRxDeadTime(90);
5622 cstruct = (struct ubik_client *)0;
5626 if (as->parms[12].items) /* if -cell specified */
5627 tcell = as->parms[12].items->data;
5628 if (as->parms[14].items) /* -serverauth specified */
5630 if (as->parms[16].items) /* -crypt specified */
5633 vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
5634 &cstruct, UV_SetSecurity))) {
5635 fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
5636 (unsigned long)code);
5640 if (as->parms[15].items) /* -verbose flag set */
5650 /* this sucks but it works for now.
5655 #include "AFS_component_version_number.c"
5661 register afs_int32 code;
5663 register struct cmd_syndesc *ts;
5665 #ifdef AFS_AIX32_ENV
5667 * The following signal action for AIX is necessary so that in case of a
5668 * crash (i.e. core is generated) we can include the user's data section
5669 * in the core dump. Unfortunately, by default, only a partial core is
5670 * generated which, in many cases, isn't too useful.
5672 struct sigaction nsa;
5674 sigemptyset(&nsa.sa_mask);
5675 nsa.sa_handler = SIG_DFL;
5676 nsa.sa_flags = SA_FULLDUMP;
5677 sigaction(SIGSEGV, &nsa, NULL);
5680 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
5682 cmd_SetBeforeProc(MyBeforeProc, NULL);
5684 ts = cmd_CreateSyntax("create", CreateVolume, NULL, "create a new volume");
5685 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5686 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5687 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "volume name");
5688 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL,
5689 "initial quota (KB)");
5691 cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
5695 ts = cmd_CreateSyntax("remove", DeleteVolume, NULL, "delete a volume");
5696 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5697 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5698 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5702 ts = cmd_CreateSyntax("move", MoveVolume, NULL, "move a volume");
5703 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5704 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5705 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5706 "partition name on source");
5707 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5708 "machine name on destination");
5709 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5710 "partition name on destination");
5711 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5712 "copy live volume without cloning");
5715 ts = cmd_CreateSyntax("copy", CopyVolume, NULL, "copy a volume");
5716 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5717 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5718 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5719 "partition name on source");
5720 cmd_AddParm(ts, "-toname", CMD_SINGLE, 0, "volume name on destination");
5721 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5722 "machine name on destination");
5723 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5724 "partition name on destination");
5725 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5726 "leave new volume offline");
5727 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5728 "make new volume read-only");
5729 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5730 "copy live volume without cloning");
5733 ts = cmd_CreateSyntax("shadow", ShadowVolume, NULL,
5734 "make or update a shadow volume");
5735 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5736 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5737 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5738 "partition name on source");
5739 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5740 "machine name on destination");
5741 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5742 "partition name on destination");
5743 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5744 "volume name on destination");
5745 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5746 "volume ID on destination");
5747 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5748 "leave shadow volume offline");
5749 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5750 "make shadow volume read-only");
5751 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5752 "copy live volume without cloning");
5753 cmd_AddParm(ts, "-incremental", CMD_FLAG, CMD_OPTIONAL,
5754 "do incremental update if target exists");
5757 ts = cmd_CreateSyntax("backup", BackupVolume, NULL,
5758 "make backup of a volume");
5759 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5762 ts = cmd_CreateSyntax("clone", CloneVolume, NULL,
5763 "make clone of a volume");
5764 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5765 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5766 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5767 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5768 "volume name on destination");
5769 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5770 "volume ID on destination");
5771 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5772 "leave clone volume offline");
5773 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5774 "make clone volume read-only, not readwrite");
5777 ts = cmd_CreateSyntax("release", ReleaseVolume, NULL, "release a volume");
5778 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5779 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5780 "force a complete release");
5783 ts = cmd_CreateSyntax("dump", DumpVolume, NULL, "dump a volume");
5784 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5785 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5786 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5787 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5788 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5789 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL,
5790 "dump a clone of the volume");
5791 cmd_AddParm(ts, "-omitdirs", CMD_FLAG, CMD_OPTIONAL,
5792 "omit unchanged directories from an incremental dump");
5795 ts = cmd_CreateSyntax("restore", RestoreVolume, NULL, "restore a volume");
5796 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5797 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5798 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of volume to be restored");
5799 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5800 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
5801 cmd_AddParm(ts, "-overwrite", CMD_SINGLE, CMD_OPTIONAL,
5802 "abort | full | incremental");
5803 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5804 "leave restored volume offline");
5805 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5806 "make restored volume read-only");
5807 cmd_AddParm(ts, "-creation", CMD_SINGLE, CMD_OPTIONAL,
5808 "dump | keep | new");
5809 cmd_AddParm(ts, "-lastupdate", CMD_SINGLE, CMD_OPTIONAL,
5810 "dump | keep | new");
5811 cmd_AddParm(ts, "-nodelete", CMD_FLAG, CMD_OPTIONAL,
5812 "do not delete old site when restoring to a new site");
5815 ts = cmd_CreateSyntax("unlock", LockReleaseCmd, NULL,
5816 "release lock on VLDB entry for a volume");
5817 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5820 ts = cmd_CreateSyntax("changeloc", ChangeLocation, NULL,
5821 "change an RW volume's location in the VLDB");
5822 cmd_AddParm(ts, "-server", CMD_SINGLE, 0,
5823 "machine name for new location");
5824 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5825 "partition name for new location");
5826 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5829 ts = cmd_CreateSyntax("addsite", AddSite, NULL, "add a replication site");
5830 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new site");
5831 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5832 "partition name for new site");
5833 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5834 cmd_AddParm(ts, "-valid", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE, "publish as an up-to-date site in VLDB");
5837 ts = cmd_CreateSyntax("remsite", RemoveSite, NULL,
5838 "remove a replication site");
5839 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5840 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5841 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5844 ts = cmd_CreateSyntax("listpart", ListPartitions, NULL, "list partitions");
5845 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5848 ts = cmd_CreateSyntax("listvol", ListVolumes, NULL,
5849 "list volumes on server (bypass VLDB)");
5850 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5851 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5852 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "minimal listing");
5853 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
5854 "list all normal volume fields");
5855 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5856 "generate minimal information");
5857 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5858 "list extended volume fields");
5859 #ifdef FULL_LISTVOL_SWITCH
5860 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5861 "machine readable format");
5862 #endif /* FULL_LISTVOL_SWITCH */
5865 ts = cmd_CreateSyntax("syncvldb", SyncVldb, NULL,
5866 "synchronize VLDB with server");
5867 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5868 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5869 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5872 ts = cmd_CreateSyntax("syncserv", SyncServer, NULL,
5873 "synchronize server with VLDB");
5874 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5875 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5878 ts = cmd_CreateSyntax("examine", ExamineVolume, NULL,
5879 "everything about the volume");
5880 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5881 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5882 "list extended volume fields");
5883 #ifdef FULL_LISTVOL_SWITCH
5884 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5885 "machine readable format");
5886 #endif /* FULL_LISTVOL_SWITCH */
5888 cmd_CreateAlias(ts, "volinfo");
5890 ts = cmd_CreateSyntax("setfields", SetFields, NULL,
5891 "change volume info fields");
5892 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5893 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "quota (KB)");
5894 cmd_AddParm(ts, "-clearuse", CMD_FLAG, CMD_OPTIONAL, "clear dayUse");
5895 cmd_AddParm(ts, "-clearVolUpCounter", CMD_FLAG, CMD_OPTIONAL, "clear volUpdateCounter");
5898 ts = cmd_CreateSyntax("offline", volOffline, NULL, (char *)CMD_HIDDEN);
5899 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5900 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5901 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5902 cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds to sleep");
5903 cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "busy volume");
5906 ts = cmd_CreateSyntax("online", volOnline, NULL, (char *)CMD_HIDDEN);
5907 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5908 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5909 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5912 ts = cmd_CreateSyntax("zap", VolumeZap, NULL,
5913 "delete the volume, don't bother with VLDB");
5914 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5915 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5916 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume ID");
5917 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5918 "force deletion of bad volumes");
5919 cmd_AddParm(ts, "-backup", CMD_FLAG, CMD_OPTIONAL,
5920 "also delete backup volume if one is found");
5923 ts = cmd_CreateSyntax("status", VolserStatus, NULL,
5924 "report on volser status");
5925 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5928 ts = cmd_CreateSyntax("rename", RenameVolume, NULL, "rename a volume");
5929 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old volume name ");
5930 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new volume name ");
5933 ts = cmd_CreateSyntax("listvldb", ListVLDB, NULL,
5934 "list volumes in the VLDB");
5935 cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5936 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5937 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5938 cmd_AddParm(ts, "-locked", CMD_FLAG, CMD_OPTIONAL, "locked volumes only");
5939 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5940 "generate minimal information");
5941 cmd_AddParm(ts, "-nosort", CMD_FLAG, CMD_OPTIONAL,
5942 "do not alphabetically sort the volume names");
5945 ts = cmd_CreateSyntax("backupsys", BackSys, NULL, "en masse backups");
5946 cmd_AddParm(ts, "-prefix", CMD_LIST, CMD_OPTIONAL,
5947 "common prefix on volume(s)");
5948 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5949 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5950 cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL,
5951 "exclude common prefix volumes");
5952 cmd_AddParm(ts, "-xprefix", CMD_LIST, CMD_OPTIONAL,
5953 "negative prefix on volume(s)");
5954 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "no action");
5957 ts = cmd_CreateSyntax("delentry", DeleteEntry, NULL,
5958 "delete VLDB entry for a volume");
5959 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "volume name or ID");
5960 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL,
5961 "prefix of the volume whose VLDB entry is to be deleted");
5962 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5963 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5964 cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE,
5968 ts = cmd_CreateSyntax("partinfo", PartitionInfo, NULL,
5969 "list partition information");
5970 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5971 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5972 cmd_AddParm(ts, "-summary", CMD_FLAG, CMD_OPTIONAL,
5973 "print storage summary");
5976 ts = cmd_CreateSyntax("unlockvldb", UnlockVLDB, NULL,
5977 "unlock all the locked entries in the VLDB");
5978 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5979 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5982 ts = cmd_CreateSyntax("lock", LockEntry, NULL,
5983 "lock VLDB entry for a volume");
5984 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5987 ts = cmd_CreateSyntax("changeaddr", ChangeAddr, NULL,
5988 "change the IP address of a file server");
5989 cmd_AddParm(ts, "-oldaddr", CMD_SINGLE, 0, "original IP address");
5990 cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
5991 cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL,
5992 "remove the IP address from the VLDB");
5995 ts = cmd_CreateSyntax("listaddrs", ListAddrs, NULL,
5996 "list the IP address of all file servers registered in the VLDB");
5997 cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
5998 cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
5999 cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL,
6000 "don't resolve addresses");
6001 cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
6002 "print uuid of hosts");
6005 ts = cmd_CreateSyntax("convertROtoRW", ConvertRO, NULL,
6006 "convert a RO volume into a RW volume (after loss of old RW volume)");
6007 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6008 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
6009 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6010 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "don't ask");
6013 ts = cmd_CreateSyntax("size", Sizes, NULL,
6014 "obtain various sizes of the volume.");
6015 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6016 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6017 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6018 cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL,
6019 "Obtain the size of the dump");
6020 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
6023 code = cmd_Dispatch(argc, argv);
6025 /* Shut down the ubik_client and rx connections */
6027 (void)ubik_ClientDestroy(cstruct);
6033 exit((code ? -1 : 0));