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"
61 #include "vsutils_prototypes.h"
62 #include "lockprocs_prototypes.h"
64 #ifdef HAVE_POSIX_REGEX
68 /* Local Prototypes */
69 int PrintDiagnostics(char *astring, afs_int32 acode);
70 int GetVolumeInfo(afs_int32 volid, afs_int32 *server, afs_int32 *part,
71 afs_int32 *voltype, struct nvldbentry *rentry);
83 #define COMMONPARMS cmd_Seek(ts, 12);\
84 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
85 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");\
86 cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
87 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
88 cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
89 cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL, "don't resolve addresses"); \
91 #define ERROR_EXIT(code) {error=(code); goto error_exit;}
94 struct rx_connection *tconn;
96 extern struct ubik_client *cstruct;
99 static struct tqHead busyHead, notokHead;
102 qInit(struct tqHead *ahead)
104 memset((char *)ahead, 0, sizeof(struct tqHead));
110 qPut(struct tqHead *ahead, afs_int32 volid)
114 elem = (struct tqElem *)malloc(sizeof(struct tqElem));
115 elem->next = ahead->next;
123 qGet(struct tqHead *ahead, afs_int32 *volid)
127 if (ahead->count <= 0)
129 *volid = ahead->next->volid;
131 ahead->next = tmp->next;
137 /* returns 1 if <filename> exists else 0 */
139 FileExists(char *filename)
145 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
149 code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
157 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
159 VolNameOK(char *name)
164 total = strlen(name);
165 if (!strcmp(&name[total - 9], ".readonly")) {
167 } else if (!strcmp(&name[total - 7], ".backup")) {
174 /* return 1 if name is a number else 0 */
176 IsNumeric(char *name)
184 for (i = 0; i < len; i++) {
185 if (*ptr < '0' || *ptr > '9') {
197 * Parse a server name/address and return the address in HOST BYTE order
200 GetServer(char *aname)
202 register struct hostent *th;
205 register afs_int32 code;
206 char hostname[MAXHOSTCHARS];
208 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
210 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
211 addr = ntohl(addr); /* convert to host order */
213 th = gethostbyname(aname);
216 memcpy(&addr, th->h_addr, sizeof(addr));
219 if (addr == htonl(0x7f000001)) { /* local host */
220 code = gethostname(hostname, MAXHOSTCHARS);
223 th = gethostbyname(hostname); /* returns host byte order */
226 memcpy(&addr, th->h_addr, sizeof(addr));
233 GetVolumeType(char *aname)
236 if (!strcmp(aname, "ro"))
238 else if (!strcmp(aname, "rw"))
240 else if (!strcmp(aname, "bk"))
247 IsPartValid(afs_int32 partId, afs_int32 server, afs_int32 *code)
249 struct partList dummyPartList;
255 *code = UV_ListPartitions(server, &dummyPartList, &cnt);
258 for (i = 0; i < cnt; i++) {
259 if (dummyPartList.partFlags[i] & PARTVALID)
260 if (dummyPartList.partId[i] == partId)
268 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
269 * associated with <call> */
271 SendFile(usd_handle_t ufd, register struct rx_call *call, long blksize)
273 char *buffer = (char *)0;
278 buffer = (char *)malloc(blksize);
280 fprintf(STDERR, "malloc failed\n");
284 while (!error && !done) {
285 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
288 FD_SET((int)(ufd->handle), &in);
289 /* don't timeout if read blocks */
290 #if defined(AFS_PTHREAD_ENV)
291 select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
293 IOMGR_Select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
296 error = USD_READ(ufd, buffer, blksize, &nbytes);
298 fprintf(STDERR, "File system read failed\n");
305 if (rx_Write(call, buffer, nbytes) != nbytes) {
315 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
316 * writes it out to the volume. */
318 WriteData(struct rx_call *call, char *rock)
323 afs_int32 error, code;
325 afs_hyper_t filesize, currOffset;
332 if (!filename || !*filename) {
333 usd_StandardInput(&ufd);
337 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
340 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
343 fprintf(STDERR, "Could not access file '%s'\n", filename);
347 /* test if we have a valid dump */
348 hset64(filesize, 0, 0);
349 USD_SEEK(ufd, filesize, SEEK_END, &currOffset);
350 hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32));
351 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
352 USD_READ(ufd, (char *)&buffer, sizeof(afs_uint32), &got);
353 if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
354 fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
358 /* rewind, we are done */
359 hset64(filesize, 0, 0);
360 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
362 code = SendFile(ufd, call, blksize);
369 code = USD_CLOSE(ufd);
371 fprintf(STDERR, "Could not close dump file %s\n",
372 (filename && *filename) ? filename : "STDOUT");
380 /* Receive data from <call> stream into file associated
381 * with <fd> <blksize>
384 ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize)
388 afs_uint32 bytesleft, w;
391 buffer = (char *)malloc(blksize);
393 fprintf(STDERR, "memory allocation failed\n");
397 while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {
398 for (bytesleft = bytesread; bytesleft; bytesleft -= w) {
399 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
402 FD_SET((int)(ufd->handle), &out);
403 /* don't timeout if write blocks */
404 #if defined(AFS_PTHREAD_ENV)
405 select(((int)(ufd->handle)) + 1, &out, 0, 0, 0);
407 IOMGR_Select(((int)(ufd->handle)) + 1, 0, &out, 0, 0);
411 USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
413 fprintf(STDERR, "File system write failed\n");
426 DumpFunction(struct rx_call *call, char *filename)
428 usd_handle_t ufd; /* default is to stdout */
429 afs_int32 error = 0, code;
434 /* Open the output file */
435 if (!filename || !*filename) {
436 usd_StandardOutput(&ufd);
441 usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
445 code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
448 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
451 fprintf(STDERR, "Could not create file '%s'\n", filename);
452 ERROR_EXIT(VOLSERBADOP);
456 code = ReceiveFile(ufd, call, blksize);
461 /* Close the output file */
463 code = USD_CLOSE(ufd);
465 fprintf(STDERR, "Could not close dump file %s\n",
466 (filename && *filename) ? filename : "STDIN");
476 vos_ctime(afs_int32 *timep)
483 DisplayFormat(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
486 afs_int32 server, part;
487 int *totalOK, *totalNotOK, *totalBusy;
488 int fast, longlist, disp;
493 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
494 } else if (longlist) {
495 if (pntr->status == VOK) {
496 fprintf(STDOUT, "%-32s ", pntr->name);
497 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
499 fprintf(STDOUT, "RW ");
501 fprintf(STDOUT, "RO ");
503 fprintf(STDOUT, "BK ");
504 fprintf(STDOUT, "%10d K ", pntr->size);
505 if (pntr->inUse == 1) {
506 fprintf(STDOUT, "On-line");
509 fprintf(STDOUT, "Off-line");
512 if (pntr->needsSalvaged == 1)
513 fprintf(STDOUT, "**needs salvage**");
514 fprintf(STDOUT, "\n");
515 MapPartIdIntoName(part, pname);
516 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
518 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
519 (unsigned long)pntr->parentID,
520 (unsigned long)pntr->cloneID,
521 (unsigned long)pntr->backupID);
522 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
523 fprintf(STDOUT, " Creation %s",
524 vos_ctime(& pntr->creationDate));
525 #ifdef FULL_LISTVOL_SWITCH
526 fprintf(STDOUT, " Copy %s",
527 vos_ctime( & pntr->copyDate));
528 if (!pntr->backupDate)
529 fprintf(STDOUT, " Backup Never\n");
531 fprintf(STDOUT, " Backup %s",
532 vos_ctime( & pntr->backupDate));
533 if (pntr->accessDate)
534 fprintf(STDOUT, " Last Access %s",
535 vos_ctime( & pntr->accessDate));
537 if (!pntr->updateDate)
538 fprintf(STDOUT, " Last Update Never\n");
540 fprintf(STDOUT, " Last Update %s",
541 vos_ctime( & pntr->updateDate));
543 " %d accesses in the past day (i.e., vnode references)\n",
546 } else if (pntr->status == VBUSY) {
548 qPut(&busyHead, pntr->volid);
550 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
551 (unsigned long)pntr->volid);
554 qPut(¬okHead, pntr->volid);
556 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
557 (unsigned long)pntr->volid);
559 fprintf(STDOUT, "\n");
560 } else { /* default listing */
561 if (pntr->status == VOK) {
562 fprintf(STDOUT, "%-32s ", pntr->name);
563 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
565 fprintf(STDOUT, "RW ");
567 fprintf(STDOUT, "RO ");
569 fprintf(STDOUT, "BK ");
570 fprintf(STDOUT, "%10d K ", pntr->size);
571 if (pntr->inUse == 1) {
572 fprintf(STDOUT, "On-line");
575 fprintf(STDOUT, "Off-line");
578 if (pntr->needsSalvaged == 1)
579 fprintf(STDOUT, "**needs salvage**");
580 fprintf(STDOUT, "\n");
581 } else if (pntr->status == VBUSY) {
583 qPut(&busyHead, pntr->volid);
585 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
586 (unsigned long)pntr->volid);
589 qPut(¬okHead, pntr->volid);
591 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
592 (unsigned long)pntr->volid);
597 /*------------------------------------------------------------------------
598 * PRIVATE XDisplayFormat
601 * Display the contents of one extended volume info structure.
604 * a_xInfoP : Ptr to extended volume info struct to print.
605 * a_servID : Server ID to print.
606 * a_partID : Partition ID to print.
607 * a_totalOKP : Ptr to total-OK counter.
608 * a_totalNotOKP : Ptr to total-screwed counter.
609 * a_totalBusyP : Ptr to total-busy counter.
610 * a_fast : Fast listing?
611 * a_int32 : Int32 listing?
612 * a_showProblems : Show volume problems?
618 * Nothing interesting.
622 *------------------------------------------------------------------------*/
625 XDisplayFormat(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
626 a_totalBusyP, a_fast, a_int32, a_showProblems)
627 volintXInfo *a_xInfoP;
637 { /*XDisplayFormat */
645 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
646 } else if (a_int32) {
648 * Fully-detailed listing.
650 if (a_xInfoP->status == VOK) {
652 * Volume's status is OK - all the fields are valid.
654 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
655 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
656 if (a_xInfoP->type == 0)
657 fprintf(STDOUT, "RW ");
658 if (a_xInfoP->type == 1)
659 fprintf(STDOUT, "RO ");
660 if (a_xInfoP->type == 2)
661 fprintf(STDOUT, "BK ");
662 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
663 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
664 if (a_xInfoP->inUse == 1) {
665 fprintf(STDOUT, "On-line");
668 fprintf(STDOUT, "Off-line");
671 fprintf(STDOUT, "\n");
672 MapPartIdIntoName(a_partID, pname);
673 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
675 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
676 (unsigned long)a_xInfoP->parentID,
677 (unsigned long)a_xInfoP->cloneID,
678 (unsigned long)a_xInfoP->backupID);
679 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
680 fprintf(STDOUT, " Creation %s",
681 vos_ctime( & a_xInfoP->creationDate));
682 #ifdef FULL_LISTVOL_SWITCH
683 fprintf(STDOUT, " Copy %s",
684 vos_ctime( & a_xInfoP->copyDate));
685 if (!a_xInfoP->backupDate)
686 fprintf(STDOUT, " Backup Never\n");
688 fprintf(STDOUT, " Backup %s",
689 vos_ctime( & a_xInfoP->backupDate));
690 if (a_xInfoP->accessDate)
691 fprintf(STDOUT, " Last Access %s",
692 vos_ctime( & a_xInfoP->accessDate));
694 if (!a_xInfoP->updateDate)
695 fprintf(STDOUT, " Last Update Never\n");
697 fprintf(STDOUT, " Last Update %s",
698 vos_ctime( & a_xInfoP->updateDate));
700 " %d accesses in the past day (i.e., vnode references)\n",
705 * Print all the read/write and authorship stats.
707 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
709 " |-------------------------------------------|\n");
711 " | Same Network | Diff Network |\n");
713 " |----------|----------|----------|----------|\n");
715 " | Total | Auth | Total | Auth |\n");
717 " |----------|----------|----------|----------|\n");
718 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
719 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
720 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
721 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
722 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
723 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
724 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
725 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
726 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
727 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
729 " |-------------------------------------------|\n\n");
732 " Writes Affecting Authorship\n");
734 " |-------------------------------------------|\n");
736 " | File Authorship | Directory Authorship|\n");
738 " |----------|----------|----------|----------|\n");
740 " | Same | Diff | Same | Diff |\n");
742 " |----------|----------|----------|----------|\n");
743 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
744 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
745 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
746 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
747 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
748 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
749 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
750 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
751 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
752 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
753 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
754 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
755 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
756 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
757 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
758 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
759 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
760 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
761 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
762 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
763 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
764 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
765 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
766 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
767 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
768 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
769 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
770 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
771 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
772 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
774 " |-------------------------------------------|\n");
775 } /*Volume status OK */
776 else if (a_xInfoP->status == VBUSY) {
778 qPut(&busyHead, a_xInfoP->volid);
780 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
781 (unsigned long)a_xInfoP->volid);
785 qPut(¬okHead, a_xInfoP->volid);
787 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
788 (unsigned long)a_xInfoP->volid);
789 } /*Screwed volume */
790 fprintf(STDOUT, "\n");
796 if (a_xInfoP->status == VOK) {
797 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
798 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
799 if (a_xInfoP->type == 0)
800 fprintf(STDOUT, "RW ");
801 if (a_xInfoP->type == 1)
802 fprintf(STDOUT, "RO ");
803 if (a_xInfoP->type == 2)
804 fprintf(STDOUT, "BK ");
805 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
806 if (a_xInfoP->inUse == 1) {
807 fprintf(STDOUT, "On-line");
810 fprintf(STDOUT, "Off-line");
813 fprintf(STDOUT, "\n");
815 else if (a_xInfoP->status == VBUSY) {
817 qPut(&busyHead, a_xInfoP->volid);
819 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
820 (unsigned long)a_xInfoP->volid);
824 qPut(¬okHead, a_xInfoP->volid);
826 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
827 (unsigned long)a_xInfoP->volid);
828 } /*Screwed volume */
829 } /*Default listing */
830 } /*XDisplayFormat */
832 #ifdef FULL_LISTVOL_SWITCH
833 /*------------------------------------------------------------------------
834 * PRIVATE XDisplayFormat2
837 * Display the formated contents of one extended volume info structure.
840 * a_xInfoP : Ptr to extended volume info struct to print.
841 * a_servID : Server ID to print.
842 * a_partID : Partition ID to print.
843 * a_totalOKP : Ptr to total-OK counter.
844 * a_totalNotOKP : Ptr to total-screwed counter.
845 * a_totalBusyP : Ptr to total-busy counter.
846 * a_fast : Fast listing?
847 * a_int32 : Int32 listing?
848 * a_showProblems : Show volume problems?
854 * Nothing interesting.
858 *------------------------------------------------------------------------*/
861 XDisplayFormat2(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
862 a_totalBusyP, a_fast, a_int32, a_showProblems)
863 volintXInfo *a_xInfoP;
873 { /*XDisplayFormat */
878 fprintf(STDOUT, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP->volid);
879 } else if (a_int32) {
881 * Fully-detailed listing.
883 if (a_xInfoP->status == VOK) {
885 * Volume's status is OK - all the fields are valid.
888 static long server_cache = -1, partition_cache = -1;
889 static char hostname[256], address[32], pname[16];
890 int i,ai[] = {VOLINT_STATS_TIME_IDX_0,VOLINT_STATS_TIME_IDX_1,VOLINT_STATS_TIME_IDX_2,
891 VOLINT_STATS_TIME_IDX_3,VOLINT_STATS_TIME_IDX_4,VOLINT_STATS_TIME_IDX_5};
893 if (a_servID != server_cache) {
897 strcpy(hostname, hostutil_GetNameByINet(a_servID));
898 strcpy(address, inet_ntoa(s));
899 server_cache = a_servID;
901 if (a_partID != partition_cache) {
902 MapPartIdIntoName(a_partID, pname);
903 partition_cache = a_partID;
906 fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name);
907 fprintf(STDOUT, "id\t\t%lu\n", a_xInfoP->volid);
908 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
909 fprintf(STDOUT, "part\t\t%s\n", pname);
910 switch (a_xInfoP->status) {
912 fprintf(STDOUT, "status\t\tOK\n");
915 fprintf(STDOUT, "status\t\tBUSY\n");
918 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
921 fprintf(STDOUT, "backupID\t%lu\n", a_xInfoP->backupID);
922 fprintf(STDOUT, "parentID\t%lu\n", a_xInfoP->parentID);
923 fprintf(STDOUT, "cloneID\t\t%lu\n", a_xInfoP->cloneID);
924 fprintf(STDOUT, "inUse\t\t%s\n", a_xInfoP->inUse ? "Y" : "N");
925 switch (a_xInfoP->type) {
927 fprintf(STDOUT, "type\t\tRW\n");
930 fprintf(STDOUT, "type\t\tRO\n");
933 fprintf(STDOUT, "type\t\tBK\n");
936 fprintf(STDOUT, "type\t\t?\n");
939 fprintf(STDOUT, "creationDate\t%-9lu\t%s", a_xInfoP->creationDate,
940 vos_ctime(&a_xInfoP->creationDate));
941 fprintf(STDOUT, "accessDate\t%-9lu\t%s", a_xInfoP->accessDate,
942 vos_ctime(&a_xInfoP->accessDate));
943 fprintf(STDOUT, "updateDate\t%-9lu\t%s", a_xInfoP->updateDate,
944 vos_ctime(&a_xInfoP->updateDate));
945 fprintf(STDOUT, "backupDate\t%-9lu\t%s", a_xInfoP->backupDate,
946 vos_ctime(&a_xInfoP->backupDate));
947 fprintf(STDOUT, "copyDate\t%-9lu\t%s", a_xInfoP->copyDate,
948 vos_ctime(&a_xInfoP->copyDate));
950 fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
951 fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
953 fprintf(STDOUT, "filecount\t%u\n", a_xInfoP->filecount);
954 fprintf(STDOUT, "dayUse\t\t%u\n", a_xInfoP->dayUse);
958 fprintf(STDOUT,"reads_same_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]);
959 fprintf(STDOUT,"reads_same_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]);
960 fprintf(STDOUT,"reads_diff_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]);
961 fprintf(STDOUT,"reads_diff_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
963 fprintf(STDOUT,"writes_same_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]);
964 fprintf(STDOUT,"writes_same_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]);
965 fprintf(STDOUT,"writes_diff_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]);
966 fprintf(STDOUT,"writes_diff_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
970 fprintf(STDOUT,"file_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileSameAuthor[ai[i]]);
971 fprintf(STDOUT,"file_diff_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileDiffAuthor[ai[i]]);
972 fprintf(STDOUT,"dir_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirSameAuthor[ai[i]]);
973 fprintf(STDOUT,"dir_dif_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirDiffAuthor[ai[i]]);
976 } /*Volume status OK */
977 else if (a_xInfoP->status == VBUSY) {
979 qPut(&busyHead, a_xInfoP->volid);
981 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
982 (unsigned long)a_xInfoP->volid);
986 qPut(¬okHead, a_xInfoP->volid);
988 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
989 (unsigned long)a_xInfoP->volid);
990 } /*Screwed volume */
996 if (a_xInfoP->status == VOK) {
997 fprintf(STDOUT, "name\t%-32s\n", a_xInfoP->name);
998 fprintf(STDOUT, "volID\t%10lu\n", (unsigned long)a_xInfoP->volid);
999 if (a_xInfoP->type == 0)
1000 fprintf(STDOUT, "type\tRW\n");
1001 if (a_xInfoP->type == 1)
1002 fprintf(STDOUT, "type\tRO\n");
1003 if (a_xInfoP->type == 2)
1004 fprintf(STDOUT, "type\tBK\n");
1005 fprintf(STDOUT, "size\t%10dK\n", a_xInfoP->size);
1007 fprintf(STDOUT, "inUse\t%d\n",a_xInfoP->inUse);
1008 if (a_xInfoP->inUse == 1)
1014 else if (a_xInfoP->status == VBUSY) {
1016 qPut(&busyHead, a_xInfoP->volid);
1018 fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
1019 (unsigned long)a_xInfoP->volid);
1023 qPut(¬okHead, a_xInfoP->volid);
1025 fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
1026 (unsigned long)a_xInfoP->volid);
1027 } /*Screwed volume */
1028 } /*Default listing */
1029 } /*XDisplayFormat */
1030 #endif /*FULL_LISTVOL_SWITCH*/
1032 #ifdef FULL_LISTVOL_SWITCH
1034 DisplayFormat2(server, partition, pntr)
1035 long server, partition;
1038 static long server_cache = -1, partition_cache = -1;
1039 static char hostname[256], address[32], pname[16];
1041 if (server != server_cache) {
1045 strcpy(hostname, hostutil_GetNameByINet(server));
1046 strcpy(address, inet_ntoa(s));
1047 server_cache = server;
1049 if (partition != partition_cache) {
1050 MapPartIdIntoName(partition, pname);
1051 partition_cache = partition;
1053 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
1054 fprintf(STDOUT, "id\t\t%lu\n", pntr->volid);
1055 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
1056 fprintf(STDOUT, "part\t\t%s\n", pname);
1057 switch (pntr->status) {
1059 fprintf(STDOUT, "status\t\tOK\n");
1062 fprintf(STDOUT, "status\t\tBUSY\n");
1065 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
1068 fprintf(STDOUT, "backupID\t%lu\n", pntr->backupID);
1069 fprintf(STDOUT, "parentID\t%lu\n", pntr->parentID);
1070 fprintf(STDOUT, "cloneID\t\t%lu\n", pntr->cloneID);
1071 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
1072 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
1073 /* 0xD3 is from afs/volume.h since I had trouble including the file */
1074 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
1075 switch (pntr->type) {
1077 fprintf(STDOUT, "type\t\tRW\n");
1080 fprintf(STDOUT, "type\t\tRO\n");
1083 fprintf(STDOUT, "type\t\tBK\n");
1086 fprintf(STDOUT, "type\t\t?\n");
1089 fprintf(STDOUT, "creationDate\t%-9lu\t%s", pntr->creationDate,
1090 vos_ctime(&pntr->creationDate));
1091 fprintf(STDOUT, "accessDate\t%-9lu\t%s", pntr->accessDate,
1092 vos_ctime(&pntr->accessDate));
1093 fprintf(STDOUT, "updateDate\t%-9lu\t%s", pntr->updateDate,
1094 vos_ctime(&pntr->updateDate));
1095 fprintf(STDOUT, "backupDate\t%-9lu\t%s", pntr->backupDate,
1096 vos_ctime(&pntr->backupDate));
1097 fprintf(STDOUT, "copyDate\t%-9lu\t%s", pntr->copyDate,
1098 vos_ctime(&pntr->copyDate));
1099 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n", pntr->flags);
1100 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
1101 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
1102 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n", pntr->spare0);
1103 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
1104 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
1105 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n", pntr->spare1);
1106 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n", pntr->spare2);
1107 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n", pntr->spare3);
1112 DisplayVolumes2(server, partition, pntr, count)
1114 long server, partition, count;
1118 for (i = 0; i < count; i++) {
1119 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1120 DisplayFormat2(server, partition, pntr);
1121 fprintf(STDOUT, "END_OF_ENTRY\n\n");
1126 #endif /* FULL_LISTVOL_SWITCH */
1129 DisplayVolumes(server, part, pntr, count, longlist, fast, quiet)
1130 afs_int32 server, part;
1132 afs_int32 count, longlist, fast;
1135 int totalOK, totalNotOK, totalBusy, i;
1143 for (i = 0; i < count; i++) {
1144 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
1149 while (busyHead.count) {
1150 qGet(&busyHead, &volid);
1151 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1152 (unsigned long)volid);
1156 while (notokHead.count) {
1157 qGet(¬okHead, &volid);
1158 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1159 (unsigned long)volid);
1163 fprintf(STDOUT, "\n");
1166 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
1167 totalOK, totalNotOK, totalBusy);
1171 /*------------------------------------------------------------------------
1172 * PRIVATE XDisplayVolumes
1175 * Display extended volume information.
1178 * a_servID : Pointer to the Rx call we're performing.
1179 * a_partID : Partition for which we want the extended list.
1180 * a_xInfoP : Ptr to extended volume info.
1181 * a_count : Number of volume records contained above.
1182 * a_int32 : Int32 listing generated?
1183 * a_fast : Fast listing generated?
1184 * a_quiet : Quiet listing generated?
1190 * Nothing interesting.
1194 *------------------------------------------------------------------------*/
1197 XDisplayVolumes(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
1201 volintXInfo *a_xInfoP;
1207 { /*XDisplayVolumes */
1209 int totalOK; /*Total OK volumes */
1210 int totalNotOK; /*Total screwed volumes */
1211 int totalBusy; /*Total busy volumes */
1212 int i; /*Loop variable */
1213 afs_int32 volid; /*Current volume ID */
1216 * Initialize counters and (global!!) queues.
1225 * Display each volume in the list.
1227 for (i = 0; i < a_count; i++) {
1228 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1229 &totalBusy, a_fast, a_int32, 0);
1234 * If any volumes were found to be busy or screwed, display them.
1237 while (busyHead.count) {
1238 qGet(&busyHead, &volid);
1239 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1240 (unsigned long)volid);
1244 while (notokHead.count) {
1245 qGet(¬okHead, &volid);
1246 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1247 (unsigned long)volid);
1252 fprintf(STDOUT, "\n");
1255 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1256 totalOK, totalNotOK, totalBusy);
1260 } /*XDisplayVolumes */
1261 #ifdef FULL_LISTVOL_SWITCH
1262 /*------------------------------------------------------------------------
1263 * PRIVATE XDisplayVolumes2
1266 * Display extended formated volume information.
1269 * a_servID : Pointer to the Rx call we're performing.
1270 * a_partID : Partition for which we want the extended list.
1271 * a_xInfoP : Ptr to extended volume info.
1272 * a_count : Number of volume records contained above.
1273 * a_int32 : Int32 listing generated?
1274 * a_fast : Fast listing generated?
1275 * a_quiet : Quiet listing generated?
1281 * Nothing interesting.
1285 *------------------------------------------------------------------------*/
1288 XDisplayVolumes2(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
1292 volintXInfo *a_xInfoP;
1298 { /*XDisplayVolumes */
1300 int totalOK; /*Total OK volumes */
1301 int totalNotOK; /*Total screwed volumes */
1302 int totalBusy; /*Total busy volumes */
1303 int i; /*Loop variable */
1304 afs_int32 volid; /*Current volume ID */
1307 * Initialize counters and (global!!) queues.
1316 * Display each volume in the list.
1318 for (i = 0; i < a_count; i++) {
1319 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1320 XDisplayFormat2(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1321 &totalBusy, a_fast, a_int32, 0);
1322 fprintf(STDOUT, "END_OF_ENTRY\n");
1327 * If any volumes were found to be busy or screwed, display them.
1330 while (busyHead.count) {
1331 qGet(&busyHead, &volid);
1332 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1333 (unsigned long)volid);
1337 while (notokHead.count) {
1338 qGet(¬okHead, &volid);
1339 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1340 (unsigned long)volid);
1345 fprintf(STDOUT, "\n");
1348 "VOLUMES_ONLINE\t%d\nVOLUMES_OFFLINE\t%d\nVOLUMES_BUSY\t%d\n",
1349 totalOK, totalNotOK, totalBusy);
1353 } /*XDisplayVolumes2 */
1354 #endif /* FULL_LISTVOL_SWITCH */
1357 /* set <server> and <part> to the correct values depending on
1358 * <voltype> and <entry> */
1360 GetServerAndPart(entry, voltype, server, part, previdx)
1361 struct nvldbentry *entry;
1362 afs_int32 *server, *part;
1366 int i, istart, vtype;
1371 /* Doesn't check for non-existance of backup volume */
1372 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1374 istart = 0; /* seach the entire entry */
1377 /* Seach from beginning of entry or pick up where we left off */
1378 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1381 for (i = istart; i < entry->nServers; i++) {
1382 if (entry->serverFlags[i] & vtype) {
1383 *server = entry->serverNumber[i];
1384 *part = entry->serverPartition[i];
1390 /* Didn't find any, return -1 */
1396 PostVolumeStats(struct nvldbentry *entry)
1398 SubEnumerateEntry(entry);
1399 /* Check for VLOP_ALLOPERS */
1400 if (entry->flags & VLOP_ALLOPERS)
1401 fprintf(STDOUT, " Volume is currently LOCKED \n");
1405 /*------------------------------------------------------------------------
1406 * PRIVATE XVolumeStats
1409 * Display extended volume information.
1412 * a_xInfoP : Ptr to extended volume info.
1413 * a_entryP : Ptr to the volume's VLDB entry.
1414 * a_srvID : Server ID.
1415 * a_partID : Partition ID.
1416 * a_volType : Type of volume to print.
1422 * Nothing interesting.
1426 *------------------------------------------------------------------------*/
1429 XVolumeStats(a_xInfoP, a_entryP, a_srvID, a_partID, a_volType)
1430 volintXInfo *a_xInfoP;
1431 struct nvldbentry *a_entryP;
1438 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1440 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1441 a_srvID, /*Server ID to print */
1442 a_partID, /*Partition ID to print */
1443 &totalOK, /*Ptr to total-OK counter */
1444 &totalNotOK, /*Ptr to total-screwed counter */
1445 &totalBusy, /*Ptr to total-busy counter */
1446 0, /*Don't do a fast listing */
1447 1, /*Do a long listing */
1448 1); /*Show volume problems */
1454 VolumeStats_int(volintInfo *pntr, struct nvldbentry *entry, afs_int32 server,
1455 afs_int32 part, int voltype)
1457 int totalOK, totalNotOK, totalBusy;
1459 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1464 /* command to forcibly remove a volume */
1466 NukeVolume(register struct cmd_syndesc *as)
1468 register afs_int32 code;
1469 afs_int32 volID, err;
1474 server = GetServer(tp = as->parms[0].items->data);
1476 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1480 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1482 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1486 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1489 PrintError("", err);
1492 "vos: could not parse '%s' as a numeric volume ID", tp);
1497 "vos: forcibly removing all traces of volume %d, please wait...",
1500 code = UV_NukeVolume(server, partID, volID);
1502 fprintf(STDOUT, "done.\n");
1504 fprintf(STDOUT, "failed with code %d.\n", code);
1509 /*------------------------------------------------------------------------
1510 * PRIVATE ExamineVolume
1513 * Routine used to examine a single volume, contacting the VLDB as
1514 * well as the Volume Server.
1517 * as : Ptr to parsed command line arguments.
1520 * 0 for a successful operation,
1521 * Otherwise, one of the ubik or VolServer error values.
1524 * Nothing interesting.
1528 *------------------------------------------------------------------------
1531 ExamineVolume(register struct cmd_syndesc *as, void *arock)
1533 struct nvldbentry entry;
1534 afs_int32 vcode = 0;
1535 volintInfo *pntr = (volintInfo *) 0;
1536 volintXInfo *xInfoP = (volintXInfo *) 0;
1538 afs_int32 code, err, error = 0;
1539 int voltype, foundserv = 0, foundentry = 0;
1540 afs_int32 aserver, apart;
1542 int wantExtendedInfo; /*Do we want extended vol info? */
1544 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1546 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1549 PrintError("", err);
1551 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1552 as->parms[0].items->data);
1557 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1558 (unsigned long)volid);
1561 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1564 "Could not fetch the entry for volume number %lu from VLDB \n",
1565 (unsigned long)volid);
1569 fprintf(STDOUT, "done\n");
1570 MapHostToNetwork(&entry);
1572 if (entry.volumeId[RWVOL] == volid)
1574 else if (entry.volumeId[BACKVOL] == volid)
1576 else /* (entry.volumeId[ROVOL] == volid) */
1579 do { /* do {...} while (voltype == ROVOL) */
1580 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1581 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1582 * If its a RO vol, get the next RO entry.
1584 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1585 &aserver, &apart, &previdx);
1586 if (previdx == -1) { /* searched all entries */
1588 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1589 as->parms[0].items->data);
1596 /* Get information about the volume from the server */
1598 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1599 hostutil_GetNameByINet(aserver));
1602 if (wantExtendedInfo)
1603 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1605 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1607 fprintf(STDOUT, "done\n");
1611 if (code == ENODEV) {
1612 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1613 /* The VLDB says there is no backup volume and its not on disk */
1614 fprintf(STDERR, "Volume %s does not exist\n",
1615 as->parms[0].items->data);
1619 "Volume does not exist on server %s as indicated by the VLDB\n",
1620 hostutil_GetNameByINet(aserver));
1623 PrintDiagnostics("examine", code);
1625 fprintf(STDOUT, "\n");
1628 if (wantExtendedInfo)
1629 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1631 #ifdef FULL_LISTVOL_SWITCH
1632 if (as->parms[2].items) {
1633 DisplayFormat2(aserver, apart, pntr);
1634 EnumerateEntry(&entry);
1636 #endif /* FULL_LISTVOL_SWITCH */
1637 VolumeStats_int(pntr, &entry, aserver, apart, voltype);
1639 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1640 /* The VLDB says there is no backup volume yet we found one on disk */
1641 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1642 as->parms[0].items->data);
1651 } while (voltype == ROVOL);
1654 fprintf(STDERR, "Dump only information from VLDB\n\n");
1655 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1657 PostVolumeStats(&entry);
1662 /*------------------------------------------------------------------------
1666 * Routine used to change the status of a single volume.
1669 * as : Ptr to parsed command line arguments.
1672 * 0 for a successful operation,
1673 * Otherwise, one of the ubik or VolServer error values.
1676 * Nothing interesting.
1680 *------------------------------------------------------------------------
1683 SetFields(register struct cmd_syndesc *as, void *arock)
1685 struct nvldbentry entry;
1686 afs_int32 vcode = 0;
1689 afs_int32 code, err;
1690 afs_int32 aserver, apart;
1693 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1696 PrintError("", err);
1698 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1699 as->parms[0].items->data);
1703 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1706 "Could not fetch the entry for volume number %lu from VLDB \n",
1707 (unsigned long)volid);
1710 MapHostToNetwork(&entry);
1712 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1713 if (previdx == -1) {
1714 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1715 as->parms[0].items->data);
1719 init_volintInfo(&info);
1723 if (as->parms[1].items) {
1725 code = util_GetInt32(as->parms[1].items->data, &info.maxquota);
1727 fprintf(STDERR, "invalid quota value\n");
1731 if (as->parms[2].items) {
1735 if (as->parms[3].items) {
1736 /* -clearVolUpCounter */
1739 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1742 "Could not update volume info fields for volume number %lu\n",
1743 (unsigned long)volid);
1747 /*------------------------------------------------------------------------
1751 * Brings a volume online.
1754 * as : Ptr to parsed command line arguments.
1757 * 0 for a successful operation,
1760 * Nothing interesting.
1764 *------------------------------------------------------------------------
1767 volOnline(register struct cmd_syndesc *as, void *arock)
1769 afs_int32 server, partition, volid;
1770 afs_int32 code, err = 0;
1772 server = GetServer(as->parms[0].items->data);
1774 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1775 as->parms[0].items->data);
1779 partition = volutil_GetPartitionID(as->parms[1].items->data);
1780 if (partition < 0) {
1781 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1782 as->parms[1].items->data);
1786 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1789 PrintError("", err);
1791 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1792 as->parms[0].items->data);
1796 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1799 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1806 /*------------------------------------------------------------------------
1807 * PRIVATE volOffline
1810 * Brings a volume offline.
1813 * as : Ptr to parsed command line arguments.
1816 * 0 for a successful operation,
1819 * Nothing interesting.
1823 *------------------------------------------------------------------------
1826 volOffline(register struct cmd_syndesc *as, void *arock)
1828 afs_int32 server, partition, volid;
1829 afs_int32 code, err = 0;
1830 afs_int32 transflag, sleeptime, transdone;
1832 server = GetServer(as->parms[0].items->data);
1834 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1835 as->parms[0].items->data);
1839 partition = volutil_GetPartitionID(as->parms[1].items->data);
1840 if (partition < 0) {
1841 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1842 as->parms[1].items->data);
1846 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1849 PrintError("", err);
1851 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1852 as->parms[0].items->data);
1856 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1857 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1858 transdone = (sleeptime ? 0 /*online */ : VTOutOfService);
1859 if (as->parms[4].items && !as->parms[3].items) {
1860 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1865 UV_SetVolume(server, partition, volid, transflag, transdone,
1868 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1876 CreateVolume(register struct cmd_syndesc *as, void *arock)
1880 afs_int32 volid, code;
1881 struct nvldbentry entry;
1886 tserver = GetServer(as->parms[0].items->data);
1888 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1889 as->parms[0].items->data);
1892 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1894 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1895 as->parms[1].items->data);
1898 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1900 PrintError("", code);
1903 "vos : partition %s does not exist on the server\n",
1904 as->parms[1].items->data);
1907 if (!ISNAMEVALID(as->parms[2].items->data)) {
1909 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1910 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1913 if (!VolNameOK(as->parms[2].items->data)) {
1915 "Illegal volume name %s, should not end in .readonly or .backup\n",
1916 as->parms[2].items->data);
1919 if (IsNumeric(as->parms[2].items->data)) {
1920 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1921 as->parms[2].items->data);
1924 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1926 fprintf(STDERR, "Volume %s already exists\n",
1927 as->parms[2].items->data);
1928 PrintDiagnostics("create", code);
1932 if (as->parms[3].items) {
1933 if (!IsNumeric(as->parms[3].items->data)) {
1934 fprintf(STDERR, "Initial quota %s should be numeric.\n",
1935 as->parms[3].items->data);
1939 code = util_GetInt32(as->parms[3].items->data, "a);
1941 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1947 UV_CreateVolume2(tserver, pnum, as->parms[2].items->data, quota, 0,
1950 PrintDiagnostics("create", code);
1953 MapPartIdIntoName(pnum, part);
1954 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
1955 (unsigned long)volid, part, as->parms[0].items->data);
1962 struct nvldbentry *entry;
1965 afs_int32 error, code, curserver, curpart, volid;
1967 MapHostToNetwork(entry);
1969 for (i = 0; i < entry->nServers; i++) {
1970 curserver = entry->serverNumber[i];
1971 curpart = entry->serverPartition[i];
1972 if (entry->serverFlags[i] & ITSROVOL) {
1973 volid = entry->volumeId[ROVOL];
1975 volid = entry->volumeId[RWVOL];
1977 code = UV_DeleteVolume(curserver, curpart, volid);
1985 DeleteVolume(struct cmd_syndesc *as, void *arock)
1987 afs_int32 err, code = 0;
1988 afs_int32 server = 0, partition = -1, volid;
1992 if (as->parms[0].items) {
1993 server = GetServer(as->parms[0].items->data);
1995 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1996 as->parms[0].items->data);
2001 if (as->parms[1].items) {
2002 partition = volutil_GetPartitionID(as->parms[1].items->data);
2003 if (partition < 0) {
2004 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2005 as->parms[1].items->data);
2009 /* Check for validity of the partition */
2010 if (!IsPartValid(partition, server, &code)) {
2012 PrintError("", code);
2015 "vos : partition %s does not exist on the server\n",
2016 as->parms[1].items->data);
2022 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2024 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
2025 as->parms[2].items->data);
2027 PrintError("", err);
2031 /* If the server or partition option are not complete, try to fill
2032 * them in from the VLDB entry.
2034 if ((partition == -1) || !server) {
2035 struct nvldbentry entry;
2037 code = VLDB_GetEntryByID(volid, -1, &entry);
2040 "Could not fetch the entry for volume %lu from VLDB\n",
2041 (unsigned long)volid);
2042 PrintError("", code);
2046 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
2047 || ((volid == entry.volumeId[BACKVOL])
2048 && (entry.flags & BACK_EXISTS))) {
2049 idx = Lp_GetRwIndex(&entry);
2050 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2051 || ((partition != -1)
2052 && (partition != entry.serverPartition[idx]))) {
2053 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2054 as->parms[2].items->data);
2057 } else if ((volid == entry.volumeId[ROVOL])
2058 && (entry.flags & RO_EXISTS)) {
2059 for (idx = -1, j = 0; j < entry.nServers; j++) {
2060 if (entry.serverFlags[j] != ITSROVOL)
2063 if (((server == 0) || (server == entry.serverNumber[j]))
2064 && ((partition == -1)
2065 || (partition == entry.serverPartition[j]))) {
2068 "VLDB: Volume '%s' matches more than one RO\n",
2069 as->parms[2].items->data);
2076 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2077 as->parms[2].items->data);
2081 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2082 as->parms[2].items->data);
2086 server = htonl(entry.serverNumber[idx]);
2087 partition = entry.serverPartition[idx];
2091 code = UV_DeleteVolume(server, partition, volid);
2093 PrintDiagnostics("remove", code);
2097 MapPartIdIntoName(partition, pname);
2098 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2099 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2103 #define TESTM 0 /* set for move space tests, clear for production */
2105 MoveVolume(register struct cmd_syndesc *as, void *arock)
2108 afs_int32 volid, fromserver, toserver, frompart, topart;
2109 afs_int32 flags, code, err;
2110 char fromPartName[10], toPartName[10];
2112 struct diskPartition64 partition; /* for space check */
2115 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2118 PrintError("", err);
2120 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2121 as->parms[0].items->data);
2124 fromserver = GetServer(as->parms[1].items->data);
2125 if (fromserver == 0) {
2126 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2127 as->parms[1].items->data);
2130 toserver = GetServer(as->parms[3].items->data);
2131 if (toserver == 0) {
2132 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2133 as->parms[3].items->data);
2136 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2138 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2139 as->parms[2].items->data);
2142 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2144 PrintError("", code);
2147 "vos : partition %s does not exist on the server\n",
2148 as->parms[2].items->data);
2151 topart = volutil_GetPartitionID(as->parms[4].items->data);
2153 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2154 as->parms[4].items->data);
2157 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2159 PrintError("", code);
2162 "vos : partition %s does not exist on the server\n",
2163 as->parms[4].items->data);
2168 if (as->parms[5].items) flags |= RV_NOCLONE;
2171 * check source partition for space to clone volume
2174 MapPartIdIntoName(topart, toPartName);
2175 MapPartIdIntoName(frompart, fromPartName);
2178 * check target partition for space to move volume
2181 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2183 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2187 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2190 p = (volintInfo *) 0;
2191 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2193 fprintf(STDERR, "vos:cannot access volume %lu\n",
2194 (unsigned long)volid);
2198 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2200 if (partition.free <= p->size) {
2202 "vos: no space on target partition %s to move volume %lu\n",
2203 toPartName, (unsigned long)volid);
2210 fprintf(STDOUT, "size test - don't do move\n");
2214 /* successful move still not guaranteed but shoot for it */
2217 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2219 PrintDiagnostics("move", code);
2222 MapPartIdIntoName(topart, toPartName);
2223 MapPartIdIntoName(frompart, fromPartName);
2224 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2225 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2226 as->parms[3].items->data, toPartName);
2232 CopyVolume(register struct cmd_syndesc *as, void *arock)
2234 afs_int32 volid, fromserver, toserver, frompart, topart, code, err, flags;
2235 char fromPartName[10], toPartName[10], *tovolume;
2236 struct nvldbentry entry;
2237 struct diskPartition64 partition; /* for space check */
2240 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2243 PrintError("", err);
2245 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2246 as->parms[0].items->data);
2249 fromserver = GetServer(as->parms[1].items->data);
2250 if (fromserver == 0) {
2251 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2252 as->parms[1].items->data);
2256 toserver = GetServer(as->parms[4].items->data);
2257 if (toserver == 0) {
2258 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2259 as->parms[4].items->data);
2263 tovolume = as->parms[3].items->data;
2264 if (!ISNAMEVALID(tovolume)) {
2266 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2267 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2270 if (!VolNameOK(tovolume)) {
2272 "Illegal volume name %s, should not end in .readonly or .backup\n",
2276 if (IsNumeric(tovolume)) {
2277 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2281 code = VLDB_GetEntryByName(tovolume, &entry);
2283 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2284 PrintDiagnostics("copy", code);
2288 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2290 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2291 as->parms[2].items->data);
2294 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2296 PrintError("", code);
2299 "vos : partition %s does not exist on the server\n",
2300 as->parms[2].items->data);
2304 topart = volutil_GetPartitionID(as->parms[5].items->data);
2306 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2307 as->parms[5].items->data);
2310 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2312 PrintError("", code);
2315 "vos : partition %s does not exist on the server\n",
2316 as->parms[5].items->data);
2321 if (as->parms[6].items) flags |= RV_OFFLINE;
2322 if (as->parms[7].items) flags |= RV_RDONLY;
2323 if (as->parms[8].items) flags |= RV_NOCLONE;
2325 MapPartIdIntoName(topart, toPartName);
2326 MapPartIdIntoName(frompart, fromPartName);
2329 * check target partition for space to move volume
2332 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2334 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2338 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2341 p = (volintInfo *) 0;
2342 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2344 fprintf(STDERR, "vos:cannot access volume %lu\n",
2345 (unsigned long)volid);
2349 if (partition.free <= p->size) {
2351 "vos: no space on target partition %s to copy volume %lu\n",
2352 toPartName, (unsigned long)volid);
2358 /* successful copy still not guaranteed but shoot for it */
2361 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2364 PrintDiagnostics("copy", code);
2367 MapPartIdIntoName(topart, toPartName);
2368 MapPartIdIntoName(frompart, fromPartName);
2369 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2370 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2371 tovolume, as->parms[4].items->data, toPartName);
2378 ShadowVolume(register struct cmd_syndesc *as, void *arock)
2380 afs_int32 volid, fromserver, toserver, frompart, topart, tovolid;
2381 afs_int32 code, err, flags;
2382 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2383 struct diskPartition64 partition; /* for space check */
2386 p = (volintInfo *) 0;
2387 q = (volintInfo *) 0;
2389 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2392 PrintError("", err);
2394 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2395 as->parms[0].items->data);
2398 fromserver = GetServer(as->parms[1].items->data);
2399 if (fromserver == 0) {
2400 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2401 as->parms[1].items->data);
2405 toserver = GetServer(as->parms[3].items->data);
2406 if (toserver == 0) {
2407 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2408 as->parms[3].items->data);
2412 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2414 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2415 as->parms[2].items->data);
2418 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2420 PrintError("", code);
2423 "vos : partition %s does not exist on the server\n",
2424 as->parms[2].items->data);
2428 topart = volutil_GetPartitionID(as->parms[4].items->data);
2430 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2431 as->parms[4].items->data);
2434 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2436 PrintError("", code);
2439 "vos : partition %s does not exist on the server\n",
2440 as->parms[4].items->data);
2444 if (as->parms[5].items) {
2445 tovolume = as->parms[5].items->data;
2446 if (!ISNAMEVALID(tovolume)) {
2448 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2449 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2452 if (!VolNameOK(tovolume)) {
2454 "Illegal volume name %s, should not end in .readonly or .backup\n",
2458 if (IsNumeric(tovolume)) {
2460 "Illegal volume name %s, should not be a number\n",
2465 /* use actual name of source volume */
2466 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2468 fprintf(STDERR, "vos:cannot access volume %lu\n",
2469 (unsigned long)volid);
2472 strcpy(toVolName, p->name);
2473 tovolume = toVolName;
2474 /* save p for size checks later */
2477 if (as->parms[6].items) {
2478 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2481 PrintError("", err);
2483 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2484 as->parms[6].items->data);
2490 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2493 PrintError("", err);
2495 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2504 if (as->parms[7].items) flags |= RV_OFFLINE;
2505 if (as->parms[8].items) flags |= RV_RDONLY;
2506 if (as->parms[9].items) flags |= RV_NOCLONE;
2507 if (as->parms[10].items) flags |= RV_CPINCR;
2509 MapPartIdIntoName(topart, toPartName);
2510 MapPartIdIntoName(frompart, fromPartName);
2513 * check target partition for space to move volume
2516 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2518 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2522 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2525 /* Don't do this again if we did it above */
2527 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2529 fprintf(STDERR, "vos:cannot access volume %lu\n",
2530 (unsigned long)volid);
2535 /* OK if this fails */
2536 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2538 /* Treat existing volume size as "free" */
2540 p->size = (q->size < p->size) ? p->size - q->size : 0;
2542 if (partition.free <= p->size) {
2544 "vos: no space on target partition %s to copy volume %lu\n",
2545 toPartName, (unsigned long)volid);
2553 /* successful copy still not guaranteed but shoot for it */
2556 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2557 topart, tovolid, flags);
2559 PrintDiagnostics("shadow", code);
2562 MapPartIdIntoName(topart, toPartName);
2563 MapPartIdIntoName(frompart, fromPartName);
2564 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2565 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2566 as->parms[3].items->data, toPartName);
2573 CloneVolume(register struct cmd_syndesc *as, void *arock)
2575 afs_int32 server, part, volid, cloneid, voltype;
2576 char partName[10], *volname;
2577 afs_int32 code, err, flags;
2578 struct nvldbentry entry;
2580 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2583 PrintError("", err);
2585 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2586 as->parms[0].items->data);
2590 if (as->parms[1].items || as->parms[2].items) {
2591 if (!as->parms[1].items || !as->parms[2].items) {
2593 "Must specify both -server and -partition options\n");
2596 server = GetServer(as->parms[1].items->data);
2598 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2599 as->parms[1].items->data);
2602 part = volutil_GetPartitionID(as->parms[2].items->data);
2604 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2605 as->parms[2].items->data);
2608 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2610 PrintError("", code);
2613 "vos : partition %s does not exist on the server\n",
2614 as->parms[2].items->data);
2618 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2624 if (as->parms[3].items) {
2625 volname = as->parms[3].items->data;
2626 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2628 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2629 volname, VOLSER_OLDMAXVOLNAME - 1);
2634 * In order that you be able to make clones of RO or BK, this
2635 * check must be omitted.
2637 if (!VolNameOK(volname)) {
2639 "Illegal volume name %s, should not end in .readonly or .backup\n",
2644 if (IsNumeric(volname)) {
2646 "Illegal volume name %s, should not be a number\n",
2653 if (as->parms[4].items) {
2654 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2657 PrintError("", err);
2659 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2660 as->parms[4].items->data);
2666 if (as->parms[5].items) flags |= RV_OFFLINE;
2667 if (as->parms[6].items) flags |= RV_RDONLY;
2671 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2674 PrintDiagnostics("clone", code);
2677 MapPartIdIntoName(part, partName);
2678 fprintf(STDOUT, "Created clone for volume %s\n",
2679 as->parms[0].items->data);
2686 BackupVolume(register struct cmd_syndesc *as, void *arock)
2688 afs_int32 avolid, aserver, apart, vtype, code, err;
2689 struct nvldbentry entry;
2691 afs_int32 buvolid, buserver, bupart, butype;
2692 struct nvldbentry buentry;
2694 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2697 PrintError("", err);
2699 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2700 as->parms[0].items->data);
2703 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2707 /* verify this is a readwrite volume */
2709 if (vtype != RWVOL) {
2710 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2714 /* is there a backup volume already? */
2716 if (entry.flags & BACK_EXISTS) {
2717 /* yep, where is it? */
2719 buvolid = entry.volumeId[BACKVOL];
2720 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2725 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2728 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2734 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2735 (unsigned long)buvolid, (unsigned long)buserver);
2740 /* nope, carry on */
2742 code = UV_BackupVolume(aserver, apart, avolid);
2745 PrintDiagnostics("backup", code);
2748 fprintf(STDOUT, "Created backup volume for %s \n",
2749 as->parms[0].items->data);
2754 ReleaseVolume(register struct cmd_syndesc *as, void *arock)
2757 struct nvldbentry entry;
2758 afs_int32 avolid, aserver, apart, vtype, code, err;
2761 if (as->parms[1].items)
2763 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2766 PrintError("", err);
2768 fprintf(STDERR, "vos: can't find volume '%s'\n",
2769 as->parms[0].items->data);
2772 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2776 if (vtype != RWVOL) {
2777 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2781 if (!ISNAMEVALID(entry.name)) {
2783 "Volume name %s is too long, rename before releasing\n",
2788 code = UV_ReleaseVolume(avolid, aserver, apart, force);
2790 PrintDiagnostics("release", code);
2793 fprintf(STDOUT, "Released volume %s successfully\n",
2794 as->parms[0].items->data);
2799 DumpVolume(register struct cmd_syndesc *as, void *arock)
2801 afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i, flags;
2802 char filename[MAXPATHLEN];
2803 struct nvldbentry entry;
2805 rx_SetRxDeadTime(60 * 10);
2806 for (i = 0; i < MAXSERVERS; i++) {
2807 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2810 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2811 if (rxConn->service)
2812 rxConn->service->connDeadTime = rx_connDeadTime;
2815 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2818 PrintError("", err);
2820 fprintf(STDERR, "vos: can't find volume '%s'\n",
2821 as->parms[0].items->data);
2825 if (as->parms[3].items || as->parms[4].items) {
2826 if (!as->parms[3].items || !as->parms[4].items) {
2828 "Must specify both -server and -partition options\n");
2831 aserver = GetServer(as->parms[3].items->data);
2833 fprintf(STDERR, "Invalid server name\n");
2836 apart = volutil_GetPartitionID(as->parms[4].items->data);
2838 fprintf(STDERR, "Invalid partition name\n");
2842 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2847 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2848 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2850 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2851 as->parms[1].items->data, code);
2855 if (as->parms[2].items) {
2856 strcpy(filename, as->parms[2].items->data);
2858 strcpy(filename, "");
2861 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
2863 if (as->parms[5].items) {
2865 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2866 DumpFunction, filename, flags);
2869 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2872 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
2873 flags &= ~VOLDUMPV2_OMITDIRS;
2877 PrintDiagnostics("dump", code);
2880 if (strcmp(filename, ""))
2881 fprintf(STDERR, "Dumped volume %s in file %s\n",
2882 as->parms[0].items->data, filename);
2884 fprintf(STDERR, "Dumped volume %s in stdout \n",
2885 as->parms[0].items->data);
2899 RestoreVolume(register struct cmd_syndesc *as, void *arock)
2901 afs_int32 avolid, aparentid, aserver, apart, code, vcode, err;
2902 afs_int32 aoverwrite = ASK;
2903 afs_int32 acreation = 0, alastupdate = 0;
2904 int restoreflags, readonly = 0, offline = 0, voltype = RWVOL;
2906 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
2907 char volname[VOLSER_MAXVOLNAME + 1];
2908 struct nvldbentry entry;
2913 if (as->parms[4].items) {
2914 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2917 PrintError("", err);
2919 fprintf(STDERR, "vos: can't find volume '%s'\n",
2920 as->parms[4].items->data);
2926 if (as->parms[5].items) {
2927 if ((strcmp(as->parms[5].items->data, "a") == 0)
2928 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
2930 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
2931 || (strcmp(as->parms[5].items->data, "full") == 0)) {
2933 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
2934 || (strcmp(as->parms[5].items->data, "inc") == 0)
2935 || (strcmp(as->parms[5].items->data, "increment") == 0)
2936 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
2939 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2940 as->parms[5].items->data);
2944 if (as->parms[6].items)
2946 if (as->parms[7].items) {
2951 if (as->parms[8].items) {
2952 if ((strcmp(as->parms[8].items->data, "d") == 0)
2953 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
2954 acreation = TS_DUMP;
2955 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
2956 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
2957 acreation = TS_KEEP;
2958 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
2959 || (strcmp(as->parms[8].items->data, "new") == 0)) {
2962 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
2963 as->parms[8].items->data);
2968 if (as->parms[9].items) {
2969 if ((strcmp(as->parms[9].items->data, "d") == 0)
2970 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
2971 alastupdate = TS_DUMP;
2972 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
2973 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
2974 alastupdate = TS_KEEP;
2975 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
2976 || (strcmp(as->parms[9].items->data, "new") == 0)) {
2977 alastupdate = TS_NEW;
2979 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
2980 as->parms[9].items->data);
2985 aserver = GetServer(as->parms[0].items->data);
2987 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2988 as->parms[0].items->data);
2991 apart = volutil_GetPartitionID(as->parms[1].items->data);
2993 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2994 as->parms[1].items->data);
2997 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
2999 PrintError("", code);
3002 "vos : partition %s does not exist on the server\n",
3003 as->parms[1].items->data);
3006 strcpy(avolname, as->parms[2].items->data);
3007 if (!ISNAMEVALID(avolname)) {
3009 "vos: the name of the volume %s exceeds the size limit\n",
3013 if (!VolNameOK(avolname)) {
3015 "Illegal volume name %s, should not end in .readonly or .backup\n",
3019 if (as->parms[3].items) {
3020 strcpy(afilename, as->parms[3].items->data);
3021 if (!FileExists(afilename)) {
3022 fprintf(STDERR, "Can't access file %s\n", afilename);
3026 strcpy(afilename, "");
3029 /* Check if volume exists or not */
3031 vsu_ExtractName(volname, avolname);
3032 vcode = VLDB_GetEntryByName(volname, &entry);
3033 if (vcode) { /* no volume - do a full restore */
3034 restoreflags = RV_FULLRST;
3035 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3037 "Volume does not exist; Will perform a full restore\n");
3040 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3041 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3042 restoreflags = RV_FULLRST;
3043 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3045 "%s Volume does not exist; Will perform a full restore\n",
3046 readonly ? "RO" : "RW");
3049 avolid = entry.volumeId[voltype];
3050 } else if (entry.volumeId[voltype] != 0
3051 && entry.volumeId[voltype] != avolid) {
3052 avolid = entry.volumeId[voltype];
3054 aparentid = entry.volumeId[RWVOL];
3057 else { /* volume exists - do we do a full incremental or abort */
3058 int Oserver, Opart, Otype, vol_elsewhere = 0;
3059 struct nvldbentry Oentry;
3063 avolid = entry.volumeId[voltype];
3064 } else if (entry.volumeId[voltype] != 0
3065 && entry.volumeId[voltype] != avolid) {
3066 avolid = entry.volumeId[voltype];
3068 aparentid = entry.volumeId[RWVOL];
3070 /* A file name was specified - check if volume is on another partition */
3071 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3075 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3078 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3082 if (!vcode || (Opart != apart))
3085 if (aoverwrite == ASK) {
3086 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3088 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3092 /* Ask what to do */
3093 if (vol_elsewhere) {
3095 "The volume %s %u already exists on a different server/part\n",
3096 volname, entry.volumeId[voltype]);
3098 "Do you want to do a full restore or abort? [fa](a): ");
3101 "The volume %s %u already exists in the VLDB\n",
3102 volname, entry.volumeId[voltype]);
3104 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3107 while (!(dc == EOF || dc == '\n'))
3108 dc = getchar(); /* goto end of line */
3109 if ((c == 'f') || (c == 'F'))
3111 else if ((c == 'i') || (c == 'I'))
3117 if (aoverwrite == ABORT) {
3118 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3120 } else if (aoverwrite == FULL) {
3121 restoreflags = RV_FULLRST;
3123 "Volume exists; Will delete and perform full restore\n");
3124 } else if (aoverwrite == INC) {
3126 if (vol_elsewhere) {
3128 "%s volume %lu already exists on a different server/part; not allowed\n",
3129 readonly ? "RO" : "RW", (unsigned long)avolid);
3135 restoreflags |= RV_OFFLINE;
3137 restoreflags |= RV_RDONLY;
3139 switch (acreation) {
3141 restoreflags |= RV_CRDUMP;
3144 restoreflags |= RV_CRKEEP;
3147 restoreflags |= RV_CRNEW;
3150 if (aoverwrite == FULL)
3151 restoreflags |= RV_CRNEW;
3153 restoreflags |= RV_CRKEEP;
3156 switch (alastupdate) {
3158 restoreflags |= RV_LUDUMP;
3161 restoreflags |= RV_LUKEEP;
3164 restoreflags |= RV_LUNEW;
3167 restoreflags |= RV_LUDUMP;
3169 if (as->parms[10].items) {
3170 restoreflags |= RV_NODEL;
3175 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3176 avolname, restoreflags, WriteData, afilename);
3178 PrintDiagnostics("restore", code);
3181 MapPartIdIntoName(apart, apartName);
3184 * patch typo here - originally "parms[1]", should be "parms[0]"
3187 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3188 as->parms[0].items->data, apartName);
3193 LockReleaseCmd(register struct cmd_syndesc *as, void *arock)
3195 afs_int32 avolid, code, err;
3197 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3200 PrintError("", err);
3202 fprintf(STDERR, "vos: can't find volume '%s'\n",
3203 as->parms[0].items->data);
3207 code = UV_LockRelease(avolid);
3209 PrintDiagnostics("unlock", code);
3212 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3213 as->parms[0].items->data);
3218 AddSite(register struct cmd_syndesc *as, void *arock)
3220 afs_int32 avolid, aserver, apart, code, err, valid = 0;
3221 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3223 vsu_ExtractName(avolname, as->parms[2].items->data);;
3224 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3227 PrintError("", err);
3229 fprintf(STDERR, "vos: can't find volume '%s'\n",
3230 as->parms[2].items->data);
3233 aserver = GetServer(as->parms[0].items->data);
3235 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3236 as->parms[0].items->data);
3239 apart = volutil_GetPartitionID(as->parms[1].items->data);
3241 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3242 as->parms[1].items->data);
3245 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3247 PrintError("", code);
3250 "vos : partition %s does not exist on the server\n",
3251 as->parms[1].items->data);
3254 if (as->parms[3].items) {
3257 code = UV_AddSite(aserver, apart, avolid, valid);
3259 PrintDiagnostics("addsite", code);
3262 MapPartIdIntoName(apart, apartName);
3263 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3264 as->parms[0].items->data, apartName, as->parms[2].items->data);
3269 RemoveSite(register struct cmd_syndesc *as, void *arock)
3272 afs_int32 avolid, aserver, apart, code, err;
3273 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3275 vsu_ExtractName(avolname, as->parms[2].items->data);
3276 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3279 PrintError("", err);
3281 fprintf(STDERR, "vos: can't find volume '%s'\n",
3282 as->parms[2].items->data);
3285 aserver = GetServer(as->parms[0].items->data);
3287 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3288 as->parms[0].items->data);
3291 apart = volutil_GetPartitionID(as->parms[1].items->data);
3293 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3294 as->parms[1].items->data);
3298 *skip the partition validity check, since it is possible that the partition
3299 *has since been decomissioned.
3302 if (!IsPartValid(apart,aserver,&code)){
3303 if(code) PrintError("",code);
3304 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3308 code = UV_RemoveSite(aserver, apart, avolid);
3310 PrintDiagnostics("remsite", code);
3313 MapPartIdIntoName(apart, apartName);
3314 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3315 as->parms[0].items->data, apartName, as->parms[2].items->data);
3320 ChangeLocation(register struct cmd_syndesc *as, void *arock)
3322 afs_int32 avolid, aserver, apart, code, err;
3325 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3328 PrintError("", err);
3330 fprintf(STDERR, "vos: can't find volume '%s'\n",
3331 as->parms[2].items->data);
3334 aserver = GetServer(as->parms[0].items->data);
3336 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3337 as->parms[0].items->data);
3340 apart = volutil_GetPartitionID(as->parms[1].items->data);
3342 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3343 as->parms[1].items->data);
3346 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3348 PrintError("", code);
3351 "vos : partition %s does not exist on the server\n",
3352 as->parms[1].items->data);
3355 code = UV_ChangeLocation(aserver, apart, avolid);
3357 PrintDiagnostics("addsite", code);
3360 MapPartIdIntoName(apart, apartName);
3361 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3362 as->parms[0].items->data, apartName, as->parms[2].items->data);
3367 ListPartitions(register struct cmd_syndesc *as, void *arock)
3369 afs_int32 aserver, code;
3370 struct partList dummyPartList;
3375 aserver = GetServer(as->parms[0].items->data);
3377 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3378 as->parms[0].items->data);
3383 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3385 PrintDiagnostics("listpart", code);
3389 fprintf(STDOUT, "The partitions on the server are:\n");
3390 for (i = 0; i < cnt; i++) {
3391 if (dummyPartList.partFlags[i] & PARTVALID) {
3392 memset(pname, 0, sizeof(pname));
3393 MapPartIdIntoName(dummyPartList.partId[i], pname);
3394 fprintf(STDOUT, " %10s ", pname);
3396 if ((i % 5) == 0 && (i != 0))
3397 fprintf(STDOUT, "\n");
3400 fprintf(STDOUT, "\n");
3401 fprintf(STDOUT, "Total: %d\n", total);
3407 CompareVolName(p1, p2)
3410 volintInfo *arg1, *arg2;
3412 arg1 = (volintInfo *) p1;
3413 arg2 = (volintInfo *) p2;
3414 return (strcmp(arg1->name, arg2->name));
3418 /*------------------------------------------------------------------------
3419 * PRIVATE XCompareVolName
3422 * Comparison routine for volume names coming from an extended
3426 * a_obj1P : Char ptr to first extended vol info object
3427 * a_obj1P : Char ptr to second extended vol info object
3430 * The value of strcmp() on the volume names within the passed
3431 * objects (i,e., -1, 0, or 1).
3434 * Passed to qsort() as the designated comparison routine.
3438 *------------------------------------------------------------------------*/
3441 XCompareVolName(a_obj1P, a_obj2P)
3442 char *a_obj1P, *a_obj2P;
3444 { /*XCompareVolName */
3447 (((struct volintXInfo *)(a_obj1P))->name,
3448 ((struct volintXInfo *)(a_obj2P))->name));
3450 } /*XCompareVolName */
3453 CompareVolID(p1, p2)
3456 volintInfo *arg1, *arg2;
3458 arg1 = (volintInfo *) p1;
3459 arg2 = (volintInfo *) p2;
3460 if (arg1->volid == arg2->volid)
3462 if (arg1->volid > arg2->volid)
3469 /*------------------------------------------------------------------------
3470 * PRIVATE XCompareVolID
3473 * Comparison routine for volume IDs coming from an extended
3477 * a_obj1P : Char ptr to first extended vol info object
3478 * a_obj1P : Char ptr to second extended vol info object
3481 * The value of strcmp() on the volume names within the passed
3482 * objects (i,e., -1, 0, or 1).
3485 * Passed to qsort() as the designated comparison routine.
3489 *------------------------------------------------------------------------*/
3492 XCompareVolID(a_obj1P, a_obj2P)
3493 char *a_obj1P, *a_obj2P;
3495 { /*XCompareVolID */
3497 afs_int32 id1, id2; /*Volume IDs we're comparing */
3499 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3500 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3508 } /*XCompareVolID */
3510 /*------------------------------------------------------------------------
3511 * PRIVATE ListVolumes
3514 * Routine used to list volumes, contacting the Volume Server
3515 * directly, bypassing the VLDB.
3518 * as : Ptr to parsed command line arguments.
3521 * 0 Successful operation
3524 * Nothing interesting.
3528 *------------------------------------------------------------------------*/
3531 ListVolumes(register struct cmd_syndesc *as, void *arock)
3533 afs_int32 apart, int32list, fast;
3534 afs_int32 aserver, code;
3535 volintInfo *pntr, *oldpntr;
3539 volintXInfo *xInfoP, *origxInfoP; /*Ptr to current/orig extended vol info */
3540 int wantExtendedInfo; /*Do we want extended vol info? */
3543 struct partList dummyPartList;
3551 if (as->parms[3].items)
3553 if (as->parms[4].items)
3557 if (as->parms[2].items)
3563 if (as->parms[5].items) {
3565 * We can't coexist with the fast flag.
3569 "vos: Can't use the -fast and -extended flags together\n");
3574 * We need to turn on ``long'' listings to get the full effect.
3576 wantExtendedInfo = 1;
3579 wantExtendedInfo = 0;
3580 if (as->parms[1].items) {
3581 apart = volutil_GetPartitionID(as->parms[1].items->data);
3583 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3584 as->parms[1].items->data);
3587 dummyPartList.partId[0] = apart;
3588 dummyPartList.partFlags[0] = PARTVALID;
3591 aserver = GetServer(as->parms[0].items->data);
3593 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3594 as->parms[0].items->data);
3599 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3601 PrintError("", code);
3604 "vos : partition %s does not exist on the server\n",
3605 as->parms[1].items->data);
3609 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3611 PrintDiagnostics("listvol", code);
3615 for (i = 0; i < cnt; i++) {
3616 if (dummyPartList.partFlags[i] & PARTVALID) {
3617 if (wantExtendedInfo)
3619 UV_XListVolumes(aserver, dummyPartList.partId[i], all,
3623 UV_ListVolumes(aserver, dummyPartList.partId[i], all,
3626 PrintDiagnostics("listvol", code);
3631 if (wantExtendedInfo) {
3632 origxInfoP = xInfoP;
3633 base = (char *)xInfoP;
3636 base = (char *)pntr;
3640 if (wantExtendedInfo)
3641 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
3643 qsort(base, count, sizeof(volintInfo), CompareVolName);
3645 if (wantExtendedInfo)
3646 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
3648 qsort(base, count, sizeof(volintInfo), CompareVolID);
3650 MapPartIdIntoName(dummyPartList.partId[i], pname);
3653 "Total number of volumes on server %s partition %s: %lu \n",
3654 as->parms[0].items->data, pname,
3655 (unsigned long)count);
3656 if (wantExtendedInfo) {
3657 #ifdef FULL_LISTVOL_SWITCH
3658 if (as->parms[6].items)
3659 XDisplayVolumes2(aserver, dummyPartList.partId[i], origxInfoP,
3660 count, int32list, fast, quiet);
3662 #endif /* FULL_LISTVOL_SWITCH */
3663 XDisplayVolumes(aserver, dummyPartList.partId[i], origxInfoP,
3664 count, int32list, fast, quiet);
3667 xInfoP = (volintXInfo *) 0;
3669 #ifdef FULL_LISTVOL_SWITCH
3670 if (as->parms[6].items)
3671 DisplayVolumes2(aserver, dummyPartList.partId[i], oldpntr,
3674 #endif /* FULL_LISTVOL_SWITCH */
3675 DisplayVolumes(aserver, dummyPartList.partId[i], oldpntr,
3676 count, int32list, fast, quiet);
3679 pntr = (volintInfo *) 0;
3687 SyncVldb(register struct cmd_syndesc *as, void *arock)
3689 afs_int32 pnum = 0, code; /* part name */
3695 if (as->parms[0].items) {
3696 tserver = GetServer(as->parms[0].items->data);
3698 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3699 as->parms[0].items->data);
3704 if (as->parms[1].items) {
3705 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3707 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3708 as->parms[1].items->data);
3711 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3713 PrintError("", code);
3716 "vos: partition %s does not exist on the server\n",
3717 as->parms[1].items->data);
3724 "The -partition option requires a -server option\n");
3729 if (as->parms[3].items) {
3730 flags |= 2; /* don't update */
3733 if (as->parms[2].items) {
3734 /* Synchronize an individual volume */
3735 volname = as->parms[2].items->data;
3736 code = UV_SyncVolume(tserver, pnum, volname, flags);
3740 "Without a -volume option, the -server option is required\n");
3743 code = UV_SyncVldb(tserver, pnum, flags, 0 /*unused */ );
3747 PrintDiagnostics("syncvldb", code);
3751 /* Print a summary of what we did */
3753 fprintf(STDOUT, "VLDB volume %s synchronized", volname);
3755 fprintf(STDOUT, "VLDB synchronized");
3757 fprintf(STDOUT, " with state of server %s", as->parms[0].items->data);
3760 MapPartIdIntoName(pnum, part);
3761 fprintf(STDOUT, " partition %s\n", part);
3763 fprintf(STDOUT, "\n");
3769 SyncServer(register struct cmd_syndesc *as, void *arock)
3771 afs_int32 pnum, code; /* part name */
3776 tserver = GetServer(as->parms[0].items->data);
3778 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3779 as->parms[0].items->data);
3782 if (as->parms[1].items) {
3783 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3785 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3786 as->parms[1].items->data);
3789 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3791 PrintError("", code);
3794 "vos : partition %s does not exist on the server\n",
3795 as->parms[1].items->data);
3803 if (as->parms[2].items) {
3804 flags |= 2; /* don't update */
3806 code = UV_SyncServer(tserver, pnum, flags, 0 /*unused */ );
3808 PrintDiagnostics("syncserv", code);
3812 MapPartIdIntoName(pnum, part);
3813 fprintf(STDOUT, "Server %s partition %s synchronized with VLDB\n",
3814 as->parms[0].items->data, part);
3816 fprintf(STDOUT, "Server %s synchronized with VLDB\n",
3817 as->parms[0].items->data);
3826 struct nvldbentry entry;
3829 /* The vlserver will handle names with the .readonly
3830 * and .backup extension as well as volume ids.
3832 vcode = VLDB_GetEntryByName(name, &entry);
3834 PrintError("", vcode);
3837 MapHostToNetwork(&entry);
3838 EnumerateEntry(&entry);
3840 /* Defect #3027: grubby check to handle locked volume.
3841 * If VLOP_ALLOPERS is set, the entry is locked.
3842 * Leave this routine as is, but put in correct check.
3844 if (entry.flags & VLOP_ALLOPERS)
3845 fprintf(STDOUT, " Volume is currently LOCKED \n");
3851 VolumeZap(register struct cmd_syndesc *as, void *arock)
3853 struct nvldbentry entry;
3854 afs_int32 volid, code, server, part, zapbackupid = 0, backupid = 0, err;
3856 if (as->parms[3].items) {
3857 /* force flag is on, use the other version */
3858 return NukeVolume(as);
3861 if (as->parms[4].items) {
3865 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3868 PrintError("", err);
3870 fprintf(STDERR, "vos: can't find volume '%s'\n",
3871 as->parms[2].items->data);
3874 part = volutil_GetPartitionID(as->parms[1].items->data);
3876 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3877 as->parms[1].items->data);
3880 server = GetServer(as->parms[0].items->data);
3882 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3883 as->parms[0].items->data);
3886 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
3888 PrintError("", code);
3891 "vos : partition %s does not exist on the server\n",
3892 as->parms[1].items->data);
3895 code = VLDB_GetEntryByID(volid, -1, &entry);
3897 if (volid == entry.volumeId[RWVOL])
3898 backupid = entry.volumeId[BACKVOL];
3900 "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
3901 (unsigned long)volid);
3904 volintInfo *pntr = (volintInfo *) 0;
3907 code = UV_ListOneVolume(server, part, volid, &pntr);
3909 if (volid == pntr->parentID)
3910 backupid = pntr->backupID;
3916 code = UV_VolumeZap(server, part, backupid);
3918 PrintDiagnostics("zap", code);
3921 fprintf(STDOUT, "Backup Volume %lu deleted\n",
3922 (unsigned long)backupid);
3925 code = UV_VolumeZap(server, part, volid);
3927 PrintDiagnostics("zap", code);
3930 fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
3936 VolserStatus(register struct cmd_syndesc *as, void *arock)
3938 afs_int32 server, code;
3939 transDebugInfo *pntr, *oldpntr;
3944 server = GetServer(as->parms[0].items->data);
3946 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3947 as->parms[0].items->data);
3950 code = UV_VolserStatus(server, &pntr, &count);
3952 PrintDiagnostics("status", code);
3957 fprintf(STDOUT, "No active transactions on %s\n",
3958 as->parms[0].items->data);
3960 fprintf(STDOUT, "Total transactions: %d\n", count);
3962 for (i = 0; i < count; i++) {
3963 /*print out the relevant info */
3964 fprintf(STDOUT, "--------------------------------------\n");
3965 fprintf(STDOUT, "transaction: %lu created: %s",
3966 (unsigned long)pntr->tid, vos_ctime( & pntr->time));
3967 if (pntr->returnCode) {
3968 fprintf(STDOUT, "returnCode: %lu\n",
3969 (unsigned long)pntr->returnCode);
3972 fprintf(STDOUT, "attachFlags: ");
3973 switch (pntr->iflags) {
3975 fprintf(STDOUT, "offline ");
3978 fprintf(STDOUT, "busy ");
3981 fprintf(STDOUT, "readonly ");
3984 fprintf(STDOUT, "create ");
3987 fprintf(STDOUT, "create volid ");
3990 fprintf(STDOUT, "\n");
3993 fprintf(STDOUT, "volumeStatus: ");
3994 switch (pntr->vflags) {
3995 case VTDeleteOnSalvage:
3996 fprintf(STDOUT, "deleteOnSalvage ");
3997 case VTOutOfService:
3998 fprintf(STDOUT, "outOfService ");
4000 fprintf(STDOUT, "deleted ");
4002 fprintf(STDOUT, "\n");
4005 fprintf(STDOUT, "transactionFlags: ");
4006 fprintf(STDOUT, "delete\n");
4008 MapPartIdIntoName(pntr->partition, pname);
4009 fprintf(STDOUT, "volume: %lu partition: %s procedure: %s\n",
4010 (unsigned long)pntr->volid, pname, pntr->lastProcName);
4011 if (pntr->callValid) {
4013 "packetRead: %lu lastReceiveTime: %d packetSend: %lu lastSendTime: %d\n",
4014 (unsigned long)pntr->readNext, pntr->lastReceiveTime,
4015 (unsigned long)pntr->transmitNext, pntr->lastSendTime);
4018 fprintf(STDOUT, "--------------------------------------\n");
4019 fprintf(STDOUT, "\n");
4027 RenameVolume(register struct cmd_syndesc *as, void *arock)
4029 afs_int32 code1, code2, code;
4030 struct nvldbentry entry;
4032 code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
4034 fprintf(STDERR, "vos: Could not find entry for volume %s\n",
4035 as->parms[0].items->data);
4038 code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
4039 if ((!code1) && (!code2)) { /*the newname already exists */
4040 fprintf(STDERR, "vos: volume %s already exists\n",
4041 as->parms[1].items->data);
4045 if (code1 && code2) {
4046 fprintf(STDERR, "vos: Could not find entry for volume %s or %s\n",
4047 as->parms[0].items->data, as->parms[1].items->data);
4050 if (!VolNameOK(as->parms[0].items->data)) {
4052 "Illegal volume name %s, should not end in .readonly or .backup\n",
4053 as->parms[0].items->data);
4056 if (!ISNAMEVALID(as->parms[1].items->data)) {
4058 "vos: the new volume name %s exceeds the size limit of %d\n",
4059 as->parms[1].items->data, VOLSER_OLDMAXVOLNAME - 10);
4062 if (!VolNameOK(as->parms[1].items->data)) {
4064 "Illegal volume name %s, should not end in .readonly or .backup\n",
4065 as->parms[1].items->data);
4068 if (IsNumeric(as->parms[1].items->data)) {
4069 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
4070 as->parms[1].items->data);
4073 MapHostToNetwork(&entry);
4075 UV_RenameVolume(&entry, as->parms[0].items->data,
4076 as->parms[1].items->data);
4078 PrintDiagnostics("rename", code);
4081 fprintf(STDOUT, "Renamed volume %s to %s\n", as->parms[0].items->data,
4082 as->parms[1].items->data);
4087 GetVolumeInfo(afs_int32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *voltype,
4088 struct nvldbentry *rentry)
4093 vcode = VLDB_GetEntryByID(volid, -1, rentry);
4096 "Could not fetch the entry for volume %lu from VLDB \n",
4097 (unsigned long)volid);
4098 PrintError("", vcode);
4101 MapHostToNetwork(rentry);
4102 if (volid == rentry->volumeId[ROVOL]) {
4104 for (i = 0; i < rentry->nServers; i++) {
4105 if ((index == -1) && (rentry->serverFlags[i] & ITSROVOL)
4106 && !(rentry->serverFlags[i] & RO_DONTUSE))
4111 "RO volume is not found in VLDB entry for volume %lu\n",
4112 (unsigned long)volid);
4116 *server = rentry->serverNumber[index];
4117 *part = rentry->serverPartition[index];
4121 index = Lp_GetRwIndex(rentry);
4124 "RW Volume is not found in VLDB entry for volume %lu\n",
4125 (unsigned long)volid);
4128 if (volid == rentry->volumeId[RWVOL]) {
4130 *server = rentry->serverNumber[index];
4131 *part = rentry->serverPartition[index];
4134 if (volid == rentry->volumeId[BACKVOL]) {
4136 *server = rentry->serverNumber[index];
4137 *part = rentry->serverPartition[index];
4141 "unexpected volume type for volume %lu\n",
4142 (unsigned long)volid);
4147 DeleteEntry(register struct cmd_syndesc *as, void *arock)
4152 struct VldbListByAttributes attributes;
4153 nbulkentries arrayEntries;
4154 register struct nvldbentry *vllist;
4155 struct cmd_item *itp;
4158 char prefix[VOLSER_MAXVOLNAME + 1];
4160 afs_int32 totalBack = 0, totalFail = 0, err;
4162 if (as->parms[0].items) { /* -id */
4163 if (as->parms[1].items || as->parms[2].items || as->parms[3].items) {
4165 "You cannot use -server, -partition, or -prefix with the -id argument\n");
4168 for (itp = as->parms[0].items; itp; itp = itp->next) {
4169 avolid = vsu_GetVolumeID(itp->data, cstruct, &err);
4172 PrintError("", err);
4174 fprintf(STDERR, "vos: can't find volume '%s'\n",
4178 if (as->parms[4].items) { /* -noexecute */
4179 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4184 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4186 fprintf(STDERR, "Could not delete entry for volume %s\n",
4189 "You must specify a RW volume name or ID "
4190 "(the entire VLDB entry will be deleted)\n");
4191 PrintError("", vcode);
4197 fprintf(STDOUT, "Deleted %d VLDB entries\n", totalBack);
4201 if (!as->parms[1].items && !as->parms[2].items && !as->parms[3].items) {
4202 fprintf(STDERR, "You must specify an option\n");
4206 /* Zero out search attributes */
4207 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4209 if (as->parms[1].items) { /* -prefix */
4210 strncpy(prefix, as->parms[1].items->data, VOLSER_MAXVOLNAME);
4212 if (!as->parms[2].items && !as->parms[3].items) { /* a single entry only */
4214 "You must provide -server with the -prefix argument\n");
4219 if (as->parms[2].items) { /* -server */
4221 aserver = GetServer(as->parms[2].items->data);
4223 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4224 as->parms[2].items->data);
4227 attributes.server = ntohl(aserver);
4228 attributes.Mask |= VLLIST_SERVER;
4231 if (as->parms[3].items) { /* -partition */
4232 if (!as->parms[2].items) {
4234 "You must provide -server with the -partition argument\n");
4237 apart = volutil_GetPartitionID(as->parms[3].items->data);
4239 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4240 as->parms[3].items->data);
4243 attributes.partition = apart;
4244 attributes.Mask |= VLLIST_PARTITION;
4247 /* Print status line of what we are doing */
4248 fprintf(STDOUT, "Deleting VLDB entries for ");
4249 if (as->parms[2].items) {
4250 fprintf(STDOUT, "server %s ", as->parms[2].items->data);
4252 if (as->parms[3].items) {
4254 MapPartIdIntoName(apart, pname);
4255 fprintf(STDOUT, "partition %s ", pname);
4258 fprintf(STDOUT, "which are prefixed with %s ", prefix);
4260 fprintf(STDOUT, "\n");
4263 /* Get all the VLDB entries on a server and/or partition */
4264 memset(&arrayEntries, 0, sizeof(arrayEntries));
4265 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4267 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4268 PrintError("", vcode);
4272 /* Process each entry */
4273 for (j = 0; j < nentries; j++) {
4274 vllist = &arrayEntries.nbulkentries_val[j];
4276 /* It only deletes the RW volumes */
4277 if (strncmp(vllist->name, prefix, strlen(prefix))) {
4280 "Omitting to delete %s due to prefix %s mismatch\n",
4281 vllist->name, prefix);
4288 if (as->parms[4].items) { /* -noexecute */
4289 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4295 /* Only matches the RW volume name */
4296 avolid = vllist->volumeId[RWVOL];
4297 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4299 fprintf(STDOUT, "Could not delete VDLB entry for %s\n",
4302 PrintError("", vcode);
4307 fprintf(STDOUT, "Deleted VLDB entry for %s \n", vllist->name);
4312 fprintf(STDOUT, "----------------------\n");
4314 "Total VLDB entries deleted: %lu; failed to delete: %lu\n",
4315 (unsigned long)totalBack, (unsigned long)totalFail);
4316 if (arrayEntries.nbulkentries_val)
4317 free(arrayEntries.nbulkentries_val);
4323 CompareVldbEntryByName(p1, p2)
4326 struct nvldbentry *arg1, *arg2;
4328 arg1 = (struct nvldbentry *)p1;
4329 arg2 = (struct nvldbentry *)p2;
4330 return (strcmp(arg1->name, arg2->name));
4334 static int CompareVldbEntry(p1,p2)
4337 struct nvldbentry *arg1,*arg2;
4340 char comp1[100],comp2[100];
4341 char temp1[20],temp2[20];
4343 arg1 = (struct nvldbentry *)p1;
4344 arg2 = (struct nvldbentry *)p2;
4348 for(i = 0; i < arg1->nServers; i++)
4349 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
4350 for(i = 0; i < arg2->nServers; i++)
4351 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
4352 if(pos1 == -1 || pos2 == -1){
4356 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
4357 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
4358 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
4359 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
4360 strcat(comp1,temp1);
4361 strcat(comp2,temp2);
4362 strcat(comp1,arg1->name);
4363 strcat(comp1,arg2->name);
4364 return(strcmp(comp1,comp2));
4370 ListVLDB(struct cmd_syndesc *as, void *arock)
4373 afs_int32 aserver, code;
4375 struct VldbListByAttributes attributes;
4376 nbulkentries arrayEntries;
4377 struct nvldbentry *vllist, *tarray = 0, *ttarray;
4378 afs_int32 centries, nentries = 0, tarraysize, parraysize;
4381 int quiet, sort, lock;
4382 afs_int32 thisindex, nextindex;
4387 attributes.Mask = 0;
4388 lock = (as->parms[3].items ? 1 : 0); /* -lock flag */
4389 quiet = (as->parms[4].items ? 1 : 0); /* -quit flag */
4390 sort = (as->parms[5].items ? 0 : 1); /* -nosort flag */
4392 /* If the volume name is given, Use VolumeInfoCmd to look it up
4393 * and not ListAttributes.
4395 if (as->parms[0].items) {
4398 "vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
4401 code = VolumeInfoCmd(as->parms[0].items->data);
4403 PrintError("", code);
4409 /* Server specified */
4410 if (as->parms[1].items) {
4411 aserver = GetServer(as->parms[1].items->data);
4413 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4414 as->parms[1].items->data);
4417 attributes.server = ntohl(aserver);
4418 attributes.Mask |= VLLIST_SERVER;
4421 /* Partition specified */
4422 if (as->parms[2].items) {
4423 apart = volutil_GetPartitionID(as->parms[2].items->data);
4425 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4426 as->parms[2].items->data);
4429 attributes.partition = apart;
4430 attributes.Mask |= VLLIST_PARTITION;
4434 attributes.Mask |= VLLIST_FLAG;
4435 attributes.flag = VLOP_ALLOPERS;
4438 /* Print header information */
4440 MapPartIdIntoName(apart, pname);
4441 fprintf(STDOUT, "VLDB entries for %s %s%s%s %s\n",
4442 (as->parms[1].items ? "server" : "all"),
4443 (as->parms[1].items ? as->parms[1].items->data : "servers"),
4444 (as->parms[2].items ? " partition " : ""),
4445 (as->parms[2].items ? pname : ""),
4446 (lock ? "which are locked:" : ""));
4449 for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
4450 memset(&arrayEntries, 0, sizeof(arrayEntries));
4455 VLDB_ListAttributesN2(&attributes, 0, thisindex, ¢ries,
4456 &arrayEntries, &nextindex);
4457 if (vcode == RXGEN_OPCODE) {
4458 /* Vlserver not running with ListAttributesN2. Fall back */
4460 VLDB_ListAttributes(&attributes, ¢ries, &arrayEntries);
4464 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4465 PrintError("", vcode);
4468 nentries += centries;
4470 /* We don't sort, so just print the entries now */
4472 for (j = 0; j < centries; j++) { /* process each entry */
4473 vllist = &arrayEntries.nbulkentries_val[j];
4474 MapHostToNetwork(vllist);
4475 EnumerateEntry(vllist);
4477 if (vllist->flags & VLOP_ALLOPERS)
4478 fprintf(STDOUT, " Volume is currently LOCKED \n");
4482 /* So we sort. First we must collect all the entries and keep
4485 else if (centries > 0) {
4487 /* steal away the first bulk entries array */
4488 tarray = (struct nvldbentry *)arrayEntries.nbulkentries_val;
4489 tarraysize = centries * sizeof(struct nvldbentry);
4490 arrayEntries.nbulkentries_val = 0;
4492 /* Grow the tarray to keep the extra entries */
4493 parraysize = (centries * sizeof(struct nvldbentry));
4495 (struct nvldbentry *)realloc(tarray,
4496 tarraysize + parraysize);
4499 "Could not allocate enough space for the VLDB entries\n");
4505 memcpy(((char *)tarray) + tarraysize,
4506 (char *)arrayEntries.nbulkentries_val, parraysize);
4507 tarraysize += parraysize;
4511 /* Free the bulk array */
4512 if (arrayEntries.nbulkentries_val) {
4513 free(arrayEntries.nbulkentries_val);
4514 arrayEntries.nbulkentries_val = 0;
4518 /* Here is where we now sort all the entries and print them */
4519 if (sort && (nentries > 0)) {
4520 qsort((char *)tarray, nentries, sizeof(struct nvldbentry),
4521 CompareVldbEntryByName);
4522 for (vllist = tarray, j = 0; j < nentries; j++, vllist++) {
4523 MapHostToNetwork(vllist);
4524 EnumerateEntry(vllist);
4526 if (vllist->flags & VLOP_ALLOPERS)
4527 fprintf(STDOUT, " Volume is currently LOCKED \n");
4533 fprintf(STDOUT, "\nTotal entries: %lu\n", (unsigned long)nentries);
4540 BackSys(register struct cmd_syndesc *as, void *arock)
4542 afs_int32 apart = 0, avolid;
4543 afs_int32 aserver = 0, code, aserver1, apart1;
4545 struct VldbListByAttributes attributes;
4546 nbulkentries arrayEntries;
4547 register struct nvldbentry *vllist;
4551 int seenprefix, seenxprefix, exclude, ex, exp, noaction;
4552 afs_int32 totalBack = 0;
4553 afs_int32 totalFail = 0;
4554 int previdx = -1, error, same;
4556 struct cmd_item *ti;
4560 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4561 attributes.Mask = 0;
4563 seenprefix = (as->parms[0].items ? 1 : 0);
4564 exclude = (as->parms[3].items ? 1 : 0);
4565 seenxprefix = (as->parms[4].items ? 1 : 0);
4566 noaction = (as->parms[5].items ? 1 : 0);
4568 if (as->parms[1].items) { /* -server */
4569 aserver = GetServer(as->parms[1].items->data);
4571 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4572 as->parms[1].items->data);
4575 attributes.server = ntohl(aserver);
4576 attributes.Mask |= VLLIST_SERVER;
4579 if (as->parms[2].items) { /* -partition */
4580 apart = volutil_GetPartitionID(as->parms[2].items->data);
4582 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4583 as->parms[2].items->data);
4586 attributes.partition = apart;
4587 attributes.Mask |= VLLIST_PARTITION;
4590 /* Check to make sure the prefix and xprefix expressions compile ok */
4592 for (ti = as->parms[0].items; ti; ti = ti->next) {
4593 if (strncmp(ti->data, "^", 1) == 0) {
4594 #ifdef HAVE_POSIX_REGEX
4598 code = regcomp(&re, ti->data, REG_NOSUB);
4600 regerror(code, &re, errbuf, sizeof errbuf);
4602 "Unrecognizable -prefix regular expression: '%s': %s\n",
4608 ccode = (char *)re_comp(ti->data);
4611 "Unrecognizable -prefix regular expression: '%s': %s\n",
4620 for (ti = as->parms[4].items; ti; ti = ti->next) {
4621 if (strncmp(ti->data, "^", 1) == 0) {
4622 #ifdef HAVE_POSIX_REGEX
4626 code = regcomp(&re, ti->data, REG_NOSUB);
4628 regerror(code, &re, errbuf, sizeof errbuf);
4630 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4636 ccode = (char *)re_comp(ti->data);
4639 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4648 memset(&arrayEntries, 0, sizeof(arrayEntries)); /* initialize to hint the stub to alloc space */
4649 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4651 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4652 PrintError("", vcode);
4656 if (as->parms[1].items || as->parms[2].items || verbose) {
4657 fprintf(STDOUT, "%s up volumes",
4658 (noaction ? "Would have backed" : "Backing"));
4660 if (as->parms[1].items) {
4661 fprintf(STDOUT, " on server %s", as->parms[1].items->data);
4662 } else if (as->parms[2].items) {
4663 fprintf(STDOUT, " for all servers");
4666 if (as->parms[2].items) {
4667 MapPartIdIntoName(apart, pname);
4668 fprintf(STDOUT, " partition %s", pname);
4671 if (seenprefix || (!seenprefix && seenxprefix)) {
4672 ti = (seenprefix ? as->parms[0].items : as->parms[4].items);
4673 ex = (seenprefix ? exclude : !exclude);
4674 exp = (strncmp(ti->data, "^", 1) == 0);
4675 fprintf(STDOUT, " which %smatch %s '%s'", (ex ? "do not " : ""),
4676 (exp ? "expression" : "prefix"), ti->data);
4677 for (ti = ti->next; ti; ti = ti->next) {
4678 exp = (strncmp(ti->data, "^", 1) == 0);
4679 printf(" %sor %s '%s'", (ex ? "n" : ""),
4680 (exp ? "expression" : "prefix"), ti->data);
4684 if (seenprefix && seenxprefix) {
4685 ti = as->parms[4].items;
4686 exp = (strncmp(ti->data, "^", 1) == 0);
4687 fprintf(STDOUT, " %swhich match %s '%s'",
4688 (exclude ? "adding those " : "removing those "),
4689 (exp ? "expression" : "prefix"), ti->data);
4690 for (ti = ti->next; ti; ti = ti->next) {
4691 exp = (strncmp(ti->data, "^", 1) == 0);
4692 printf(" or %s '%s'", (exp ? "expression" : "prefix"),
4696 fprintf(STDOUT, " .. ");
4698 fprintf(STDOUT, "\n");
4702 for (j = 0; j < nentries; j++) { /* process each vldb entry */
4703 vllist = &arrayEntries.nbulkentries_val[j];
4706 for (ti = as->parms[0].items; ti; ti = ti->next) {
4707 if (strncmp(ti->data, "^", 1) == 0) {
4708 #ifdef HAVE_POSIX_REGEX
4712 /* XXX -- should just do the compile once! */
4713 code = regcomp(&re, ti->data, REG_NOSUB);
4715 regerror(code, &re, errbuf, sizeof errbuf);
4717 "Error in -prefix regular expression: '%s': %s\n",
4721 match = (regexec(&re, vllist->name, 0, NULL, 0) == 0);
4724 ccode = (char *)re_comp(ti->data);
4727 "Error in -prefix regular expression: '%s': %s\n",
4731 match = (re_exec(vllist->name) == 1);
4735 (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4745 /* Without the -exclude flag: If it matches the prefix, then
4746 * check if we want to exclude any from xprefix.
4747 * With the -exclude flag: If it matches the prefix, then
4748 * check if we want to add any from xprefix.
4750 if (match && seenxprefix) {
4751 for (ti = as->parms[4].items; ti; ti = ti->next) {
4752 if (strncmp(ti->data, "^", 1) == 0) {
4753 #ifdef HAVE_POSIX_REGEX
4757 /* XXX -- should just do the compile once! */
4758 code = regcomp(&re, ti->data, REG_NOSUB);
4760 regerror(code, &re, errbuf, sizeof errbuf);
4762 "Error in -xprefix regular expression: '%s': %s\n",
4766 if (regexec(&re, vllist->name, 0, NULL, 0) == 0)
4770 ccode = (char *)re_comp(ti->data);
4773 "Error in -xprefix regular expression: '%s': %s\n",
4777 if (re_exec(vllist->name) == 1) {
4783 if (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4793 match = !match; /* -exclude will reverse the match */
4795 continue; /* Skip if no match */
4797 /* Print list of volumes to backup */
4799 fprintf(STDOUT, " %s\n", vllist->name);
4803 if (!(vllist->flags & RW_EXISTS)) {
4806 "Omitting to backup %s since RW volume does not exist \n",
4808 fprintf(STDOUT, "\n");
4814 avolid = vllist->volumeId[RWVOL];
4815 MapHostToNetwork(vllist);
4816 GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
4817 if (aserver1 == -1 || apart1 == -1) {
4818 fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n",
4824 same = VLDB_IsSameAddrs(aserver, aserver1, &error);
4827 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4833 if ((aserver && !same) || (apart && (apart != apart1))) {
4836 "Omitting to backup %s since the RW is in a different location\n",
4842 time_t now = time(0);
4843 fprintf(STDOUT, "Creating backup volume for %s on %s",
4844 vllist->name, ctime(&now));
4848 code = UV_BackupVolume(aserver1, apart1, avolid);
4850 fprintf(STDOUT, "Could not backup %s\n", vllist->name);
4856 fprintf(STDOUT, "\n");
4858 } /* process each vldb entry */
4859 fprintf(STDOUT, "done\n");
4860 fprintf(STDOUT, "Total volumes backed up: %lu; failed to backup: %lu\n",
4861 (unsigned long)totalBack, (unsigned long)totalFail);
4863 if (arrayEntries.nbulkentries_val)
4864 free(arrayEntries.nbulkentries_val);
4869 UnlockVLDB(register struct cmd_syndesc *as, void *arock)
4872 afs_int32 aserver, code;
4874 struct VldbListByAttributes attributes;
4875 nbulkentries arrayEntries;
4876 register struct nvldbentry *vllist;
4885 attributes.Mask = 0;
4887 if (as->parms[0].items) { /* server specified */
4888 aserver = GetServer(as->parms[0].items->data);
4890 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4891 as->parms[0].items->data);
4894 attributes.server = ntohl(aserver);
4895 attributes.Mask |= VLLIST_SERVER;
4897 if (as->parms[1].items) { /* partition specified */
4898 apart = volutil_GetPartitionID(as->parms[1].items->data);
4900 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4901 as->parms[1].items->data);
4904 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4906 PrintError("", code);
4909 "vos : partition %s does not exist on the server\n",
4910 as->parms[1].items->data);
4913 attributes.partition = apart;
4914 attributes.Mask |= VLLIST_PARTITION;
4916 attributes.flag = VLOP_ALLOPERS;
4917 attributes.Mask |= VLLIST_FLAG;
4918 memset(&arrayEntries, 0, sizeof(arrayEntries)); /*initialize to hint the stub to alloc space */
4919 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4921 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4922 PrintError("", vcode);
4925 for (j = 0; j < nentries; j++) { /* process each entry */
4926 vllist = &arrayEntries.nbulkentries_val[j];
4927 volid = vllist->volumeId[RWVOL];
4929 ubik_VL_ReleaseLock(cstruct, 0, volid, -1,
4930 LOCKREL_OPCODE | LOCKREL_AFSID |
4933 fprintf(STDERR, "Could not unlock entry for volume %s\n",
4935 PrintError("", vcode);
4940 MapPartIdIntoName(apart, pname);
4943 "Could not lock %lu VLDB entries of %lu locked entries\n",
4944 (unsigned long)totalE, (unsigned long)nentries);
4946 if (as->parms[0].items) {
4948 "Unlocked all the VLDB entries for volumes on server %s ",
4949 as->parms[0].items->data);
4950 if (as->parms[1].items) {
4951 MapPartIdIntoName(apart, pname);
4952 fprintf(STDOUT, "partition %s\n", pname);
4954 fprintf(STDOUT, "\n");
4956 } else if (as->parms[1].items) {
4957 MapPartIdIntoName(apart, pname);
4959 "Unlocked all the VLDB entries for volumes on partition %s on all servers\n",
4964 if (arrayEntries.nbulkentries_val)
4965 free(arrayEntries.nbulkentries_val);
4970 PrintInt64Size(afs_uint64 in)
4972 register afs_uint32 hi, lo;
4973 register char * units;
4974 static char output[16];
4976 SplitInt64(in,hi,lo);
4980 } else if (!(hi & 0xFFFFFC00)) {
4982 lo = (hi << 22) | (lo >> 10);
4983 } else if (!(hi & 0xFFF00000)) {
4985 lo = (hi << 12) | (lo >> 20);
4986 } else if (!(hi & 0xC0000000)) {
4988 lo = (hi << 2) | (lo >> 30);
4993 sprintf(output,"%u %s", lo, units);
4998 PartitionInfo(register struct cmd_syndesc *as, void *arock)
5001 afs_int32 aserver, code;
5003 struct diskPartition64 partition;
5004 struct partList dummyPartList;
5006 int printSummary=0, sumPartitions=0;
5007 afs_uint64 sumFree, sumStorage;
5010 ZeroInt64(sumStorage);
5012 aserver = GetServer(as->parms[0].items->data);
5014 fprintf(STDERR, "vos: server '%s' not found in host table\n",
5015 as->parms[0].items->data);
5018 if (as->parms[1].items) {
5019 apart = volutil_GetPartitionID(as->parms[1].items->data);
5021 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5022 as->parms[1].items->data);
5025 dummyPartList.partId[0] = apart;
5026 dummyPartList.partFlags[0] = PARTVALID;
5029 if (as->parms[2].items) {
5033 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
5035 PrintError("", code);
5038 "vos : partition %s does not exist on the server\n",
5039 as->parms[1].items->data);
5043 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
5045 PrintDiagnostics("listpart", code);
5049 for (i = 0; i < cnt; i++) {
5050 if (dummyPartList.partFlags[i] & PARTVALID) {
5051 MapPartIdIntoName(dummyPartList.partId[i], pname);
5052 code = UV_PartitionInfo64(aserver, pname, &partition);
5054 fprintf(STDERR, "Could not get information on partition %s\n",
5056 PrintError("", code);
5060 "Free space on partition %s: %lld K blocks out of total %lld\n",
5061 pname, partition.free, partition.minFree);
5063 AddUInt64(sumFree,partition.free,&sumFree);
5064 AddUInt64(sumStorage,partition.minFree,&sumStorage);
5069 "Summary: %s free out of ",
5070 PrintInt64Size(sumFree));
5072 "%s on %d partitions\n",
5073 PrintInt64Size(sumStorage),
5080 ChangeAddr(register struct cmd_syndesc *as, void *arock)
5082 afs_int32 ip1, ip2, vcode;
5085 ip1 = GetServer(as->parms[0].items->data);
5087 fprintf(STDERR, "vos: invalid host address\n");
5091 if ((as->parms[1].items && as->parms[2].items)
5092 || (!as->parms[1].items && !as->parms[2].items)) {
5094 "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
5098 if (as->parms[1].items) {
5099 ip2 = GetServer(as->parms[1].items->data);
5101 fprintf(STDERR, "vos: invalid host address\n");
5105 /* Play a trick here. If we are removing an address, ip1 will be -1
5106 * and ip2 will be the original address. This switch prevents an
5107 * older revision vlserver from removing the IP address.
5114 vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
5117 fprintf(STDERR, "Could not remove server %s from the VLDB\n",
5118 as->parms[0].items->data);
5119 if (vcode == VL_NOENT) {
5121 "vlserver does not support the remove flag or ");
5124 fprintf(STDERR, "Could not change server %s to server %s\n",
5125 as->parms[0].items->data, as->parms[1].items->data);
5127 PrintError("", vcode);
5132 fprintf(STDOUT, "Removed server %s from the VLDB\n",
5133 as->parms[0].items->data);
5135 fprintf(STDOUT, "Changed server %s to server %s\n",
5136 as->parms[0].items->data, as->parms[1].items->data);
5142 print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
5147 struct VLCallBack vlcb;
5150 ListAddrByAttributes m_attrs;
5151 afs_int32 m_nentries, *m_addrp;
5152 afs_int32 base, index;
5156 afsUUID_to_string(m_uuid, buf, sizeof(buf));
5157 printf("UUID: %s\n", buf);
5160 /* print out the list of all the server */
5161 addrp = (afs_int32 *) addrs->bulkaddrs_val;
5162 for (i = 0; i < nentries; i++, addrp++) {
5163 /* If it is a multihomed address, then we will need to
5164 * get the addresses for this multihomed server from
5165 * the vlserver and print them.
5167 if (((*addrp & 0xff000000) == 0xff000000) && ((*addrp) & 0xffff)) {
5168 /* Get the list of multihomed fileservers */
5169 base = (*addrp >> 16) & 0xff;
5170 index = (*addrp) & 0xffff;
5172 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
5173 && (index <= VL_MHSRV_PERBLK)) {
5174 m_attrs.Mask = VLADDR_INDEX;
5175 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
5177 m_addrs.bulkaddrs_val = 0;
5178 m_addrs.bulkaddrs_len = 0;
5180 ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, &m_uuid,
5181 (afs_int32 *)&vlcb, &m_nentries, &m_addrs);
5184 "vos: could not list the multi-homed server addresses\n");
5185 PrintError("", vcode);
5188 /* Print the list */
5189 m_addrp = (afs_int32 *) m_addrs.bulkaddrs_val;
5190 for (j = 0; j < m_nentries; j++, m_addrp++) {
5191 *m_addrp = htonl(*m_addrp);
5194 printf("%s ", afs_inet_ntoa_r(*m_addrp, hoststr));
5196 printf("%s ", hostutil_GetNameByINet(*m_addrp));
5200 printf("<unknown>\n");
5209 /* Otherwise, it is a non-multihomed entry and contains
5210 * the IP address of the server - print it.
5212 *addrp = htonl(*addrp);
5215 printf("%s\n", afs_inet_ntoa_r(*addrp, hoststr));
5217 printf("%s\n", hostutil_GetNameByINet(*addrp));
5228 ListAddrs(register struct cmd_syndesc *as, void *arock)
5231 afs_int32 i, printuuid = 0;
5232 struct VLCallBack vlcb;
5235 ListAddrByAttributes m_attrs;
5236 afsUUID m_uuid, askuuid;
5237 afs_int32 m_nentries;
5239 memset(&m_attrs, 0, sizeof(struct ListAddrByAttributes));
5240 m_attrs.Mask = VLADDR_INDEX;
5242 memset(&m_addrs, 0, sizeof(bulkaddrs));
5243 memset(&askuuid, 0, sizeof(afsUUID));
5244 if (as->parms[0].items) {
5246 if (afsUUID_from_string(as->parms[0].items->data, &askuuid) < 0) {
5247 fprintf(STDERR, "vos: invalid UUID '%s'\n",
5248 as->parms[0].items->data);
5251 m_attrs.Mask = VLADDR_UUID;
5252 m_attrs.uuid = askuuid;
5254 if (as->parms[1].items) {
5258 he = hostutil_GetHostByName((char *)as->parms[1].items->data);
5260 fprintf(STDERR, "vos: Can't get host info for '%s'\n",
5261 as->parms[1].items->data);
5264 memcpy(&saddr, he->h_addr, 4);
5265 m_attrs.Mask = VLADDR_IPADDR;
5266 m_attrs.ipaddr = ntohl(saddr);
5268 if (as->parms[2].items) {
5272 m_addrs.bulkaddrs_val = 0;
5273 m_addrs.bulkaddrs_len = 0;
5276 ubik_Call_New(VL_GetAddrs, cstruct, 0, 0, 0, &vlcb, &nentries,
5279 fprintf(STDERR, "vos: could not list the server addresses\n");
5280 PrintError("", vcode);
5285 m_addrs.bulkaddrs_val = 0;
5286 m_addrs.bulkaddrs_len = 0;
5292 ubik_Call_New(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
5293 &vlcb, &m_nentries, &m_addrs);
5295 if (vcode == VL_NOENT) {
5296 if (m_attrs.Mask == VLADDR_UUID) {
5297 fprintf(STDERR, "vos: no entry for UUID '%s' found in VLDB\n",
5298 as->parms[0].items->data);
5300 } else if (m_attrs.Mask == VLADDR_IPADDR) {
5301 fprintf(STDERR, "vos: no entry for host '%s' [0x%08x] found in VLDB\n",
5302 as->parms[1].items->data, m_attrs.ipaddr);
5311 if (vcode == VL_INDEXERANGE) {
5316 fprintf(STDERR, "vos: could not list the server addresses\n");
5317 PrintError("", vcode);
5321 print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid);
5324 if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
5332 LockEntry(register struct cmd_syndesc *as, void *arock)
5334 afs_int32 avolid, vcode, err;
5336 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5339 PrintError("", err);
5341 fprintf(STDERR, "vos: can't find volume '%s'\n",
5342 as->parms[0].items->data);
5345 vcode = ubik_VL_SetLock(cstruct, 0, avolid, -1, VLOP_DELETE);
5347 fprintf(STDERR, "Could not lock VLDB entry for volume %s\n",
5348 as->parms[0].items->data);
5349 PrintError("", vcode);
5352 fprintf(STDOUT, "Locked VLDB entry for volume %s\n",
5353 as->parms[0].items->data);
5358 ConvertRO(register struct cmd_syndesc *as, void *arock)
5360 afs_int32 partition = -1;
5361 afs_int32 server, volid, code, i, same;
5362 struct nvldbentry entry, storeEntry;
5365 afs_int32 rwserver = 0;
5366 afs_int32 rwpartition;
5368 afs_int32 roserver = 0;
5369 afs_int32 ropartition;
5371 struct rx_connection *aconn;
5374 server = GetServer(as->parms[0].items->data);
5376 fprintf(STDERR, "vos: host '%s' not found in host table\n",
5377 as->parms[0].items->data);
5380 partition = volutil_GetPartitionID(as->parms[1].items->data);
5381 if (partition < 0) {
5382 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5383 as->parms[1].items->data);
5386 if (!IsPartValid(partition, server, &code)) {
5388 PrintError("", code);
5391 "vos : partition %s does not exist on the server\n",
5392 as->parms[1].items->data);
5395 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &code);
5398 PrintError("", code);
5400 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
5401 as->parms[0].items->data);
5404 if (as->parms[3].items)
5407 vcode = VLDB_GetEntryByID(volid, -1, &entry);
5410 "Could not fetch the entry for volume %lu from VLDB\n",
5411 (unsigned long)volid);
5412 PrintError("convertROtoRW", code);
5416 /* use RO volid even if user specified RW or BK volid */
5418 if (volid != entry.volumeId[ROVOL])
5419 volid = entry.volumeId[ROVOL];
5421 MapHostToNetwork(&entry);
5422 for (i = 0; i < entry.nServers; i++) {
5423 if (entry.serverFlags[i] & ITSRWVOL) {
5425 rwserver = entry.serverNumber[i];
5426 rwpartition = entry.serverPartition[i];
5428 if (entry.serverFlags[i] & ITSROVOL) {
5429 same = VLDB_IsSameAddrs(server, entry.serverNumber[i], &code);
5432 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
5438 roserver = entry.serverNumber[i];
5439 ropartition = entry.serverPartition[i];
5445 fprintf(STDERR, "Warning: RO volume didn't exist in vldb!\n");
5447 if (ropartition != partition) {
5449 "Warning: RO volume should be in partition %d instead of %d (vldb)\n",
5450 ropartition, partition);
5455 "VLDB indicates that a RW volume exists already on %s in partition %s.\n",
5456 hostutil_GetNameByINet(rwserver),
5457 volutil_PartitionName(rwpartition));
5459 fprintf(STDERR, "Overwrite this VLDB entry? [y|n] (n)\n");
5461 while (!(dc == EOF || dc == '\n'))
5462 dc = getchar(); /* goto end of line */
5463 if ((c != 'y') && (c != 'Y')) {
5464 fprintf(STDERR, "aborted.\n");
5471 ubik_VL_SetLock(cstruct, 0, entry.volumeId[RWVOL], RWVOL,
5473 aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
5474 code = AFSVolConvertROtoRWvolume(aconn, partition, volid);
5477 "Converting RO volume %lu to RW volume failed with code %d\n",
5478 (unsigned long)volid, code);
5479 PrintError("convertROtoRW ", code);
5482 entry.serverFlags[roindex] = ITSRWVOL;
5483 entry.flags |= RW_EXISTS;
5484 entry.flags &= ~BACK_EXISTS;
5487 if (rwindex != entry.nServers) {
5488 entry.serverNumber[rwindex] = entry.serverNumber[entry.nServers];
5489 entry.serverPartition[rwindex] =
5490 entry.serverPartition[entry.nServers];
5491 entry.serverFlags[rwindex] = entry.serverFlags[entry.nServers];
5492 entry.serverNumber[entry.nServers] = 0;
5493 entry.serverPartition[entry.nServers] = 0;
5494 entry.serverFlags[entry.nServers] = 0;
5497 entry.flags &= ~RO_EXISTS;
5498 for (i = 0; i < entry.nServers; i++) {
5499 if (entry.serverFlags[i] & ITSROVOL) {
5500 if (!(entry.serverFlags[i] & (RO_DONTUSE | NEW_REPSITE)))
5501 entry.flags |= RO_EXISTS;
5504 MapNetworkToHost(&entry, &storeEntry);
5506 VLDB_ReplaceEntry(entry.volumeId[RWVOL], RWVOL, &storeEntry,
5507 (LOCKREL_OPCODE | LOCKREL_AFSID |
5508 LOCKREL_TIMESTAMP));
5511 "Warning: volume converted, but vldb update failed with code %d!\n",
5514 vcode = UV_LockRelease(entry.volumeId[RWVOL]);
5516 PrintDiagnostics("unlock", vcode);
5522 Sizes(register struct cmd_syndesc *as, void *arock)
5524 afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i;
5525 struct nvldbentry entry;
5526 volintSize vol_size;
5528 rx_SetRxDeadTime(60 * 10);
5529 for (i = 0; i < MAXSERVERS; i++) {
5530 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
5533 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
5534 if (rxConn->service)
5535 rxConn->service->connDeadTime = rx_connDeadTime;
5538 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5541 PrintError("", err);
5543 fprintf(STDERR, "vos: can't find volume '%s'\n",
5544 as->parms[0].items->data);
5548 if (as->parms[1].items || as->parms[2].items) {
5549 if (!as->parms[1].items || !as->parms[2].items) {
5551 "Must specify both -server and -partition options\n");
5554 aserver = GetServer(as->parms[2].items->data);
5556 fprintf(STDERR, "Invalid server name\n");
5559 apart = volutil_GetPartitionID(as->parms[1].items->data);
5561 fprintf(STDERR, "Invalid partition name\n");
5565 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
5572 if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
5573 code = ktime_DateToInt32(as->parms[4].items->data, &fromdate);
5575 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
5576 as->parms[4].items->data, code);
5581 fprintf(STDOUT, "Volume: %s\n", as->parms[0].items->data);
5583 if (as->parms[3].items) { /* do the dump estimate */
5584 #ifdef AFS_64BIT_ENV
5585 vol_size.dump_size = 0;
5587 FillInt64(vol_size.dump_size,0, 1);
5589 code = UV_GetSize(avolid, aserver, apart, fromdate, &vol_size);
5591 PrintDiagnostics("size", code);
5594 /* presumably the size info is now gathered in pntr */
5595 /* now we display it */
5597 fprintf(STDOUT, "dump_size: %llu\n", vol_size.dump_size);
5606 PrintDiagnostics(char *astring, afs_int32 acode)
5608 if (acode == EACCES) {
5610 "You are not authorized to perform the 'vos %s' command (%d)\n",
5613 fprintf(STDERR, "Error in vos %s command.\n", astring);
5614 PrintError("", acode);
5621 MyBeforeProc(struct cmd_syndesc *as, void *arock)
5623 register char *tcell;
5624 register afs_int32 code;
5625 register afs_int32 sauth;
5627 /* Initialize the ubik_client connection */
5628 rx_SetRxDeadTime(90);
5629 cstruct = (struct ubik_client *)0;
5633 if (as->parms[12].items) /* if -cell specified */
5634 tcell = as->parms[12].items->data;
5635 if (as->parms[14].items) /* -serverauth specified */
5637 if (as->parms[16].items) /* -crypt specified */
5640 vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
5641 &cstruct, UV_SetSecurity))) {
5642 fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
5643 (unsigned long)code);
5647 if (as->parms[15].items) /* -verbose flag set */
5651 if (as->parms[17].items) /* -noresolve flag set */
5661 /* this sucks but it works for now.
5666 #include "AFS_component_version_number.c"
5672 register afs_int32 code;
5674 register struct cmd_syndesc *ts;
5676 #ifdef AFS_AIX32_ENV
5678 * The following signal action for AIX is necessary so that in case of a
5679 * crash (i.e. core is generated) we can include the user's data section
5680 * in the core dump. Unfortunately, by default, only a partial core is
5681 * generated which, in many cases, isn't too useful.
5683 struct sigaction nsa;
5685 sigemptyset(&nsa.sa_mask);
5686 nsa.sa_handler = SIG_DFL;
5687 nsa.sa_flags = SA_FULLDUMP;
5688 sigaction(SIGSEGV, &nsa, NULL);
5691 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
5693 cmd_SetBeforeProc(MyBeforeProc, NULL);
5695 ts = cmd_CreateSyntax("create", CreateVolume, NULL, "create a new volume");
5696 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5697 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5698 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "volume name");
5699 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL,
5700 "initial quota (KB)");
5702 cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
5706 ts = cmd_CreateSyntax("remove", DeleteVolume, NULL, "delete a volume");
5707 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5708 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5709 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5713 ts = cmd_CreateSyntax("move", MoveVolume, NULL, "move a volume");
5714 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5715 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5716 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5717 "partition name on source");
5718 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5719 "machine name on destination");
5720 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5721 "partition name on destination");
5722 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5723 "copy live volume without cloning");
5726 ts = cmd_CreateSyntax("copy", CopyVolume, NULL, "copy a volume");
5727 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5728 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5729 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5730 "partition name on source");
5731 cmd_AddParm(ts, "-toname", CMD_SINGLE, 0, "volume name on destination");
5732 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5733 "machine name on destination");
5734 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5735 "partition name on destination");
5736 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5737 "leave new volume offline");
5738 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5739 "make new volume read-only");
5740 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5741 "copy live volume without cloning");
5744 ts = cmd_CreateSyntax("shadow", ShadowVolume, NULL,
5745 "make or update a shadow volume");
5746 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5747 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5748 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5749 "partition name on source");
5750 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5751 "machine name on destination");
5752 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5753 "partition name on destination");
5754 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5755 "volume name on destination");
5756 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5757 "volume ID on destination");
5758 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5759 "leave shadow volume offline");
5760 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5761 "make shadow volume read-only");
5762 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5763 "copy live volume without cloning");
5764 cmd_AddParm(ts, "-incremental", CMD_FLAG, CMD_OPTIONAL,
5765 "do incremental update if target exists");
5768 ts = cmd_CreateSyntax("backup", BackupVolume, NULL,
5769 "make backup of a volume");
5770 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5773 ts = cmd_CreateSyntax("clone", CloneVolume, NULL,
5774 "make clone of a volume");
5775 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5776 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5777 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5778 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5779 "volume name on destination");
5780 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5781 "volume ID on destination");
5782 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5783 "leave clone volume offline");
5784 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5785 "make clone volume read-only, not readwrite");
5788 ts = cmd_CreateSyntax("release", ReleaseVolume, NULL, "release a volume");
5789 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5790 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5791 "force a complete release");
5794 ts = cmd_CreateSyntax("dump", DumpVolume, NULL, "dump a volume");
5795 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5796 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5797 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5798 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5799 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5800 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL,
5801 "dump a clone of the volume");
5802 cmd_AddParm(ts, "-omitdirs", CMD_FLAG, CMD_OPTIONAL,
5803 "omit unchanged directories from an incremental dump");
5806 ts = cmd_CreateSyntax("restore", RestoreVolume, NULL, "restore a volume");
5807 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5808 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5809 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of volume to be restored");
5810 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5811 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
5812 cmd_AddParm(ts, "-overwrite", CMD_SINGLE, CMD_OPTIONAL,
5813 "abort | full | incremental");
5814 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5815 "leave restored volume offline");
5816 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5817 "make restored volume read-only");
5818 cmd_AddParm(ts, "-creation", CMD_SINGLE, CMD_OPTIONAL,
5819 "dump | keep | new");
5820 cmd_AddParm(ts, "-lastupdate", CMD_SINGLE, CMD_OPTIONAL,
5821 "dump | keep | new");
5822 cmd_AddParm(ts, "-nodelete", CMD_FLAG, CMD_OPTIONAL,
5823 "do not delete old site when restoring to a new site");
5826 ts = cmd_CreateSyntax("unlock", LockReleaseCmd, NULL,
5827 "release lock on VLDB entry for a volume");
5828 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5831 ts = cmd_CreateSyntax("changeloc", ChangeLocation, NULL,
5832 "change an RW volume's location in the VLDB");
5833 cmd_AddParm(ts, "-server", CMD_SINGLE, 0,
5834 "machine name for new location");
5835 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5836 "partition name for new location");
5837 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5840 ts = cmd_CreateSyntax("addsite", AddSite, NULL, "add a replication site");
5841 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new site");
5842 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5843 "partition name for new site");
5844 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5845 cmd_AddParm(ts, "-valid", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE, "publish as an up-to-date site in VLDB");
5848 ts = cmd_CreateSyntax("remsite", RemoveSite, NULL,
5849 "remove a replication site");
5850 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5851 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5852 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5855 ts = cmd_CreateSyntax("listpart", ListPartitions, NULL, "list partitions");
5856 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5859 ts = cmd_CreateSyntax("listvol", ListVolumes, NULL,
5860 "list volumes on server (bypass VLDB)");
5861 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5862 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5863 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "minimal listing");
5864 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
5865 "list all normal volume fields");
5866 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5867 "generate minimal information");
5868 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5869 "list extended volume fields");
5870 #ifdef FULL_LISTVOL_SWITCH
5871 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5872 "machine readable format");
5873 #endif /* FULL_LISTVOL_SWITCH */
5876 ts = cmd_CreateSyntax("syncvldb", SyncVldb, NULL,
5877 "synchronize VLDB with server");
5878 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5879 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5880 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5881 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5884 ts = cmd_CreateSyntax("syncserv", SyncServer, NULL,
5885 "synchronize server with VLDB");
5886 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5887 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5888 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5891 ts = cmd_CreateSyntax("examine", ExamineVolume, NULL,
5892 "everything about the volume");
5893 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5894 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5895 "list extended volume fields");
5896 #ifdef FULL_LISTVOL_SWITCH
5897 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5898 "machine readable format");
5899 #endif /* FULL_LISTVOL_SWITCH */
5901 cmd_CreateAlias(ts, "volinfo");
5903 ts = cmd_CreateSyntax("setfields", SetFields, NULL,
5904 "change volume info fields");
5905 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5906 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "quota (KB)");
5907 cmd_AddParm(ts, "-clearuse", CMD_FLAG, CMD_OPTIONAL, "clear dayUse");
5908 cmd_AddParm(ts, "-clearVolUpCounter", CMD_FLAG, CMD_OPTIONAL, "clear volUpdateCounter");
5911 ts = cmd_CreateSyntax("offline", volOffline, NULL, (char *)CMD_HIDDEN);
5912 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5913 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5914 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5915 cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds to sleep");
5916 cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "busy volume");
5919 ts = cmd_CreateSyntax("online", volOnline, NULL, (char *)CMD_HIDDEN);
5920 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5921 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5922 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5925 ts = cmd_CreateSyntax("zap", VolumeZap, NULL,
5926 "delete the volume, don't bother with VLDB");
5927 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5928 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5929 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume ID");
5930 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5931 "force deletion of bad volumes");
5932 cmd_AddParm(ts, "-backup", CMD_FLAG, CMD_OPTIONAL,
5933 "also delete backup volume if one is found");
5936 ts = cmd_CreateSyntax("status", VolserStatus, NULL,
5937 "report on volser status");
5938 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5941 ts = cmd_CreateSyntax("rename", RenameVolume, NULL, "rename a volume");
5942 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old volume name ");
5943 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new volume name ");
5946 ts = cmd_CreateSyntax("listvldb", ListVLDB, NULL,
5947 "list volumes in the VLDB");
5948 cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5949 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5950 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5951 cmd_AddParm(ts, "-locked", CMD_FLAG, CMD_OPTIONAL, "locked volumes only");
5952 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5953 "generate minimal information");
5954 cmd_AddParm(ts, "-nosort", CMD_FLAG, CMD_OPTIONAL,
5955 "do not alphabetically sort the volume names");
5958 ts = cmd_CreateSyntax("backupsys", BackSys, NULL, "en masse backups");
5959 cmd_AddParm(ts, "-prefix", CMD_LIST, CMD_OPTIONAL,
5960 "common prefix on volume(s)");
5961 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5962 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5963 cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL,
5964 "exclude common prefix volumes");
5965 cmd_AddParm(ts, "-xprefix", CMD_LIST, CMD_OPTIONAL,
5966 "negative prefix on volume(s)");
5967 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "no action");
5970 ts = cmd_CreateSyntax("delentry", DeleteEntry, NULL,
5971 "delete VLDB entry for a volume");
5972 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "volume name or ID");
5973 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL,
5974 "prefix of the volume whose VLDB entry is to be deleted");
5975 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5976 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5977 cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE,
5981 ts = cmd_CreateSyntax("partinfo", PartitionInfo, NULL,
5982 "list partition information");
5983 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5984 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5985 cmd_AddParm(ts, "-summary", CMD_FLAG, CMD_OPTIONAL,
5986 "print storage summary");
5989 ts = cmd_CreateSyntax("unlockvldb", UnlockVLDB, NULL,
5990 "unlock all the locked entries in the VLDB");
5991 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5992 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5995 ts = cmd_CreateSyntax("lock", LockEntry, NULL,
5996 "lock VLDB entry for a volume");
5997 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6000 ts = cmd_CreateSyntax("changeaddr", ChangeAddr, NULL,
6001 "change the IP address of a file server");
6002 cmd_AddParm(ts, "-oldaddr", CMD_SINGLE, 0, "original IP address");
6003 cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
6004 cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL,
6005 "remove the IP address from the VLDB");
6008 ts = cmd_CreateSyntax("listaddrs", ListAddrs, NULL,
6009 "list the IP address of all file servers registered in the VLDB");
6010 cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
6011 cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
6012 cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
6013 "print uuid of hosts");
6016 ts = cmd_CreateSyntax("convertROtoRW", ConvertRO, NULL,
6017 "convert a RO volume into a RW volume (after loss of old RW volume)");
6018 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6019 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
6020 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6021 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "don't ask");
6024 ts = cmd_CreateSyntax("size", Sizes, NULL,
6025 "obtain various sizes of the volume.");
6026 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6027 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6028 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6029 cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL,
6030 "Obtain the size of the dump");
6031 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
6034 code = cmd_Dispatch(argc, argv);
6036 /* Shut down the ubik_client and rx connections */
6038 (void)ubik_ClientDestroy(cstruct);
6044 exit((code ? -1 : 0));