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");
477 vos_ctime(afs_int32 *timep)
483 #define vos_ctime ctime
487 DisplayFormat(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
490 afs_int32 server, part;
491 int *totalOK, *totalNotOK, *totalBusy;
492 int fast, longlist, disp;
497 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
498 } else if (longlist) {
499 if (pntr->status == VOK) {
500 fprintf(STDOUT, "%-32s ", pntr->name);
501 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
503 fprintf(STDOUT, "RW ");
505 fprintf(STDOUT, "RO ");
507 fprintf(STDOUT, "BK ");
508 fprintf(STDOUT, "%10d K ", pntr->size);
509 if (pntr->inUse == 1) {
510 fprintf(STDOUT, "On-line");
513 fprintf(STDOUT, "Off-line");
516 if (pntr->needsSalvaged == 1)
517 fprintf(STDOUT, "**needs salvage**");
518 fprintf(STDOUT, "\n");
519 MapPartIdIntoName(part, pname);
520 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
522 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
523 (unsigned long)pntr->parentID,
524 (unsigned long)pntr->cloneID,
525 (unsigned long)pntr->backupID);
526 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
527 fprintf(STDOUT, " Creation %s",
528 vos_ctime(& pntr->creationDate));
529 #ifdef FULL_LISTVOL_SWITCH
530 fprintf(STDOUT, " Copy %s",
531 vos_ctime( & pntr->copyDate));
532 if (!pntr->backupDate)
533 fprintf(STDOUT, " Backup Never\n");
535 fprintf(STDOUT, " Backup %s",
536 vos_ctime( & pntr->backupDate));
537 if (pntr->accessDate)
538 fprintf(STDOUT, " Last Access %s",
539 vos_ctime( & pntr->accessDate));
541 if (!pntr->updateDate)
542 fprintf(STDOUT, " Last Update Never\n");
544 fprintf(STDOUT, " Last Update %s",
545 vos_ctime( & pntr->updateDate));
547 " %d accesses in the past day (i.e., vnode references)\n",
550 } else if (pntr->status == VBUSY) {
552 qPut(&busyHead, pntr->volid);
554 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
555 (unsigned long)pntr->volid);
558 qPut(¬okHead, pntr->volid);
560 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
561 (unsigned long)pntr->volid);
563 fprintf(STDOUT, "\n");
564 } else { /* default listing */
565 if (pntr->status == VOK) {
566 fprintf(STDOUT, "%-32s ", pntr->name);
567 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
569 fprintf(STDOUT, "RW ");
571 fprintf(STDOUT, "RO ");
573 fprintf(STDOUT, "BK ");
574 fprintf(STDOUT, "%10d K ", pntr->size);
575 if (pntr->inUse == 1) {
576 fprintf(STDOUT, "On-line");
579 fprintf(STDOUT, "Off-line");
582 if (pntr->needsSalvaged == 1)
583 fprintf(STDOUT, "**needs salvage**");
584 fprintf(STDOUT, "\n");
585 } else if (pntr->status == VBUSY) {
587 qPut(&busyHead, pntr->volid);
589 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
590 (unsigned long)pntr->volid);
593 qPut(¬okHead, pntr->volid);
595 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
596 (unsigned long)pntr->volid);
601 /*------------------------------------------------------------------------
602 * PRIVATE XDisplayFormat
605 * Display the contents of one extended volume info structure.
608 * a_xInfoP : Ptr to extended volume info struct to print.
609 * a_servID : Server ID to print.
610 * a_partID : Partition ID to print.
611 * a_totalOKP : Ptr to total-OK counter.
612 * a_totalNotOKP : Ptr to total-screwed counter.
613 * a_totalBusyP : Ptr to total-busy counter.
614 * a_fast : Fast listing?
615 * a_int32 : Int32 listing?
616 * a_showProblems : Show volume problems?
622 * Nothing interesting.
626 *------------------------------------------------------------------------*/
629 XDisplayFormat(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
630 a_totalBusyP, a_fast, a_int32, a_showProblems)
631 volintXInfo *a_xInfoP;
641 { /*XDisplayFormat */
649 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
650 } else if (a_int32) {
652 * Fully-detailed listing.
654 if (a_xInfoP->status == VOK) {
656 * Volume's status is OK - all the fields are valid.
658 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
659 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
660 if (a_xInfoP->type == 0)
661 fprintf(STDOUT, "RW ");
662 if (a_xInfoP->type == 1)
663 fprintf(STDOUT, "RO ");
664 if (a_xInfoP->type == 2)
665 fprintf(STDOUT, "BK ");
666 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
667 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
668 if (a_xInfoP->inUse == 1) {
669 fprintf(STDOUT, "On-line");
672 fprintf(STDOUT, "Off-line");
675 fprintf(STDOUT, "\n");
676 MapPartIdIntoName(a_partID, pname);
677 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
679 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
680 (unsigned long)a_xInfoP->parentID,
681 (unsigned long)a_xInfoP->cloneID,
682 (unsigned long)a_xInfoP->backupID);
683 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
684 fprintf(STDOUT, " Creation %s",
685 vos_ctime( & a_xInfoP->creationDate));
686 #ifdef FULL_LISTVOL_SWITCH
687 fprintf(STDOUT, " Copy %s",
688 vos_ctime( & a_xInfoP->copyDate));
689 if (!a_xInfoP->backupDate)
690 fprintf(STDOUT, " Backup Never\n");
692 fprintf(STDOUT, " Backup %s",
693 vos_ctime( & a_xInfoP->backupDate));
694 if (a_xInfoP->accessDate)
695 fprintf(STDOUT, " Last Access %s",
696 vos_ctime( & a_xInfoP->accessDate));
698 if (!a_xInfoP->updateDate)
699 fprintf(STDOUT, " Last Update Never\n");
701 fprintf(STDOUT, " Last Update %s",
702 vos_ctime( & a_xInfoP->updateDate));
704 " %d accesses in the past day (i.e., vnode references)\n",
709 * Print all the read/write and authorship stats.
711 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
713 " |-------------------------------------------|\n");
715 " | Same Network | Diff Network |\n");
717 " |----------|----------|----------|----------|\n");
719 " | Total | Auth | Total | Auth |\n");
721 " |----------|----------|----------|----------|\n");
722 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
723 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
724 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
725 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
726 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
727 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
728 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
729 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
730 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
731 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
733 " |-------------------------------------------|\n\n");
736 " Writes Affecting Authorship\n");
738 " |-------------------------------------------|\n");
740 " | File Authorship | Directory Authorship|\n");
742 " |----------|----------|----------|----------|\n");
744 " | Same | Diff | Same | Diff |\n");
746 " |----------|----------|----------|----------|\n");
747 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
748 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
749 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
750 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
751 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
752 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
753 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
754 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
755 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
756 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
757 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
758 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
759 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
760 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
761 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
762 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
763 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
764 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
765 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
766 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
767 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
768 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
769 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
770 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
771 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
772 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
773 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
774 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
775 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
776 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
778 " |-------------------------------------------|\n");
779 } /*Volume status OK */
780 else if (a_xInfoP->status == VBUSY) {
782 qPut(&busyHead, a_xInfoP->volid);
784 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
785 (unsigned long)a_xInfoP->volid);
789 qPut(¬okHead, a_xInfoP->volid);
791 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
792 (unsigned long)a_xInfoP->volid);
793 } /*Screwed volume */
794 fprintf(STDOUT, "\n");
800 if (a_xInfoP->status == VOK) {
801 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
802 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
803 if (a_xInfoP->type == 0)
804 fprintf(STDOUT, "RW ");
805 if (a_xInfoP->type == 1)
806 fprintf(STDOUT, "RO ");
807 if (a_xInfoP->type == 2)
808 fprintf(STDOUT, "BK ");
809 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
810 if (a_xInfoP->inUse == 1) {
811 fprintf(STDOUT, "On-line");
814 fprintf(STDOUT, "Off-line");
817 fprintf(STDOUT, "\n");
819 else if (a_xInfoP->status == VBUSY) {
821 qPut(&busyHead, a_xInfoP->volid);
823 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
824 (unsigned long)a_xInfoP->volid);
828 qPut(¬okHead, a_xInfoP->volid);
830 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
831 (unsigned long)a_xInfoP->volid);
832 } /*Screwed volume */
833 } /*Default listing */
834 } /*XDisplayFormat */
836 #ifdef FULL_LISTVOL_SWITCH
837 /*------------------------------------------------------------------------
838 * PRIVATE XDisplayFormat2
841 * Display the formated contents of one extended volume info structure.
844 * a_xInfoP : Ptr to extended volume info struct to print.
845 * a_servID : Server ID to print.
846 * a_partID : Partition ID to print.
847 * a_totalOKP : Ptr to total-OK counter.
848 * a_totalNotOKP : Ptr to total-screwed counter.
849 * a_totalBusyP : Ptr to total-busy counter.
850 * a_fast : Fast listing?
851 * a_int32 : Int32 listing?
852 * a_showProblems : Show volume problems?
858 * Nothing interesting.
862 *------------------------------------------------------------------------*/
865 XDisplayFormat2(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
866 a_totalBusyP, a_fast, a_int32, a_showProblems)
867 volintXInfo *a_xInfoP;
877 { /*XDisplayFormat */
882 fprintf(STDOUT, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP->volid);
883 } else if (a_int32) {
885 * Fully-detailed listing.
887 if (a_xInfoP->status == VOK) {
889 * Volume's status is OK - all the fields are valid.
892 static long server_cache = -1, partition_cache = -1;
893 static char hostname[256], address[32], pname[16];
894 int i,ai[] = {VOLINT_STATS_TIME_IDX_0,VOLINT_STATS_TIME_IDX_1,VOLINT_STATS_TIME_IDX_2,
895 VOLINT_STATS_TIME_IDX_3,VOLINT_STATS_TIME_IDX_4,VOLINT_STATS_TIME_IDX_5};
897 if (a_servID != server_cache) {
901 strcpy(hostname, hostutil_GetNameByINet(a_servID));
902 strcpy(address, inet_ntoa(s));
903 server_cache = a_servID;
905 if (a_partID != partition_cache) {
906 MapPartIdIntoName(a_partID, pname);
907 partition_cache = a_partID;
910 fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name);
911 fprintf(STDOUT, "id\t\t%lu\n", a_xInfoP->volid);
912 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
913 fprintf(STDOUT, "part\t\t%s\n", pname);
914 switch (a_xInfoP->status) {
916 fprintf(STDOUT, "status\t\tOK\n");
919 fprintf(STDOUT, "status\t\tBUSY\n");
922 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
925 fprintf(STDOUT, "backupID\t%lu\n", a_xInfoP->backupID);
926 fprintf(STDOUT, "parentID\t%lu\n", a_xInfoP->parentID);
927 fprintf(STDOUT, "cloneID\t\t%lu\n", a_xInfoP->cloneID);
928 fprintf(STDOUT, "inUse\t\t%s\n", a_xInfoP->inUse ? "Y" : "N");
929 switch (a_xInfoP->type) {
931 fprintf(STDOUT, "type\t\tRW\n");
934 fprintf(STDOUT, "type\t\tRO\n");
937 fprintf(STDOUT, "type\t\tBK\n");
940 fprintf(STDOUT, "type\t\t?\n");
943 fprintf(STDOUT, "creationDate\t%-9lu\t%s", a_xInfoP->creationDate,
944 vos_ctime(&a_xInfoP->creationDate));
945 fprintf(STDOUT, "accessDate\t%-9lu\t%s", a_xInfoP->accessDate,
946 vos_ctime(&a_xInfoP->accessDate));
947 fprintf(STDOUT, "updateDate\t%-9lu\t%s", a_xInfoP->updateDate,
948 vos_ctime(&a_xInfoP->updateDate));
949 fprintf(STDOUT, "backupDate\t%-9lu\t%s", a_xInfoP->backupDate,
950 vos_ctime(&a_xInfoP->backupDate));
951 fprintf(STDOUT, "copyDate\t%-9lu\t%s", a_xInfoP->copyDate,
952 vos_ctime(&a_xInfoP->copyDate));
954 fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
955 fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
957 fprintf(STDOUT, "filecount\t%u\n", a_xInfoP->filecount);
958 fprintf(STDOUT, "dayUse\t\t%u\n", a_xInfoP->dayUse);
962 fprintf(STDOUT,"reads_same_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]);
963 fprintf(STDOUT,"reads_same_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]);
964 fprintf(STDOUT,"reads_diff_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]);
965 fprintf(STDOUT,"reads_diff_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
967 fprintf(STDOUT,"writes_same_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]);
968 fprintf(STDOUT,"writes_same_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]);
969 fprintf(STDOUT,"writes_diff_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]);
970 fprintf(STDOUT,"writes_diff_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
974 fprintf(STDOUT,"file_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileSameAuthor[ai[i]]);
975 fprintf(STDOUT,"file_diff_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileDiffAuthor[ai[i]]);
976 fprintf(STDOUT,"dir_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirSameAuthor[ai[i]]);
977 fprintf(STDOUT,"dir_dif_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirDiffAuthor[ai[i]]);
980 } /*Volume status OK */
981 else if (a_xInfoP->status == VBUSY) {
983 qPut(&busyHead, a_xInfoP->volid);
985 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
986 (unsigned long)a_xInfoP->volid);
990 qPut(¬okHead, a_xInfoP->volid);
992 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
993 (unsigned long)a_xInfoP->volid);
994 } /*Screwed volume */
1000 if (a_xInfoP->status == VOK) {
1001 fprintf(STDOUT, "name\t%-32s\n", a_xInfoP->name);
1002 fprintf(STDOUT, "volID\t%10lu\n", (unsigned long)a_xInfoP->volid);
1003 if (a_xInfoP->type == 0)
1004 fprintf(STDOUT, "type\tRW\n");
1005 if (a_xInfoP->type == 1)
1006 fprintf(STDOUT, "type\tRO\n");
1007 if (a_xInfoP->type == 2)
1008 fprintf(STDOUT, "type\tBK\n");
1009 fprintf(STDOUT, "size\t%10dK\n", a_xInfoP->size);
1011 fprintf(STDOUT, "inUse\t%d\n",a_xInfoP->inUse);
1012 if (a_xInfoP->inUse == 1)
1018 else if (a_xInfoP->status == VBUSY) {
1020 qPut(&busyHead, a_xInfoP->volid);
1022 fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
1023 (unsigned long)a_xInfoP->volid);
1027 qPut(¬okHead, a_xInfoP->volid);
1029 fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
1030 (unsigned long)a_xInfoP->volid);
1031 } /*Screwed volume */
1032 } /*Default listing */
1033 } /*XDisplayFormat */
1034 #endif /*FULL_LISTVOL_SWITCH*/
1036 #ifdef FULL_LISTVOL_SWITCH
1038 DisplayFormat2(server, partition, pntr)
1039 long server, partition;
1042 static long server_cache = -1, partition_cache = -1;
1043 static char hostname[256], address[32], pname[16];
1045 if (server != server_cache) {
1049 strcpy(hostname, hostutil_GetNameByINet(server));
1050 strcpy(address, inet_ntoa(s));
1051 server_cache = server;
1053 if (partition != partition_cache) {
1054 MapPartIdIntoName(partition, pname);
1055 partition_cache = partition;
1057 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
1058 fprintf(STDOUT, "id\t\t%lu\n", pntr->volid);
1059 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
1060 fprintf(STDOUT, "part\t\t%s\n", pname);
1061 switch (pntr->status) {
1063 fprintf(STDOUT, "status\t\tOK\n");
1066 fprintf(STDOUT, "status\t\tBUSY\n");
1069 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
1072 fprintf(STDOUT, "backupID\t%lu\n", pntr->backupID);
1073 fprintf(STDOUT, "parentID\t%lu\n", pntr->parentID);
1074 fprintf(STDOUT, "cloneID\t\t%lu\n", pntr->cloneID);
1075 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
1076 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
1077 /* 0xD3 is from afs/volume.h since I had trouble including the file */
1078 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
1079 switch (pntr->type) {
1081 fprintf(STDOUT, "type\t\tRW\n");
1084 fprintf(STDOUT, "type\t\tRO\n");
1087 fprintf(STDOUT, "type\t\tBK\n");
1090 fprintf(STDOUT, "type\t\t?\n");
1093 fprintf(STDOUT, "creationDate\t%-9lu\t%s", pntr->creationDate,
1094 vos_ctime(&pntr->creationDate));
1095 fprintf(STDOUT, "accessDate\t%-9lu\t%s", pntr->accessDate,
1096 vos_ctime(&pntr->accessDate));
1097 fprintf(STDOUT, "updateDate\t%-9lu\t%s", pntr->updateDate,
1098 vos_ctime(&pntr->updateDate));
1099 fprintf(STDOUT, "backupDate\t%-9lu\t%s", pntr->backupDate,
1100 vos_ctime(&pntr->backupDate));
1101 fprintf(STDOUT, "copyDate\t%-9lu\t%s", pntr->copyDate,
1102 vos_ctime(&pntr->copyDate));
1103 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n", pntr->flags);
1104 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
1105 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
1106 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n", pntr->spare0);
1107 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
1108 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
1109 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n", pntr->spare1);
1110 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n", pntr->spare2);
1111 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n", pntr->spare3);
1116 DisplayVolumes2(server, partition, pntr, count)
1118 long server, partition, count;
1122 for (i = 0; i < count; i++) {
1123 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1124 DisplayFormat2(server, partition, pntr);
1125 fprintf(STDOUT, "END_OF_ENTRY\n\n");
1130 #endif /* FULL_LISTVOL_SWITCH */
1133 DisplayVolumes(server, part, pntr, count, longlist, fast, quiet)
1134 afs_int32 server, part;
1136 afs_int32 count, longlist, fast;
1139 int totalOK, totalNotOK, totalBusy, i;
1147 for (i = 0; i < count; i++) {
1148 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
1153 while (busyHead.count) {
1154 qGet(&busyHead, &volid);
1155 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1156 (unsigned long)volid);
1160 while (notokHead.count) {
1161 qGet(¬okHead, &volid);
1162 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1163 (unsigned long)volid);
1167 fprintf(STDOUT, "\n");
1170 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
1171 totalOK, totalNotOK, totalBusy);
1175 /*------------------------------------------------------------------------
1176 * PRIVATE XDisplayVolumes
1179 * Display extended volume information.
1182 * a_servID : Pointer to the Rx call we're performing.
1183 * a_partID : Partition for which we want the extended list.
1184 * a_xInfoP : Ptr to extended volume info.
1185 * a_count : Number of volume records contained above.
1186 * a_int32 : Int32 listing generated?
1187 * a_fast : Fast listing generated?
1188 * a_quiet : Quiet listing generated?
1194 * Nothing interesting.
1198 *------------------------------------------------------------------------*/
1201 XDisplayVolumes(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
1205 volintXInfo *a_xInfoP;
1211 { /*XDisplayVolumes */
1213 int totalOK; /*Total OK volumes */
1214 int totalNotOK; /*Total screwed volumes */
1215 int totalBusy; /*Total busy volumes */
1216 int i; /*Loop variable */
1217 afs_int32 volid; /*Current volume ID */
1220 * Initialize counters and (global!!) queues.
1229 * Display each volume in the list.
1231 for (i = 0; i < a_count; i++) {
1232 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1233 &totalBusy, a_fast, a_int32, 0);
1238 * If any volumes were found to be busy or screwed, display them.
1241 while (busyHead.count) {
1242 qGet(&busyHead, &volid);
1243 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1244 (unsigned long)volid);
1248 while (notokHead.count) {
1249 qGet(¬okHead, &volid);
1250 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1251 (unsigned long)volid);
1256 fprintf(STDOUT, "\n");
1259 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1260 totalOK, totalNotOK, totalBusy);
1264 } /*XDisplayVolumes */
1265 #ifdef FULL_LISTVOL_SWITCH
1266 /*------------------------------------------------------------------------
1267 * PRIVATE XDisplayVolumes2
1270 * Display extended formated volume information.
1273 * a_servID : Pointer to the Rx call we're performing.
1274 * a_partID : Partition for which we want the extended list.
1275 * a_xInfoP : Ptr to extended volume info.
1276 * a_count : Number of volume records contained above.
1277 * a_int32 : Int32 listing generated?
1278 * a_fast : Fast listing generated?
1279 * a_quiet : Quiet listing generated?
1285 * Nothing interesting.
1289 *------------------------------------------------------------------------*/
1292 XDisplayVolumes2(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
1296 volintXInfo *a_xInfoP;
1302 { /*XDisplayVolumes */
1304 int totalOK; /*Total OK volumes */
1305 int totalNotOK; /*Total screwed volumes */
1306 int totalBusy; /*Total busy volumes */
1307 int i; /*Loop variable */
1308 afs_int32 volid; /*Current volume ID */
1311 * Initialize counters and (global!!) queues.
1320 * Display each volume in the list.
1322 for (i = 0; i < a_count; i++) {
1323 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1324 XDisplayFormat2(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1325 &totalBusy, a_fast, a_int32, 0);
1326 fprintf(STDOUT, "END_OF_ENTRY\n");
1331 * If any volumes were found to be busy or screwed, display them.
1334 while (busyHead.count) {
1335 qGet(&busyHead, &volid);
1336 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1337 (unsigned long)volid);
1341 while (notokHead.count) {
1342 qGet(¬okHead, &volid);
1343 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1344 (unsigned long)volid);
1349 fprintf(STDOUT, "\n");
1352 "VOLUMES_ONLINE\t%d\nVOLUMES_OFFLINE\t%d\nVOLUMES_BUSY\t%d\n",
1353 totalOK, totalNotOK, totalBusy);
1357 } /*XDisplayVolumes2 */
1358 #endif /* FULL_LISTVOL_SWITCH */
1361 /* set <server> and <part> to the correct values depending on
1362 * <voltype> and <entry> */
1364 GetServerAndPart(entry, voltype, server, part, previdx)
1365 struct nvldbentry *entry;
1366 afs_int32 *server, *part;
1370 int i, istart, vtype;
1375 /* Doesn't check for non-existance of backup volume */
1376 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1378 istart = 0; /* seach the entire entry */
1381 /* Seach from beginning of entry or pick up where we left off */
1382 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1385 for (i = istart; i < entry->nServers; i++) {
1386 if (entry->serverFlags[i] & vtype) {
1387 *server = entry->serverNumber[i];
1388 *part = entry->serverPartition[i];
1394 /* Didn't find any, return -1 */
1400 PostVolumeStats(struct nvldbentry *entry)
1402 SubEnumerateEntry(entry);
1403 /* Check for VLOP_ALLOPERS */
1404 if (entry->flags & VLOP_ALLOPERS)
1405 fprintf(STDOUT, " Volume is currently LOCKED \n");
1409 /*------------------------------------------------------------------------
1410 * PRIVATE XVolumeStats
1413 * Display extended volume information.
1416 * a_xInfoP : Ptr to extended volume info.
1417 * a_entryP : Ptr to the volume's VLDB entry.
1418 * a_srvID : Server ID.
1419 * a_partID : Partition ID.
1420 * a_volType : Type of volume to print.
1426 * Nothing interesting.
1430 *------------------------------------------------------------------------*/
1433 XVolumeStats(a_xInfoP, a_entryP, a_srvID, a_partID, a_volType)
1434 volintXInfo *a_xInfoP;
1435 struct nvldbentry *a_entryP;
1442 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1444 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1445 a_srvID, /*Server ID to print */
1446 a_partID, /*Partition ID to print */
1447 &totalOK, /*Ptr to total-OK counter */
1448 &totalNotOK, /*Ptr to total-screwed counter */
1449 &totalBusy, /*Ptr to total-busy counter */
1450 0, /*Don't do a fast listing */
1451 1, /*Do a long listing */
1452 1); /*Show volume problems */
1458 VolumeStats(pntr, entry, server, part, voltype)
1460 struct nvldbentry *entry;
1462 afs_int32 server, part;
1464 int totalOK, totalNotOK, totalBusy;
1466 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1471 /* command to forcibly remove a volume */
1473 NukeVolume(register struct cmd_syndesc *as)
1475 register afs_int32 code;
1476 afs_int32 volID, err;
1481 server = GetServer(tp = as->parms[0].items->data);
1483 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1487 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1489 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1493 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1496 PrintError("", err);
1499 "vos: could not parse '%s' as a numeric volume ID", tp);
1504 "vos: forcibly removing all traces of volume %d, please wait...",
1507 code = UV_NukeVolume(server, partID, volID);
1509 fprintf(STDOUT, "done.\n");
1511 fprintf(STDOUT, "failed with code %d.\n", code);
1516 /*------------------------------------------------------------------------
1517 * PRIVATE ExamineVolume
1520 * Routine used to examine a single volume, contacting the VLDB as
1521 * well as the Volume Server.
1524 * as : Ptr to parsed command line arguments.
1527 * 0 for a successful operation,
1528 * Otherwise, one of the ubik or VolServer error values.
1531 * Nothing interesting.
1535 *------------------------------------------------------------------------
1538 ExamineVolume(register struct cmd_syndesc *as, void *arock)
1540 struct nvldbentry entry;
1541 afs_int32 vcode = 0;
1542 volintInfo *pntr = (volintInfo *) 0;
1543 volintXInfo *xInfoP = (volintXInfo *) 0;
1545 afs_int32 code, err, error = 0;
1546 int voltype, foundserv = 0, foundentry = 0;
1547 afs_int32 aserver, apart;
1549 int wantExtendedInfo; /*Do we want extended vol info? */
1551 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1553 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1556 PrintError("", err);
1558 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1559 as->parms[0].items->data);
1564 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1565 (unsigned long)volid);
1568 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1571 "Could not fetch the entry for volume number %lu from VLDB \n",
1572 (unsigned long)volid);
1576 fprintf(STDOUT, "done\n");
1577 MapHostToNetwork(&entry);
1579 if (entry.volumeId[RWVOL] == volid)
1581 else if (entry.volumeId[BACKVOL] == volid)
1583 else /* (entry.volumeId[ROVOL] == volid) */
1586 do { /* do {...} while (voltype == ROVOL) */
1587 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1588 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1589 * If its a RO vol, get the next RO entry.
1591 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1592 &aserver, &apart, &previdx);
1593 if (previdx == -1) { /* searched all entries */
1595 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1596 as->parms[0].items->data);
1603 /* Get information about the volume from the server */
1605 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1606 hostutil_GetNameByINet(aserver));
1609 if (wantExtendedInfo)
1610 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1612 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1614 fprintf(STDOUT, "done\n");
1618 if (code == ENODEV) {
1619 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1620 /* The VLDB says there is no backup volume and its not on disk */
1621 fprintf(STDERR, "Volume %s does not exist\n",
1622 as->parms[0].items->data);
1626 "Volume does not exist on server %s as indicated by the VLDB\n",
1627 hostutil_GetNameByINet(aserver));
1630 PrintDiagnostics("examine", code);
1632 fprintf(STDOUT, "\n");
1635 if (wantExtendedInfo)
1636 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1638 #ifdef FULL_LISTVOL_SWITCH
1639 if (as->parms[2].items) {
1640 DisplayFormat2(aserver, apart, pntr);
1641 EnumerateEntry(&entry);
1643 #endif /* FULL_LISTVOL_SWITCH */
1644 VolumeStats(pntr, &entry, aserver, apart, voltype);
1646 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1647 /* The VLDB says there is no backup volume yet we found one on disk */
1648 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1649 as->parms[0].items->data);
1658 } while (voltype == ROVOL);
1661 fprintf(STDERR, "Dump only information from VLDB\n\n");
1662 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1664 PostVolumeStats(&entry);
1669 /*------------------------------------------------------------------------
1673 * Routine used to change the status of a single volume.
1676 * as : Ptr to parsed command line arguments.
1679 * 0 for a successful operation,
1680 * Otherwise, one of the ubik or VolServer error values.
1683 * Nothing interesting.
1687 *------------------------------------------------------------------------
1690 SetFields(register struct cmd_syndesc *as, void *arock)
1692 struct nvldbentry entry;
1693 afs_int32 vcode = 0;
1696 afs_int32 code, err;
1697 afs_int32 aserver, apart;
1700 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1703 PrintError("", err);
1705 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1706 as->parms[0].items->data);
1710 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1713 "Could not fetch the entry for volume number %lu from VLDB \n",
1714 (unsigned long)volid);
1717 MapHostToNetwork(&entry);
1719 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1720 if (previdx == -1) {
1721 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1722 as->parms[0].items->data);
1726 init_volintInfo(&info);
1730 if (as->parms[1].items) {
1732 code = util_GetInt32(as->parms[1].items->data, &info.maxquota);
1734 fprintf(STDERR, "invalid quota value\n");
1738 if (as->parms[2].items) {
1742 if (as->parms[3].items) {
1743 /* -clearVolUpCounter */
1746 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1749 "Could not update volume info fields for volume number %lu\n",
1750 (unsigned long)volid);
1754 /*------------------------------------------------------------------------
1758 * Brings a volume online.
1761 * as : Ptr to parsed command line arguments.
1764 * 0 for a successful operation,
1767 * Nothing interesting.
1771 *------------------------------------------------------------------------
1774 volOnline(register struct cmd_syndesc *as, void *arock)
1776 afs_int32 server, partition, volid;
1777 afs_int32 code, err = 0;
1779 server = GetServer(as->parms[0].items->data);
1781 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1782 as->parms[0].items->data);
1786 partition = volutil_GetPartitionID(as->parms[1].items->data);
1787 if (partition < 0) {
1788 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1789 as->parms[1].items->data);
1793 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1796 PrintError("", err);
1798 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1799 as->parms[0].items->data);
1803 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1806 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1813 /*------------------------------------------------------------------------
1814 * PRIVATE volOffline
1817 * Brings a volume offline.
1820 * as : Ptr to parsed command line arguments.
1823 * 0 for a successful operation,
1826 * Nothing interesting.
1830 *------------------------------------------------------------------------
1833 volOffline(register struct cmd_syndesc *as, void *arock)
1835 afs_int32 server, partition, volid;
1836 afs_int32 code, err = 0;
1837 afs_int32 transflag, sleeptime, transdone;
1839 server = GetServer(as->parms[0].items->data);
1841 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1842 as->parms[0].items->data);
1846 partition = volutil_GetPartitionID(as->parms[1].items->data);
1847 if (partition < 0) {
1848 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1849 as->parms[1].items->data);
1853 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1856 PrintError("", err);
1858 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1859 as->parms[0].items->data);
1863 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1864 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1865 transdone = (sleeptime ? 0 /*online */ : VTOutOfService);
1866 if (as->parms[4].items && !as->parms[3].items) {
1867 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1872 UV_SetVolume(server, partition, volid, transflag, transdone,
1875 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1883 CreateVolume(register struct cmd_syndesc *as, void *arock)
1887 afs_int32 volid, code;
1888 struct nvldbentry entry;
1893 tserver = GetServer(as->parms[0].items->data);
1895 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1896 as->parms[0].items->data);
1899 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1901 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1902 as->parms[1].items->data);
1905 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1907 PrintError("", code);
1910 "vos : partition %s does not exist on the server\n",
1911 as->parms[1].items->data);
1914 if (!ISNAMEVALID(as->parms[2].items->data)) {
1916 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1917 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1920 if (!VolNameOK(as->parms[2].items->data)) {
1922 "Illegal volume name %s, should not end in .readonly or .backup\n",
1923 as->parms[2].items->data);
1926 if (IsNumeric(as->parms[2].items->data)) {
1927 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1928 as->parms[2].items->data);
1931 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1933 fprintf(STDERR, "Volume %s already exists\n",
1934 as->parms[2].items->data);
1935 PrintDiagnostics("create", code);
1939 if (as->parms[3].items) {
1940 if (!IsNumeric(as->parms[3].items->data)) {
1941 fprintf(STDERR, "Initial quota %s should be numeric.\n",
1942 as->parms[3].items->data);
1946 code = util_GetInt32(as->parms[3].items->data, "a);
1948 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1954 UV_CreateVolume2(tserver, pnum, as->parms[2].items->data, quota, 0,
1957 PrintDiagnostics("create", code);
1960 MapPartIdIntoName(pnum, part);
1961 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
1962 (unsigned long)volid, part, as->parms[0].items->data);
1969 struct nvldbentry *entry;
1972 afs_int32 error, code, curserver, curpart, volid;
1974 MapHostToNetwork(entry);
1976 for (i = 0; i < entry->nServers; i++) {
1977 curserver = entry->serverNumber[i];
1978 curpart = entry->serverPartition[i];
1979 if (entry->serverFlags[i] & ITSROVOL) {
1980 volid = entry->volumeId[ROVOL];
1982 volid = entry->volumeId[RWVOL];
1984 code = UV_DeleteVolume(curserver, curpart, volid);
1992 DeleteVolume(struct cmd_syndesc *as, void *arock)
1994 afs_int32 err, code = 0;
1995 afs_int32 server = 0, partition = -1, volid;
1999 if (as->parms[0].items) {
2000 server = GetServer(as->parms[0].items->data);
2002 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2003 as->parms[0].items->data);
2008 if (as->parms[1].items) {
2009 partition = volutil_GetPartitionID(as->parms[1].items->data);
2010 if (partition < 0) {
2011 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2012 as->parms[1].items->data);
2016 /* Check for validity of the partition */
2017 if (!IsPartValid(partition, server, &code)) {
2019 PrintError("", code);
2022 "vos : partition %s does not exist on the server\n",
2023 as->parms[1].items->data);
2029 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2031 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
2032 as->parms[2].items->data);
2034 PrintError("", err);
2038 /* If the server or partition option are not complete, try to fill
2039 * them in from the VLDB entry.
2041 if ((partition == -1) || !server) {
2042 struct nvldbentry entry;
2044 code = VLDB_GetEntryByID(volid, -1, &entry);
2047 "Could not fetch the entry for volume %lu from VLDB\n",
2048 (unsigned long)volid);
2049 PrintError("", code);
2053 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
2054 || ((volid == entry.volumeId[BACKVOL])
2055 && (entry.flags & BACK_EXISTS))) {
2056 idx = Lp_GetRwIndex(&entry);
2057 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2058 || ((partition != -1)
2059 && (partition != entry.serverPartition[idx]))) {
2060 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2061 as->parms[2].items->data);
2064 } else if ((volid == entry.volumeId[ROVOL])
2065 && (entry.flags & RO_EXISTS)) {
2066 for (idx = -1, j = 0; j < entry.nServers; j++) {
2067 if (entry.serverFlags[j] != ITSROVOL)
2070 if (((server == 0) || (server == entry.serverNumber[j]))
2071 && ((partition == -1)
2072 || (partition == entry.serverPartition[j]))) {
2075 "VLDB: Volume '%s' matches more than one RO\n",
2076 as->parms[2].items->data);
2083 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2084 as->parms[2].items->data);
2088 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2089 as->parms[2].items->data);
2093 server = htonl(entry.serverNumber[idx]);
2094 partition = entry.serverPartition[idx];
2098 code = UV_DeleteVolume(server, partition, volid);
2100 PrintDiagnostics("remove", code);
2104 MapPartIdIntoName(partition, pname);
2105 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2106 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2110 #define TESTM 0 /* set for move space tests, clear for production */
2112 MoveVolume(register struct cmd_syndesc *as, void *arock)
2115 afs_int32 volid, fromserver, toserver, frompart, topart;
2116 afs_int32 flags, code, err;
2117 char fromPartName[10], toPartName[10];
2119 struct diskPartition64 partition; /* for space check */
2122 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2125 PrintError("", err);
2127 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2128 as->parms[0].items->data);
2131 fromserver = GetServer(as->parms[1].items->data);
2132 if (fromserver == 0) {
2133 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2134 as->parms[1].items->data);
2137 toserver = GetServer(as->parms[3].items->data);
2138 if (toserver == 0) {
2139 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2140 as->parms[3].items->data);
2143 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2145 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2146 as->parms[2].items->data);
2149 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2151 PrintError("", code);
2154 "vos : partition %s does not exist on the server\n",
2155 as->parms[2].items->data);
2158 topart = volutil_GetPartitionID(as->parms[4].items->data);
2160 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2161 as->parms[4].items->data);
2164 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2166 PrintError("", code);
2169 "vos : partition %s does not exist on the server\n",
2170 as->parms[4].items->data);
2175 if (as->parms[5].items) flags |= RV_NOCLONE;
2178 * check source partition for space to clone volume
2181 MapPartIdIntoName(topart, toPartName);
2182 MapPartIdIntoName(frompart, fromPartName);
2185 * check target partition for space to move volume
2188 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2190 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2194 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2197 p = (volintInfo *) 0;
2198 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2200 fprintf(STDERR, "vos:cannot access volume %lu\n",
2201 (unsigned long)volid);
2205 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2207 if (partition.free <= p->size) {
2209 "vos: no space on target partition %s to move volume %lu\n",
2210 toPartName, (unsigned long)volid);
2217 fprintf(STDOUT, "size test - don't do move\n");
2221 /* successful move still not guaranteed but shoot for it */
2224 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2226 PrintDiagnostics("move", code);
2229 MapPartIdIntoName(topart, toPartName);
2230 MapPartIdIntoName(frompart, fromPartName);
2231 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2232 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2233 as->parms[3].items->data, toPartName);
2239 CopyVolume(register struct cmd_syndesc *as, void *arock)
2241 afs_int32 volid, fromserver, toserver, frompart, topart, code, err, flags;
2242 char fromPartName[10], toPartName[10], *tovolume;
2243 struct nvldbentry entry;
2244 struct diskPartition64 partition; /* for space check */
2247 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2250 PrintError("", err);
2252 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2253 as->parms[0].items->data);
2256 fromserver = GetServer(as->parms[1].items->data);
2257 if (fromserver == 0) {
2258 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2259 as->parms[1].items->data);
2263 toserver = GetServer(as->parms[4].items->data);
2264 if (toserver == 0) {
2265 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2266 as->parms[4].items->data);
2270 tovolume = as->parms[3].items->data;
2271 if (!ISNAMEVALID(tovolume)) {
2273 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2274 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2277 if (!VolNameOK(tovolume)) {
2279 "Illegal volume name %s, should not end in .readonly or .backup\n",
2283 if (IsNumeric(tovolume)) {
2284 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2288 code = VLDB_GetEntryByName(tovolume, &entry);
2290 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2291 PrintDiagnostics("copy", code);
2295 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2297 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2298 as->parms[2].items->data);
2301 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2303 PrintError("", code);
2306 "vos : partition %s does not exist on the server\n",
2307 as->parms[2].items->data);
2311 topart = volutil_GetPartitionID(as->parms[5].items->data);
2313 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2314 as->parms[5].items->data);
2317 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2319 PrintError("", code);
2322 "vos : partition %s does not exist on the server\n",
2323 as->parms[5].items->data);
2328 if (as->parms[6].items) flags |= RV_OFFLINE;
2329 if (as->parms[7].items) flags |= RV_RDONLY;
2330 if (as->parms[8].items) flags |= RV_NOCLONE;
2332 MapPartIdIntoName(topart, toPartName);
2333 MapPartIdIntoName(frompart, fromPartName);
2336 * check target partition for space to move volume
2339 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2341 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2345 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2348 p = (volintInfo *) 0;
2349 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2351 fprintf(STDERR, "vos:cannot access volume %lu\n",
2352 (unsigned long)volid);
2356 if (partition.free <= p->size) {
2358 "vos: no space on target partition %s to copy volume %lu\n",
2359 toPartName, (unsigned long)volid);
2365 /* successful copy still not guaranteed but shoot for it */
2368 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2371 PrintDiagnostics("copy", code);
2374 MapPartIdIntoName(topart, toPartName);
2375 MapPartIdIntoName(frompart, fromPartName);
2376 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2377 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2378 tovolume, as->parms[4].items->data, toPartName);
2385 ShadowVolume(register struct cmd_syndesc *as, void *arock)
2387 afs_int32 volid, fromserver, toserver, frompart, topart, tovolid;
2388 afs_int32 code, err, flags;
2389 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2390 struct diskPartition64 partition; /* for space check */
2393 p = (volintInfo *) 0;
2394 q = (volintInfo *) 0;
2396 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2399 PrintError("", err);
2401 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2402 as->parms[0].items->data);
2405 fromserver = GetServer(as->parms[1].items->data);
2406 if (fromserver == 0) {
2407 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2408 as->parms[1].items->data);
2412 toserver = GetServer(as->parms[3].items->data);
2413 if (toserver == 0) {
2414 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2415 as->parms[3].items->data);
2419 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2421 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2422 as->parms[2].items->data);
2425 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2427 PrintError("", code);
2430 "vos : partition %s does not exist on the server\n",
2431 as->parms[2].items->data);
2435 topart = volutil_GetPartitionID(as->parms[4].items->data);
2437 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2438 as->parms[4].items->data);
2441 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2443 PrintError("", code);
2446 "vos : partition %s does not exist on the server\n",
2447 as->parms[4].items->data);
2451 if (as->parms[5].items) {
2452 tovolume = as->parms[5].items->data;
2453 if (!ISNAMEVALID(tovolume)) {
2455 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2456 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2459 if (!VolNameOK(tovolume)) {
2461 "Illegal volume name %s, should not end in .readonly or .backup\n",
2465 if (IsNumeric(tovolume)) {
2467 "Illegal volume name %s, should not be a number\n",
2472 /* use actual name of source volume */
2473 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2475 fprintf(STDERR, "vos:cannot access volume %lu\n",
2476 (unsigned long)volid);
2479 strcpy(toVolName, p->name);
2480 tovolume = toVolName;
2481 /* save p for size checks later */
2484 if (as->parms[6].items) {
2485 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2488 PrintError("", err);
2490 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2491 as->parms[6].items->data);
2497 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2500 PrintError("", err);
2502 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2511 if (as->parms[7].items) flags |= RV_OFFLINE;
2512 if (as->parms[8].items) flags |= RV_RDONLY;
2513 if (as->parms[9].items) flags |= RV_NOCLONE;
2514 if (as->parms[10].items) flags |= RV_CPINCR;
2516 MapPartIdIntoName(topart, toPartName);
2517 MapPartIdIntoName(frompart, fromPartName);
2520 * check target partition for space to move volume
2523 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2525 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2529 fprintf(STDOUT, "target partition %s free space %d\n", toPartName,
2532 /* Don't do this again if we did it above */
2534 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2536 fprintf(STDERR, "vos:cannot access volume %lu\n",
2537 (unsigned long)volid);
2542 /* OK if this fails */
2543 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2545 /* Treat existing volume size as "free" */
2547 p->size = (q->size < p->size) ? p->size - q->size : 0;
2549 if (partition.free <= p->size) {
2551 "vos: no space on target partition %s to copy volume %lu\n",
2552 toPartName, (unsigned long)volid);
2560 /* successful copy still not guaranteed but shoot for it */
2563 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2564 topart, tovolid, flags);
2566 PrintDiagnostics("shadow", code);
2569 MapPartIdIntoName(topart, toPartName);
2570 MapPartIdIntoName(frompart, fromPartName);
2571 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2572 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2573 as->parms[3].items->data, toPartName);
2580 CloneVolume(register struct cmd_syndesc *as, void *arock)
2582 afs_int32 server, part, volid, cloneid, voltype;
2583 char partName[10], *volname;
2584 afs_int32 code, err, flags;
2585 struct nvldbentry entry;
2587 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2590 PrintError("", err);
2592 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2593 as->parms[0].items->data);
2597 if (as->parms[1].items || as->parms[2].items) {
2598 if (!as->parms[1].items || !as->parms[2].items) {
2600 "Must specify both -server and -partition options\n");
2603 server = GetServer(as->parms[1].items->data);
2605 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2606 as->parms[1].items->data);
2609 part = volutil_GetPartitionID(as->parms[2].items->data);
2611 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2612 as->parms[2].items->data);
2615 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2617 PrintError("", code);
2620 "vos : partition %s does not exist on the server\n",
2621 as->parms[2].items->data);
2625 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2631 if (as->parms[3].items) {
2632 volname = as->parms[3].items->data;
2633 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2635 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2636 volname, VOLSER_OLDMAXVOLNAME - 1);
2641 * In order that you be able to make clones of RO or BK, this
2642 * check must be omitted.
2644 if (!VolNameOK(volname)) {
2646 "Illegal volume name %s, should not end in .readonly or .backup\n",
2651 if (IsNumeric(volname)) {
2653 "Illegal volume name %s, should not be a number\n",
2660 if (as->parms[4].items) {
2661 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2664 PrintError("", err);
2666 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2667 as->parms[4].items->data);
2673 if (as->parms[5].items) flags |= RV_OFFLINE;
2674 if (as->parms[6].items) flags |= RV_RDONLY;
2678 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2681 PrintDiagnostics("clone", code);
2684 MapPartIdIntoName(part, partName);
2685 fprintf(STDOUT, "Created clone for volume %s\n",
2686 as->parms[0].items->data);
2693 BackupVolume(register struct cmd_syndesc *as, void *arock)
2695 afs_int32 avolid, aserver, apart, vtype, code, err;
2696 struct nvldbentry entry;
2698 afs_int32 buvolid, buserver, bupart, butype;
2699 struct nvldbentry buentry;
2701 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2704 PrintError("", err);
2706 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2707 as->parms[0].items->data);
2710 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2714 /* verify this is a readwrite volume */
2716 if (vtype != RWVOL) {
2717 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2721 /* is there a backup volume already? */
2723 if (entry.flags & BACK_EXISTS) {
2724 /* yep, where is it? */
2726 buvolid = entry.volumeId[BACKVOL];
2727 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2732 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2735 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2741 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2742 (unsigned long)buvolid, (unsigned long)buserver);
2747 /* nope, carry on */
2749 code = UV_BackupVolume(aserver, apart, avolid);
2752 PrintDiagnostics("backup", code);
2755 fprintf(STDOUT, "Created backup volume for %s \n",
2756 as->parms[0].items->data);
2761 ReleaseVolume(register struct cmd_syndesc *as, void *arock)
2764 struct nvldbentry entry;
2765 afs_int32 avolid, aserver, apart, vtype, code, err;
2768 if (as->parms[1].items)
2770 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2773 PrintError("", err);
2775 fprintf(STDERR, "vos: can't find volume '%s'\n",
2776 as->parms[0].items->data);
2779 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2783 if (vtype != RWVOL) {
2784 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2788 if (!ISNAMEVALID(entry.name)) {
2790 "Volume name %s is too long, rename before releasing\n",
2795 code = UV_ReleaseVolume(avolid, aserver, apart, force);
2797 PrintDiagnostics("release", code);
2800 fprintf(STDOUT, "Released volume %s successfully\n",
2801 as->parms[0].items->data);
2806 DumpVolume(register struct cmd_syndesc *as, void *arock)
2808 afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i, flags;
2809 char filename[MAXPATHLEN];
2810 struct nvldbentry entry;
2812 rx_SetRxDeadTime(60 * 10);
2813 for (i = 0; i < MAXSERVERS; i++) {
2814 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2817 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2818 if (rxConn->service)
2819 rxConn->service->connDeadTime = rx_connDeadTime;
2822 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2825 PrintError("", err);
2827 fprintf(STDERR, "vos: can't find volume '%s'\n",
2828 as->parms[0].items->data);
2832 if (as->parms[3].items || as->parms[4].items) {
2833 if (!as->parms[3].items || !as->parms[4].items) {
2835 "Must specify both -server and -partition options\n");
2838 aserver = GetServer(as->parms[3].items->data);
2840 fprintf(STDERR, "Invalid server name\n");
2843 apart = volutil_GetPartitionID(as->parms[4].items->data);
2845 fprintf(STDERR, "Invalid partition name\n");
2849 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2854 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2855 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2857 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2858 as->parms[1].items->data, code);
2862 if (as->parms[2].items) {
2863 strcpy(filename, as->parms[2].items->data);
2865 strcpy(filename, "");
2868 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
2870 if (as->parms[5].items) {
2872 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2873 DumpFunction, filename, flags);
2876 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2879 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
2880 flags &= ~VOLDUMPV2_OMITDIRS;
2884 PrintDiagnostics("dump", code);
2887 if (strcmp(filename, ""))
2888 fprintf(STDERR, "Dumped volume %s in file %s\n",
2889 as->parms[0].items->data, filename);
2891 fprintf(STDERR, "Dumped volume %s in stdout \n",
2892 as->parms[0].items->data);
2906 RestoreVolume(register struct cmd_syndesc *as, void *arock)
2908 afs_int32 avolid, aparentid, aserver, apart, code, vcode, err;
2909 afs_int32 aoverwrite = ASK;
2910 afs_int32 acreation = 0, alastupdate = 0;
2911 int restoreflags, readonly = 0, offline = 0, voltype = RWVOL;
2913 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
2914 char volname[VOLSER_MAXVOLNAME + 1];
2915 struct nvldbentry entry;
2920 if (as->parms[4].items) {
2921 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2924 PrintError("", err);
2926 fprintf(STDERR, "vos: can't find volume '%s'\n",
2927 as->parms[4].items->data);
2933 if (as->parms[5].items) {
2934 if ((strcmp(as->parms[5].items->data, "a") == 0)
2935 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
2937 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
2938 || (strcmp(as->parms[5].items->data, "full") == 0)) {
2940 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
2941 || (strcmp(as->parms[5].items->data, "inc") == 0)
2942 || (strcmp(as->parms[5].items->data, "increment") == 0)
2943 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
2946 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2947 as->parms[5].items->data);
2951 if (as->parms[6].items)
2953 if (as->parms[7].items) {
2958 if (as->parms[8].items) {
2959 if ((strcmp(as->parms[8].items->data, "d") == 0)
2960 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
2961 acreation = TS_DUMP;
2962 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
2963 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
2964 acreation = TS_KEEP;
2965 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
2966 || (strcmp(as->parms[8].items->data, "new") == 0)) {
2969 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
2970 as->parms[8].items->data);
2975 if (as->parms[9].items) {
2976 if ((strcmp(as->parms[9].items->data, "d") == 0)
2977 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
2978 alastupdate = TS_DUMP;
2979 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
2980 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
2981 alastupdate = TS_KEEP;
2982 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
2983 || (strcmp(as->parms[9].items->data, "new") == 0)) {
2984 alastupdate = TS_NEW;
2986 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
2987 as->parms[9].items->data);
2992 aserver = GetServer(as->parms[0].items->data);
2994 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2995 as->parms[0].items->data);
2998 apart = volutil_GetPartitionID(as->parms[1].items->data);
3000 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3001 as->parms[1].items->data);
3004 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3006 PrintError("", code);
3009 "vos : partition %s does not exist on the server\n",
3010 as->parms[1].items->data);
3013 strcpy(avolname, as->parms[2].items->data);
3014 if (!ISNAMEVALID(avolname)) {
3016 "vos: the name of the volume %s exceeds the size limit\n",
3020 if (!VolNameOK(avolname)) {
3022 "Illegal volume name %s, should not end in .readonly or .backup\n",
3026 if (as->parms[3].items) {
3027 strcpy(afilename, as->parms[3].items->data);
3028 if (!FileExists(afilename)) {
3029 fprintf(STDERR, "Can't access file %s\n", afilename);
3033 strcpy(afilename, "");
3036 /* Check if volume exists or not */
3038 vsu_ExtractName(volname, avolname);
3039 vcode = VLDB_GetEntryByName(volname, &entry);
3040 if (vcode) { /* no volume - do a full restore */
3041 restoreflags = RV_FULLRST;
3042 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3044 "Volume does not exist; Will perform a full restore\n");
3047 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3048 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3049 restoreflags = RV_FULLRST;
3050 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3052 "%s Volume does not exist; Will perform a full restore\n",
3053 readonly ? "RO" : "RW");
3056 avolid = entry.volumeId[voltype];
3057 } else if (entry.volumeId[voltype] != 0
3058 && entry.volumeId[voltype] != avolid) {
3059 avolid = entry.volumeId[voltype];
3061 aparentid = entry.volumeId[RWVOL];
3064 else { /* volume exists - do we do a full incremental or abort */
3065 int Oserver, Opart, Otype, vol_elsewhere = 0;
3066 struct nvldbentry Oentry;
3070 avolid = entry.volumeId[voltype];
3071 } else if (entry.volumeId[voltype] != 0
3072 && entry.volumeId[voltype] != avolid) {
3073 avolid = entry.volumeId[voltype];
3075 aparentid = entry.volumeId[RWVOL];
3077 /* A file name was specified - check if volume is on another partition */
3078 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3082 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3085 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3089 if (!vcode || (Opart != apart))
3092 if (aoverwrite == ASK) {
3093 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3095 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3099 /* Ask what to do */
3100 if (vol_elsewhere) {
3102 "The volume %s %u already exists on a different server/part\n",
3103 volname, entry.volumeId[voltype]);
3105 "Do you want to do a full restore or abort? [fa](a): ");
3108 "The volume %s %u already exists in the VLDB\n",
3109 volname, entry.volumeId[voltype]);
3111 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3114 while (!(dc == EOF || dc == '\n'))
3115 dc = getchar(); /* goto end of line */
3116 if ((c == 'f') || (c == 'F'))
3118 else if ((c == 'i') || (c == 'I'))
3124 if (aoverwrite == ABORT) {
3125 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3127 } else if (aoverwrite == FULL) {
3128 restoreflags = RV_FULLRST;
3130 "Volume exists; Will delete and perform full restore\n");
3131 } else if (aoverwrite == INC) {
3133 if (vol_elsewhere) {
3135 "%s volume %lu already exists on a different server/part; not allowed\n",
3136 readonly ? "RO" : "RW", (unsigned long)avolid);
3142 restoreflags |= RV_OFFLINE;
3144 restoreflags |= RV_RDONLY;
3146 switch (acreation) {
3148 restoreflags |= RV_CRDUMP;
3151 restoreflags |= RV_CRKEEP;
3154 restoreflags |= RV_CRNEW;
3157 if (aoverwrite == FULL)
3158 restoreflags |= RV_CRNEW;
3160 restoreflags |= RV_CRKEEP;
3163 switch (alastupdate) {
3165 restoreflags |= RV_LUDUMP;
3168 restoreflags |= RV_LUKEEP;
3171 restoreflags |= RV_LUNEW;
3174 restoreflags |= RV_LUDUMP;
3176 if (as->parms[10].items) {
3177 restoreflags |= RV_NODEL;
3182 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3183 avolname, restoreflags, WriteData, afilename);
3185 PrintDiagnostics("restore", code);
3188 MapPartIdIntoName(apart, apartName);
3191 * patch typo here - originally "parms[1]", should be "parms[0]"
3194 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3195 as->parms[0].items->data, apartName);
3200 LockReleaseCmd(register struct cmd_syndesc *as, void *arock)
3202 afs_int32 avolid, code, err;
3204 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3207 PrintError("", err);
3209 fprintf(STDERR, "vos: can't find volume '%s'\n",
3210 as->parms[0].items->data);
3214 code = UV_LockRelease(avolid);
3216 PrintDiagnostics("unlock", code);
3219 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3220 as->parms[0].items->data);
3225 AddSite(register struct cmd_syndesc *as, void *arock)
3227 afs_int32 avolid, aserver, apart, code, err, valid = 0;
3228 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3230 vsu_ExtractName(avolname, as->parms[2].items->data);;
3231 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3234 PrintError("", err);
3236 fprintf(STDERR, "vos: can't find volume '%s'\n",
3237 as->parms[2].items->data);
3240 aserver = GetServer(as->parms[0].items->data);
3242 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3243 as->parms[0].items->data);
3246 apart = volutil_GetPartitionID(as->parms[1].items->data);
3248 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3249 as->parms[1].items->data);
3252 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3254 PrintError("", code);
3257 "vos : partition %s does not exist on the server\n",
3258 as->parms[1].items->data);
3261 if (as->parms[3].items) {
3264 code = UV_AddSite(aserver, apart, avolid, valid);
3266 PrintDiagnostics("addsite", code);
3269 MapPartIdIntoName(apart, apartName);
3270 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3271 as->parms[0].items->data, apartName, as->parms[2].items->data);
3276 RemoveSite(register struct cmd_syndesc *as, void *arock)
3279 afs_int32 avolid, aserver, apart, code, err;
3280 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3282 vsu_ExtractName(avolname, as->parms[2].items->data);
3283 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3286 PrintError("", err);
3288 fprintf(STDERR, "vos: can't find volume '%s'\n",
3289 as->parms[2].items->data);
3292 aserver = GetServer(as->parms[0].items->data);
3294 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3295 as->parms[0].items->data);
3298 apart = volutil_GetPartitionID(as->parms[1].items->data);
3300 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3301 as->parms[1].items->data);
3305 *skip the partition validity check, since it is possible that the partition
3306 *has since been decomissioned.
3309 if (!IsPartValid(apart,aserver,&code)){
3310 if(code) PrintError("",code);
3311 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3315 code = UV_RemoveSite(aserver, apart, avolid);
3317 PrintDiagnostics("remsite", code);
3320 MapPartIdIntoName(apart, apartName);
3321 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3322 as->parms[0].items->data, apartName, as->parms[2].items->data);
3327 ChangeLocation(register struct cmd_syndesc *as, void *arock)
3329 afs_int32 avolid, aserver, apart, code, err;
3332 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3335 PrintError("", err);
3337 fprintf(STDERR, "vos: can't find volume '%s'\n",
3338 as->parms[2].items->data);
3341 aserver = GetServer(as->parms[0].items->data);
3343 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3344 as->parms[0].items->data);
3347 apart = volutil_GetPartitionID(as->parms[1].items->data);
3349 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3350 as->parms[1].items->data);
3353 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3355 PrintError("", code);
3358 "vos : partition %s does not exist on the server\n",
3359 as->parms[1].items->data);
3362 code = UV_ChangeLocation(aserver, apart, avolid);
3364 PrintDiagnostics("addsite", code);
3367 MapPartIdIntoName(apart, apartName);
3368 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3369 as->parms[0].items->data, apartName, as->parms[2].items->data);
3374 ListPartitions(register struct cmd_syndesc *as, void *arock)
3376 afs_int32 aserver, code;
3377 struct partList dummyPartList;
3382 aserver = GetServer(as->parms[0].items->data);
3384 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3385 as->parms[0].items->data);
3390 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3392 PrintDiagnostics("listpart", code);
3396 fprintf(STDOUT, "The partitions on the server are:\n");
3397 for (i = 0; i < cnt; i++) {
3398 if (dummyPartList.partFlags[i] & PARTVALID) {
3399 memset(pname, 0, sizeof(pname));
3400 MapPartIdIntoName(dummyPartList.partId[i], pname);
3401 fprintf(STDOUT, " %10s ", pname);
3403 if ((i % 5) == 0 && (i != 0))
3404 fprintf(STDOUT, "\n");
3407 fprintf(STDOUT, "\n");
3408 fprintf(STDOUT, "Total: %d\n", total);
3414 CompareVolName(p1, p2)
3417 volintInfo *arg1, *arg2;
3419 arg1 = (volintInfo *) p1;
3420 arg2 = (volintInfo *) p2;
3421 return (strcmp(arg1->name, arg2->name));
3425 /*------------------------------------------------------------------------
3426 * PRIVATE XCompareVolName
3429 * Comparison routine for volume names coming from an extended
3433 * a_obj1P : Char ptr to first extended vol info object
3434 * a_obj1P : Char ptr to second extended vol info object
3437 * The value of strcmp() on the volume names within the passed
3438 * objects (i,e., -1, 0, or 1).
3441 * Passed to qsort() as the designated comparison routine.
3445 *------------------------------------------------------------------------*/
3448 XCompareVolName(a_obj1P, a_obj2P)
3449 char *a_obj1P, *a_obj2P;
3451 { /*XCompareVolName */
3454 (((struct volintXInfo *)(a_obj1P))->name,
3455 ((struct volintXInfo *)(a_obj2P))->name));
3457 } /*XCompareVolName */
3460 CompareVolID(p1, p2)
3463 volintInfo *arg1, *arg2;
3465 arg1 = (volintInfo *) p1;
3466 arg2 = (volintInfo *) p2;
3467 if (arg1->volid == arg2->volid)
3469 if (arg1->volid > arg2->volid)
3476 /*------------------------------------------------------------------------
3477 * PRIVATE XCompareVolID
3480 * Comparison routine for volume IDs coming from an extended
3484 * a_obj1P : Char ptr to first extended vol info object
3485 * a_obj1P : Char ptr to second extended vol info object
3488 * The value of strcmp() on the volume names within the passed
3489 * objects (i,e., -1, 0, or 1).
3492 * Passed to qsort() as the designated comparison routine.
3496 *------------------------------------------------------------------------*/
3499 XCompareVolID(a_obj1P, a_obj2P)
3500 char *a_obj1P, *a_obj2P;
3502 { /*XCompareVolID */
3504 afs_int32 id1, id2; /*Volume IDs we're comparing */
3506 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3507 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3515 } /*XCompareVolID */
3517 /*------------------------------------------------------------------------
3518 * PRIVATE ListVolumes
3521 * Routine used to list volumes, contacting the Volume Server
3522 * directly, bypassing the VLDB.
3525 * as : Ptr to parsed command line arguments.
3528 * 0 Successful operation
3531 * Nothing interesting.
3535 *------------------------------------------------------------------------*/
3538 ListVolumes(register struct cmd_syndesc *as, void *arock)
3540 afs_int32 apart, int32list, fast;
3541 afs_int32 aserver, code;
3542 volintInfo *pntr, *oldpntr;
3546 volintXInfo *xInfoP, *origxInfoP; /*Ptr to current/orig extended vol info */
3547 int wantExtendedInfo; /*Do we want extended vol info? */
3550 struct partList dummyPartList;
3558 if (as->parms[3].items)
3560 if (as->parms[4].items)
3564 if (as->parms[2].items)
3570 if (as->parms[5].items) {
3572 * We can't coexist with the fast flag.
3576 "vos: Can't use the -fast and -extended flags together\n");
3581 * We need to turn on ``long'' listings to get the full effect.
3583 wantExtendedInfo = 1;
3586 wantExtendedInfo = 0;
3587 if (as->parms[1].items) {
3588 apart = volutil_GetPartitionID(as->parms[1].items->data);
3590 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3591 as->parms[1].items->data);
3594 dummyPartList.partId[0] = apart;
3595 dummyPartList.partFlags[0] = PARTVALID;
3598 aserver = GetServer(as->parms[0].items->data);
3600 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3601 as->parms[0].items->data);
3606 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3608 PrintError("", code);
3611 "vos : partition %s does not exist on the server\n",
3612 as->parms[1].items->data);
3616 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3618 PrintDiagnostics("listvol", code);
3622 for (i = 0; i < cnt; i++) {
3623 if (dummyPartList.partFlags[i] & PARTVALID) {
3624 if (wantExtendedInfo)
3626 UV_XListVolumes(aserver, dummyPartList.partId[i], all,
3630 UV_ListVolumes(aserver, dummyPartList.partId[i], all,
3633 PrintDiagnostics("listvol", code);
3638 if (wantExtendedInfo) {
3639 origxInfoP = xInfoP;
3640 base = (char *)xInfoP;
3643 base = (char *)pntr;
3647 if (wantExtendedInfo)
3648 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
3650 qsort(base, count, sizeof(volintInfo), CompareVolName);
3652 if (wantExtendedInfo)
3653 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
3655 qsort(base, count, sizeof(volintInfo), CompareVolID);
3657 MapPartIdIntoName(dummyPartList.partId[i], pname);
3660 "Total number of volumes on server %s partition %s: %lu \n",
3661 as->parms[0].items->data, pname,
3662 (unsigned long)count);
3663 if (wantExtendedInfo) {
3664 #ifdef FULL_LISTVOL_SWITCH
3665 if (as->parms[6].items)
3666 XDisplayVolumes2(aserver, dummyPartList.partId[i], origxInfoP,
3667 count, int32list, fast, quiet);
3669 #endif /* FULL_LISTVOL_SWITCH */
3670 XDisplayVolumes(aserver, dummyPartList.partId[i], origxInfoP,
3671 count, int32list, fast, quiet);
3674 xInfoP = (volintXInfo *) 0;
3676 #ifdef FULL_LISTVOL_SWITCH
3677 if (as->parms[6].items)
3678 DisplayVolumes2(aserver, dummyPartList.partId[i], oldpntr,
3681 #endif /* FULL_LISTVOL_SWITCH */
3682 DisplayVolumes(aserver, dummyPartList.partId[i], oldpntr,
3683 count, int32list, fast, quiet);
3686 pntr = (volintInfo *) 0;
3694 SyncVldb(register struct cmd_syndesc *as, void *arock)
3696 afs_int32 pnum = 0, code; /* part name */
3702 if (as->parms[0].items) {
3703 tserver = GetServer(as->parms[0].items->data);
3705 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3706 as->parms[0].items->data);
3711 if (as->parms[1].items) {
3712 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3714 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3715 as->parms[1].items->data);
3718 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3720 PrintError("", code);
3723 "vos: partition %s does not exist on the server\n",
3724 as->parms[1].items->data);
3731 "The -partition option requires a -server option\n");
3736 if (as->parms[3].items) {
3737 flags |= 2; /* don't update */
3740 if (as->parms[2].items) {
3741 /* Synchronize an individual volume */
3742 volname = as->parms[2].items->data;
3743 code = UV_SyncVolume(tserver, pnum, volname, flags);
3747 "Without a -volume option, the -server option is required\n");
3750 code = UV_SyncVldb(tserver, pnum, flags, 0 /*unused */ );
3754 PrintDiagnostics("syncvldb", code);
3758 /* Print a summary of what we did */
3760 fprintf(STDOUT, "VLDB volume %s synchronized", volname);
3762 fprintf(STDOUT, "VLDB synchronized");
3764 fprintf(STDOUT, " with state of server %s", as->parms[0].items->data);
3767 MapPartIdIntoName(pnum, part);
3768 fprintf(STDOUT, " partition %s\n", part);
3770 fprintf(STDOUT, "\n");
3776 SyncServer(register struct cmd_syndesc *as, void *arock)
3778 afs_int32 pnum, code; /* part name */
3783 tserver = GetServer(as->parms[0].items->data);
3785 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3786 as->parms[0].items->data);
3789 if (as->parms[1].items) {
3790 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3792 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3793 as->parms[1].items->data);
3796 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3798 PrintError("", code);
3801 "vos : partition %s does not exist on the server\n",
3802 as->parms[1].items->data);
3810 if (as->parms[2].items) {
3811 flags |= 2; /* don't update */
3813 code = UV_SyncServer(tserver, pnum, flags, 0 /*unused */ );
3815 PrintDiagnostics("syncserv", code);
3819 MapPartIdIntoName(pnum, part);
3820 fprintf(STDOUT, "Server %s partition %s synchronized with VLDB\n",
3821 as->parms[0].items->data, part);
3823 fprintf(STDOUT, "Server %s synchronized with VLDB\n",
3824 as->parms[0].items->data);
3833 struct nvldbentry entry;
3836 /* The vlserver will handle names with the .readonly
3837 * and .backup extension as well as volume ids.
3839 vcode = VLDB_GetEntryByName(name, &entry);
3841 PrintError("", vcode);
3844 MapHostToNetwork(&entry);
3845 EnumerateEntry(&entry);
3847 /* Defect #3027: grubby check to handle locked volume.
3848 * If VLOP_ALLOPERS is set, the entry is locked.
3849 * Leave this routine as is, but put in correct check.
3851 if (entry.flags & VLOP_ALLOPERS)
3852 fprintf(STDOUT, " Volume is currently LOCKED \n");
3858 VolumeZap(register struct cmd_syndesc *as, void *arock)
3860 struct nvldbentry entry;
3861 afs_int32 volid, code, server, part, zapbackupid = 0, backupid = 0, err;
3863 if (as->parms[3].items) {
3864 /* force flag is on, use the other version */
3865 return NukeVolume(as);
3868 if (as->parms[4].items) {
3872 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3875 PrintError("", err);
3877 fprintf(STDERR, "vos: can't find volume '%s'\n",
3878 as->parms[2].items->data);
3881 part = volutil_GetPartitionID(as->parms[1].items->data);
3883 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3884 as->parms[1].items->data);
3887 server = GetServer(as->parms[0].items->data);
3889 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3890 as->parms[0].items->data);
3893 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
3895 PrintError("", code);
3898 "vos : partition %s does not exist on the server\n",
3899 as->parms[1].items->data);
3902 code = VLDB_GetEntryByID(volid, -1, &entry);
3904 if (volid == entry.volumeId[RWVOL])
3905 backupid = entry.volumeId[BACKVOL];
3907 "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
3908 (unsigned long)volid);
3911 volintInfo *pntr = (volintInfo *) 0;
3914 code = UV_ListOneVolume(server, part, volid, &pntr);
3916 if (volid == pntr->parentID)
3917 backupid = pntr->backupID;
3923 code = UV_VolumeZap(server, part, backupid);
3925 PrintDiagnostics("zap", code);
3928 fprintf(STDOUT, "Backup Volume %lu deleted\n",
3929 (unsigned long)backupid);
3932 code = UV_VolumeZap(server, part, volid);
3934 PrintDiagnostics("zap", code);
3937 fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
3943 VolserStatus(register struct cmd_syndesc *as, void *arock)
3945 afs_int32 server, code;
3946 transDebugInfo *pntr, *oldpntr;
3951 server = GetServer(as->parms[0].items->data);
3953 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3954 as->parms[0].items->data);
3957 code = UV_VolserStatus(server, &pntr, &count);
3959 PrintDiagnostics("status", code);
3964 fprintf(STDOUT, "No active transactions on %s\n",
3965 as->parms[0].items->data);
3967 fprintf(STDOUT, "Total transactions: %d\n", count);
3969 for (i = 0; i < count; i++) {
3970 /*print out the relevant info */
3971 fprintf(STDOUT, "--------------------------------------\n");
3972 fprintf(STDOUT, "transaction: %lu created: %s",
3973 (unsigned long)pntr->tid, vos_ctime( & pntr->time));
3974 if (pntr->returnCode) {
3975 fprintf(STDOUT, "returnCode: %lu\n",
3976 (unsigned long)pntr->returnCode);
3979 fprintf(STDOUT, "attachFlags: ");
3980 switch (pntr->iflags) {
3982 fprintf(STDOUT, "offline ");
3985 fprintf(STDOUT, "busy ");
3988 fprintf(STDOUT, "readonly ");
3991 fprintf(STDOUT, "create ");
3994 fprintf(STDOUT, "create volid ");
3997 fprintf(STDOUT, "\n");
4000 fprintf(STDOUT, "volumeStatus: ");
4001 switch (pntr->vflags) {
4002 case VTDeleteOnSalvage:
4003 fprintf(STDOUT, "deleteOnSalvage ");
4004 case VTOutOfService:
4005 fprintf(STDOUT, "outOfService ");
4007 fprintf(STDOUT, "deleted ");
4009 fprintf(STDOUT, "\n");
4012 fprintf(STDOUT, "transactionFlags: ");
4013 fprintf(STDOUT, "delete\n");
4015 MapPartIdIntoName(pntr->partition, pname);
4016 fprintf(STDOUT, "volume: %lu partition: %s procedure: %s\n",
4017 (unsigned long)pntr->volid, pname, pntr->lastProcName);
4018 if (pntr->callValid) {
4020 "packetRead: %lu lastReceiveTime: %d packetSend: %lu lastSendTime: %d\n",
4021 (unsigned long)pntr->readNext, pntr->lastReceiveTime,
4022 (unsigned long)pntr->transmitNext, pntr->lastSendTime);
4025 fprintf(STDOUT, "--------------------------------------\n");
4026 fprintf(STDOUT, "\n");
4034 RenameVolume(register struct cmd_syndesc *as, void *arock)
4036 afs_int32 code1, code2, code;
4037 struct nvldbentry entry;
4039 code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
4041 fprintf(STDERR, "vos: Could not find entry for volume %s\n",
4042 as->parms[0].items->data);
4045 code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
4046 if ((!code1) && (!code2)) { /*the newname already exists */
4047 fprintf(STDERR, "vos: volume %s already exists\n",
4048 as->parms[1].items->data);
4052 if (code1 && code2) {
4053 fprintf(STDERR, "vos: Could not find entry for volume %s or %s\n",
4054 as->parms[0].items->data, as->parms[1].items->data);
4057 if (!VolNameOK(as->parms[0].items->data)) {
4059 "Illegal volume name %s, should not end in .readonly or .backup\n",
4060 as->parms[0].items->data);
4063 if (!ISNAMEVALID(as->parms[1].items->data)) {
4065 "vos: the new volume name %s exceeds the size limit of %d\n",
4066 as->parms[1].items->data, VOLSER_OLDMAXVOLNAME - 10);
4069 if (!VolNameOK(as->parms[1].items->data)) {
4071 "Illegal volume name %s, should not end in .readonly or .backup\n",
4072 as->parms[1].items->data);
4075 if (IsNumeric(as->parms[1].items->data)) {
4076 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
4077 as->parms[1].items->data);
4080 MapHostToNetwork(&entry);
4082 UV_RenameVolume(&entry, as->parms[0].items->data,
4083 as->parms[1].items->data);
4085 PrintDiagnostics("rename", code);
4088 fprintf(STDOUT, "Renamed volume %s to %s\n", as->parms[0].items->data,
4089 as->parms[1].items->data);
4094 GetVolumeInfo(afs_int32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *voltype,
4095 struct nvldbentry *rentry)
4100 vcode = VLDB_GetEntryByID(volid, -1, rentry);
4103 "Could not fetch the entry for volume %lu from VLDB \n",
4104 (unsigned long)volid);
4105 PrintError("", vcode);
4108 MapHostToNetwork(rentry);
4109 if (volid == rentry->volumeId[ROVOL]) {
4111 for (i = 0; i < rentry->nServers; i++) {
4112 if ((index == -1) && (rentry->serverFlags[i] & ITSROVOL)
4113 && !(rentry->serverFlags[i] & RO_DONTUSE))
4118 "RO volume is not found in VLDB entry for volume %lu\n",
4119 (unsigned long)volid);
4123 *server = rentry->serverNumber[index];
4124 *part = rentry->serverPartition[index];
4128 index = Lp_GetRwIndex(rentry);
4131 "RW Volume is not found in VLDB entry for volume %lu\n",
4132 (unsigned long)volid);
4135 if (volid == rentry->volumeId[RWVOL]) {
4137 *server = rentry->serverNumber[index];
4138 *part = rentry->serverPartition[index];
4141 if (volid == rentry->volumeId[BACKVOL]) {
4143 *server = rentry->serverNumber[index];
4144 *part = rentry->serverPartition[index];
4148 "unexpected volume type for volume %lu\n",
4149 (unsigned long)volid);
4154 DeleteEntry(register struct cmd_syndesc *as, void *arock)
4159 struct VldbListByAttributes attributes;
4160 nbulkentries arrayEntries;
4161 register struct nvldbentry *vllist;
4162 struct cmd_item *itp;
4165 char prefix[VOLSER_MAXVOLNAME + 1];
4167 afs_int32 totalBack = 0, totalFail = 0, err;
4169 if (as->parms[0].items) { /* -id */
4170 if (as->parms[1].items || as->parms[2].items || as->parms[3].items) {
4172 "You cannot use -server, -partition, or -prefix with the -id argument\n");
4175 for (itp = as->parms[0].items; itp; itp = itp->next) {
4176 avolid = vsu_GetVolumeID(itp->data, cstruct, &err);
4179 PrintError("", err);
4181 fprintf(STDERR, "vos: can't find volume '%s'\n",
4185 if (as->parms[4].items) { /* -noexecute */
4186 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4191 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4193 fprintf(STDERR, "Could not delete entry for volume %s\n",
4196 "You must specify a RW volume name or ID "
4197 "(the entire VLDB entry will be deleted)\n");
4198 PrintError("", vcode);
4204 fprintf(STDOUT, "Deleted %d VLDB entries\n", totalBack);
4208 if (!as->parms[1].items && !as->parms[2].items && !as->parms[3].items) {
4209 fprintf(STDERR, "You must specify an option\n");
4213 /* Zero out search attributes */
4214 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4216 if (as->parms[1].items) { /* -prefix */
4217 strncpy(prefix, as->parms[1].items->data, VOLSER_MAXVOLNAME);
4219 if (!as->parms[2].items && !as->parms[3].items) { /* a single entry only */
4221 "You must provide -server with the -prefix argument\n");
4226 if (as->parms[2].items) { /* -server */
4228 aserver = GetServer(as->parms[2].items->data);
4230 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4231 as->parms[2].items->data);
4234 attributes.server = ntohl(aserver);
4235 attributes.Mask |= VLLIST_SERVER;
4238 if (as->parms[3].items) { /* -partition */
4239 if (!as->parms[2].items) {
4241 "You must provide -server with the -partition argument\n");
4244 apart = volutil_GetPartitionID(as->parms[3].items->data);
4246 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4247 as->parms[3].items->data);
4250 attributes.partition = apart;
4251 attributes.Mask |= VLLIST_PARTITION;
4254 /* Print status line of what we are doing */
4255 fprintf(STDOUT, "Deleting VLDB entries for ");
4256 if (as->parms[2].items) {
4257 fprintf(STDOUT, "server %s ", as->parms[2].items->data);
4259 if (as->parms[3].items) {
4261 MapPartIdIntoName(apart, pname);
4262 fprintf(STDOUT, "partition %s ", pname);
4265 fprintf(STDOUT, "which are prefixed with %s ", prefix);
4267 fprintf(STDOUT, "\n");
4270 /* Get all the VLDB entries on a server and/or partition */
4271 memset(&arrayEntries, 0, sizeof(arrayEntries));
4272 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4274 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4275 PrintError("", vcode);
4279 /* Process each entry */
4280 for (j = 0; j < nentries; j++) {
4281 vllist = &arrayEntries.nbulkentries_val[j];
4283 /* It only deletes the RW volumes */
4284 if (strncmp(vllist->name, prefix, strlen(prefix))) {
4287 "Omitting to delete %s due to prefix %s mismatch\n",
4288 vllist->name, prefix);
4295 if (as->parms[4].items) { /* -noexecute */
4296 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4302 /* Only matches the RW volume name */
4303 avolid = vllist->volumeId[RWVOL];
4304 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4306 fprintf(STDOUT, "Could not delete VDLB entry for %s\n",
4309 PrintError("", vcode);
4314 fprintf(STDOUT, "Deleted VLDB entry for %s \n", vllist->name);
4319 fprintf(STDOUT, "----------------------\n");
4321 "Total VLDB entries deleted: %lu; failed to delete: %lu\n",
4322 (unsigned long)totalBack, (unsigned long)totalFail);
4323 if (arrayEntries.nbulkentries_val)
4324 free(arrayEntries.nbulkentries_val);
4330 CompareVldbEntryByName(p1, p2)
4333 struct nvldbentry *arg1, *arg2;
4335 arg1 = (struct nvldbentry *)p1;
4336 arg2 = (struct nvldbentry *)p2;
4337 return (strcmp(arg1->name, arg2->name));
4341 static int CompareVldbEntry(p1,p2)
4344 struct nvldbentry *arg1,*arg2;
4347 char comp1[100],comp2[100];
4348 char temp1[20],temp2[20];
4350 arg1 = (struct nvldbentry *)p1;
4351 arg2 = (struct nvldbentry *)p2;
4355 for(i = 0; i < arg1->nServers; i++)
4356 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
4357 for(i = 0; i < arg2->nServers; i++)
4358 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
4359 if(pos1 == -1 || pos2 == -1){
4363 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
4364 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
4365 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
4366 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
4367 strcat(comp1,temp1);
4368 strcat(comp2,temp2);
4369 strcat(comp1,arg1->name);
4370 strcat(comp1,arg2->name);
4371 return(strcmp(comp1,comp2));
4377 ListVLDB(struct cmd_syndesc *as, void *arock)
4380 afs_int32 aserver, code;
4382 struct VldbListByAttributes attributes;
4383 nbulkentries arrayEntries;
4384 struct nvldbentry *vllist, *tarray = 0, *ttarray;
4385 afs_int32 centries, nentries = 0, tarraysize, parraysize;
4388 int quiet, sort, lock;
4389 afs_int32 thisindex, nextindex;
4394 attributes.Mask = 0;
4395 lock = (as->parms[3].items ? 1 : 0); /* -lock flag */
4396 quiet = (as->parms[4].items ? 1 : 0); /* -quit flag */
4397 sort = (as->parms[5].items ? 0 : 1); /* -nosort flag */
4399 /* If the volume name is given, Use VolumeInfoCmd to look it up
4400 * and not ListAttributes.
4402 if (as->parms[0].items) {
4405 "vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
4408 code = VolumeInfoCmd(as->parms[0].items->data);
4410 PrintError("", code);
4416 /* Server specified */
4417 if (as->parms[1].items) {
4418 aserver = GetServer(as->parms[1].items->data);
4420 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4421 as->parms[1].items->data);
4424 attributes.server = ntohl(aserver);
4425 attributes.Mask |= VLLIST_SERVER;
4428 /* Partition specified */
4429 if (as->parms[2].items) {
4430 apart = volutil_GetPartitionID(as->parms[2].items->data);
4432 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4433 as->parms[2].items->data);
4436 attributes.partition = apart;
4437 attributes.Mask |= VLLIST_PARTITION;
4441 attributes.Mask |= VLLIST_FLAG;
4442 attributes.flag = VLOP_ALLOPERS;
4445 /* Print header information */
4447 MapPartIdIntoName(apart, pname);
4448 fprintf(STDOUT, "VLDB entries for %s %s%s%s %s\n",
4449 (as->parms[1].items ? "server" : "all"),
4450 (as->parms[1].items ? as->parms[1].items->data : "servers"),
4451 (as->parms[2].items ? " partition " : ""),
4452 (as->parms[2].items ? pname : ""),
4453 (lock ? "which are locked:" : ""));
4456 for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
4457 memset(&arrayEntries, 0, sizeof(arrayEntries));
4462 VLDB_ListAttributesN2(&attributes, 0, thisindex, ¢ries,
4463 &arrayEntries, &nextindex);
4464 if (vcode == RXGEN_OPCODE) {
4465 /* Vlserver not running with ListAttributesN2. Fall back */
4467 VLDB_ListAttributes(&attributes, ¢ries, &arrayEntries);
4471 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4472 PrintError("", vcode);
4475 nentries += centries;
4477 /* We don't sort, so just print the entries now */
4479 for (j = 0; j < centries; j++) { /* process each entry */
4480 vllist = &arrayEntries.nbulkentries_val[j];
4481 MapHostToNetwork(vllist);
4482 EnumerateEntry(vllist);
4484 if (vllist->flags & VLOP_ALLOPERS)
4485 fprintf(STDOUT, " Volume is currently LOCKED \n");
4489 /* So we sort. First we must collect all the entries and keep
4492 else if (centries > 0) {
4494 /* steal away the first bulk entries array */
4495 tarray = (struct nvldbentry *)arrayEntries.nbulkentries_val;
4496 tarraysize = centries * sizeof(struct nvldbentry);
4497 arrayEntries.nbulkentries_val = 0;
4499 /* Grow the tarray to keep the extra entries */
4500 parraysize = (centries * sizeof(struct nvldbentry));
4502 (struct nvldbentry *)realloc(tarray,
4503 tarraysize + parraysize);
4506 "Could not allocate enough space for the VLDB entries\n");
4512 memcpy(((char *)tarray) + tarraysize,
4513 (char *)arrayEntries.nbulkentries_val, parraysize);
4514 tarraysize += parraysize;
4518 /* Free the bulk array */
4519 if (arrayEntries.nbulkentries_val) {
4520 free(arrayEntries.nbulkentries_val);
4521 arrayEntries.nbulkentries_val = 0;
4525 /* Here is where we now sort all the entries and print them */
4526 if (sort && (nentries > 0)) {
4527 qsort((char *)tarray, nentries, sizeof(struct nvldbentry),
4528 CompareVldbEntryByName);
4529 for (vllist = tarray, j = 0; j < nentries; j++, vllist++) {
4530 MapHostToNetwork(vllist);
4531 EnumerateEntry(vllist);
4533 if (vllist->flags & VLOP_ALLOPERS)
4534 fprintf(STDOUT, " Volume is currently LOCKED \n");
4540 fprintf(STDOUT, "\nTotal entries: %lu\n", (unsigned long)nentries);
4547 BackSys(register struct cmd_syndesc *as, void *arock)
4549 afs_int32 apart = 0, avolid;
4550 afs_int32 aserver = 0, code, aserver1, apart1;
4552 struct VldbListByAttributes attributes;
4553 nbulkentries arrayEntries;
4554 register struct nvldbentry *vllist;
4558 int seenprefix, seenxprefix, exclude, ex, exp, noaction;
4559 afs_int32 totalBack = 0;
4560 afs_int32 totalFail = 0;
4561 int previdx = -1, error, same;
4563 struct cmd_item *ti;
4567 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4568 attributes.Mask = 0;
4570 seenprefix = (as->parms[0].items ? 1 : 0);
4571 exclude = (as->parms[3].items ? 1 : 0);
4572 seenxprefix = (as->parms[4].items ? 1 : 0);
4573 noaction = (as->parms[5].items ? 1 : 0);
4575 if (as->parms[1].items) { /* -server */
4576 aserver = GetServer(as->parms[1].items->data);
4578 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4579 as->parms[1].items->data);
4582 attributes.server = ntohl(aserver);
4583 attributes.Mask |= VLLIST_SERVER;
4586 if (as->parms[2].items) { /* -partition */
4587 apart = volutil_GetPartitionID(as->parms[2].items->data);
4589 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4590 as->parms[2].items->data);
4593 attributes.partition = apart;
4594 attributes.Mask |= VLLIST_PARTITION;
4597 /* Check to make sure the prefix and xprefix expressions compile ok */
4599 for (ti = as->parms[0].items; ti; ti = ti->next) {
4600 if (strncmp(ti->data, "^", 1) == 0) {
4601 #ifdef HAVE_POSIX_REGEX
4605 code = regcomp(&re, ti->data, REG_NOSUB);
4607 regerror(code, &re, errbuf, sizeof errbuf);
4609 "Unrecognizable -prefix regular expression: '%s': %s\n",
4615 ccode = (char *)re_comp(ti->data);
4618 "Unrecognizable -prefix regular expression: '%s': %s\n",
4627 for (ti = as->parms[4].items; ti; ti = ti->next) {
4628 if (strncmp(ti->data, "^", 1) == 0) {
4629 #ifdef HAVE_POSIX_REGEX
4633 code = regcomp(&re, ti->data, REG_NOSUB);
4635 regerror(code, &re, errbuf, sizeof errbuf);
4637 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4643 ccode = (char *)re_comp(ti->data);
4646 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4655 memset(&arrayEntries, 0, sizeof(arrayEntries)); /* initialize to hint the stub to alloc space */
4656 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4658 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4659 PrintError("", vcode);
4663 if (as->parms[1].items || as->parms[2].items || verbose) {
4664 fprintf(STDOUT, "%s up volumes",
4665 (noaction ? "Would have backed" : "Backing"));
4667 if (as->parms[1].items) {
4668 fprintf(STDOUT, " on server %s", as->parms[1].items->data);
4669 } else if (as->parms[2].items) {
4670 fprintf(STDOUT, " for all servers");
4673 if (as->parms[2].items) {
4674 MapPartIdIntoName(apart, pname);
4675 fprintf(STDOUT, " partition %s", pname);
4678 if (seenprefix || (!seenprefix && seenxprefix)) {
4679 ti = (seenprefix ? as->parms[0].items : as->parms[4].items);
4680 ex = (seenprefix ? exclude : !exclude);
4681 exp = (strncmp(ti->data, "^", 1) == 0);
4682 fprintf(STDOUT, " which %smatch %s '%s'", (ex ? "do not " : ""),
4683 (exp ? "expression" : "prefix"), ti->data);
4684 for (ti = ti->next; ti; ti = ti->next) {
4685 exp = (strncmp(ti->data, "^", 1) == 0);
4686 printf(" %sor %s '%s'", (ex ? "n" : ""),
4687 (exp ? "expression" : "prefix"), ti->data);
4691 if (seenprefix && seenxprefix) {
4692 ti = as->parms[4].items;
4693 exp = (strncmp(ti->data, "^", 1) == 0);
4694 fprintf(STDOUT, " %swhich match %s '%s'",
4695 (exclude ? "adding those " : "removing those "),
4696 (exp ? "expression" : "prefix"), ti->data);
4697 for (ti = ti->next; ti; ti = ti->next) {
4698 exp = (strncmp(ti->data, "^", 1) == 0);
4699 printf(" or %s '%s'", (exp ? "expression" : "prefix"),
4703 fprintf(STDOUT, " .. ");
4705 fprintf(STDOUT, "\n");
4709 for (j = 0; j < nentries; j++) { /* process each vldb entry */
4710 vllist = &arrayEntries.nbulkentries_val[j];
4713 for (ti = as->parms[0].items; ti; ti = ti->next) {
4714 if (strncmp(ti->data, "^", 1) == 0) {
4715 #ifdef HAVE_POSIX_REGEX
4719 /* XXX -- should just do the compile once! */
4720 code = regcomp(&re, ti->data, REG_NOSUB);
4722 regerror(code, &re, errbuf, sizeof errbuf);
4724 "Error in -prefix regular expression: '%s': %s\n",
4728 match = (regexec(&re, vllist->name, 0, NULL, 0) == 0);
4731 ccode = (char *)re_comp(ti->data);
4734 "Error in -prefix regular expression: '%s': %s\n",
4738 match = (re_exec(vllist->name) == 1);
4742 (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4752 /* Without the -exclude flag: If it matches the prefix, then
4753 * check if we want to exclude any from xprefix.
4754 * With the -exclude flag: If it matches the prefix, then
4755 * check if we want to add any from xprefix.
4757 if (match && seenxprefix) {
4758 for (ti = as->parms[4].items; ti; ti = ti->next) {
4759 if (strncmp(ti->data, "^", 1) == 0) {
4760 #ifdef HAVE_POSIX_REGEX
4764 /* XXX -- should just do the compile once! */
4765 code = regcomp(&re, ti->data, REG_NOSUB);
4767 regerror(code, &re, errbuf, sizeof errbuf);
4769 "Error in -xprefix regular expression: '%s': %s\n",
4773 if (regexec(&re, vllist->name, 0, NULL, 0) == 0)
4777 ccode = (char *)re_comp(ti->data);
4780 "Error in -xprefix regular expression: '%s': %s\n",
4784 if (re_exec(vllist->name) == 1) {
4790 if (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4800 match = !match; /* -exclude will reverse the match */
4802 continue; /* Skip if no match */
4804 /* Print list of volumes to backup */
4806 fprintf(STDOUT, " %s\n", vllist->name);
4810 if (!(vllist->flags & RW_EXISTS)) {
4813 "Omitting to backup %s since RW volume does not exist \n",
4815 fprintf(STDOUT, "\n");
4821 avolid = vllist->volumeId[RWVOL];
4822 MapHostToNetwork(vllist);
4823 GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
4824 if (aserver1 == -1 || apart1 == -1) {
4825 fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n",
4831 same = VLDB_IsSameAddrs(aserver, aserver1, &error);
4834 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4840 if ((aserver && !same) || (apart && (apart != apart1))) {
4843 "Omitting to backup %s since the RW is in a different location\n",
4849 time_t now = time(0);
4850 fprintf(STDOUT, "Creating backup volume for %s on %s",
4851 vllist->name, ctime(&now));
4855 code = UV_BackupVolume(aserver1, apart1, avolid);
4857 fprintf(STDOUT, "Could not backup %s\n", vllist->name);
4863 fprintf(STDOUT, "\n");
4865 } /* process each vldb entry */
4866 fprintf(STDOUT, "done\n");
4867 fprintf(STDOUT, "Total volumes backed up: %lu; failed to backup: %lu\n",
4868 (unsigned long)totalBack, (unsigned long)totalFail);
4870 if (arrayEntries.nbulkentries_val)
4871 free(arrayEntries.nbulkentries_val);
4876 UnlockVLDB(register struct cmd_syndesc *as, void *arock)
4879 afs_int32 aserver, code;
4881 struct VldbListByAttributes attributes;
4882 nbulkentries arrayEntries;
4883 register struct nvldbentry *vllist;
4892 attributes.Mask = 0;
4894 if (as->parms[0].items) { /* server specified */
4895 aserver = GetServer(as->parms[0].items->data);
4897 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4898 as->parms[0].items->data);
4901 attributes.server = ntohl(aserver);
4902 attributes.Mask |= VLLIST_SERVER;
4904 if (as->parms[1].items) { /* partition specified */
4905 apart = volutil_GetPartitionID(as->parms[1].items->data);
4907 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4908 as->parms[1].items->data);
4911 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4913 PrintError("", code);
4916 "vos : partition %s does not exist on the server\n",
4917 as->parms[1].items->data);
4920 attributes.partition = apart;
4921 attributes.Mask |= VLLIST_PARTITION;
4923 attributes.flag = VLOP_ALLOPERS;
4924 attributes.Mask |= VLLIST_FLAG;
4925 memset(&arrayEntries, 0, sizeof(arrayEntries)); /*initialize to hint the stub to alloc space */
4926 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4928 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4929 PrintError("", vcode);
4932 for (j = 0; j < nentries; j++) { /* process each entry */
4933 vllist = &arrayEntries.nbulkentries_val[j];
4934 volid = vllist->volumeId[RWVOL];
4936 ubik_VL_ReleaseLock(cstruct, 0, volid, -1,
4937 LOCKREL_OPCODE | LOCKREL_AFSID |
4940 fprintf(STDERR, "Could not unlock entry for volume %s\n",
4942 PrintError("", vcode);
4947 MapPartIdIntoName(apart, pname);
4950 "Could not lock %lu VLDB entries of %lu locked entries\n",
4951 (unsigned long)totalE, (unsigned long)nentries);
4953 if (as->parms[0].items) {
4955 "Unlocked all the VLDB entries for volumes on server %s ",
4956 as->parms[0].items->data);
4957 if (as->parms[1].items) {
4958 MapPartIdIntoName(apart, pname);
4959 fprintf(STDOUT, "partition %s\n", pname);
4961 fprintf(STDOUT, "\n");
4963 } else if (as->parms[1].items) {
4964 MapPartIdIntoName(apart, pname);
4966 "Unlocked all the VLDB entries for volumes on partition %s on all servers\n",
4971 if (arrayEntries.nbulkentries_val)
4972 free(arrayEntries.nbulkentries_val);
4977 PrintInt64Size(afs_uint64 in)
4979 register afs_uint32 hi, lo;
4980 register char * units;
4981 static char output[16];
4983 SplitInt64(in,hi,lo);
4987 } else if (!(hi & 0xFFFFFC00)) {
4989 lo = (hi << 22) | (lo >> 10);
4990 } else if (!(hi & 0xFFF00000)) {
4992 lo = (hi << 12) | (lo >> 20);
4993 } else if (!(hi & 0xC0000000)) {
4995 lo = (hi << 2) | (lo >> 30);
5000 sprintf(output,"%u %s", lo, units);
5005 PartitionInfo(register struct cmd_syndesc *as, void *arock)
5008 afs_int32 aserver, code;
5010 struct diskPartition64 partition;
5011 struct partList dummyPartList;
5013 int printSummary=0, sumPartitions=0;
5014 afs_uint64 sumFree, sumStorage;
5017 ZeroInt64(sumStorage);
5019 aserver = GetServer(as->parms[0].items->data);
5021 fprintf(STDERR, "vos: server '%s' not found in host table\n",
5022 as->parms[0].items->data);
5025 if (as->parms[1].items) {
5026 apart = volutil_GetPartitionID(as->parms[1].items->data);
5028 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5029 as->parms[1].items->data);
5032 dummyPartList.partId[0] = apart;
5033 dummyPartList.partFlags[0] = PARTVALID;
5036 if (as->parms[2].items) {
5040 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
5042 PrintError("", code);
5045 "vos : partition %s does not exist on the server\n",
5046 as->parms[1].items->data);
5050 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
5052 PrintDiagnostics("listpart", code);
5056 for (i = 0; i < cnt; i++) {
5057 if (dummyPartList.partFlags[i] & PARTVALID) {
5058 MapPartIdIntoName(dummyPartList.partId[i], pname);
5059 code = UV_PartitionInfo64(aserver, pname, &partition);
5061 fprintf(STDERR, "Could not get information on partition %s\n",
5063 PrintError("", code);
5067 "Free space on partition %s: %lld K blocks out of total %lld\n",
5068 pname, partition.free, partition.minFree);
5070 AddUInt64(sumFree,partition.free,&sumFree);
5071 AddUInt64(sumStorage,partition.minFree,&sumStorage);
5076 "Summary: %s free out of ",
5077 PrintInt64Size(sumFree));
5079 "%s on %d partitions\n",
5080 PrintInt64Size(sumStorage),
5087 ChangeAddr(register struct cmd_syndesc *as, void *arock)
5089 afs_int32 ip1, ip2, vcode;
5092 ip1 = GetServer(as->parms[0].items->data);
5094 fprintf(STDERR, "vos: invalid host address\n");
5098 if ((as->parms[1].items && as->parms[2].items)
5099 || (!as->parms[1].items && !as->parms[2].items)) {
5101 "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
5105 if (as->parms[1].items) {
5106 ip2 = GetServer(as->parms[1].items->data);
5108 fprintf(STDERR, "vos: invalid host address\n");
5112 /* Play a trick here. If we are removing an address, ip1 will be -1
5113 * and ip2 will be the original address. This switch prevents an
5114 * older revision vlserver from removing the IP address.
5121 vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
5124 fprintf(STDERR, "Could not remove server %s from the VLDB\n",
5125 as->parms[0].items->data);
5126 if (vcode == VL_NOENT) {
5128 "vlserver does not support the remove flag or ");
5131 fprintf(STDERR, "Could not change server %s to server %s\n",
5132 as->parms[0].items->data, as->parms[1].items->data);
5134 PrintError("", vcode);
5139 fprintf(STDOUT, "Removed server %s from the VLDB\n",
5140 as->parms[0].items->data);
5142 fprintf(STDOUT, "Changed server %s to server %s\n",
5143 as->parms[0].items->data, as->parms[1].items->data);
5149 print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
5154 struct VLCallBack vlcb;
5157 ListAddrByAttributes m_attrs;
5158 afs_int32 m_nentries, *m_addrp;
5159 afs_int32 base, index;
5163 afsUUID_to_string(m_uuid, buf, sizeof(buf));
5164 printf("UUID: %s\n", buf);
5167 /* print out the list of all the server */
5168 addrp = (afs_int32 *) addrs->bulkaddrs_val;
5169 for (i = 0; i < nentries; i++, addrp++) {
5170 /* If it is a multihomed address, then we will need to
5171 * get the addresses for this multihomed server from
5172 * the vlserver and print them.
5174 if (((*addrp & 0xff000000) == 0xff000000) && ((*addrp) & 0xffff)) {
5175 /* Get the list of multihomed fileservers */
5176 base = (*addrp >> 16) & 0xff;
5177 index = (*addrp) & 0xffff;
5179 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
5180 && (index <= VL_MHSRV_PERBLK)) {
5181 m_attrs.Mask = VLADDR_INDEX;
5182 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
5184 m_addrs.bulkaddrs_val = 0;
5185 m_addrs.bulkaddrs_len = 0;
5187 ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, &m_uuid,
5188 (afs_int32 *)&vlcb, &m_nentries, &m_addrs);
5191 "vos: could not list the multi-homed server addresses\n");
5192 PrintError("", vcode);
5195 /* Print the list */
5196 m_addrp = (afs_int32 *) m_addrs.bulkaddrs_val;
5197 for (j = 0; j < m_nentries; j++, m_addrp++) {
5198 *m_addrp = htonl(*m_addrp);
5201 printf("%s ", afs_inet_ntoa_r(*m_addrp, hoststr));
5203 printf("%s ", hostutil_GetNameByINet(*m_addrp));
5207 printf("<unknown>\n");
5216 /* Otherwise, it is a non-multihomed entry and contains
5217 * the IP address of the server - print it.
5219 *addrp = htonl(*addrp);
5222 printf("%s\n", afs_inet_ntoa_r(*addrp, hoststr));
5224 printf("%s\n", hostutil_GetNameByINet(*addrp));
5235 ListAddrs(register struct cmd_syndesc *as, void *arock)
5238 afs_int32 i, printuuid = 0;
5239 struct VLCallBack vlcb;
5242 ListAddrByAttributes m_attrs;
5243 afsUUID m_uuid, askuuid;
5244 afs_int32 m_nentries;
5246 memset(&m_attrs, 0, sizeof(struct ListAddrByAttributes));
5247 m_attrs.Mask = VLADDR_INDEX;
5249 memset(&m_addrs, 0, sizeof(bulkaddrs));
5250 memset(&askuuid, 0, sizeof(afsUUID));
5251 if (as->parms[0].items) {
5253 if (afsUUID_from_string(as->parms[0].items->data, &askuuid) < 0) {
5254 fprintf(STDERR, "vos: invalid UUID '%s'\n",
5255 as->parms[0].items->data);
5258 m_attrs.Mask = VLADDR_UUID;
5259 m_attrs.uuid = askuuid;
5261 if (as->parms[1].items) {
5265 he = hostutil_GetHostByName((char *)as->parms[1].items->data);
5267 fprintf(STDERR, "vos: Can't get host info for '%s'\n",
5268 as->parms[1].items->data);
5271 memcpy(&saddr, he->h_addr, 4);
5272 m_attrs.Mask = VLADDR_IPADDR;
5273 m_attrs.ipaddr = ntohl(saddr);
5275 if (as->parms[2].items) {
5279 m_addrs.bulkaddrs_val = 0;
5280 m_addrs.bulkaddrs_len = 0;
5283 ubik_Call_New(VL_GetAddrs, cstruct, 0, 0, 0, &vlcb, &nentries,
5286 fprintf(STDERR, "vos: could not list the server addresses\n");
5287 PrintError("", vcode);
5292 m_addrs.bulkaddrs_val = 0;
5293 m_addrs.bulkaddrs_len = 0;
5299 ubik_Call_New(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
5300 &vlcb, &m_nentries, &m_addrs);
5302 if (vcode == VL_NOENT) {
5303 if (m_attrs.Mask == VLADDR_UUID) {
5304 fprintf(STDERR, "vos: no entry for UUID '%s' found in VLDB\n",
5305 as->parms[0].items->data);
5307 } else if (m_attrs.Mask == VLADDR_IPADDR) {
5308 fprintf(STDERR, "vos: no entry for host '%s' [0x%08x] found in VLDB\n",
5309 as->parms[1].items->data, m_attrs.ipaddr);
5318 if (vcode == VL_INDEXERANGE) {
5323 fprintf(STDERR, "vos: could not list the server addresses\n");
5324 PrintError("", vcode);
5328 print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid);
5331 if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
5339 LockEntry(register struct cmd_syndesc *as, void *arock)
5341 afs_int32 avolid, vcode, err;
5343 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5346 PrintError("", err);
5348 fprintf(STDERR, "vos: can't find volume '%s'\n",
5349 as->parms[0].items->data);
5352 vcode = ubik_VL_SetLock(cstruct, 0, avolid, -1, VLOP_DELETE);
5354 fprintf(STDERR, "Could not lock VLDB entry for volume %s\n",
5355 as->parms[0].items->data);
5356 PrintError("", vcode);
5359 fprintf(STDOUT, "Locked VLDB entry for volume %s\n",
5360 as->parms[0].items->data);
5365 ConvertRO(register struct cmd_syndesc *as, void *arock)
5367 afs_int32 partition = -1;
5368 afs_int32 server, volid, code, i, same;
5369 struct nvldbentry entry, storeEntry;
5372 afs_int32 rwserver = 0;
5373 afs_int32 rwpartition;
5375 afs_int32 roserver = 0;
5376 afs_int32 ropartition;
5378 struct rx_connection *aconn;
5381 server = GetServer(as->parms[0].items->data);
5383 fprintf(STDERR, "vos: host '%s' not found in host table\n",
5384 as->parms[0].items->data);
5387 partition = volutil_GetPartitionID(as->parms[1].items->data);
5388 if (partition < 0) {
5389 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5390 as->parms[1].items->data);
5393 if (!IsPartValid(partition, server, &code)) {
5395 PrintError("", code);
5398 "vos : partition %s does not exist on the server\n",
5399 as->parms[1].items->data);
5402 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &code);
5405 PrintError("", code);
5407 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
5408 as->parms[0].items->data);
5411 if (as->parms[3].items)
5414 vcode = VLDB_GetEntryByID(volid, -1, &entry);
5417 "Could not fetch the entry for volume %lu from VLDB\n",
5418 (unsigned long)volid);
5419 PrintError("convertROtoRW", code);
5423 /* use RO volid even if user specified RW or BK volid */
5425 if (volid != entry.volumeId[ROVOL])
5426 volid = entry.volumeId[ROVOL];
5428 MapHostToNetwork(&entry);
5429 for (i = 0; i < entry.nServers; i++) {
5430 if (entry.serverFlags[i] & ITSRWVOL) {
5432 rwserver = entry.serverNumber[i];
5433 rwpartition = entry.serverPartition[i];
5435 if (entry.serverFlags[i] & ITSROVOL) {
5436 same = VLDB_IsSameAddrs(server, entry.serverNumber[i], &code);
5439 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
5445 roserver = entry.serverNumber[i];
5446 ropartition = entry.serverPartition[i];
5452 fprintf(STDERR, "Warning: RO volume didn't exist in vldb!\n");
5454 if (ropartition != partition) {
5456 "Warning: RO volume should be in partition %d instead of %d (vldb)\n",
5457 ropartition, partition);
5462 "VLDB indicates that a RW volume exists already on %s in partition %s.\n",
5463 hostutil_GetNameByINet(rwserver),
5464 volutil_PartitionName(rwpartition));
5466 fprintf(STDERR, "Overwrite this VLDB entry? [y|n] (n)\n");
5468 while (!(dc == EOF || dc == '\n'))
5469 dc = getchar(); /* goto end of line */
5470 if ((c != 'y') && (c != 'Y')) {
5471 fprintf(STDERR, "aborted.\n");
5478 ubik_VL_SetLock(cstruct, 0, entry.volumeId[RWVOL], RWVOL,
5480 aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
5481 code = AFSVolConvertROtoRWvolume(aconn, partition, volid);
5484 "Converting RO volume %lu to RW volume failed with code %d\n",
5485 (unsigned long)volid, code);
5486 PrintError("convertROtoRW ", code);
5489 entry.serverFlags[roindex] = ITSRWVOL;
5490 entry.flags |= RW_EXISTS;
5491 entry.flags &= ~BACK_EXISTS;
5494 if (rwindex != entry.nServers) {
5495 entry.serverNumber[rwindex] = entry.serverNumber[entry.nServers];
5496 entry.serverPartition[rwindex] =
5497 entry.serverPartition[entry.nServers];
5498 entry.serverFlags[rwindex] = entry.serverFlags[entry.nServers];
5499 entry.serverNumber[entry.nServers] = 0;
5500 entry.serverPartition[entry.nServers] = 0;
5501 entry.serverFlags[entry.nServers] = 0;
5504 entry.flags &= ~RO_EXISTS;
5505 for (i = 0; i < entry.nServers; i++) {
5506 if (entry.serverFlags[i] & ITSROVOL) {
5507 if (!(entry.serverFlags[i] & (RO_DONTUSE | NEW_REPSITE)))
5508 entry.flags |= RO_EXISTS;
5511 MapNetworkToHost(&entry, &storeEntry);
5513 VLDB_ReplaceEntry(entry.volumeId[RWVOL], RWVOL, &storeEntry,
5514 (LOCKREL_OPCODE | LOCKREL_AFSID |
5515 LOCKREL_TIMESTAMP));
5518 "Warning: volume converted, but vldb update failed with code %d!\n",
5521 vcode = UV_LockRelease(entry.volumeId[RWVOL]);
5523 PrintDiagnostics("unlock", vcode);
5529 Sizes(register struct cmd_syndesc *as, void *arock)
5531 afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i;
5532 struct nvldbentry entry;
5533 volintSize vol_size;
5535 rx_SetRxDeadTime(60 * 10);
5536 for (i = 0; i < MAXSERVERS; i++) {
5537 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
5540 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
5541 if (rxConn->service)
5542 rxConn->service->connDeadTime = rx_connDeadTime;
5545 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5548 PrintError("", err);
5550 fprintf(STDERR, "vos: can't find volume '%s'\n",
5551 as->parms[0].items->data);
5555 if (as->parms[1].items || as->parms[2].items) {
5556 if (!as->parms[1].items || !as->parms[2].items) {
5558 "Must specify both -server and -partition options\n");
5561 aserver = GetServer(as->parms[2].items->data);
5563 fprintf(STDERR, "Invalid server name\n");
5566 apart = volutil_GetPartitionID(as->parms[1].items->data);
5568 fprintf(STDERR, "Invalid partition name\n");
5572 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
5579 if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
5580 code = ktime_DateToInt32(as->parms[4].items->data, &fromdate);
5582 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
5583 as->parms[4].items->data, code);
5588 fprintf(STDOUT, "Volume: %s\n", as->parms[0].items->data);
5590 if (as->parms[3].items) { /* do the dump estimate */
5591 #ifdef AFS_64BIT_ENV
5592 vol_size.dump_size = 0;
5594 FillInt64(vol_size.dump_size,0, 1);
5596 code = UV_GetSize(avolid, aserver, apart, fromdate, &vol_size);
5598 PrintDiagnostics("size", code);
5601 /* presumably the size info is now gathered in pntr */
5602 /* now we display it */
5604 fprintf(STDOUT, "dump_size: %llu\n", vol_size.dump_size);
5613 PrintDiagnostics(char *astring, afs_int32 acode)
5615 if (acode == EACCES) {
5617 "You are not authorized to perform the 'vos %s' command (%d)\n",
5620 fprintf(STDERR, "Error in vos %s command.\n", astring);
5621 PrintError("", acode);
5628 MyBeforeProc(struct cmd_syndesc *as, void *arock)
5630 register char *tcell;
5631 register afs_int32 code;
5632 register afs_int32 sauth;
5634 /* Initialize the ubik_client connection */
5635 rx_SetRxDeadTime(90);
5636 cstruct = (struct ubik_client *)0;
5640 if (as->parms[12].items) /* if -cell specified */
5641 tcell = as->parms[12].items->data;
5642 if (as->parms[14].items) /* -serverauth specified */
5644 if (as->parms[16].items) /* -crypt specified */
5647 vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
5648 &cstruct, UV_SetSecurity))) {
5649 fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
5650 (unsigned long)code);
5654 if (as->parms[15].items) /* -verbose flag set */
5658 if (as->parms[17].items) /* -noresolve flag set */
5668 /* this sucks but it works for now.
5673 #include "AFS_component_version_number.c"
5679 register afs_int32 code;
5681 register struct cmd_syndesc *ts;
5683 #ifdef AFS_AIX32_ENV
5685 * The following signal action for AIX is necessary so that in case of a
5686 * crash (i.e. core is generated) we can include the user's data section
5687 * in the core dump. Unfortunately, by default, only a partial core is
5688 * generated which, in many cases, isn't too useful.
5690 struct sigaction nsa;
5692 sigemptyset(&nsa.sa_mask);
5693 nsa.sa_handler = SIG_DFL;
5694 nsa.sa_flags = SA_FULLDUMP;
5695 sigaction(SIGSEGV, &nsa, NULL);
5698 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
5700 cmd_SetBeforeProc(MyBeforeProc, NULL);
5702 ts = cmd_CreateSyntax("create", CreateVolume, NULL, "create a new volume");
5703 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5704 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5705 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "volume name");
5706 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL,
5707 "initial quota (KB)");
5709 cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
5713 ts = cmd_CreateSyntax("remove", DeleteVolume, NULL, "delete a volume");
5714 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5715 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5716 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5720 ts = cmd_CreateSyntax("move", MoveVolume, NULL, "move a volume");
5721 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5722 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5723 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5724 "partition name on source");
5725 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5726 "machine name on destination");
5727 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5728 "partition name on destination");
5729 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5730 "copy live volume without cloning");
5733 ts = cmd_CreateSyntax("copy", CopyVolume, NULL, "copy a volume");
5734 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5735 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5736 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5737 "partition name on source");
5738 cmd_AddParm(ts, "-toname", CMD_SINGLE, 0, "volume name on destination");
5739 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5740 "machine name on destination");
5741 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5742 "partition name on destination");
5743 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5744 "leave new volume offline");
5745 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5746 "make new volume read-only");
5747 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5748 "copy live volume without cloning");
5751 ts = cmd_CreateSyntax("shadow", ShadowVolume, NULL,
5752 "make or update a shadow volume");
5753 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5754 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5755 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5756 "partition name on source");
5757 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5758 "machine name on destination");
5759 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5760 "partition name on destination");
5761 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5762 "volume name on destination");
5763 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5764 "volume ID on destination");
5765 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5766 "leave shadow volume offline");
5767 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5768 "make shadow volume read-only");
5769 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5770 "copy live volume without cloning");
5771 cmd_AddParm(ts, "-incremental", CMD_FLAG, CMD_OPTIONAL,
5772 "do incremental update if target exists");
5775 ts = cmd_CreateSyntax("backup", BackupVolume, NULL,
5776 "make backup of a volume");
5777 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5780 ts = cmd_CreateSyntax("clone", CloneVolume, NULL,
5781 "make clone of a volume");
5782 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5783 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5784 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5785 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5786 "volume name on destination");
5787 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5788 "volume ID on destination");
5789 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5790 "leave clone volume offline");
5791 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5792 "make clone volume read-only, not readwrite");
5795 ts = cmd_CreateSyntax("release", ReleaseVolume, NULL, "release a volume");
5796 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5797 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5798 "force a complete release");
5801 ts = cmd_CreateSyntax("dump", DumpVolume, NULL, "dump a volume");
5802 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5803 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5804 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5805 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5806 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5807 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL,
5808 "dump a clone of the volume");
5809 cmd_AddParm(ts, "-omitdirs", CMD_FLAG, CMD_OPTIONAL,
5810 "omit unchanged directories from an incremental dump");
5813 ts = cmd_CreateSyntax("restore", RestoreVolume, NULL, "restore a volume");
5814 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5815 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5816 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of volume to be restored");
5817 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5818 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
5819 cmd_AddParm(ts, "-overwrite", CMD_SINGLE, CMD_OPTIONAL,
5820 "abort | full | incremental");
5821 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5822 "leave restored volume offline");
5823 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5824 "make restored volume read-only");
5825 cmd_AddParm(ts, "-creation", CMD_SINGLE, CMD_OPTIONAL,
5826 "dump | keep | new");
5827 cmd_AddParm(ts, "-lastupdate", CMD_SINGLE, CMD_OPTIONAL,
5828 "dump | keep | new");
5829 cmd_AddParm(ts, "-nodelete", CMD_FLAG, CMD_OPTIONAL,
5830 "do not delete old site when restoring to a new site");
5833 ts = cmd_CreateSyntax("unlock", LockReleaseCmd, NULL,
5834 "release lock on VLDB entry for a volume");
5835 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5838 ts = cmd_CreateSyntax("changeloc", ChangeLocation, NULL,
5839 "change an RW volume's location in the VLDB");
5840 cmd_AddParm(ts, "-server", CMD_SINGLE, 0,
5841 "machine name for new location");
5842 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5843 "partition name for new location");
5844 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5847 ts = cmd_CreateSyntax("addsite", AddSite, NULL, "add a replication site");
5848 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new site");
5849 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5850 "partition name for new site");
5851 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5852 cmd_AddParm(ts, "-valid", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE, "publish as an up-to-date site in VLDB");
5855 ts = cmd_CreateSyntax("remsite", RemoveSite, NULL,
5856 "remove a replication site");
5857 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5858 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5859 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5862 ts = cmd_CreateSyntax("listpart", ListPartitions, NULL, "list partitions");
5863 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5866 ts = cmd_CreateSyntax("listvol", ListVolumes, NULL,
5867 "list volumes on server (bypass VLDB)");
5868 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5869 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5870 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "minimal listing");
5871 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
5872 "list all normal volume fields");
5873 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5874 "generate minimal information");
5875 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5876 "list extended volume fields");
5877 #ifdef FULL_LISTVOL_SWITCH
5878 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5879 "machine readable format");
5880 #endif /* FULL_LISTVOL_SWITCH */
5883 ts = cmd_CreateSyntax("syncvldb", SyncVldb, NULL,
5884 "synchronize VLDB with server");
5885 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5886 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5887 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5888 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5891 ts = cmd_CreateSyntax("syncserv", SyncServer, NULL,
5892 "synchronize server with VLDB");
5893 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5894 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5895 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5898 ts = cmd_CreateSyntax("examine", ExamineVolume, NULL,
5899 "everything about the volume");
5900 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5901 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5902 "list extended volume fields");
5903 #ifdef FULL_LISTVOL_SWITCH
5904 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5905 "machine readable format");
5906 #endif /* FULL_LISTVOL_SWITCH */
5908 cmd_CreateAlias(ts, "volinfo");
5910 ts = cmd_CreateSyntax("setfields", SetFields, NULL,
5911 "change volume info fields");
5912 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5913 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "quota (KB)");
5914 cmd_AddParm(ts, "-clearuse", CMD_FLAG, CMD_OPTIONAL, "clear dayUse");
5915 cmd_AddParm(ts, "-clearVolUpCounter", CMD_FLAG, CMD_OPTIONAL, "clear volUpdateCounter");
5918 ts = cmd_CreateSyntax("offline", volOffline, NULL, (char *)CMD_HIDDEN);
5919 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5920 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5921 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5922 cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds to sleep");
5923 cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "busy volume");
5926 ts = cmd_CreateSyntax("online", volOnline, NULL, (char *)CMD_HIDDEN);
5927 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5928 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5929 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5932 ts = cmd_CreateSyntax("zap", VolumeZap, NULL,
5933 "delete the volume, don't bother with VLDB");
5934 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5935 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5936 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume ID");
5937 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5938 "force deletion of bad volumes");
5939 cmd_AddParm(ts, "-backup", CMD_FLAG, CMD_OPTIONAL,
5940 "also delete backup volume if one is found");
5943 ts = cmd_CreateSyntax("status", VolserStatus, NULL,
5944 "report on volser status");
5945 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5948 ts = cmd_CreateSyntax("rename", RenameVolume, NULL, "rename a volume");
5949 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old volume name ");
5950 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new volume name ");
5953 ts = cmd_CreateSyntax("listvldb", ListVLDB, NULL,
5954 "list volumes in the VLDB");
5955 cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5956 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5957 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5958 cmd_AddParm(ts, "-locked", CMD_FLAG, CMD_OPTIONAL, "locked volumes only");
5959 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5960 "generate minimal information");
5961 cmd_AddParm(ts, "-nosort", CMD_FLAG, CMD_OPTIONAL,
5962 "do not alphabetically sort the volume names");
5965 ts = cmd_CreateSyntax("backupsys", BackSys, NULL, "en masse backups");
5966 cmd_AddParm(ts, "-prefix", CMD_LIST, CMD_OPTIONAL,
5967 "common prefix on volume(s)");
5968 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5969 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5970 cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL,
5971 "exclude common prefix volumes");
5972 cmd_AddParm(ts, "-xprefix", CMD_LIST, CMD_OPTIONAL,
5973 "negative prefix on volume(s)");
5974 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "no action");
5977 ts = cmd_CreateSyntax("delentry", DeleteEntry, NULL,
5978 "delete VLDB entry for a volume");
5979 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "volume name or ID");
5980 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL,
5981 "prefix of the volume whose VLDB entry is to be deleted");
5982 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5983 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5984 cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE,
5988 ts = cmd_CreateSyntax("partinfo", PartitionInfo, NULL,
5989 "list partition information");
5990 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5991 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5992 cmd_AddParm(ts, "-summary", CMD_FLAG, CMD_OPTIONAL,
5993 "print storage summary");
5996 ts = cmd_CreateSyntax("unlockvldb", UnlockVLDB, NULL,
5997 "unlock all the locked entries in the VLDB");
5998 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5999 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6002 ts = cmd_CreateSyntax("lock", LockEntry, NULL,
6003 "lock VLDB entry for a volume");
6004 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6007 ts = cmd_CreateSyntax("changeaddr", ChangeAddr, NULL,
6008 "change the IP address of a file server");
6009 cmd_AddParm(ts, "-oldaddr", CMD_SINGLE, 0, "original IP address");
6010 cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
6011 cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL,
6012 "remove the IP address from the VLDB");
6015 ts = cmd_CreateSyntax("listaddrs", ListAddrs, NULL,
6016 "list the IP address of all file servers registered in the VLDB");
6017 cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
6018 cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
6019 cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
6020 "print uuid of hosts");
6023 ts = cmd_CreateSyntax("convertROtoRW", ConvertRO, NULL,
6024 "convert a RO volume into a RW volume (after loss of old RW volume)");
6025 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6026 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
6027 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6028 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "don't ask");
6031 ts = cmd_CreateSyntax("size", Sizes, NULL,
6032 "obtain various sizes of the volume.");
6033 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6034 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6035 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6036 cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL,
6037 "Obtain the size of the dump");
6038 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
6041 code = cmd_Dispatch(argc, argv);
6043 /* Shut down the ubik_client and rx connections */
6045 (void)ubik_ClientDestroy(cstruct);
6051 exit((code ? -1 : 0));