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>
14 #include <sys/types.h>
24 #include <netinet/in.h>
25 #include <arpa/inet.h>
29 #include <sys/statfs.h>
37 #include <rx/rx_globals.h>
39 #include <afs/vlserver.h>
40 #include <afs/cellconfig.h>
42 #include <afs/afsutil.h>
44 #include <afs/afsint.h>
49 #include <afs/ihandle.h>
50 #include <afs/vnode.h>
51 #include <afs/volume.h>
58 #include "volser_prototypes.h"
59 #include "vsutils_prototypes.h"
60 #include "lockprocs_prototypes.h"
62 #ifdef HAVE_POSIX_REGEX
66 /* Local Prototypes */
67 int PrintDiagnostics(char *astring, afs_int32 acode);
68 int GetVolumeInfo(afs_uint32 volid, afs_int32 *server, afs_int32 *part,
69 afs_int32 *voltype, struct nvldbentry *rentry);
81 #define COMMONPARMS cmd_Seek(ts, 12);\
82 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
83 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");\
84 cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
85 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
86 cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
87 cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL, "don't resolve addresses"); \
89 #define ERROR_EXIT(code) {error=(code); goto error_exit;}
92 struct rx_connection *tconn;
94 extern struct ubik_client *cstruct;
97 static struct tqHead busyHead, notokHead;
100 qInit(struct tqHead *ahead)
102 memset((char *)ahead, 0, sizeof(struct tqHead));
108 qPut(struct tqHead *ahead, afs_uint32 volid)
112 elem = (struct tqElem *)malloc(sizeof(struct tqElem));
113 elem->next = ahead->next;
121 qGet(struct tqHead *ahead, afs_uint32 *volid)
125 if (ahead->count <= 0)
127 *volid = ahead->next->volid;
129 ahead->next = tmp->next;
135 /* returns 1 if <filename> exists else 0 */
137 FileExists(char *filename)
143 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
147 code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
155 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
157 VolNameOK(char *name)
162 total = strlen(name);
163 if (!strcmp(&name[total - 9], ".readonly")) {
165 } else if (!strcmp(&name[total - 7], ".backup")) {
172 /* return 1 if name is a number else 0 */
174 IsNumeric(char *name)
182 for (i = 0; i < len; i++) {
183 if (*ptr < '0' || *ptr > '9') {
195 * Parse a server name/address and return the address in HOST BYTE order
198 GetServer(char *aname)
200 register struct hostent *th;
203 register afs_int32 code;
204 char hostname[MAXHOSTCHARS];
206 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
208 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
209 addr = ntohl(addr); /* convert to host order */
211 th = gethostbyname(aname);
214 memcpy(&addr, th->h_addr, sizeof(addr));
217 if (addr == htonl(0x7f000001)) { /* local host */
218 code = gethostname(hostname, MAXHOSTCHARS);
221 th = gethostbyname(hostname); /* returns host byte order */
224 memcpy(&addr, th->h_addr, sizeof(addr));
231 GetVolumeType(char *aname)
234 if (!strcmp(aname, "ro"))
236 else if (!strcmp(aname, "rw"))
238 else if (!strcmp(aname, "bk"))
245 IsPartValid(afs_int32 partId, afs_int32 server, afs_int32 *code)
247 struct partList dummyPartList;
253 *code = UV_ListPartitions(server, &dummyPartList, &cnt);
256 for (i = 0; i < cnt; i++) {
257 if (dummyPartList.partFlags[i] & PARTVALID)
258 if (dummyPartList.partId[i] == partId)
266 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
267 * associated with <call> */
269 SendFile(usd_handle_t ufd, register struct rx_call *call, long blksize)
271 char *buffer = (char *)0;
276 buffer = (char *)malloc(blksize);
278 fprintf(STDERR, "malloc failed\n");
282 while (!error && !done) {
283 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
286 FD_SET((int)(ufd->handle), &in);
287 /* don't timeout if read blocks */
288 #if defined(AFS_PTHREAD_ENV)
289 select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
291 IOMGR_Select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
294 error = USD_READ(ufd, buffer, blksize, &nbytes);
296 fprintf(STDERR, "File system read failed\n");
303 if (rx_Write(call, buffer, nbytes) != nbytes) {
313 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
314 * writes it out to the volume. */
316 WriteData(struct rx_call *call, void *rock)
318 char *filename = (char *) rock;
321 afs_int32 error, code;
323 afs_hyper_t filesize, currOffset;
329 if (!filename || !*filename) {
330 usd_StandardInput(&ufd);
334 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
337 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
340 fprintf(STDERR, "Could not access file '%s'\n", filename);
344 /* test if we have a valid dump */
345 hset64(filesize, 0, 0);
346 USD_SEEK(ufd, filesize, SEEK_END, &currOffset);
347 hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32));
348 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
349 USD_READ(ufd, (char *)&buffer, sizeof(afs_uint32), &got);
350 if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
351 fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
355 /* rewind, we are done */
356 hset64(filesize, 0, 0);
357 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
359 code = SendFile(ufd, call, blksize);
366 code = USD_CLOSE(ufd);
368 fprintf(STDERR, "Could not close dump file %s\n",
369 (filename && *filename) ? filename : "STDOUT");
377 /* Receive data from <call> stream into file associated
378 * with <fd> <blksize>
381 ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize)
385 afs_uint32 bytesleft, w;
388 buffer = (char *)malloc(blksize);
390 fprintf(STDERR, "memory allocation failed\n");
394 while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {
395 for (bytesleft = bytesread; bytesleft; bytesleft -= w) {
396 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
399 FD_SET((int)(ufd->handle), &out);
400 /* don't timeout if write blocks */
401 #if defined(AFS_PTHREAD_ENV)
402 select(((int)(ufd->handle)) + 1, &out, 0, 0, 0);
404 IOMGR_Select(((int)(ufd->handle)) + 1, 0, &out, 0, 0);
408 USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
410 fprintf(STDERR, "File system write failed\n");
423 DumpFunction(struct rx_call *call, void *rock)
425 char *filename = (char *)rock;
426 usd_handle_t ufd; /* default is to stdout */
427 afs_int32 error = 0, code;
432 /* Open the output file */
433 if (!filename || !*filename) {
434 usd_StandardOutput(&ufd);
439 usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
443 code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
446 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
449 fprintf(STDERR, "Could not create file '%s'\n", filename);
450 ERROR_EXIT(VOLSERBADOP);
454 code = ReceiveFile(ufd, call, blksize);
459 /* Close the output file */
461 code = USD_CLOSE(ufd);
463 fprintf(STDERR, "Could not close dump file %s\n",
464 (filename && *filename) ? filename : "STDIN");
474 DisplayFormat(volintInfo *pntr, afs_int32 server, afs_int32 part,
475 int *totalOK, int *totalNotOK, int *totalBusy, int fast,
476 int longlist, int disp)
482 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
483 } else if (longlist) {
484 if (pntr->status == VOK) {
485 fprintf(STDOUT, "%-32s ", pntr->name);
486 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
488 fprintf(STDOUT, "RW ");
490 fprintf(STDOUT, "RO ");
492 fprintf(STDOUT, "BK ");
493 fprintf(STDOUT, "%10d K ", pntr->size);
494 if (pntr->inUse == 1) {
495 fprintf(STDOUT, "On-line");
498 fprintf(STDOUT, "Off-line");
501 if (pntr->needsSalvaged == 1)
502 fprintf(STDOUT, "**needs salvage**");
503 fprintf(STDOUT, "\n");
504 MapPartIdIntoName(part, pname);
505 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
507 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
508 (unsigned long)pntr->parentID,
509 (unsigned long)pntr->cloneID,
510 (unsigned long)pntr->backupID);
511 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
512 t = pntr->creationDate;
513 fprintf(STDOUT, " Creation %s",
515 #ifdef FULL_LISTVOL_SWITCH
517 fprintf(STDOUT, " Copy %s",
520 t = pntr->backupDate;
522 fprintf(STDOUT, " Backup Never\n");
524 fprintf(STDOUT, " Backup %s",
527 t = pntr->accessDate;
529 fprintf(STDOUT, " Last Access %s",
532 t = pntr->updateDate;
534 fprintf(STDOUT, " Last Update Never\n");
536 fprintf(STDOUT, " Last Update %s",
539 " %d accesses in the past day (i.e., vnode references)\n",
541 } else if (pntr->status == VBUSY) {
543 qPut(&busyHead, pntr->volid);
545 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
546 (unsigned long)pntr->volid);
549 qPut(¬okHead, pntr->volid);
551 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
552 (unsigned long)pntr->volid);
554 fprintf(STDOUT, "\n");
555 } else { /* default listing */
556 if (pntr->status == VOK) {
557 fprintf(STDOUT, "%-32s ", pntr->name);
558 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
560 fprintf(STDOUT, "RW ");
562 fprintf(STDOUT, "RO ");
564 fprintf(STDOUT, "BK ");
565 fprintf(STDOUT, "%10d K ", pntr->size);
566 if (pntr->inUse == 1) {
567 fprintf(STDOUT, "On-line");
570 fprintf(STDOUT, "Off-line");
573 if (pntr->needsSalvaged == 1)
574 fprintf(STDOUT, "**needs salvage**");
575 fprintf(STDOUT, "\n");
576 } else if (pntr->status == VBUSY) {
578 qPut(&busyHead, pntr->volid);
580 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
581 (unsigned long)pntr->volid);
584 qPut(¬okHead, pntr->volid);
586 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
587 (unsigned long)pntr->volid);
592 /*------------------------------------------------------------------------
593 * PRIVATE XDisplayFormat
596 * Display the contents of one extended volume info structure.
599 * a_xInfoP : Ptr to extended volume info struct to print.
600 * a_servID : Server ID to print.
601 * a_partID : Partition ID to print.
602 * a_totalOKP : Ptr to total-OK counter.
603 * a_totalNotOKP : Ptr to total-screwed counter.
604 * a_totalBusyP : Ptr to total-busy counter.
605 * a_fast : Fast listing?
606 * a_int32 : Int32 listing?
607 * a_showProblems : Show volume problems?
613 * Nothing interesting.
617 *------------------------------------------------------------------------*/
620 XDisplayFormat(volintXInfo *a_xInfoP, afs_int32 a_servID, afs_int32 a_partID,
621 int *a_totalOKP, int *a_totalNotOKP, int *a_totalBusyP,
622 int a_fast, int a_int32, int a_showProblems)
623 { /*XDisplayFormat */
631 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
632 } else if (a_int32) {
634 * Fully-detailed listing.
636 if (a_xInfoP->status == VOK) {
638 * Volume's status is OK - all the fields are valid.
640 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
641 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
642 if (a_xInfoP->type == 0)
643 fprintf(STDOUT, "RW ");
644 if (a_xInfoP->type == 1)
645 fprintf(STDOUT, "RO ");
646 if (a_xInfoP->type == 2)
647 fprintf(STDOUT, "BK ");
648 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
649 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
650 if (a_xInfoP->inUse == 1) {
651 fprintf(STDOUT, "On-line");
654 fprintf(STDOUT, "Off-line");
657 fprintf(STDOUT, "\n");
658 MapPartIdIntoName(a_partID, pname);
659 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
661 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
662 (unsigned long)a_xInfoP->parentID,
663 (unsigned long)a_xInfoP->cloneID,
664 (unsigned long)a_xInfoP->backupID);
665 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
667 t = a_xInfoP->creationDate;
668 fprintf(STDOUT, " Creation %s",
670 #ifdef FULL_LISTVOL_SWITCH
671 t = a_xInfoP->copyDate;
672 fprintf(STDOUT, " Copy %s",
675 t = a_xInfoP->backupDate;
677 fprintf(STDOUT, " Backup Never\n");
679 fprintf(STDOUT, " Backup %s",
682 t = a_xInfoP->accessDate;
684 fprintf(STDOUT, " Last Access %s",
687 t = a_xInfoP->updateDate;
689 fprintf(STDOUT, " Last Update Never\n");
691 fprintf(STDOUT, " Last Update %s",
694 " %d accesses in the past day (i.e., vnode references)\n",
698 * Print all the read/write and authorship stats.
700 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
702 " |-------------------------------------------|\n");
704 " | Same Network | Diff Network |\n");
706 " |----------|----------|----------|----------|\n");
708 " | Total | Auth | Total | Auth |\n");
710 " |----------|----------|----------|----------|\n");
711 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
712 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
713 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
714 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
715 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
716 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
717 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
718 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
719 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
720 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
722 " |-------------------------------------------|\n\n");
725 " Writes Affecting Authorship\n");
727 " |-------------------------------------------|\n");
729 " | File Authorship | Directory Authorship|\n");
731 " |----------|----------|----------|----------|\n");
733 " | Same | Diff | Same | Diff |\n");
735 " |----------|----------|----------|----------|\n");
736 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
737 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
738 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
739 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
740 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
741 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
742 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
743 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
744 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
745 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
746 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
747 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
748 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
749 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
750 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
751 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
752 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
753 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
754 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
755 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
756 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
757 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
758 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
759 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
760 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
761 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
762 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
763 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
764 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
765 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
767 " |-------------------------------------------|\n");
768 } /*Volume status OK */
769 else if (a_xInfoP->status == VBUSY) {
771 qPut(&busyHead, a_xInfoP->volid);
773 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
774 (unsigned long)a_xInfoP->volid);
778 qPut(¬okHead, a_xInfoP->volid);
780 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
781 (unsigned long)a_xInfoP->volid);
782 } /*Screwed volume */
783 fprintf(STDOUT, "\n");
789 if (a_xInfoP->status == VOK) {
790 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
791 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
792 if (a_xInfoP->type == 0)
793 fprintf(STDOUT, "RW ");
794 if (a_xInfoP->type == 1)
795 fprintf(STDOUT, "RO ");
796 if (a_xInfoP->type == 2)
797 fprintf(STDOUT, "BK ");
798 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
799 if (a_xInfoP->inUse == 1) {
800 fprintf(STDOUT, "On-line");
803 fprintf(STDOUT, "Off-line");
806 fprintf(STDOUT, "\n");
808 else if (a_xInfoP->status == VBUSY) {
810 qPut(&busyHead, a_xInfoP->volid);
812 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
813 (unsigned long)a_xInfoP->volid);
817 qPut(¬okHead, a_xInfoP->volid);
819 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
820 (unsigned long)a_xInfoP->volid);
821 } /*Screwed volume */
822 } /*Default listing */
823 } /*XDisplayFormat */
825 #ifdef FULL_LISTVOL_SWITCH
826 /*------------------------------------------------------------------------
827 * PRIVATE XDisplayFormat2
830 * Display the formated contents of one extended volume info structure.
833 * a_xInfoP : Ptr to extended volume info struct to print.
834 * a_servID : Server ID to print.
835 * a_partID : Partition ID to print.
836 * a_totalOKP : Ptr to total-OK counter.
837 * a_totalNotOKP : Ptr to total-screwed counter.
838 * a_totalBusyP : Ptr to total-busy counter.
839 * a_fast : Fast listing?
840 * a_int32 : Int32 listing?
841 * a_showProblems : Show volume problems?
847 * Nothing interesting.
851 *------------------------------------------------------------------------*/
854 XDisplayFormat2(volintXInfo *a_xInfoP, afs_int32 a_servID, afs_int32 a_partID,
855 int *a_totalOKP, int *a_totalNotOKP, int *a_totalBusyP,
856 int a_fast, int a_int32, int a_showProblems)
857 { /*XDisplayFormat */
863 fprintf(STDOUT, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP->volid);
864 } else if (a_int32) {
866 * Fully-detailed listing.
868 if (a_xInfoP->status == VOK) {
870 * Volume's status is OK - all the fields are valid.
873 static long server_cache = -1, partition_cache = -1;
874 static char hostname[256], address[32], pname[16];
875 int i,ai[] = {VOLINT_STATS_TIME_IDX_0,VOLINT_STATS_TIME_IDX_1,VOLINT_STATS_TIME_IDX_2,
876 VOLINT_STATS_TIME_IDX_3,VOLINT_STATS_TIME_IDX_4,VOLINT_STATS_TIME_IDX_5};
878 if (a_servID != server_cache) {
882 strcpy(hostname, hostutil_GetNameByINet(a_servID));
883 strcpy(address, inet_ntoa(s));
884 server_cache = a_servID;
886 if (a_partID != partition_cache) {
887 MapPartIdIntoName(a_partID, pname);
888 partition_cache = a_partID;
891 fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name);
892 fprintf(STDOUT, "id\t\t%lu\n", afs_printable_uint32_lu(a_xInfoP->volid));
893 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
894 fprintf(STDOUT, "part\t\t%s\n", pname);
895 fprintf(STDOUT, "status\t\tOK\n");
896 fprintf(STDOUT, "backupID\t%lu\n",
897 afs_printable_uint32_lu(a_xInfoP->backupID));
898 fprintf(STDOUT, "parentID\t%lu\n",
899 afs_printable_uint32_lu(a_xInfoP->parentID));
900 fprintf(STDOUT, "cloneID\t\t%lu\n",
901 afs_printable_uint32_lu(a_xInfoP->cloneID));
902 fprintf(STDOUT, "inUse\t\t%s\n", a_xInfoP->inUse ? "Y" : "N");
903 switch (a_xInfoP->type) {
905 fprintf(STDOUT, "type\t\tRW\n");
908 fprintf(STDOUT, "type\t\tRO\n");
911 fprintf(STDOUT, "type\t\tBK\n");
914 fprintf(STDOUT, "type\t\t?\n");
917 t = a_xInfoP->creationDate;
918 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
919 afs_printable_uint32_lu(a_xInfoP->creationDate),
922 t = a_xInfoP->accessDate;
923 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
924 afs_printable_uint32_lu(a_xInfoP->accessDate),
927 t = a_xInfoP->updateDate;
928 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
929 afs_printable_uint32_lu(a_xInfoP->updateDate),
932 t = a_xInfoP->backupDate;
933 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
934 afs_printable_uint32_lu(a_xInfoP->backupDate),
937 t = a_xInfoP->copyDate;
938 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
939 afs_printable_uint32_lu(a_xInfoP->copyDate),
942 fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
943 fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
945 fprintf(STDOUT, "filecount\t%u\n", a_xInfoP->filecount);
946 fprintf(STDOUT, "dayUse\t\t%u\n", a_xInfoP->dayUse);
950 fprintf(STDOUT,"reads_same_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]);
951 fprintf(STDOUT,"reads_same_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]);
952 fprintf(STDOUT,"reads_diff_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]);
953 fprintf(STDOUT,"reads_diff_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
955 fprintf(STDOUT,"writes_same_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]);
956 fprintf(STDOUT,"writes_same_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]);
957 fprintf(STDOUT,"writes_diff_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]);
958 fprintf(STDOUT,"writes_diff_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
962 fprintf(STDOUT,"file_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileSameAuthor[ai[i]]);
963 fprintf(STDOUT,"file_diff_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileDiffAuthor[ai[i]]);
964 fprintf(STDOUT,"dir_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirSameAuthor[ai[i]]);
965 fprintf(STDOUT,"dir_dif_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirDiffAuthor[ai[i]]);
968 } /*Volume status OK */
969 else if (a_xInfoP->status == VBUSY) {
971 qPut(&busyHead, a_xInfoP->volid);
973 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
974 (unsigned long)a_xInfoP->volid);
978 qPut(¬okHead, a_xInfoP->volid);
980 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
981 (unsigned long)a_xInfoP->volid);
982 } /*Screwed volume */
988 if (a_xInfoP->status == VOK) {
989 fprintf(STDOUT, "name\t%-32s\n", a_xInfoP->name);
990 fprintf(STDOUT, "volID\t%10lu\n", (unsigned long)a_xInfoP->volid);
991 if (a_xInfoP->type == 0)
992 fprintf(STDOUT, "type\tRW\n");
993 if (a_xInfoP->type == 1)
994 fprintf(STDOUT, "type\tRO\n");
995 if (a_xInfoP->type == 2)
996 fprintf(STDOUT, "type\tBK\n");
997 fprintf(STDOUT, "size\t%10dK\n", a_xInfoP->size);
999 fprintf(STDOUT, "inUse\t%d\n",a_xInfoP->inUse);
1000 if (a_xInfoP->inUse == 1)
1006 else if (a_xInfoP->status == VBUSY) {
1008 qPut(&busyHead, a_xInfoP->volid);
1010 fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
1011 (unsigned long)a_xInfoP->volid);
1015 qPut(¬okHead, a_xInfoP->volid);
1017 fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
1018 (unsigned long)a_xInfoP->volid);
1019 } /*Screwed volume */
1020 } /*Default listing */
1021 } /*XDisplayFormat */
1022 #endif /*FULL_LISTVOL_SWITCH*/
1024 #ifdef FULL_LISTVOL_SWITCH
1026 DisplayFormat2(long server, long partition, volintInfo *pntr)
1028 static long server_cache = -1, partition_cache = -1;
1029 static char hostname[256], address[32], pname[16];
1032 if (server != server_cache) {
1036 strcpy(hostname, hostutil_GetNameByINet(server));
1037 strcpy(address, inet_ntoa(s));
1038 server_cache = server;
1040 if (partition != partition_cache) {
1041 MapPartIdIntoName(partition, pname);
1042 partition_cache = partition;
1045 if (pntr->status == VOK)
1046 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
1048 fprintf(STDOUT, "id\t\t%lu\n",
1049 afs_printable_uint32_lu(pntr->volid));
1050 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
1051 fprintf(STDOUT, "part\t\t%s\n", pname);
1052 switch (pntr->status) {
1054 fprintf(STDOUT, "status\t\tOK\n");
1057 fprintf(STDOUT, "status\t\tBUSY\n");
1060 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
1063 fprintf(STDOUT, "backupID\t%lu\n",
1064 afs_printable_uint32_lu(pntr->backupID));
1065 fprintf(STDOUT, "parentID\t%lu\n",
1066 afs_printable_uint32_lu(pntr->parentID));
1067 fprintf(STDOUT, "cloneID\t\t%lu\n",
1068 afs_printable_uint32_lu(pntr->cloneID));
1069 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
1070 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
1071 /* 0xD3 is from afs/volume.h since I had trouble including the file */
1072 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
1073 switch (pntr->type) {
1075 fprintf(STDOUT, "type\t\tRW\n");
1078 fprintf(STDOUT, "type\t\tRO\n");
1081 fprintf(STDOUT, "type\t\tBK\n");
1084 fprintf(STDOUT, "type\t\t?\n");
1087 t = pntr->creationDate;
1088 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
1089 afs_printable_uint32_lu(pntr->creationDate),
1092 t = pntr->accessDate;
1093 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
1094 afs_printable_uint32_lu(pntr->accessDate),
1097 t = pntr->updateDate;
1098 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
1099 afs_printable_uint32_lu(pntr->updateDate),
1102 t = pntr->backupDate;
1103 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
1104 afs_printable_uint32_lu(pntr->backupDate),
1108 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
1109 afs_printable_uint32_lu(pntr->copyDate),
1112 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n",
1113 afs_printable_uint32_lu(pntr->flags));
1114 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
1115 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
1116 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n",
1117 afs_printable_uint32_lu(pntr->spare0));
1118 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
1119 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
1120 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n",
1121 afs_printable_uint32_lu(pntr->spare1));
1122 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n",
1123 afs_printable_uint32_lu(pntr->spare2));
1124 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n",
1125 afs_printable_uint32_lu(pntr->spare3));
1130 DisplayVolumes2(long server, long partition, volintInfo *pntr, long count)
1134 for (i = 0; i < count; i++) {
1135 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1136 DisplayFormat2(server, partition, pntr);
1137 fprintf(STDOUT, "END_OF_ENTRY\n\n");
1142 #endif /* FULL_LISTVOL_SWITCH */
1145 DisplayVolumes(afs_int32 server, afs_int32 part, volintInfo *pntr,
1146 afs_int32 count, afs_int32 longlist, afs_int32 fast,
1149 int totalOK, totalNotOK, totalBusy, i;
1150 afs_uint32 volid = 0;
1157 for (i = 0; i < count; i++) {
1158 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
1163 while (busyHead.count) {
1164 qGet(&busyHead, &volid);
1165 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1166 (unsigned long)volid);
1170 while (notokHead.count) {
1171 qGet(¬okHead, &volid);
1172 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1173 (unsigned long)volid);
1177 fprintf(STDOUT, "\n");
1180 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
1181 totalOK, totalNotOK, totalBusy);
1185 /*------------------------------------------------------------------------
1186 * PRIVATE XDisplayVolumes
1189 * Display extended volume information.
1192 * a_servID : Pointer to the Rx call we're performing.
1193 * a_partID : Partition for which we want the extended list.
1194 * a_xInfoP : Ptr to extended volume info.
1195 * a_count : Number of volume records contained above.
1196 * a_int32 : Int32 listing generated?
1197 * a_fast : Fast listing generated?
1198 * a_quiet : Quiet listing generated?
1204 * Nothing interesting.
1208 *------------------------------------------------------------------------*/
1211 XDisplayVolumes(afs_int32 a_servID, afs_int32 a_partID, volintXInfo *a_xInfoP,
1212 afs_int32 a_count, afs_int32 a_int32, afs_int32 a_fast,
1214 { /*XDisplayVolumes */
1216 int totalOK; /*Total OK volumes */
1217 int totalNotOK; /*Total screwed volumes */
1218 int totalBusy; /*Total busy volumes */
1219 int i; /*Loop variable */
1220 afs_uint32 volid = 0; /*Current volume ID */
1223 * Initialize counters and (global!!) queues.
1232 * Display each volume in the list.
1234 for (i = 0; i < a_count; i++) {
1235 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1236 &totalBusy, a_fast, a_int32, 0);
1241 * If any volumes were found to be busy or screwed, display them.
1244 while (busyHead.count) {
1245 qGet(&busyHead, &volid);
1246 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1247 (unsigned long)volid);
1251 while (notokHead.count) {
1252 qGet(¬okHead, &volid);
1253 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1254 (unsigned long)volid);
1259 fprintf(STDOUT, "\n");
1262 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1263 totalOK, totalNotOK, totalBusy);
1267 } /*XDisplayVolumes */
1268 #ifdef FULL_LISTVOL_SWITCH
1269 /*------------------------------------------------------------------------
1270 * PRIVATE XDisplayVolumes2
1273 * Display extended formated volume information.
1276 * a_servID : Pointer to the Rx call we're performing.
1277 * a_partID : Partition for which we want the extended list.
1278 * a_xInfoP : Ptr to extended volume info.
1279 * a_count : Number of volume records contained above.
1280 * a_int32 : Int32 listing generated?
1281 * a_fast : Fast listing generated?
1282 * a_quiet : Quiet listing generated?
1288 * Nothing interesting.
1292 *------------------------------------------------------------------------*/
1295 XDisplayVolumes2(afs_int32 a_servID, afs_int32 a_partID, volintXInfo *a_xInfoP,
1296 afs_int32 a_count, afs_int32 a_int32, afs_int32 a_fast,
1298 { /*XDisplayVolumes */
1300 int totalOK; /*Total OK volumes */
1301 int totalNotOK; /*Total screwed volumes */
1302 int totalBusy; /*Total busy volumes */
1303 int i; /*Loop variable */
1304 afs_uint32 volid = 0; /*Current volume ID */
1307 * Initialize counters and (global!!) queues.
1316 * Display each volume in the list.
1318 for (i = 0; i < a_count; i++) {
1319 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1320 XDisplayFormat2(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1321 &totalBusy, a_fast, a_int32, 0);
1322 fprintf(STDOUT, "END_OF_ENTRY\n");
1327 * If any volumes were found to be busy or screwed, display them.
1330 while (busyHead.count) {
1331 qGet(&busyHead, &volid);
1332 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1333 (unsigned long)volid);
1337 while (notokHead.count) {
1338 qGet(¬okHead, &volid);
1339 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1340 (unsigned long)volid);
1345 fprintf(STDOUT, "\n");
1348 "VOLUMES_ONLINE\t%d\nVOLUMES_OFFLINE\t%d\nVOLUMES_BUSY\t%d\n",
1349 totalOK, totalNotOK, totalBusy);
1353 } /*XDisplayVolumes2 */
1354 #endif /* FULL_LISTVOL_SWITCH */
1357 /* set <server> and <part> to the correct values depending on
1358 * <voltype> and <entry> */
1360 GetServerAndPart(struct nvldbentry *entry, int voltype, afs_int32 *server,
1361 afs_int32 *part, int *previdx)
1363 int i, istart, vtype;
1368 /* Doesn't check for non-existance of backup volume */
1369 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1371 istart = 0; /* seach the entire entry */
1374 /* Seach from beginning of entry or pick up where we left off */
1375 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1378 for (i = istart; i < entry->nServers; i++) {
1379 if (entry->serverFlags[i] & vtype) {
1380 *server = entry->serverNumber[i];
1381 *part = entry->serverPartition[i];
1387 /* Didn't find any, return -1 */
1393 PostVolumeStats(struct nvldbentry *entry)
1395 SubEnumerateEntry(entry);
1396 /* Check for VLOP_ALLOPERS */
1397 if (entry->flags & VLOP_ALLOPERS)
1398 fprintf(STDOUT, " Volume is currently LOCKED \n");
1402 /*------------------------------------------------------------------------
1403 * PRIVATE XVolumeStats
1406 * Display extended volume information.
1409 * a_xInfoP : Ptr to extended volume info.
1410 * a_entryP : Ptr to the volume's VLDB entry.
1411 * a_srvID : Server ID.
1412 * a_partID : Partition ID.
1413 * a_volType : Type of volume to print.
1419 * Nothing interesting.
1423 *------------------------------------------------------------------------*/
1426 XVolumeStats(volintXInfo *a_xInfoP, struct nvldbentry *a_entryP,
1427 afs_int32 a_srvID, afs_int32 a_partID, int a_volType)
1430 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1432 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1433 a_srvID, /*Server ID to print */
1434 a_partID, /*Partition ID to print */
1435 &totalOK, /*Ptr to total-OK counter */
1436 &totalNotOK, /*Ptr to total-screwed counter */
1437 &totalBusy, /*Ptr to total-busy counter */
1438 0, /*Don't do a fast listing */
1439 1, /*Do a long listing */
1440 1); /*Show volume problems */
1446 VolumeStats_int(volintInfo *pntr, struct nvldbentry *entry, afs_int32 server,
1447 afs_int32 part, int voltype)
1449 int totalOK, totalNotOK, totalBusy;
1451 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1456 /* command to forcibly remove a volume */
1458 NukeVolume(register struct cmd_syndesc *as)
1460 register afs_int32 code;
1467 server = GetServer(tp = as->parms[0].items->data);
1469 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1473 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1475 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1479 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1482 PrintError("", err);
1485 "vos: could not parse '%s' as a numeric volume ID", tp);
1490 "vos: forcibly removing all traces of volume %d, please wait...",
1493 code = UV_NukeVolume(server, partID, volID);
1495 fprintf(STDOUT, "done.\n");
1497 fprintf(STDOUT, "failed with code %d.\n", code);
1502 /*------------------------------------------------------------------------
1503 * PRIVATE ExamineVolume
1506 * Routine used to examine a single volume, contacting the VLDB as
1507 * well as the Volume Server.
1510 * as : Ptr to parsed command line arguments.
1513 * 0 for a successful operation,
1514 * Otherwise, one of the ubik or VolServer error values.
1517 * Nothing interesting.
1521 *------------------------------------------------------------------------
1524 ExamineVolume(register struct cmd_syndesc *as, void *arock)
1526 struct nvldbentry entry;
1527 afs_int32 vcode = 0;
1528 volintInfo *pntr = (volintInfo *) 0;
1529 volintXInfo *xInfoP = (volintXInfo *) 0;
1531 afs_int32 code, err, error = 0;
1532 int voltype, foundserv = 0, foundentry = 0;
1533 afs_int32 aserver, apart;
1535 int wantExtendedInfo; /*Do we want extended vol info? */
1537 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1539 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1542 PrintError("", err);
1544 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1545 as->parms[0].items->data);
1550 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1551 (unsigned long)volid);
1554 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1557 "Could not fetch the entry for volume number %lu from VLDB \n",
1558 (unsigned long)volid);
1562 fprintf(STDOUT, "done\n");
1563 MapHostToNetwork(&entry);
1565 if (entry.volumeId[RWVOL] == volid)
1567 else if (entry.volumeId[BACKVOL] == volid)
1569 else /* (entry.volumeId[ROVOL] == volid) */
1572 do { /* do {...} while (voltype == ROVOL) */
1573 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1574 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1575 * If its a RO vol, get the next RO entry.
1577 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1578 &aserver, &apart, &previdx);
1579 if (previdx == -1) { /* searched all entries */
1581 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1582 as->parms[0].items->data);
1589 /* Get information about the volume from the server */
1591 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1592 hostutil_GetNameByINet(aserver));
1595 if (wantExtendedInfo)
1596 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1598 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1600 fprintf(STDOUT, "done\n");
1604 if (code == ENODEV) {
1605 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1606 /* The VLDB says there is no backup volume and its not on disk */
1607 fprintf(STDERR, "Volume %s does not exist\n",
1608 as->parms[0].items->data);
1612 "Volume does not exist on server %s as indicated by the VLDB\n",
1613 hostutil_GetNameByINet(aserver));
1616 PrintDiagnostics("examine", code);
1618 fprintf(STDOUT, "\n");
1621 if (wantExtendedInfo)
1622 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1624 #ifdef FULL_LISTVOL_SWITCH
1625 if (as->parms[2].items) {
1626 DisplayFormat2(aserver, apart, pntr);
1627 EnumerateEntry(&entry);
1629 #endif /* FULL_LISTVOL_SWITCH */
1630 VolumeStats_int(pntr, &entry, aserver, apart, voltype);
1632 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1633 /* The VLDB says there is no backup volume yet we found one on disk */
1634 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1635 as->parms[0].items->data);
1644 } while (voltype == ROVOL);
1647 fprintf(STDERR, "Dump only information from VLDB\n\n");
1648 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1650 PostVolumeStats(&entry);
1655 /*------------------------------------------------------------------------
1659 * Routine used to change the status of a single volume.
1662 * as : Ptr to parsed command line arguments.
1665 * 0 for a successful operation,
1666 * Otherwise, one of the ubik or VolServer error values.
1669 * Nothing interesting.
1673 *------------------------------------------------------------------------
1676 SetFields(register struct cmd_syndesc *as, void *arock)
1678 struct nvldbentry entry;
1681 afs_int32 code, err;
1682 afs_int32 aserver, apart;
1685 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1688 PrintError("", err);
1690 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1691 as->parms[0].items->data);
1695 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1698 "Could not fetch the entry for volume number %lu from VLDB \n",
1699 (unsigned long)volid);
1702 MapHostToNetwork(&entry);
1704 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1705 if (previdx == -1) {
1706 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1707 as->parms[0].items->data);
1711 init_volintInfo(&info);
1715 if (as->parms[1].items) {
1717 code = util_GetHumanInt32(as->parms[1].items->data, &info.maxquota);
1719 fprintf(STDERR, "invalid quota value\n");
1723 if (as->parms[2].items) {
1727 if (as->parms[3].items) {
1728 /* -clearVolUpCounter */
1731 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1734 "Could not update volume info fields for volume number %lu\n",
1735 (unsigned long)volid);
1739 /*------------------------------------------------------------------------
1743 * Brings a volume online.
1746 * as : Ptr to parsed command line arguments.
1749 * 0 for a successful operation,
1752 * Nothing interesting.
1756 *------------------------------------------------------------------------
1759 volOnline(register struct cmd_syndesc *as, void *arock)
1761 afs_int32 server, partition;
1763 afs_int32 code, err = 0;
1765 server = GetServer(as->parms[0].items->data);
1767 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1768 as->parms[0].items->data);
1772 partition = volutil_GetPartitionID(as->parms[1].items->data);
1773 if (partition < 0) {
1774 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1775 as->parms[1].items->data);
1779 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1782 PrintError("", err);
1784 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1785 as->parms[0].items->data);
1789 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1792 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1799 /*------------------------------------------------------------------------
1800 * PRIVATE volOffline
1803 * Brings a volume offline.
1806 * as : Ptr to parsed command line arguments.
1809 * 0 for a successful operation,
1812 * Nothing interesting.
1816 *------------------------------------------------------------------------
1819 volOffline(register struct cmd_syndesc *as, void *arock)
1821 afs_int32 server, partition;
1823 afs_int32 code, err = 0;
1824 afs_int32 transflag, sleeptime, transdone;
1826 server = GetServer(as->parms[0].items->data);
1828 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1829 as->parms[0].items->data);
1833 partition = volutil_GetPartitionID(as->parms[1].items->data);
1834 if (partition < 0) {
1835 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1836 as->parms[1].items->data);
1840 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1843 PrintError("", err);
1845 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1846 as->parms[0].items->data);
1850 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1851 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1852 transdone = (sleeptime ? 0 /*online */ : VTOutOfService);
1853 if (as->parms[4].items && !as->parms[3].items) {
1854 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1859 UV_SetVolume(server, partition, volid, transflag, transdone,
1862 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1870 CreateVolume(register struct cmd_syndesc *as, void *arock)
1876 struct nvldbentry entry;
1881 tserver = GetServer(as->parms[0].items->data);
1883 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1884 as->parms[0].items->data);
1887 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1889 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1890 as->parms[1].items->data);
1893 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1895 PrintError("", code);
1898 "vos : partition %s does not exist on the server\n",
1899 as->parms[1].items->data);
1902 if (!ISNAMEVALID(as->parms[2].items->data)) {
1904 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1905 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1908 if (!VolNameOK(as->parms[2].items->data)) {
1910 "Illegal volume name %s, should not end in .readonly or .backup\n",
1911 as->parms[2].items->data);
1914 if (IsNumeric(as->parms[2].items->data)) {
1915 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1916 as->parms[2].items->data);
1919 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1921 fprintf(STDERR, "Volume %s already exists\n",
1922 as->parms[2].items->data);
1923 PrintDiagnostics("create", code);
1927 if (as->parms[3].items) {
1928 code = util_GetHumanInt32(as->parms[3].items->data, "a);
1930 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1936 UV_CreateVolume2(tserver, pnum, as->parms[2].items->data, quota, 0,
1939 PrintDiagnostics("create", code);
1942 MapPartIdIntoName(pnum, part);
1943 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
1944 (unsigned long)volid, part, as->parms[0].items->data);
1951 DeleteAll(struct nvldbentry *entry)
1954 afs_int32 error, code, curserver, curpart;
1957 MapHostToNetwork(entry);
1959 for (i = 0; i < entry->nServers; i++) {
1960 curserver = entry->serverNumber[i];
1961 curpart = entry->serverPartition[i];
1962 if (entry->serverFlags[i] & ITSROVOL) {
1963 volid = entry->volumeId[ROVOL];
1965 volid = entry->volumeId[RWVOL];
1967 code = UV_DeleteVolume(curserver, curpart, volid);
1976 DeleteVolume(struct cmd_syndesc *as, void *arock)
1978 afs_int32 err, code = 0;
1979 afs_int32 server = 0, partition = -1;
1984 if (as->parms[0].items) {
1985 server = GetServer(as->parms[0].items->data);
1987 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1988 as->parms[0].items->data);
1993 if (as->parms[1].items) {
1994 partition = volutil_GetPartitionID(as->parms[1].items->data);
1995 if (partition < 0) {
1996 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1997 as->parms[1].items->data);
2001 /* Check for validity of the partition */
2002 if (!IsPartValid(partition, server, &code)) {
2004 PrintError("", code);
2007 "vos : partition %s does not exist on the server\n",
2008 as->parms[1].items->data);
2014 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2016 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
2017 as->parms[2].items->data);
2019 PrintError("", err);
2023 /* If the server or partition option are not complete, try to fill
2024 * them in from the VLDB entry.
2026 if ((partition == -1) || !server) {
2027 struct nvldbentry entry;
2029 code = VLDB_GetEntryByID(volid, -1, &entry);
2032 "Could not fetch the entry for volume %lu from VLDB\n",
2033 (unsigned long)volid);
2034 PrintError("", code);
2038 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
2039 || ((volid == entry.volumeId[BACKVOL])
2040 && (entry.flags & BACK_EXISTS))) {
2041 idx = Lp_GetRwIndex(&entry);
2042 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2043 || ((partition != -1)
2044 && (partition != entry.serverPartition[idx]))) {
2045 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2046 as->parms[2].items->data);
2049 } else if ((volid == entry.volumeId[ROVOL])
2050 && (entry.flags & RO_EXISTS)) {
2051 for (idx = -1, j = 0; j < entry.nServers; j++) {
2052 if (entry.serverFlags[j] != ITSROVOL)
2055 if (((server == 0) || (server == entry.serverNumber[j]))
2056 && ((partition == -1)
2057 || (partition == entry.serverPartition[j]))) {
2060 "VLDB: Volume '%s' matches more than one RO\n",
2061 as->parms[2].items->data);
2068 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2069 as->parms[2].items->data);
2073 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2074 as->parms[2].items->data);
2078 server = htonl(entry.serverNumber[idx]);
2079 partition = entry.serverPartition[idx];
2083 code = UV_DeleteVolume(server, partition, volid);
2085 PrintDiagnostics("remove", code);
2089 MapPartIdIntoName(partition, pname);
2090 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2091 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2095 #define TESTM 0 /* set for move space tests, clear for production */
2097 MoveVolume(register struct cmd_syndesc *as, void *arock)
2101 afs_int32 fromserver, toserver, frompart, topart;
2102 afs_int32 flags, code, err;
2103 char fromPartName[10], toPartName[10];
2105 struct diskPartition64 partition; /* for space check */
2108 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2111 PrintError("", err);
2113 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2114 as->parms[0].items->data);
2117 fromserver = GetServer(as->parms[1].items->data);
2118 if (fromserver == 0) {
2119 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2120 as->parms[1].items->data);
2123 toserver = GetServer(as->parms[3].items->data);
2124 if (toserver == 0) {
2125 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2126 as->parms[3].items->data);
2129 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2131 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2132 as->parms[2].items->data);
2135 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2137 PrintError("", code);
2140 "vos : partition %s does not exist on the server\n",
2141 as->parms[2].items->data);
2144 topart = volutil_GetPartitionID(as->parms[4].items->data);
2146 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2147 as->parms[4].items->data);
2150 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2152 PrintError("", code);
2155 "vos : partition %s does not exist on the server\n",
2156 as->parms[4].items->data);
2161 if (as->parms[5].items) flags |= RV_NOCLONE;
2164 * check source partition for space to clone volume
2167 MapPartIdIntoName(topart, toPartName);
2168 MapPartIdIntoName(frompart, fromPartName);
2171 * check target partition for space to move volume
2174 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2176 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2180 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2183 p = (volintInfo *) 0;
2184 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2186 fprintf(STDERR, "vos:cannot access volume %lu\n",
2187 (unsigned long)volid);
2191 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2193 if (partition.free <= p->size) {
2195 "vos: no space on target partition %s to move volume %lu\n",
2196 toPartName, (unsigned long)volid);
2203 fprintf(STDOUT, "size test - don't do move\n");
2207 /* successful move still not guaranteed but shoot for it */
2210 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2212 PrintDiagnostics("move", code);
2215 MapPartIdIntoName(topart, toPartName);
2216 MapPartIdIntoName(frompart, fromPartName);
2217 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2218 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2219 as->parms[3].items->data, toPartName);
2225 CopyVolume(register struct cmd_syndesc *as, void *arock)
2228 afs_int32 fromserver, toserver, frompart, topart, code, err, flags;
2229 char fromPartName[10], toPartName[10], *tovolume;
2230 struct nvldbentry entry;
2231 struct diskPartition64 partition; /* for space check */
2234 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2237 PrintError("", err);
2239 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2240 as->parms[0].items->data);
2243 fromserver = GetServer(as->parms[1].items->data);
2244 if (fromserver == 0) {
2245 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2246 as->parms[1].items->data);
2250 toserver = GetServer(as->parms[4].items->data);
2251 if (toserver == 0) {
2252 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2253 as->parms[4].items->data);
2257 tovolume = as->parms[3].items->data;
2258 if (!ISNAMEVALID(tovolume)) {
2260 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2261 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2264 if (!VolNameOK(tovolume)) {
2266 "Illegal volume name %s, should not end in .readonly or .backup\n",
2270 if (IsNumeric(tovolume)) {
2271 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2275 code = VLDB_GetEntryByName(tovolume, &entry);
2277 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2278 PrintDiagnostics("copy", code);
2282 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2284 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2285 as->parms[2].items->data);
2288 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2290 PrintError("", code);
2293 "vos : partition %s does not exist on the server\n",
2294 as->parms[2].items->data);
2298 topart = volutil_GetPartitionID(as->parms[5].items->data);
2300 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2301 as->parms[5].items->data);
2304 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2306 PrintError("", code);
2309 "vos : partition %s does not exist on the server\n",
2310 as->parms[5].items->data);
2315 if (as->parms[6].items) flags |= RV_OFFLINE;
2316 if (as->parms[7].items) flags |= RV_RDONLY;
2317 if (as->parms[8].items) flags |= RV_NOCLONE;
2319 MapPartIdIntoName(topart, toPartName);
2320 MapPartIdIntoName(frompart, fromPartName);
2323 * check target partition for space to move volume
2326 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2328 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2332 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2335 p = (volintInfo *) 0;
2336 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2338 fprintf(STDERR, "vos:cannot access volume %lu\n",
2339 (unsigned long)volid);
2343 if (partition.free <= p->size) {
2345 "vos: no space on target partition %s to copy volume %lu\n",
2346 toPartName, (unsigned long)volid);
2352 /* successful copy still not guaranteed but shoot for it */
2355 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2358 PrintDiagnostics("copy", code);
2361 MapPartIdIntoName(topart, toPartName);
2362 MapPartIdIntoName(frompart, fromPartName);
2363 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2364 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2365 tovolume, as->parms[4].items->data, toPartName);
2372 ShadowVolume(register struct cmd_syndesc *as, void *arock)
2374 afs_uint32 volid, tovolid;
2375 afs_int32 fromserver, toserver, frompart, topart;
2376 afs_int32 code, err, flags;
2377 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2378 struct diskPartition64 partition; /* for space check */
2381 p = (volintInfo *) 0;
2382 q = (volintInfo *) 0;
2384 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2387 PrintError("", err);
2389 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2390 as->parms[0].items->data);
2393 fromserver = GetServer(as->parms[1].items->data);
2394 if (fromserver == 0) {
2395 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2396 as->parms[1].items->data);
2400 toserver = GetServer(as->parms[3].items->data);
2401 if (toserver == 0) {
2402 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2403 as->parms[3].items->data);
2407 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2409 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2410 as->parms[2].items->data);
2413 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2415 PrintError("", code);
2418 "vos : partition %s does not exist on the server\n",
2419 as->parms[2].items->data);
2423 topart = volutil_GetPartitionID(as->parms[4].items->data);
2425 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2426 as->parms[4].items->data);
2429 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2431 PrintError("", code);
2434 "vos : partition %s does not exist on the server\n",
2435 as->parms[4].items->data);
2439 if (as->parms[5].items) {
2440 tovolume = as->parms[5].items->data;
2441 if (!ISNAMEVALID(tovolume)) {
2443 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2444 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2447 if (!VolNameOK(tovolume)) {
2449 "Illegal volume name %s, should not end in .readonly or .backup\n",
2453 if (IsNumeric(tovolume)) {
2455 "Illegal volume name %s, should not be a number\n",
2460 /* use actual name of source volume */
2461 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2463 fprintf(STDERR, "vos:cannot access volume %lu\n",
2464 (unsigned long)volid);
2467 strcpy(toVolName, p->name);
2468 tovolume = toVolName;
2469 /* save p for size checks later */
2472 if (as->parms[6].items) {
2473 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2476 PrintError("", err);
2478 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2479 as->parms[6].items->data);
2485 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2488 PrintError("", err);
2490 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2499 if (as->parms[7].items) flags |= RV_OFFLINE;
2500 if (as->parms[8].items) flags |= RV_RDONLY;
2501 if (as->parms[9].items) flags |= RV_NOCLONE;
2502 if (as->parms[10].items) flags |= RV_CPINCR;
2504 MapPartIdIntoName(topart, toPartName);
2505 MapPartIdIntoName(frompart, fromPartName);
2508 * check target partition for space to move volume
2511 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2513 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2517 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2520 /* Don't do this again if we did it above */
2522 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2524 fprintf(STDERR, "vos:cannot access volume %lu\n",
2525 (unsigned long)volid);
2530 /* OK if this fails */
2531 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2533 /* Treat existing volume size as "free" */
2535 p->size = (q->size < p->size) ? p->size - q->size : 0;
2537 if (partition.free <= p->size) {
2539 "vos: no space on target partition %s to copy volume %lu\n",
2540 toPartName, (unsigned long)volid);
2548 /* successful copy still not guaranteed but shoot for it */
2551 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2552 topart, tovolid, flags);
2554 PrintDiagnostics("shadow", code);
2557 MapPartIdIntoName(topart, toPartName);
2558 MapPartIdIntoName(frompart, fromPartName);
2559 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2560 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2561 as->parms[3].items->data, toPartName);
2568 CloneVolume(register struct cmd_syndesc *as, void *arock)
2570 afs_uint32 volid, cloneid;
2571 afs_int32 server, part, voltype;
2572 char partName[10], *volname;
2573 afs_int32 code, err, flags;
2574 struct nvldbentry entry;
2576 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2579 PrintError("", err);
2581 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2582 as->parms[0].items->data);
2586 if (as->parms[1].items || as->parms[2].items) {
2587 if (!as->parms[1].items || !as->parms[2].items) {
2589 "Must specify both -server and -partition options\n");
2592 server = GetServer(as->parms[1].items->data);
2594 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2595 as->parms[1].items->data);
2598 part = volutil_GetPartitionID(as->parms[2].items->data);
2600 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2601 as->parms[2].items->data);
2604 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2606 PrintError("", code);
2609 "vos : partition %s does not exist on the server\n",
2610 as->parms[2].items->data);
2614 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2620 if (as->parms[3].items) {
2621 volname = as->parms[3].items->data;
2622 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2624 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2625 volname, VOLSER_OLDMAXVOLNAME - 1);
2630 * In order that you be able to make clones of RO or BK, this
2631 * check must be omitted.
2633 if (!VolNameOK(volname)) {
2635 "Illegal volume name %s, should not end in .readonly or .backup\n",
2640 if (IsNumeric(volname)) {
2642 "Illegal volume name %s, should not be a number\n",
2649 if (as->parms[4].items) {
2650 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2653 PrintError("", err);
2655 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2656 as->parms[4].items->data);
2662 if (as->parms[5].items) flags |= RV_OFFLINE;
2663 if (as->parms[6].items) flags |= RV_RDONLY;
2667 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2670 PrintDiagnostics("clone", code);
2673 MapPartIdIntoName(part, partName);
2674 fprintf(STDOUT, "Created clone for volume %s\n",
2675 as->parms[0].items->data);
2682 BackupVolume(register struct cmd_syndesc *as, void *arock)
2685 afs_int32 aserver, apart, vtype, code, err;
2686 struct nvldbentry entry;
2689 afs_int32 buserver, bupart, butype;
2690 struct nvldbentry buentry;
2692 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2695 PrintError("", err);
2697 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2698 as->parms[0].items->data);
2701 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2705 /* verify this is a readwrite volume */
2707 if (vtype != RWVOL) {
2708 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2712 /* is there a backup volume already? */
2714 if (entry.flags & BACK_EXISTS) {
2715 /* yep, where is it? */
2717 buvolid = entry.volumeId[BACKVOL];
2718 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2723 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2726 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2732 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2733 (unsigned long)buvolid, (unsigned long)buserver);
2738 /* nope, carry on */
2740 code = UV_BackupVolume(aserver, apart, avolid);
2743 PrintDiagnostics("backup", code);
2746 fprintf(STDOUT, "Created backup volume for %s \n",
2747 as->parms[0].items->data);
2752 ReleaseVolume(register struct cmd_syndesc *as, void *arock)
2755 struct nvldbentry entry;
2757 afs_int32 aserver, apart, vtype, code, err;
2760 if (as->parms[1].items)
2762 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2765 PrintError("", err);
2767 fprintf(STDERR, "vos: can't find volume '%s'\n",
2768 as->parms[0].items->data);
2771 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2775 if (vtype != RWVOL) {
2776 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2780 if (!ISNAMEVALID(entry.name)) {
2782 "Volume name %s is too long, rename before releasing\n",
2787 code = UV_ReleaseVolume(avolid, aserver, apart, force);
2789 PrintDiagnostics("release", code);
2792 fprintf(STDOUT, "Released volume %s successfully\n",
2793 as->parms[0].items->data);
2798 DumpVolumeCmd(register struct cmd_syndesc *as, void *arock)
2801 afs_int32 aserver, apart, voltype, fromdate = 0, code, err, i, flags;
2802 char filename[MAXPATHLEN];
2803 struct nvldbentry entry;
2805 rx_SetRxDeadTime(60 * 10);
2806 for (i = 0; i < MAXSERVERS; i++) {
2807 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2810 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2811 if (rxConn->service)
2812 rxConn->service->connDeadTime = rx_connDeadTime;
2815 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2818 PrintError("", err);
2820 fprintf(STDERR, "vos: can't find volume '%s'\n",
2821 as->parms[0].items->data);
2825 if (as->parms[3].items || as->parms[4].items) {
2826 if (!as->parms[3].items || !as->parms[4].items) {
2828 "Must specify both -server and -partition options\n");
2831 aserver = GetServer(as->parms[3].items->data);
2833 fprintf(STDERR, "Invalid server name\n");
2836 apart = volutil_GetPartitionID(as->parms[4].items->data);
2838 fprintf(STDERR, "Invalid partition name\n");
2842 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2847 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2848 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2850 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2851 as->parms[1].items->data, code);
2855 if (as->parms[2].items) {
2856 strcpy(filename, as->parms[2].items->data);
2858 strcpy(filename, "");
2861 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
2863 if (as->parms[5].items) {
2865 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2866 DumpFunction, filename, flags);
2869 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2872 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
2873 flags &= ~VOLDUMPV2_OMITDIRS;
2877 PrintDiagnostics("dump", code);
2880 if (strcmp(filename, ""))
2881 fprintf(STDERR, "Dumped volume %s in file %s\n",
2882 as->parms[0].items->data, filename);
2884 fprintf(STDERR, "Dumped volume %s in stdout \n",
2885 as->parms[0].items->data);
2899 RestoreVolumeCmd(register struct cmd_syndesc *as, void *arock)
2901 afs_uint32 avolid, aparentid;
2902 afs_int32 aserver, apart, code, vcode, err;
2903 afs_int32 aoverwrite = ASK;
2904 afs_int32 acreation = 0, alastupdate = 0;
2905 int restoreflags = 0;
2906 int readonly = 0, offline = 0, voltype = RWVOL;
2908 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
2909 char volname[VOLSER_MAXVOLNAME + 1];
2910 struct nvldbentry entry;
2915 if (as->parms[4].items) {
2916 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2919 PrintError("", err);
2921 fprintf(STDERR, "vos: can't find volume '%s'\n",
2922 as->parms[4].items->data);
2928 if (as->parms[5].items) {
2929 if ((strcmp(as->parms[5].items->data, "a") == 0)
2930 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
2932 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
2933 || (strcmp(as->parms[5].items->data, "full") == 0)) {
2935 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
2936 || (strcmp(as->parms[5].items->data, "inc") == 0)
2937 || (strcmp(as->parms[5].items->data, "increment") == 0)
2938 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
2941 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2942 as->parms[5].items->data);
2946 if (as->parms[6].items)
2948 if (as->parms[7].items) {
2953 if (as->parms[8].items) {
2954 if ((strcmp(as->parms[8].items->data, "d") == 0)
2955 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
2956 acreation = TS_DUMP;
2957 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
2958 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
2959 acreation = TS_KEEP;
2960 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
2961 || (strcmp(as->parms[8].items->data, "new") == 0)) {
2964 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
2965 as->parms[8].items->data);
2970 if (as->parms[9].items) {
2971 if ((strcmp(as->parms[9].items->data, "d") == 0)
2972 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
2973 alastupdate = TS_DUMP;
2974 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
2975 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
2976 alastupdate = TS_KEEP;
2977 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
2978 || (strcmp(as->parms[9].items->data, "new") == 0)) {
2979 alastupdate = TS_NEW;
2981 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
2982 as->parms[9].items->data);
2987 aserver = GetServer(as->parms[0].items->data);
2989 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2990 as->parms[0].items->data);
2993 apart = volutil_GetPartitionID(as->parms[1].items->data);
2995 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2996 as->parms[1].items->data);
2999 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3001 PrintError("", code);
3004 "vos : partition %s does not exist on the server\n",
3005 as->parms[1].items->data);
3008 strcpy(avolname, as->parms[2].items->data);
3009 if (!ISNAMEVALID(avolname)) {
3011 "vos: the name of the volume %s exceeds the size limit\n",
3015 if (!VolNameOK(avolname)) {
3017 "Illegal volume name %s, should not end in .readonly or .backup\n",
3021 if (as->parms[3].items) {
3022 strcpy(afilename, as->parms[3].items->data);
3023 if (!FileExists(afilename)) {
3024 fprintf(STDERR, "Can't access file %s\n", afilename);
3028 strcpy(afilename, "");
3031 /* Check if volume exists or not */
3033 vsu_ExtractName(volname, avolname);
3034 vcode = VLDB_GetEntryByName(volname, &entry);
3035 if (vcode) { /* no volume - do a full restore */
3036 restoreflags = RV_FULLRST;
3037 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3039 "Volume does not exist; Will perform a full restore\n");
3042 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3043 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3044 restoreflags = RV_FULLRST;
3045 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3047 "%s Volume does not exist; Will perform a full restore\n",
3048 readonly ? "RO" : "RW");
3051 avolid = entry.volumeId[voltype];
3052 } else if (entry.volumeId[voltype] != 0
3053 && entry.volumeId[voltype] != avolid) {
3054 avolid = entry.volumeId[voltype];
3056 aparentid = entry.volumeId[RWVOL];
3059 else { /* volume exists - do we do a full incremental or abort */
3060 int Oserver, Opart, Otype, vol_elsewhere = 0;
3061 struct nvldbentry Oentry;
3065 avolid = entry.volumeId[voltype];
3066 } else if (entry.volumeId[voltype] != 0
3067 && entry.volumeId[voltype] != avolid) {
3068 avolid = entry.volumeId[voltype];
3070 aparentid = entry.volumeId[RWVOL];
3072 /* A file name was specified - check if volume is on another partition */
3073 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3077 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3080 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3084 if (!vcode || (Opart != apart))
3087 if (aoverwrite == ASK) {
3088 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3090 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3094 /* Ask what to do */
3095 if (vol_elsewhere) {
3097 "The volume %s %u already exists on a different server/part\n",
3098 volname, entry.volumeId[voltype]);
3100 "Do you want to do a full restore or abort? [fa](a): ");
3103 "The volume %s %u already exists in the VLDB\n",
3104 volname, entry.volumeId[voltype]);
3106 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3109 while (!(dc == EOF || dc == '\n'))
3110 dc = getchar(); /* goto end of line */
3111 if ((c == 'f') || (c == 'F'))
3113 else if ((c == 'i') || (c == 'I'))
3119 if (aoverwrite == ABORT) {
3120 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3122 } else if (aoverwrite == FULL) {
3123 restoreflags = RV_FULLRST;
3125 "Volume exists; Will delete and perform full restore\n");
3126 } else if (aoverwrite == INC) {
3128 if (vol_elsewhere) {
3130 "%s volume %lu already exists on a different server/part; not allowed\n",
3131 readonly ? "RO" : "RW", (unsigned long)avolid);
3137 restoreflags |= RV_OFFLINE;
3139 restoreflags |= RV_RDONLY;
3141 switch (acreation) {
3143 restoreflags |= RV_CRDUMP;
3146 restoreflags |= RV_CRKEEP;
3149 restoreflags |= RV_CRNEW;
3152 if (aoverwrite == FULL)
3153 restoreflags |= RV_CRNEW;
3155 restoreflags |= RV_CRKEEP;
3158 switch (alastupdate) {
3160 restoreflags |= RV_LUDUMP;
3163 restoreflags |= RV_LUKEEP;
3166 restoreflags |= RV_LUNEW;
3169 restoreflags |= RV_LUDUMP;
3171 if (as->parms[10].items) {
3172 restoreflags |= RV_NODEL;
3177 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3178 avolname, restoreflags, WriteData, afilename);
3180 PrintDiagnostics("restore", code);
3183 MapPartIdIntoName(apart, apartName);
3186 * patch typo here - originally "parms[1]", should be "parms[0]"
3189 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3190 as->parms[0].items->data, apartName);
3195 LockReleaseCmd(register struct cmd_syndesc *as, void *arock)
3198 afs_int32 code, err;
3200 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3203 PrintError("", err);
3205 fprintf(STDERR, "vos: can't find volume '%s'\n",
3206 as->parms[0].items->data);
3210 code = UV_LockRelease(avolid);
3212 PrintDiagnostics("unlock", code);
3215 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3216 as->parms[0].items->data);
3221 AddSite(register struct cmd_syndesc *as, void *arock)
3224 afs_int32 aserver, apart, code, err, valid = 0;
3225 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3227 vsu_ExtractName(avolname, as->parms[2].items->data);;
3228 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3231 PrintError("", err);
3233 fprintf(STDERR, "vos: can't find volume '%s'\n",
3234 as->parms[2].items->data);
3237 aserver = GetServer(as->parms[0].items->data);
3239 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3240 as->parms[0].items->data);
3243 apart = volutil_GetPartitionID(as->parms[1].items->data);
3245 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3246 as->parms[1].items->data);
3249 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3251 PrintError("", code);
3254 "vos : partition %s does not exist on the server\n",
3255 as->parms[1].items->data);
3258 if (as->parms[3].items) {
3261 code = UV_AddSite(aserver, apart, avolid, valid);
3263 PrintDiagnostics("addsite", code);
3266 MapPartIdIntoName(apart, apartName);
3267 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3268 as->parms[0].items->data, apartName, as->parms[2].items->data);
3273 RemoveSite(register struct cmd_syndesc *as, void *arock)
3277 afs_int32 aserver, apart, code, err;
3278 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3280 vsu_ExtractName(avolname, as->parms[2].items->data);
3281 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3284 PrintError("", err);
3286 fprintf(STDERR, "vos: can't find volume '%s'\n",
3287 as->parms[2].items->data);
3290 aserver = GetServer(as->parms[0].items->data);
3292 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3293 as->parms[0].items->data);
3296 apart = volutil_GetPartitionID(as->parms[1].items->data);
3298 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3299 as->parms[1].items->data);
3303 *skip the partition validity check, since it is possible that the partition
3304 *has since been decomissioned.
3307 if (!IsPartValid(apart,aserver,&code)){
3308 if(code) PrintError("",code);
3309 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3313 code = UV_RemoveSite(aserver, apart, avolid);
3315 PrintDiagnostics("remsite", code);
3318 MapPartIdIntoName(apart, apartName);
3319 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3320 as->parms[0].items->data, apartName, as->parms[2].items->data);
3325 ChangeLocation(register struct cmd_syndesc *as, void *arock)
3328 afs_int32 aserver, apart, code, err;
3331 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3334 PrintError("", err);
3336 fprintf(STDERR, "vos: can't find volume '%s'\n",
3337 as->parms[2].items->data);
3340 aserver = GetServer(as->parms[0].items->data);
3342 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3343 as->parms[0].items->data);
3346 apart = volutil_GetPartitionID(as->parms[1].items->data);
3348 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3349 as->parms[1].items->data);
3352 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3354 PrintError("", code);
3357 "vos : partition %s does not exist on the server\n",
3358 as->parms[1].items->data);
3361 code = UV_ChangeLocation(aserver, apart, avolid);
3363 PrintDiagnostics("addsite", code);
3366 MapPartIdIntoName(apart, apartName);
3367 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3368 as->parms[0].items->data, apartName, as->parms[2].items->data);
3373 ListPartitions(register struct cmd_syndesc *as, void *arock)
3375 afs_int32 aserver, code;
3376 struct partList dummyPartList;
3381 aserver = GetServer(as->parms[0].items->data);
3383 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3384 as->parms[0].items->data);
3389 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3391 PrintDiagnostics("listpart", code);
3395 fprintf(STDOUT, "The partitions on the server are:\n");
3396 for (i = 0; i < cnt; i++) {
3397 if (dummyPartList.partFlags[i] & PARTVALID) {
3398 memset(pname, 0, sizeof(pname));
3399 MapPartIdIntoName(dummyPartList.partId[i], pname);
3400 fprintf(STDOUT, " %10s ", pname);
3402 if ((i % 5) == 0 && (i != 0))
3403 fprintf(STDOUT, "\n");
3406 fprintf(STDOUT, "\n");
3407 fprintf(STDOUT, "Total: %d\n", total);
3413 CompareVolName(const void *p1, const void *p2)
3415 volintInfo *arg1, *arg2;
3417 arg1 = (volintInfo *) p1;
3418 arg2 = (volintInfo *) p2;
3419 return (strcmp(arg1->name, arg2->name));
3423 /*------------------------------------------------------------------------
3424 * PRIVATE XCompareVolName
3427 * Comparison routine for volume names coming from an extended
3431 * a_obj1P : Char ptr to first extended vol info object
3432 * a_obj1P : Char ptr to second extended vol info object
3435 * The value of strcmp() on the volume names within the passed
3436 * objects (i,e., -1, 0, or 1).
3439 * Passed to qsort() as the designated comparison routine.
3443 *------------------------------------------------------------------------*/
3446 XCompareVolName(const void *a_obj1P, const void *a_obj2P)
3447 { /*XCompareVolName */
3450 (((struct volintXInfo *)(a_obj1P))->name,
3451 ((struct volintXInfo *)(a_obj2P))->name));
3453 } /*XCompareVolName */
3456 CompareVolID(const void *p1, const void *p2)
3458 volintInfo *arg1, *arg2;
3460 arg1 = (volintInfo *) p1;
3461 arg2 = (volintInfo *) p2;
3462 if (arg1->volid == arg2->volid)
3464 if (arg1->volid > arg2->volid)
3471 /*------------------------------------------------------------------------
3472 * PRIVATE XCompareVolID
3475 * Comparison routine for volume IDs coming from an extended
3479 * a_obj1P : Char ptr to first extended vol info object
3480 * a_obj1P : Char ptr to second extended vol info object
3483 * The value of strcmp() on the volume names within the passed
3484 * objects (i,e., -1, 0, or 1).
3487 * Passed to qsort() as the designated comparison routine.
3491 *------------------------------------------------------------------------*/
3494 XCompareVolID(const void *a_obj1P, const void *a_obj2P)
3495 { /*XCompareVolID */
3497 afs_int32 id1, id2; /*Volume IDs we're comparing */
3499 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3500 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3508 } /*XCompareVolID */
3510 /*------------------------------------------------------------------------
3511 * PRIVATE ListVolumes
3514 * Routine used to list volumes, contacting the Volume Server
3515 * directly, bypassing the VLDB.
3518 * as : Ptr to parsed command line arguments.
3521 * 0 Successful operation
3524 * Nothing interesting.
3528 *------------------------------------------------------------------------*/
3531 ListVolumes(register struct cmd_syndesc *as, void *arock)
3533 afs_int32 apart, int32list, fast;
3534 afs_int32 aserver, code;
3536 volintInfo *oldpntr = NULL;
3540 volintXInfo *xInfoP;
3541 volintXInfo *origxInfoP = NULL; /*Ptr to current/orig extended vol info */
3542 int wantExtendedInfo; /*Do we want extended vol info? */
3545 struct partList dummyPartList;
3553 if (as->parms[3].items)
3555 if (as->parms[4].items)
3559 if (as->parms[2].items)
3565 if (as->parms[5].items) {
3567 * We can't coexist with the fast flag.
3571 "vos: Can't use the -fast and -extended flags together\n");
3576 * We need to turn on ``long'' listings to get the full effect.
3578 wantExtendedInfo = 1;
3581 wantExtendedInfo = 0;
3582 if (as->parms[1].items) {
3583 apart = volutil_GetPartitionID(as->parms[1].items->data);
3585 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3586 as->parms[1].items->data);
3589 dummyPartList.partId[0] = apart;
3590 dummyPartList.partFlags[0] = PARTVALID;
3593 aserver = GetServer(as->parms[0].items->data);
3595 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3596 as->parms[0].items->data);
3601 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3603 PrintError("", code);
3606 "vos : partition %s does not exist on the server\n",
3607 as->parms[1].items->data);
3611 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3613 PrintDiagnostics("listvol", code);
3617 for (i = 0; i < cnt; i++) {
3618 if (dummyPartList.partFlags[i] & PARTVALID) {
3619 if (wantExtendedInfo)
3621 UV_XListVolumes(aserver, dummyPartList.partId[i], all,
3625 UV_ListVolumes(aserver, dummyPartList.partId[i], all,
3628 PrintDiagnostics("listvol", code);
3633 if (wantExtendedInfo) {
3634 origxInfoP = xInfoP;
3635 base = (char *)xInfoP;
3638 base = (char *)pntr;
3642 if (wantExtendedInfo)
3643 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
3645 qsort(base, count, sizeof(volintInfo), CompareVolName);
3647 if (wantExtendedInfo)
3648 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
3650 qsort(base, count, sizeof(volintInfo), CompareVolID);
3652 MapPartIdIntoName(dummyPartList.partId[i], pname);
3655 "Total number of volumes on server %s partition %s: %lu \n",
3656 as->parms[0].items->data, pname,
3657 (unsigned long)count);
3658 if (wantExtendedInfo) {
3659 #ifdef FULL_LISTVOL_SWITCH
3660 if (as->parms[6].items)
3661 XDisplayVolumes2(aserver, dummyPartList.partId[i], origxInfoP,
3662 count, int32list, fast, quiet);
3664 #endif /* FULL_LISTVOL_SWITCH */
3665 XDisplayVolumes(aserver, dummyPartList.partId[i], origxInfoP,
3666 count, int32list, fast, quiet);
3669 xInfoP = (volintXInfo *) 0;
3671 #ifdef FULL_LISTVOL_SWITCH
3672 if (as->parms[6].items)
3673 DisplayVolumes2(aserver, dummyPartList.partId[i], oldpntr,
3676 #endif /* FULL_LISTVOL_SWITCH */
3677 DisplayVolumes(aserver, dummyPartList.partId[i], oldpntr,
3678 count, int32list, fast, quiet);
3681 pntr = (volintInfo *) 0;
3689 SyncVldb(register struct cmd_syndesc *as, void *arock)
3691 afs_int32 pnum = 0, code; /* part name */
3697 if (as->parms[0].items) {
3698 tserver = GetServer(as->parms[0].items->data);
3700 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3701 as->parms[0].items->data);
3706 if (as->parms[1].items) {
3707 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3709 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3710 as->parms[1].items->data);
3713 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3715 PrintError("", code);
3718 "vos: partition %s does not exist on the server\n",
3719 as->parms[1].items->data);
3726 "The -partition option requires a -server option\n");
3731 if (as->parms[3].items) {
3732 flags |= 2; /* don't update */
3735 if (as->parms[2].items) {
3736 /* Synchronize an individual volume */
3737 volname = as->parms[2].items->data;
3738 code = UV_SyncVolume(tserver, pnum, volname, flags);
3742 "Without a -volume option, the -server option is required\n");
3745 code = UV_SyncVldb(tserver, pnum, flags, 0 /*unused */ );
3749 PrintDiagnostics("syncvldb", code);
3753 /* Print a summary of what we did */
3755 fprintf(STDOUT, "VLDB volume %s synchronized", volname);
3757 fprintf(STDOUT, "VLDB synchronized");
3759 fprintf(STDOUT, " with state of server %s", as->parms[0].items->data);
3762 MapPartIdIntoName(pnum, part);
3763 fprintf(STDOUT, " partition %s\n", part);
3765 fprintf(STDOUT, "\n");
3771 SyncServer(register struct cmd_syndesc *as, void *arock)
3773 afs_int32 pnum, code; /* part name */
3778 tserver = GetServer(as->parms[0].items->data);
3780 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3781 as->parms[0].items->data);
3784 if (as->parms[1].items) {
3785 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3787 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3788 as->parms[1].items->data);
3791 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3793 PrintError("", code);
3796 "vos : partition %s does not exist on the server\n",
3797 as->parms[1].items->data);
3805 if (as->parms[2].items) {
3806 flags |= 2; /* don't update */
3808 code = UV_SyncServer(tserver, pnum, flags, 0 /*unused */ );
3810 PrintDiagnostics("syncserv", code);
3814 MapPartIdIntoName(pnum, part);
3815 fprintf(STDOUT, "Server %s partition %s synchronized with VLDB\n",
3816 as->parms[0].items->data, part);
3818 fprintf(STDOUT, "Server %s synchronized with VLDB\n",
3819 as->parms[0].items->data);
3825 VolumeInfoCmd(char *name)
3827 struct nvldbentry entry;
3830 /* The vlserver will handle names with the .readonly
3831 * and .backup extension as well as volume ids.
3833 vcode = VLDB_GetEntryByName(name, &entry);
3835 PrintError("", vcode);
3838 MapHostToNetwork(&entry);
3839 EnumerateEntry(&entry);
3841 /* Defect #3027: grubby check to handle locked volume.
3842 * If VLOP_ALLOPERS is set, the entry is locked.
3843 * Leave this routine as is, but put in correct check.
3845 if (entry.flags & VLOP_ALLOPERS)
3846 fprintf(STDOUT, " Volume is currently LOCKED \n");
3852 VolumeZap(register struct cmd_syndesc *as, void *arock)
3854 struct nvldbentry entry;
3855 afs_uint32 volid, zapbackupid = 0, backupid = 0;
3856 afs_int32 code, server, part, err;
3858 if (as->parms[3].items) {
3859 /* force flag is on, use the other version */
3860 return NukeVolume(as);
3863 if (as->parms[4].items) {
3867 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3870 PrintError("", err);
3872 fprintf(STDERR, "vos: can't find volume '%s'\n",
3873 as->parms[2].items->data);
3876 part = volutil_GetPartitionID(as->parms[1].items->data);
3878 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3879 as->parms[1].items->data);
3882 server = GetServer(as->parms[0].items->data);
3884 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3885 as->parms[0].items->data);
3888 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
3890 PrintError("", code);
3893 "vos : partition %s does not exist on the server\n",
3894 as->parms[1].items->data);
3897 code = VLDB_GetEntryByID(volid, -1, &entry);
3899 if (volid == entry.volumeId[RWVOL])
3900 backupid = entry.volumeId[BACKVOL];
3902 "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
3903 (unsigned long)volid);
3906 volintInfo *pntr = (volintInfo *) 0;
3909 code = UV_ListOneVolume(server, part, volid, &pntr);
3911 if (volid == pntr->parentID)
3912 backupid = pntr->backupID;
3918 code = UV_VolumeZap(server, part, backupid);
3920 PrintDiagnostics("zap", code);
3923 fprintf(STDOUT, "Backup Volume %lu deleted\n",
3924 (unsigned long)backupid);
3927 code = UV_VolumeZap(server, part, volid);
3929 PrintDiagnostics("zap", code);
3932 fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
3938 VolserStatus(register struct cmd_syndesc *as, void *arock)
3940 afs_int32 server, code;
3941 transDebugInfo *pntr, *oldpntr;
3947 server = GetServer(as->parms[0].items->data);
3949 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3950 as->parms[0].items->data);
3953 code = UV_VolserStatus(server, &pntr, &count);
3955 PrintDiagnostics("status", code);
3960 fprintf(STDOUT, "No active transactions on %s\n",
3961 as->parms[0].items->data);
3963 fprintf(STDOUT, "Total transactions: %d\n", count);
3965 for (i = 0; i < count; i++) {
3966 /*print out the relevant info */
3967 fprintf(STDOUT, "--------------------------------------\n");
3969 fprintf(STDOUT, "transaction: %lu created: %s",
3970 (unsigned long)pntr->tid, ctime(&t));
3971 if (pntr->returnCode) {
3972 fprintf(STDOUT, "returnCode: %lu\n",
3973 (unsigned long)pntr->returnCode);
3976 fprintf(STDOUT, "attachFlags: ");
3977 switch (pntr->iflags) {
3979 fprintf(STDOUT, "offline ");
3982 fprintf(STDOUT, "busy ");
3985 fprintf(STDOUT, "readonly ");
3988 fprintf(STDOUT, "create ");
3991 fprintf(STDOUT, "create volid ");
3994 fprintf(STDOUT, "\n");
3997 fprintf(STDOUT, "volumeStatus: ");
3998 switch (pntr->vflags) {
3999 case VTDeleteOnSalvage:
4000 fprintf(STDOUT, "deleteOnSalvage ");
4001 case VTOutOfService:
4002 fprintf(STDOUT, "outOfService ");
4004 fprintf(STDOUT, "deleted ");
4006 fprintf(STDOUT, "\n");
4009 fprintf(STDOUT, "transactionFlags: ");
4010 fprintf(STDOUT, "delete\n");
4012 MapPartIdIntoName(pntr->partition, pname);
4013 fprintf(STDOUT, "volume: %lu partition: %s procedure: %s\n",
4014 (unsigned long)pntr->volid, pname, pntr->lastProcName);
4015 if (pntr->callValid) {
4017 "packetRead: %lu lastReceiveTime: %d packetSend: %lu lastSendTime: %d\n",
4018 (unsigned long)pntr->readNext, pntr->lastReceiveTime,
4019 (unsigned long)pntr->transmitNext, pntr->lastSendTime);
4022 fprintf(STDOUT, "--------------------------------------\n");
4023 fprintf(STDOUT, "\n");
4031 RenameVolume(register struct cmd_syndesc *as, void *arock)
4033 afs_int32 code1, code2, code;
4034 struct nvldbentry entry;
4036 code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
4038 fprintf(STDERR, "vos: Could not find entry for volume %s\n",
4039 as->parms[0].items->data);
4042 code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
4043 if ((!code1) && (!code2)) { /*the newname already exists */
4044 fprintf(STDERR, "vos: volume %s already exists\n",
4045 as->parms[1].items->data);
4049 if (code1 && code2) {
4050 fprintf(STDERR, "vos: Could not find entry for volume %s or %s\n",
4051 as->parms[0].items->data, as->parms[1].items->data);
4054 if (!VolNameOK(as->parms[0].items->data)) {
4056 "Illegal volume name %s, should not end in .readonly or .backup\n",
4057 as->parms[0].items->data);
4060 if (!ISNAMEVALID(as->parms[1].items->data)) {
4062 "vos: the new volume name %s exceeds the size limit of %d\n",
4063 as->parms[1].items->data, VOLSER_OLDMAXVOLNAME - 10);
4066 if (!VolNameOK(as->parms[1].items->data)) {
4068 "Illegal volume name %s, should not end in .readonly or .backup\n",
4069 as->parms[1].items->data);
4072 if (IsNumeric(as->parms[1].items->data)) {
4073 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
4074 as->parms[1].items->data);
4077 MapHostToNetwork(&entry);
4079 UV_RenameVolume(&entry, as->parms[0].items->data,
4080 as->parms[1].items->data);
4082 PrintDiagnostics("rename", code);
4085 fprintf(STDOUT, "Renamed volume %s to %s\n", as->parms[0].items->data,
4086 as->parms[1].items->data);
4091 GetVolumeInfo(afs_uint32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *voltype,
4092 struct nvldbentry *rentry)
4097 vcode = VLDB_GetEntryByID(volid, -1, rentry);
4100 "Could not fetch the entry for volume %lu from VLDB \n",
4101 (unsigned long)volid);
4102 PrintError("", vcode);
4105 MapHostToNetwork(rentry);
4106 if (volid == rentry->volumeId[ROVOL]) {
4108 for (i = 0; i < rentry->nServers; i++) {
4109 if ((index == -1) && (rentry->serverFlags[i] & ITSROVOL)
4110 && !(rentry->serverFlags[i] & RO_DONTUSE))
4115 "RO volume is not found in VLDB entry for volume %lu\n",
4116 (unsigned long)volid);
4120 *server = rentry->serverNumber[index];
4121 *part = rentry->serverPartition[index];
4125 index = Lp_GetRwIndex(rentry);
4128 "RW Volume is not found in VLDB entry for volume %lu\n",
4129 (unsigned long)volid);
4132 if (volid == rentry->volumeId[RWVOL]) {
4134 *server = rentry->serverNumber[index];
4135 *part = rentry->serverPartition[index];
4138 if (volid == rentry->volumeId[BACKVOL]) {
4140 *server = rentry->serverNumber[index];
4141 *part = rentry->serverPartition[index];
4145 "unexpected volume type for volume %lu\n",
4146 (unsigned long)volid);
4151 DeleteEntry(register struct cmd_syndesc *as, void *arock)
4153 afs_int32 apart = 0;
4156 struct VldbListByAttributes attributes;
4157 nbulkentries arrayEntries;
4158 register struct nvldbentry *vllist;
4159 struct cmd_item *itp;
4162 char prefix[VOLSER_MAXVOLNAME + 1];
4164 afs_int32 totalBack = 0, totalFail = 0, err;
4166 if (as->parms[0].items) { /* -id */
4167 if (as->parms[1].items || as->parms[2].items || as->parms[3].items) {
4169 "You cannot use -server, -partition, or -prefix with the -id argument\n");
4172 for (itp = as->parms[0].items; itp; itp = itp->next) {
4173 avolid = vsu_GetVolumeID(itp->data, cstruct, &err);
4176 PrintError("", err);
4178 fprintf(STDERR, "vos: can't find volume '%s'\n",
4182 if (as->parms[4].items) { /* -noexecute */
4183 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4188 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4190 fprintf(STDERR, "Could not delete entry for volume %s\n",
4193 "You must specify a RW volume name or ID "
4194 "(the entire VLDB entry will be deleted)\n");
4195 PrintError("", vcode);
4201 fprintf(STDOUT, "Deleted %d VLDB entries\n", totalBack);
4205 if (!as->parms[1].items && !as->parms[2].items && !as->parms[3].items) {
4206 fprintf(STDERR, "You must specify an option\n");
4210 /* Zero out search attributes */
4211 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4213 if (as->parms[1].items) { /* -prefix */
4214 strncpy(prefix, as->parms[1].items->data, VOLSER_MAXVOLNAME);
4216 if (!as->parms[2].items && !as->parms[3].items) { /* a single entry only */
4218 "You must provide -server with the -prefix argument\n");
4223 if (as->parms[2].items) { /* -server */
4225 aserver = GetServer(as->parms[2].items->data);
4227 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4228 as->parms[2].items->data);
4231 attributes.server = ntohl(aserver);
4232 attributes.Mask |= VLLIST_SERVER;
4235 if (as->parms[3].items) { /* -partition */
4236 if (!as->parms[2].items) {
4238 "You must provide -server with the -partition argument\n");
4241 apart = volutil_GetPartitionID(as->parms[3].items->data);
4243 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4244 as->parms[3].items->data);
4247 attributes.partition = apart;
4248 attributes.Mask |= VLLIST_PARTITION;
4251 /* Print status line of what we are doing */
4252 fprintf(STDOUT, "Deleting VLDB entries for ");
4253 if (as->parms[2].items) {
4254 fprintf(STDOUT, "server %s ", as->parms[2].items->data);
4256 if (as->parms[3].items) {
4258 MapPartIdIntoName(apart, pname);
4259 fprintf(STDOUT, "partition %s ", pname);
4262 fprintf(STDOUT, "which are prefixed with %s ", prefix);
4264 fprintf(STDOUT, "\n");
4267 /* Get all the VLDB entries on a server and/or partition */
4268 memset(&arrayEntries, 0, sizeof(arrayEntries));
4269 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4271 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4272 PrintError("", vcode);
4276 /* Process each entry */
4277 for (j = 0; j < nentries; j++) {
4278 vllist = &arrayEntries.nbulkentries_val[j];
4280 /* It only deletes the RW volumes */
4281 if (strncmp(vllist->name, prefix, strlen(prefix))) {
4284 "Omitting to delete %s due to prefix %s mismatch\n",
4285 vllist->name, prefix);
4292 if (as->parms[4].items) { /* -noexecute */
4293 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4299 /* Only matches the RW volume name */
4300 avolid = vllist->volumeId[RWVOL];
4301 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4303 fprintf(STDOUT, "Could not delete VDLB entry for %s\n",
4306 PrintError("", vcode);
4311 fprintf(STDOUT, "Deleted VLDB entry for %s \n", vllist->name);
4316 fprintf(STDOUT, "----------------------\n");
4318 "Total VLDB entries deleted: %lu; failed to delete: %lu\n",
4319 (unsigned long)totalBack, (unsigned long)totalFail);
4320 if (arrayEntries.nbulkentries_val)
4321 free(arrayEntries.nbulkentries_val);
4327 CompareVldbEntryByName(const void *p1, const void *p2)
4329 struct nvldbentry *arg1, *arg2;
4331 arg1 = (struct nvldbentry *)p1;
4332 arg2 = (struct nvldbentry *)p2;
4333 return (strcmp(arg1->name, arg2->name));
4337 static int CompareVldbEntry(char *p1, char *p2)
4339 struct nvldbentry *arg1,*arg2;
4342 char comp1[100],comp2[100];
4343 char temp1[20],temp2[20];
4345 arg1 = (struct nvldbentry *)p1;
4346 arg2 = (struct nvldbentry *)p2;
4350 for(i = 0; i < arg1->nServers; i++)
4351 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
4352 for(i = 0; i < arg2->nServers; i++)
4353 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
4354 if(pos1 == -1 || pos2 == -1){
4358 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
4359 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
4360 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
4361 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
4362 strcat(comp1,temp1);
4363 strcat(comp2,temp2);
4364 strcat(comp1,arg1->name);
4365 strcat(comp1,arg2->name);
4366 return(strcmp(comp1,comp2));
4372 ListVLDB(struct cmd_syndesc *as, void *arock)
4375 afs_int32 aserver, code;
4377 struct VldbListByAttributes attributes;
4378 nbulkentries arrayEntries;
4379 struct nvldbentry *vllist, *tarray = 0, *ttarray;
4380 afs_int32 centries, nentries = 0;
4381 afs_int32 tarraysize = 0;
4382 afs_int32 parraysize;
4385 int quiet, sort, lock;
4386 afs_int32 thisindex, nextindex;
4391 attributes.Mask = 0;
4392 lock = (as->parms[3].items ? 1 : 0); /* -lock flag */
4393 quiet = (as->parms[4].items ? 1 : 0); /* -quit flag */
4394 sort = (as->parms[5].items ? 0 : 1); /* -nosort flag */
4396 /* If the volume name is given, Use VolumeInfoCmd to look it up
4397 * and not ListAttributes.
4399 if (as->parms[0].items) {
4402 "vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
4405 code = VolumeInfoCmd(as->parms[0].items->data);
4407 PrintError("", code);
4413 /* Server specified */
4414 if (as->parms[1].items) {
4415 aserver = GetServer(as->parms[1].items->data);
4417 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4418 as->parms[1].items->data);
4421 attributes.server = ntohl(aserver);
4422 attributes.Mask |= VLLIST_SERVER;
4425 /* Partition specified */
4426 if (as->parms[2].items) {
4427 apart = volutil_GetPartitionID(as->parms[2].items->data);
4429 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4430 as->parms[2].items->data);
4433 attributes.partition = apart;
4434 attributes.Mask |= VLLIST_PARTITION;
4438 attributes.Mask |= VLLIST_FLAG;
4439 attributes.flag = VLOP_ALLOPERS;
4442 /* Print header information */
4444 MapPartIdIntoName(apart, pname);
4445 fprintf(STDOUT, "VLDB entries for %s %s%s%s %s\n",
4446 (as->parms[1].items ? "server" : "all"),
4447 (as->parms[1].items ? as->parms[1].items->data : "servers"),
4448 (as->parms[2].items ? " partition " : ""),
4449 (as->parms[2].items ? pname : ""),
4450 (lock ? "which are locked:" : ""));
4453 for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
4454 memset(&arrayEntries, 0, sizeof(arrayEntries));
4459 VLDB_ListAttributesN2(&attributes, 0, thisindex, ¢ries,
4460 &arrayEntries, &nextindex);
4461 if (vcode == RXGEN_OPCODE) {
4462 /* Vlserver not running with ListAttributesN2. Fall back */
4464 VLDB_ListAttributes(&attributes, ¢ries, &arrayEntries);
4468 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4469 PrintError("", vcode);
4472 nentries += centries;
4474 /* We don't sort, so just print the entries now */
4476 for (j = 0; j < centries; j++) { /* process each entry */
4477 vllist = &arrayEntries.nbulkentries_val[j];
4478 MapHostToNetwork(vllist);
4479 EnumerateEntry(vllist);
4481 if (vllist->flags & VLOP_ALLOPERS)
4482 fprintf(STDOUT, " Volume is currently LOCKED \n");
4486 /* So we sort. First we must collect all the entries and keep
4489 else if (centries > 0) {
4491 /* steal away the first bulk entries array */
4492 tarray = (struct nvldbentry *)arrayEntries.nbulkentries_val;
4493 tarraysize = centries * sizeof(struct nvldbentry);
4494 arrayEntries.nbulkentries_val = 0;
4496 /* Grow the tarray to keep the extra entries */
4497 parraysize = (centries * sizeof(struct nvldbentry));
4499 (struct nvldbentry *)realloc(tarray,
4500 tarraysize + parraysize);
4503 "Could not allocate enough space for the VLDB entries\n");
4509 memcpy(((char *)tarray) + tarraysize,
4510 (char *)arrayEntries.nbulkentries_val, parraysize);
4511 tarraysize += parraysize;
4515 /* Free the bulk array */
4516 if (arrayEntries.nbulkentries_val) {
4517 free(arrayEntries.nbulkentries_val);
4518 arrayEntries.nbulkentries_val = 0;
4522 /* Here is where we now sort all the entries and print them */
4523 if (sort && (nentries > 0)) {
4524 qsort((char *)tarray, nentries, sizeof(struct nvldbentry),
4525 CompareVldbEntryByName);
4526 for (vllist = tarray, j = 0; j < nentries; j++, vllist++) {
4527 MapHostToNetwork(vllist);
4528 EnumerateEntry(vllist);
4530 if (vllist->flags & VLOP_ALLOPERS)
4531 fprintf(STDOUT, " Volume is currently LOCKED \n");
4537 fprintf(STDOUT, "\nTotal entries: %lu\n", (unsigned long)nentries);
4544 BackSys(register struct cmd_syndesc *as, void *arock)
4547 afs_int32 apart = 0;
4548 afs_int32 aserver = 0, code, aserver1, apart1;
4550 struct VldbListByAttributes attributes;
4551 nbulkentries arrayEntries;
4552 register struct nvldbentry *vllist;
4556 int seenprefix, seenxprefix, exclude, ex, exp, noaction;
4557 afs_int32 totalBack = 0;
4558 afs_int32 totalFail = 0;
4562 struct cmd_item *ti;
4564 #ifndef HAVE_POSIX_REGEX
4568 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4569 attributes.Mask = 0;
4571 seenprefix = (as->parms[0].items ? 1 : 0);
4572 exclude = (as->parms[3].items ? 1 : 0);
4573 seenxprefix = (as->parms[4].items ? 1 : 0);
4574 noaction = (as->parms[5].items ? 1 : 0);
4576 if (as->parms[1].items) { /* -server */
4577 aserver = GetServer(as->parms[1].items->data);
4579 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4580 as->parms[1].items->data);
4583 attributes.server = ntohl(aserver);
4584 attributes.Mask |= VLLIST_SERVER;
4587 if (as->parms[2].items) { /* -partition */
4588 apart = volutil_GetPartitionID(as->parms[2].items->data);
4590 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4591 as->parms[2].items->data);
4594 attributes.partition = apart;
4595 attributes.Mask |= VLLIST_PARTITION;
4598 /* Check to make sure the prefix and xprefix expressions compile ok */
4600 for (ti = as->parms[0].items; ti; ti = ti->next) {
4601 if (strncmp(ti->data, "^", 1) == 0) {
4602 #ifdef HAVE_POSIX_REGEX
4606 code = regcomp(&re, ti->data, REG_NOSUB);
4608 regerror(code, &re, errbuf, sizeof errbuf);
4610 "Unrecognizable -prefix regular expression: '%s': %s\n",
4616 ccode = (char *)re_comp(ti->data);
4619 "Unrecognizable -prefix regular expression: '%s': %s\n",
4628 for (ti = as->parms[4].items; ti; ti = ti->next) {
4629 if (strncmp(ti->data, "^", 1) == 0) {
4630 #ifdef HAVE_POSIX_REGEX
4634 code = regcomp(&re, ti->data, REG_NOSUB);
4636 regerror(code, &re, errbuf, sizeof errbuf);
4638 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4644 ccode = (char *)re_comp(ti->data);
4647 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4656 memset(&arrayEntries, 0, sizeof(arrayEntries)); /* initialize to hint the stub to alloc space */
4657 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4659 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4660 PrintError("", vcode);
4664 if (as->parms[1].items || as->parms[2].items || verbose) {
4665 fprintf(STDOUT, "%s up volumes",
4666 (noaction ? "Would have backed" : "Backing"));
4668 if (as->parms[1].items) {
4669 fprintf(STDOUT, " on server %s", as->parms[1].items->data);
4670 } else if (as->parms[2].items) {
4671 fprintf(STDOUT, " for all servers");
4674 if (as->parms[2].items) {
4675 MapPartIdIntoName(apart, pname);
4676 fprintf(STDOUT, " partition %s", pname);
4679 if (seenprefix || (!seenprefix && seenxprefix)) {
4680 ti = (seenprefix ? as->parms[0].items : as->parms[4].items);
4681 ex = (seenprefix ? exclude : !exclude);
4682 exp = (strncmp(ti->data, "^", 1) == 0);
4683 fprintf(STDOUT, " which %smatch %s '%s'", (ex ? "do not " : ""),
4684 (exp ? "expression" : "prefix"), ti->data);
4685 for (ti = ti->next; ti; ti = ti->next) {
4686 exp = (strncmp(ti->data, "^", 1) == 0);
4687 printf(" %sor %s '%s'", (ex ? "n" : ""),
4688 (exp ? "expression" : "prefix"), ti->data);
4692 if (seenprefix && seenxprefix) {
4693 ti = as->parms[4].items;
4694 exp = (strncmp(ti->data, "^", 1) == 0);
4695 fprintf(STDOUT, " %swhich match %s '%s'",
4696 (exclude ? "adding those " : "removing those "),
4697 (exp ? "expression" : "prefix"), ti->data);
4698 for (ti = ti->next; ti; ti = ti->next) {
4699 exp = (strncmp(ti->data, "^", 1) == 0);
4700 printf(" or %s '%s'", (exp ? "expression" : "prefix"),
4704 fprintf(STDOUT, " .. ");
4706 fprintf(STDOUT, "\n");
4710 for (j = 0; j < nentries; j++) { /* process each vldb entry */
4711 vllist = &arrayEntries.nbulkentries_val[j];
4714 for (ti = as->parms[0].items; ti; ti = ti->next) {
4715 if (strncmp(ti->data, "^", 1) == 0) {
4716 #ifdef HAVE_POSIX_REGEX
4720 /* XXX -- should just do the compile once! */
4721 code = regcomp(&re, ti->data, REG_NOSUB);
4723 regerror(code, &re, errbuf, sizeof errbuf);
4725 "Error in -prefix regular expression: '%s': %s\n",
4729 match = (regexec(&re, vllist->name, 0, NULL, 0) == 0);
4732 ccode = (char *)re_comp(ti->data);
4735 "Error in -prefix regular expression: '%s': %s\n",
4739 match = (re_exec(vllist->name) == 1);
4743 (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4753 /* Without the -exclude flag: If it matches the prefix, then
4754 * check if we want to exclude any from xprefix.
4755 * With the -exclude flag: If it matches the prefix, then
4756 * check if we want to add any from xprefix.
4758 if (match && seenxprefix) {
4759 for (ti = as->parms[4].items; ti; ti = ti->next) {
4760 if (strncmp(ti->data, "^", 1) == 0) {
4761 #ifdef HAVE_POSIX_REGEX
4765 /* XXX -- should just do the compile once! */
4766 code = regcomp(&re, ti->data, REG_NOSUB);
4768 regerror(code, &re, errbuf, sizeof errbuf);
4770 "Error in -xprefix regular expression: '%s': %s\n",
4774 if (regexec(&re, vllist->name, 0, NULL, 0) == 0)
4778 ccode = (char *)re_comp(ti->data);
4781 "Error in -xprefix regular expression: '%s': %s\n",
4785 if (re_exec(vllist->name) == 1) {
4791 if (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4801 match = !match; /* -exclude will reverse the match */
4803 continue; /* Skip if no match */
4805 /* Print list of volumes to backup */
4807 fprintf(STDOUT, " %s\n", vllist->name);
4811 if (!(vllist->flags & RW_EXISTS)) {
4814 "Omitting to backup %s since RW volume does not exist \n",
4816 fprintf(STDOUT, "\n");
4822 avolid = vllist->volumeId[RWVOL];
4823 MapHostToNetwork(vllist);
4824 GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
4825 if (aserver1 == -1 || apart1 == -1) {
4826 fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n",
4832 same = VLDB_IsSameAddrs(aserver, aserver1, &error);
4835 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4841 if ((aserver && !same) || (apart && (apart != apart1))) {
4844 "Omitting to backup %s since the RW is in a different location\n",
4850 time_t now = time(0);
4851 fprintf(STDOUT, "Creating backup volume for %s on %s",
4852 vllist->name, ctime(&now));
4856 code = UV_BackupVolume(aserver1, apart1, avolid);
4858 fprintf(STDOUT, "Could not backup %s\n", vllist->name);
4864 fprintf(STDOUT, "\n");
4866 } /* process each vldb entry */
4867 fprintf(STDOUT, "done\n");
4868 fprintf(STDOUT, "Total volumes backed up: %lu; failed to backup: %lu\n",
4869 (unsigned long)totalBack, (unsigned long)totalFail);
4871 if (arrayEntries.nbulkentries_val)
4872 free(arrayEntries.nbulkentries_val);
4877 UnlockVLDB(register struct cmd_syndesc *as, void *arock)
4880 afs_int32 aserver = 0;
4883 struct VldbListByAttributes attributes;
4884 nbulkentries arrayEntries;
4885 register struct nvldbentry *vllist;
4894 attributes.Mask = 0;
4896 if (as->parms[0].items) { /* server specified */
4897 aserver = GetServer(as->parms[0].items->data);
4899 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4900 as->parms[0].items->data);
4903 attributes.server = ntohl(aserver);
4904 attributes.Mask |= VLLIST_SERVER;
4906 if (as->parms[1].items) { /* partition specified */
4907 apart = volutil_GetPartitionID(as->parms[1].items->data);
4909 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4910 as->parms[1].items->data);
4913 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4915 PrintError("", code);
4918 "vos : partition %s does not exist on the server\n",
4919 as->parms[1].items->data);
4922 attributes.partition = apart;
4923 attributes.Mask |= VLLIST_PARTITION;
4925 attributes.flag = VLOP_ALLOPERS;
4926 attributes.Mask |= VLLIST_FLAG;
4927 memset(&arrayEntries, 0, sizeof(arrayEntries)); /*initialize to hint the stub to alloc space */
4928 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4930 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4931 PrintError("", vcode);
4934 for (j = 0; j < nentries; j++) { /* process each entry */
4935 vllist = &arrayEntries.nbulkentries_val[j];
4936 volid = vllist->volumeId[RWVOL];
4938 ubik_VL_ReleaseLock(cstruct, 0, volid, -1,
4939 LOCKREL_OPCODE | LOCKREL_AFSID |
4942 fprintf(STDERR, "Could not unlock entry for volume %s\n",
4944 PrintError("", vcode);
4949 MapPartIdIntoName(apart, pname);
4952 "Could not lock %lu VLDB entries of %lu locked entries\n",
4953 (unsigned long)totalE, (unsigned long)nentries);
4955 if (as->parms[0].items) {
4957 "Unlocked all the VLDB entries for volumes on server %s ",
4958 as->parms[0].items->data);
4959 if (as->parms[1].items) {
4960 MapPartIdIntoName(apart, pname);
4961 fprintf(STDOUT, "partition %s\n", pname);
4963 fprintf(STDOUT, "\n");
4965 } else if (as->parms[1].items) {
4966 MapPartIdIntoName(apart, pname);
4968 "Unlocked all the VLDB entries for volumes on partition %s on all servers\n",
4973 if (arrayEntries.nbulkentries_val)
4974 free(arrayEntries.nbulkentries_val);
4979 PrintInt64Size(afs_uint64 in)
4981 register afs_uint32 hi, lo;
4982 register char * units;
4983 static char output[16];
4985 SplitInt64(in,hi,lo);
4989 } else if (!(hi & 0xFFFFFC00)) {
4991 lo = (hi << 22) | (lo >> 10);
4992 } else if (!(hi & 0xFFF00000)) {
4994 lo = (hi << 12) | (lo >> 20);
4995 } else if (!(hi & 0xC0000000)) {
4997 lo = (hi << 2) | (lo >> 30);
5002 sprintf(output,"%u %s", lo, units);
5007 PartitionInfo(register struct cmd_syndesc *as, void *arock)
5010 afs_int32 aserver, code;
5012 struct diskPartition64 partition;
5013 struct partList dummyPartList;
5015 int printSummary=0, sumPartitions=0;
5016 afs_uint64 sumFree, sumStorage;
5019 ZeroInt64(sumStorage);
5021 aserver = GetServer(as->parms[0].items->data);
5023 fprintf(STDERR, "vos: server '%s' not found in host table\n",
5024 as->parms[0].items->data);
5027 if (as->parms[1].items) {
5028 apart = volutil_GetPartitionID(as->parms[1].items->data);
5030 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5031 as->parms[1].items->data);
5034 dummyPartList.partId[0] = apart;
5035 dummyPartList.partFlags[0] = PARTVALID;
5038 if (as->parms[2].items) {
5042 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
5044 PrintError("", code);
5047 "vos : partition %s does not exist on the server\n",
5048 as->parms[1].items->data);
5052 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
5054 PrintDiagnostics("listpart", code);
5058 for (i = 0; i < cnt; i++) {
5059 if (dummyPartList.partFlags[i] & PARTVALID) {
5060 MapPartIdIntoName(dummyPartList.partId[i], pname);
5061 code = UV_PartitionInfo64(aserver, pname, &partition);
5063 fprintf(STDERR, "Could not get information on partition %s\n",
5065 PrintError("", code);
5069 "Free space on partition %s: %" AFS_INT64_FMT " K blocks out of total %" AFS_INT64_FMT "\n",
5070 pname, partition.free, partition.minFree);
5072 AddUInt64(sumFree,partition.free,&sumFree);
5073 AddUInt64(sumStorage,partition.minFree,&sumStorage);
5078 "Summary: %s free out of ",
5079 PrintInt64Size(sumFree));
5081 "%s on %d partitions\n",
5082 PrintInt64Size(sumStorage),
5089 ChangeAddr(register struct cmd_syndesc *as, void *arock)
5091 afs_int32 ip1, ip2, vcode;
5094 ip1 = GetServer(as->parms[0].items->data);
5096 fprintf(STDERR, "vos: invalid host address\n");
5100 if ((as->parms[1].items && as->parms[2].items)
5101 || (!as->parms[1].items && !as->parms[2].items)) {
5103 "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
5107 if (as->parms[1].items) {
5108 ip2 = GetServer(as->parms[1].items->data);
5110 fprintf(STDERR, "vos: invalid host address\n");
5114 /* Play a trick here. If we are removing an address, ip1 will be -1
5115 * and ip2 will be the original address. This switch prevents an
5116 * older revision vlserver from removing the IP address.
5123 vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
5126 fprintf(STDERR, "Could not remove server %s from the VLDB\n",
5127 as->parms[0].items->data);
5128 if (vcode == VL_NOENT) {
5130 "vlserver does not support the remove flag or ");
5133 fprintf(STDERR, "Could not change server %s to server %s\n",
5134 as->parms[0].items->data, as->parms[1].items->data);
5136 PrintError("", vcode);
5141 fprintf(STDOUT, "Removed server %s from the VLDB\n",
5142 as->parms[0].items->data);
5144 fprintf(STDOUT, "Changed server %s to server %s\n",
5145 as->parms[0].items->data, as->parms[1].items->data);
5151 print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
5156 struct VLCallBack vlcb;
5159 ListAddrByAttributes m_attrs;
5160 afs_int32 m_nentries, *m_addrp;
5161 afs_int32 base, index;
5165 afsUUID_to_string(m_uuid, buf, sizeof(buf));
5166 printf("UUID: %s\n", buf);
5169 /* print out the list of all the server */
5170 addrp = (afs_int32 *) addrs->bulkaddrs_val;
5171 for (i = 0; i < nentries; i++, addrp++) {
5172 /* If it is a multihomed address, then we will need to
5173 * get the addresses for this multihomed server from
5174 * the vlserver and print them.
5176 if (((*addrp & 0xff000000) == 0xff000000) && ((*addrp) & 0xffff)) {
5177 /* Get the list of multihomed fileservers */
5178 base = (*addrp >> 16) & 0xff;
5179 index = (*addrp) & 0xffff;
5181 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
5182 && (index <= VL_MHSRV_PERBLK)) {
5183 m_attrs.Mask = VLADDR_INDEX;
5184 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
5186 m_addrs.bulkaddrs_val = 0;
5187 m_addrs.bulkaddrs_len = 0;
5189 ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, m_uuid,
5190 (afs_int32 *)&vlcb, &m_nentries, &m_addrs);
5193 "vos: could not list the multi-homed server addresses\n");
5194 PrintError("", vcode);
5197 /* Print the list */
5198 m_addrp = (afs_int32 *) m_addrs.bulkaddrs_val;
5199 for (j = 0; j < m_nentries; j++, m_addrp++) {
5200 *m_addrp = htonl(*m_addrp);
5203 printf("%s ", afs_inet_ntoa_r(*m_addrp, hoststr));
5205 printf("%s ", hostutil_GetNameByINet(*m_addrp));
5209 printf("<unknown>\n");
5218 /* Otherwise, it is a non-multihomed entry and contains
5219 * the IP address of the server - print it.
5221 *addrp = htonl(*addrp);
5224 printf("%s\n", afs_inet_ntoa_r(*addrp, hoststr));
5226 printf("%s\n", hostutil_GetNameByINet(*addrp));
5237 ListAddrs(register struct cmd_syndesc *as, void *arock)
5240 afs_int32 i, printuuid = 0;
5241 struct VLCallBack vlcb;
5244 ListAddrByAttributes m_attrs;
5245 afsUUID m_uuid, askuuid;
5246 afs_int32 m_nentries;
5248 memset(&m_attrs, 0, sizeof(struct ListAddrByAttributes));
5249 m_attrs.Mask = VLADDR_INDEX;
5251 memset(&m_addrs, 0, sizeof(bulkaddrs));
5252 memset(&askuuid, 0, sizeof(afsUUID));
5253 if (as->parms[0].items) {
5255 if (afsUUID_from_string(as->parms[0].items->data, &askuuid) < 0) {
5256 fprintf(STDERR, "vos: invalid UUID '%s'\n",
5257 as->parms[0].items->data);
5260 m_attrs.Mask = VLADDR_UUID;
5261 m_attrs.uuid = askuuid;
5263 if (as->parms[1].items) {
5267 he = hostutil_GetHostByName((char *)as->parms[1].items->data);
5269 fprintf(STDERR, "vos: Can't get host info for '%s'\n",
5270 as->parms[1].items->data);
5273 memcpy(&saddr, he->h_addr, 4);
5274 m_attrs.Mask = VLADDR_IPADDR;
5275 m_attrs.ipaddr = ntohl(saddr);
5277 if (as->parms[2].items) {
5281 m_addrs.bulkaddrs_val = 0;
5282 m_addrs.bulkaddrs_len = 0;
5285 ubik_Call_New(VL_GetAddrs, cstruct, 0, 0, 0, &vlcb, &nentries,
5288 fprintf(STDERR, "vos: could not list the server addresses\n");
5289 PrintError("", vcode);
5294 m_addrs.bulkaddrs_val = 0;
5295 m_addrs.bulkaddrs_len = 0;
5301 ubik_Call_New(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
5302 &vlcb, &m_nentries, &m_addrs);
5304 if (vcode == VL_NOENT) {
5305 if (m_attrs.Mask == VLADDR_UUID) {
5306 fprintf(STDERR, "vos: no entry for UUID '%s' found in VLDB\n",
5307 as->parms[0].items->data);
5309 } else if (m_attrs.Mask == VLADDR_IPADDR) {
5310 fprintf(STDERR, "vos: no entry for host '%s' [0x%08x] found in VLDB\n",
5311 as->parms[1].items->data, m_attrs.ipaddr);
5320 if (vcode == VL_INDEXERANGE) {
5325 fprintf(STDERR, "vos: could not list the server addresses\n");
5326 PrintError("", vcode);
5330 print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid);
5333 if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
5341 LockEntry(register struct cmd_syndesc *as, void *arock)
5344 afs_int32 vcode, err;
5346 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5349 PrintError("", err);
5351 fprintf(STDERR, "vos: can't find volume '%s'\n",
5352 as->parms[0].items->data);
5355 vcode = ubik_VL_SetLock(cstruct, 0, avolid, -1, VLOP_DELETE);
5357 fprintf(STDERR, "Could not lock VLDB entry for volume %s\n",
5358 as->parms[0].items->data);
5359 PrintError("", vcode);
5362 fprintf(STDOUT, "Locked VLDB entry for volume %s\n",
5363 as->parms[0].items->data);
5368 ConvertRO(register struct cmd_syndesc *as, void *arock)
5370 afs_int32 partition = -1;
5372 afs_int32 server, code, i, same;
5373 struct nvldbentry entry, storeEntry;
5375 afs_int32 rwindex = 0;
5376 afs_int32 rwserver = 0;
5377 afs_int32 rwpartition = 0;
5378 afs_int32 roindex = 0;
5379 afs_int32 roserver = 0;
5380 afs_int32 ropartition = 0;
5382 struct rx_connection *aconn;
5385 server = GetServer(as->parms[0].items->data);
5387 fprintf(STDERR, "vos: host '%s' not found in host table\n",
5388 as->parms[0].items->data);
5391 partition = volutil_GetPartitionID(as->parms[1].items->data);
5392 if (partition < 0) {
5393 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5394 as->parms[1].items->data);
5397 if (!IsPartValid(partition, server, &code)) {
5399 PrintError("", code);
5402 "vos : partition %s does not exist on the server\n",
5403 as->parms[1].items->data);
5406 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &code);
5409 PrintError("", code);
5411 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
5412 as->parms[0].items->data);
5415 if (as->parms[3].items)
5418 vcode = VLDB_GetEntryByID(volid, -1, &entry);
5421 "Could not fetch the entry for volume %lu from VLDB\n",
5422 (unsigned long)volid);
5423 PrintError("convertROtoRW", code);
5427 /* use RO volid even if user specified RW or BK volid */
5429 if (volid != entry.volumeId[ROVOL])
5430 volid = entry.volumeId[ROVOL];
5432 MapHostToNetwork(&entry);
5433 for (i = 0; i < entry.nServers; i++) {
5434 if (entry.serverFlags[i] & ITSRWVOL) {
5436 rwserver = entry.serverNumber[i];
5437 rwpartition = entry.serverPartition[i];
5439 if (entry.serverFlags[i] & ITSROVOL) {
5440 same = VLDB_IsSameAddrs(server, entry.serverNumber[i], &code);
5443 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
5449 roserver = entry.serverNumber[i];
5450 ropartition = entry.serverPartition[i];
5456 fprintf(STDERR, "Warning: RO volume didn't exist in vldb!\n");
5458 if (ropartition != partition) {
5460 "Warning: RO volume should be in partition %d instead of %d (vldb)\n",
5461 ropartition, partition);
5466 "VLDB indicates that a RW volume exists already on %s in partition %s.\n",
5467 hostutil_GetNameByINet(rwserver),
5468 volutil_PartitionName(rwpartition));
5470 fprintf(STDERR, "Overwrite this VLDB entry? [y|n] (n)\n");
5472 while (!(dc == EOF || dc == '\n'))
5473 dc = getchar(); /* goto end of line */
5474 if ((c != 'y') && (c != 'Y')) {
5475 fprintf(STDERR, "aborted.\n");
5482 ubik_VL_SetLock(cstruct, 0, entry.volumeId[RWVOL], RWVOL,
5484 aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
5485 code = AFSVolConvertROtoRWvolume(aconn, partition, volid);
5488 "Converting RO volume %lu to RW volume failed with code %d\n",
5489 (unsigned long)volid, code);
5490 PrintError("convertROtoRW ", code);
5493 entry.serverFlags[roindex] = ITSRWVOL;
5494 entry.flags |= RW_EXISTS;
5495 entry.flags &= ~BACK_EXISTS;
5498 if (rwindex != entry.nServers) {
5499 entry.serverNumber[rwindex] = entry.serverNumber[entry.nServers];
5500 entry.serverPartition[rwindex] =
5501 entry.serverPartition[entry.nServers];
5502 entry.serverFlags[rwindex] = entry.serverFlags[entry.nServers];
5503 entry.serverNumber[entry.nServers] = 0;
5504 entry.serverPartition[entry.nServers] = 0;
5505 entry.serverFlags[entry.nServers] = 0;
5508 entry.flags &= ~RO_EXISTS;
5509 for (i = 0; i < entry.nServers; i++) {
5510 if (entry.serverFlags[i] & ITSROVOL) {
5511 if (!(entry.serverFlags[i] & (RO_DONTUSE | NEW_REPSITE)))
5512 entry.flags |= RO_EXISTS;
5515 MapNetworkToHost(&entry, &storeEntry);
5517 VLDB_ReplaceEntry(entry.volumeId[RWVOL], RWVOL, &storeEntry,
5518 (LOCKREL_OPCODE | LOCKREL_AFSID |
5519 LOCKREL_TIMESTAMP));
5522 "Warning: volume converted, but vldb update failed with code %d!\n",
5525 vcode = UV_LockRelease(entry.volumeId[RWVOL]);
5527 PrintDiagnostics("unlock", vcode);
5533 Sizes(register struct cmd_syndesc *as, void *arock)
5536 afs_int32 aserver, apart, voltype, fromdate = 0, code, err, i;
5537 struct nvldbentry entry;
5538 volintSize vol_size;
5540 rx_SetRxDeadTime(60 * 10);
5541 for (i = 0; i < MAXSERVERS; i++) {
5542 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
5545 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
5546 if (rxConn->service)
5547 rxConn->service->connDeadTime = rx_connDeadTime;
5550 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5553 PrintError("", err);
5555 fprintf(STDERR, "vos: can't find volume '%s'\n",
5556 as->parms[0].items->data);
5560 if (as->parms[1].items || as->parms[2].items) {
5561 if (!as->parms[1].items || !as->parms[2].items) {
5563 "Must specify both -server and -partition options\n");
5566 aserver = GetServer(as->parms[2].items->data);
5568 fprintf(STDERR, "Invalid server name\n");
5571 apart = volutil_GetPartitionID(as->parms[1].items->data);
5573 fprintf(STDERR, "Invalid partition name\n");
5577 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
5584 if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
5585 code = ktime_DateToInt32(as->parms[4].items->data, &fromdate);
5587 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
5588 as->parms[4].items->data, code);
5593 fprintf(STDOUT, "Volume: %s\n", as->parms[0].items->data);
5595 if (as->parms[3].items) { /* do the dump estimate */
5596 #ifdef AFS_64BIT_ENV
5597 vol_size.dump_size = 0;
5599 FillInt64(vol_size.dump_size,0, 1);
5601 code = UV_GetSize(avolid, aserver, apart, fromdate, &vol_size);
5603 PrintDiagnostics("size", code);
5606 /* presumably the size info is now gathered in pntr */
5607 /* now we display it */
5609 fprintf(STDOUT, "dump_size: %llu\n", vol_size.dump_size);
5618 PrintDiagnostics(char *astring, afs_int32 acode)
5620 if (acode == EACCES) {
5622 "You are not authorized to perform the 'vos %s' command (%d)\n",
5625 fprintf(STDERR, "Error in vos %s command.\n", astring);
5626 PrintError("", acode);
5633 MyBeforeProc(struct cmd_syndesc *as, void *arock)
5635 register char *tcell;
5636 register afs_int32 code;
5637 register afs_int32 sauth;
5639 /* Initialize the ubik_client connection */
5640 rx_SetRxDeadTime(90);
5641 cstruct = (struct ubik_client *)0;
5645 if (as->parms[12].items) /* if -cell specified */
5646 tcell = as->parms[12].items->data;
5647 if (as->parms[14].items) /* -serverauth specified */
5649 if (as->parms[16].items) /* -crypt specified */
5652 vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
5653 &cstruct, UV_SetSecurity))) {
5654 fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
5655 (unsigned long)code);
5659 if (as->parms[15].items) /* -verbose flag set */
5663 if (as->parms[17].items) /* -noresolve flag set */
5673 /* this sucks but it works for now.
5678 #include "AFS_component_version_number.c"
5681 main(int argc, char **argv)
5683 register afs_int32 code;
5685 register struct cmd_syndesc *ts;
5687 #ifdef AFS_AIX32_ENV
5689 * The following signal action for AIX is necessary so that in case of a
5690 * crash (i.e. core is generated) we can include the user's data section
5691 * in the core dump. Unfortunately, by default, only a partial core is
5692 * generated which, in many cases, isn't too useful.
5694 struct sigaction nsa;
5696 sigemptyset(&nsa.sa_mask);
5697 nsa.sa_handler = SIG_DFL;
5698 nsa.sa_flags = SA_FULLDUMP;
5699 sigaction(SIGSEGV, &nsa, NULL);
5702 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
5704 cmd_SetBeforeProc(MyBeforeProc, NULL);
5706 ts = cmd_CreateSyntax("create", CreateVolume, NULL, "create a new volume");
5707 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5708 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5709 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "volume name");
5710 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL,
5711 "initial quota (KB)");
5713 cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
5717 ts = cmd_CreateSyntax("remove", DeleteVolume, NULL, "delete a volume");
5718 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5719 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5720 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5724 ts = cmd_CreateSyntax("move", MoveVolume, NULL, "move a volume");
5725 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5726 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5727 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5728 "partition name on source");
5729 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5730 "machine name on destination");
5731 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5732 "partition name on destination");
5733 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5734 "copy live volume without cloning");
5737 ts = cmd_CreateSyntax("copy", CopyVolume, NULL, "copy a volume");
5738 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5739 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5740 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5741 "partition name on source");
5742 cmd_AddParm(ts, "-toname", CMD_SINGLE, 0, "volume name on destination");
5743 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5744 "machine name on destination");
5745 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5746 "partition name on destination");
5747 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5748 "leave new volume offline");
5749 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5750 "make new volume read-only");
5751 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5752 "copy live volume without cloning");
5755 ts = cmd_CreateSyntax("shadow", ShadowVolume, NULL,
5756 "make or update a shadow volume");
5757 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5758 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5759 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5760 "partition name on source");
5761 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5762 "machine name on destination");
5763 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5764 "partition name on destination");
5765 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5766 "volume name on destination");
5767 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5768 "volume ID on destination");
5769 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5770 "leave shadow volume offline");
5771 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5772 "make shadow volume read-only");
5773 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5774 "copy live volume without cloning");
5775 cmd_AddParm(ts, "-incremental", CMD_FLAG, CMD_OPTIONAL,
5776 "do incremental update if target exists");
5779 ts = cmd_CreateSyntax("backup", BackupVolume, NULL,
5780 "make backup of a volume");
5781 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5784 ts = cmd_CreateSyntax("clone", CloneVolume, NULL,
5785 "make clone of a volume");
5786 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5787 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5788 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5789 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5790 "volume name on destination");
5791 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5792 "volume ID on destination");
5793 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5794 "leave clone volume offline");
5795 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5796 "make clone volume read-only, not readwrite");
5799 ts = cmd_CreateSyntax("release", ReleaseVolume, NULL, "release a volume");
5800 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5801 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5802 "force a complete release");
5805 ts = cmd_CreateSyntax("dump", DumpVolumeCmd, NULL, "dump a volume");
5806 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5807 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5808 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5809 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5810 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5811 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL,
5812 "dump a clone of the volume");
5813 cmd_AddParm(ts, "-omitdirs", CMD_FLAG, CMD_OPTIONAL,
5814 "omit unchanged directories from an incremental dump");
5817 ts = cmd_CreateSyntax("restore", RestoreVolumeCmd, NULL,
5818 "restore a volume");
5819 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5820 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5821 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of volume to be restored");
5822 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5823 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
5824 cmd_AddParm(ts, "-overwrite", CMD_SINGLE, CMD_OPTIONAL,
5825 "abort | full | incremental");
5826 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5827 "leave restored volume offline");
5828 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5829 "make restored volume read-only");
5830 cmd_AddParm(ts, "-creation", CMD_SINGLE, CMD_OPTIONAL,
5831 "dump | keep | new");
5832 cmd_AddParm(ts, "-lastupdate", CMD_SINGLE, CMD_OPTIONAL,
5833 "dump | keep | new");
5834 cmd_AddParm(ts, "-nodelete", CMD_FLAG, CMD_OPTIONAL,
5835 "do not delete old site when restoring to a new site");
5838 ts = cmd_CreateSyntax("unlock", LockReleaseCmd, NULL,
5839 "release lock on VLDB entry for a volume");
5840 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5843 ts = cmd_CreateSyntax("changeloc", ChangeLocation, NULL,
5844 "change an RW volume's location in the VLDB");
5845 cmd_AddParm(ts, "-server", CMD_SINGLE, 0,
5846 "machine name for new location");
5847 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5848 "partition name for new location");
5849 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5852 ts = cmd_CreateSyntax("addsite", AddSite, NULL, "add a replication site");
5853 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new site");
5854 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5855 "partition name for new site");
5856 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5857 cmd_AddParm(ts, "-valid", CMD_FLAG, CMD_OPTIONAL, "publish as an up-to-date site in VLDB");
5860 ts = cmd_CreateSyntax("remsite", RemoveSite, NULL,
5861 "remove a replication site");
5862 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5863 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5864 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5867 ts = cmd_CreateSyntax("listpart", ListPartitions, NULL, "list partitions");
5868 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5871 ts = cmd_CreateSyntax("listvol", ListVolumes, NULL,
5872 "list volumes on server (bypass VLDB)");
5873 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5874 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5875 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "minimal listing");
5876 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
5877 "list all normal volume fields");
5878 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5879 "generate minimal information");
5880 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5881 "list extended volume fields");
5882 #ifdef FULL_LISTVOL_SWITCH
5883 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5884 "machine readable format");
5885 #endif /* FULL_LISTVOL_SWITCH */
5888 ts = cmd_CreateSyntax("syncvldb", SyncVldb, NULL,
5889 "synchronize VLDB with server");
5890 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5891 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5892 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5893 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5896 ts = cmd_CreateSyntax("syncserv", SyncServer, NULL,
5897 "synchronize server with VLDB");
5898 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5899 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5900 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5903 ts = cmd_CreateSyntax("examine", ExamineVolume, NULL,
5904 "everything about the volume");
5905 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5906 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5907 "list extended volume fields");
5908 #ifdef FULL_LISTVOL_SWITCH
5909 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5910 "machine readable format");
5911 #endif /* FULL_LISTVOL_SWITCH */
5913 cmd_CreateAlias(ts, "volinfo");
5915 ts = cmd_CreateSyntax("setfields", SetFields, NULL,
5916 "change volume info fields");
5917 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5918 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "quota (KB)");
5919 cmd_AddParm(ts, "-clearuse", CMD_FLAG, CMD_OPTIONAL, "clear dayUse");
5920 cmd_AddParm(ts, "-clearVolUpCounter", CMD_FLAG, CMD_OPTIONAL, "clear volUpdateCounter");
5923 ts = cmd_CreateSyntax("offline", volOffline, NULL, "force the volume status to offline");
5924 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5925 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5926 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5927 cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds to sleep");
5928 cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "busy volume");
5931 ts = cmd_CreateSyntax("online", volOnline, NULL, "force the volume status to online");
5932 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5933 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5934 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5937 ts = cmd_CreateSyntax("zap", VolumeZap, NULL,
5938 "delete the volume, don't bother with VLDB");
5939 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5940 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5941 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume ID");
5942 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5943 "force deletion of bad volumes");
5944 cmd_AddParm(ts, "-backup", CMD_FLAG, CMD_OPTIONAL,
5945 "also delete backup volume if one is found");
5948 ts = cmd_CreateSyntax("status", VolserStatus, NULL,
5949 "report on volser status");
5950 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5953 ts = cmd_CreateSyntax("rename", RenameVolume, NULL, "rename a volume");
5954 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old volume name ");
5955 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new volume name ");
5958 ts = cmd_CreateSyntax("listvldb", ListVLDB, NULL,
5959 "list volumes in the VLDB");
5960 cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5961 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5962 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5963 cmd_AddParm(ts, "-locked", CMD_FLAG, CMD_OPTIONAL, "locked volumes only");
5964 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5965 "generate minimal information");
5966 cmd_AddParm(ts, "-nosort", CMD_FLAG, CMD_OPTIONAL,
5967 "do not alphabetically sort the volume names");
5970 ts = cmd_CreateSyntax("backupsys", BackSys, NULL, "en masse backups");
5971 cmd_AddParm(ts, "-prefix", CMD_LIST, CMD_OPTIONAL,
5972 "common prefix on volume(s)");
5973 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5974 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5975 cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL,
5976 "exclude common prefix volumes");
5977 cmd_AddParm(ts, "-xprefix", CMD_LIST, CMD_OPTIONAL,
5978 "negative prefix on volume(s)");
5979 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "no action");
5982 ts = cmd_CreateSyntax("delentry", DeleteEntry, NULL,
5983 "delete VLDB entry for a volume");
5984 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "volume name or ID");
5985 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL,
5986 "prefix of the volume whose VLDB entry is to be deleted");
5987 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5988 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5989 cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL,
5993 ts = cmd_CreateSyntax("partinfo", PartitionInfo, NULL,
5994 "list partition information");
5995 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5996 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5997 cmd_AddParm(ts, "-summary", CMD_FLAG, CMD_OPTIONAL,
5998 "print storage summary");
6001 ts = cmd_CreateSyntax("unlockvldb", UnlockVLDB, NULL,
6002 "unlock all the locked entries in the VLDB");
6003 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6004 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6007 ts = cmd_CreateSyntax("lock", LockEntry, NULL,
6008 "lock VLDB entry for a volume");
6009 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6012 ts = cmd_CreateSyntax("changeaddr", ChangeAddr, NULL,
6013 "change the IP address of a file server");
6014 cmd_AddParm(ts, "-oldaddr", CMD_SINGLE, 0, "original IP address");
6015 cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
6016 cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL,
6017 "remove the IP address from the VLDB");
6020 ts = cmd_CreateSyntax("listaddrs", ListAddrs, NULL,
6021 "list the IP address of all file servers registered in the VLDB");
6022 cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
6023 cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
6024 cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
6025 "print uuid of hosts");
6028 ts = cmd_CreateSyntax("convertROtoRW", ConvertRO, NULL,
6029 "convert a RO volume into a RW volume (after loss of old RW volume)");
6030 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6031 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
6032 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6033 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "don't ask");
6036 ts = cmd_CreateSyntax("size", Sizes, NULL,
6037 "obtain various sizes of the volume.");
6038 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6039 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6040 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6041 cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL,
6042 "Obtain the size of the dump");
6043 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
6046 code = cmd_Dispatch(argc, argv);
6048 /* Shut down the ubik_client and rx connections */
6050 (void)ubik_ClientDestroy(cstruct);
6056 exit((code ? -1 : 0));