2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
16 #include <sys/types.h>
26 #include <netinet/in.h>
27 #include <arpa/inet.h>
31 #include <sys/statfs.h>
39 #include <rx/rx_globals.h>
41 #include <afs/vlserver.h>
42 #include <afs/cellconfig.h>
44 #include <afs/afsutil.h>
46 #include <afs/afsint.h>
51 #include <afs/ihandle.h>
52 #include <afs/vnode.h>
53 #include <afs/volume.h>
60 #include "volser_prototypes.h"
61 #include "vsutils_prototypes.h"
62 #include "lockprocs_prototypes.h"
64 #ifdef HAVE_POSIX_REGEX
68 /* Local Prototypes */
69 int PrintDiagnostics(char *astring, afs_int32 acode);
70 int GetVolumeInfo(afs_uint32 volid, afs_int32 *server, afs_int32 *part,
71 afs_int32 *voltype, struct nvldbentry *rentry);
83 #define COMMONPARMS cmd_Seek(ts, 12);\
84 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
85 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");\
86 cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
87 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
88 cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
89 cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL, "don't resolve addresses"); \
91 #define ERROR_EXIT(code) {error=(code); goto error_exit;}
94 struct rx_connection *tconn;
96 extern struct ubik_client *cstruct;
99 static struct tqHead busyHead, notokHead;
102 qInit(struct tqHead *ahead)
104 memset((char *)ahead, 0, sizeof(struct tqHead));
110 qPut(struct tqHead *ahead, afs_uint32 volid)
114 elem = (struct tqElem *)malloc(sizeof(struct tqElem));
115 elem->next = ahead->next;
123 qGet(struct tqHead *ahead, afs_int32 *volid)
127 if (ahead->count <= 0)
129 *volid = ahead->next->volid;
131 ahead->next = tmp->next;
137 /* returns 1 if <filename> exists else 0 */
139 FileExists(char *filename)
145 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
149 code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
157 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
159 VolNameOK(char *name)
164 total = strlen(name);
165 if (!strcmp(&name[total - 9], ".readonly")) {
167 } else if (!strcmp(&name[total - 7], ".backup")) {
174 /* return 1 if name is a number else 0 */
176 IsNumeric(char *name)
184 for (i = 0; i < len; i++) {
185 if (*ptr < '0' || *ptr > '9') {
197 * Parse a server name/address and return the address in HOST BYTE order
200 GetServer(char *aname)
202 register struct hostent *th;
205 register afs_int32 code;
206 char hostname[MAXHOSTCHARS];
208 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
210 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
211 addr = ntohl(addr); /* convert to host order */
213 th = gethostbyname(aname);
216 memcpy(&addr, th->h_addr, sizeof(addr));
219 if (addr == htonl(0x7f000001)) { /* local host */
220 code = gethostname(hostname, MAXHOSTCHARS);
223 th = gethostbyname(hostname); /* returns host byte order */
226 memcpy(&addr, th->h_addr, sizeof(addr));
233 GetVolumeType(char *aname)
236 if (!strcmp(aname, "ro"))
238 else if (!strcmp(aname, "rw"))
240 else if (!strcmp(aname, "bk"))
247 IsPartValid(afs_int32 partId, afs_int32 server, afs_int32 *code)
249 struct partList dummyPartList;
255 *code = UV_ListPartitions(server, &dummyPartList, &cnt);
258 for (i = 0; i < cnt; i++) {
259 if (dummyPartList.partFlags[i] & PARTVALID)
260 if (dummyPartList.partId[i] == partId)
268 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
269 * associated with <call> */
271 SendFile(usd_handle_t ufd, register struct rx_call *call, long blksize)
273 char *buffer = (char *)0;
278 buffer = (char *)malloc(blksize);
280 fprintf(STDERR, "malloc failed\n");
284 while (!error && !done) {
285 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
288 FD_SET((int)(ufd->handle), &in);
289 /* don't timeout if read blocks */
290 #if defined(AFS_PTHREAD_ENV)
291 select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
293 IOMGR_Select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
296 error = USD_READ(ufd, buffer, blksize, &nbytes);
298 fprintf(STDERR, "File system read failed\n");
305 if (rx_Write(call, buffer, nbytes) != nbytes) {
315 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
316 * writes it out to the volume. */
318 WriteData(struct rx_call *call, char *rock)
323 afs_int32 error, code;
325 afs_hyper_t filesize, currOffset;
332 if (!filename || !*filename) {
333 usd_StandardInput(&ufd);
337 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
340 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
343 fprintf(STDERR, "Could not access file '%s'\n", filename);
347 /* test if we have a valid dump */
348 hset64(filesize, 0, 0);
349 USD_SEEK(ufd, filesize, SEEK_END, &currOffset);
350 hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32));
351 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
352 USD_READ(ufd, (char *)&buffer, sizeof(afs_uint32), &got);
353 if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
354 fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
358 /* rewind, we are done */
359 hset64(filesize, 0, 0);
360 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
362 code = SendFile(ufd, call, blksize);
369 code = USD_CLOSE(ufd);
371 fprintf(STDERR, "Could not close dump file %s\n",
372 (filename && *filename) ? filename : "STDOUT");
380 /* Receive data from <call> stream into file associated
381 * with <fd> <blksize>
384 ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize)
388 afs_uint32 bytesleft, w;
391 buffer = (char *)malloc(blksize);
393 fprintf(STDERR, "memory allocation failed\n");
397 while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {
398 for (bytesleft = bytesread; bytesleft; bytesleft -= w) {
399 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
402 FD_SET((int)(ufd->handle), &out);
403 /* don't timeout if write blocks */
404 #if defined(AFS_PTHREAD_ENV)
405 select(((int)(ufd->handle)) + 1, &out, 0, 0, 0);
407 IOMGR_Select(((int)(ufd->handle)) + 1, 0, &out, 0, 0);
411 USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
413 fprintf(STDERR, "File system write failed\n");
426 DumpFunction(struct rx_call *call, char *filename)
428 usd_handle_t ufd; /* default is to stdout */
429 afs_int32 error = 0, code;
434 /* Open the output file */
435 if (!filename || !*filename) {
436 usd_StandardOutput(&ufd);
441 usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
445 code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
448 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
451 fprintf(STDERR, "Could not create file '%s'\n", filename);
452 ERROR_EXIT(VOLSERBADOP);
456 code = ReceiveFile(ufd, call, blksize);
461 /* Close the output file */
463 code = USD_CLOSE(ufd);
465 fprintf(STDERR, "Could not close dump file %s\n",
466 (filename && *filename) ? filename : "STDIN");
476 vos_ctime(afs_int32 *timep)
483 DisplayFormat(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
486 afs_int32 server, part;
487 int *totalOK, *totalNotOK, *totalBusy;
488 int fast, longlist, disp;
493 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
494 } else if (longlist) {
495 if (pntr->status == VOK) {
496 fprintf(STDOUT, "%-32s ", pntr->name);
497 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
499 fprintf(STDOUT, "RW ");
501 fprintf(STDOUT, "RO ");
503 fprintf(STDOUT, "BK ");
504 fprintf(STDOUT, "%10d K ", pntr->size);
505 if (pntr->inUse == 1) {
506 fprintf(STDOUT, "On-line");
509 fprintf(STDOUT, "Off-line");
512 if (pntr->needsSalvaged == 1)
513 fprintf(STDOUT, "**needs salvage**");
514 fprintf(STDOUT, "\n");
515 MapPartIdIntoName(part, pname);
516 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
518 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
519 (unsigned long)pntr->parentID,
520 (unsigned long)pntr->cloneID,
521 (unsigned long)pntr->backupID);
522 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
523 fprintf(STDOUT, " Creation %s",
524 vos_ctime(& pntr->creationDate));
525 #ifdef FULL_LISTVOL_SWITCH
526 fprintf(STDOUT, " Copy %s",
527 vos_ctime( & pntr->copyDate));
528 if (!pntr->backupDate)
529 fprintf(STDOUT, " Backup Never\n");
531 fprintf(STDOUT, " Backup %s",
532 vos_ctime( & pntr->backupDate));
533 if (pntr->accessDate)
534 fprintf(STDOUT, " Last Access %s",
535 vos_ctime( & pntr->accessDate));
537 if (!pntr->updateDate)
538 fprintf(STDOUT, " Last Update Never\n");
540 fprintf(STDOUT, " Last Update %s",
541 vos_ctime( & pntr->updateDate));
543 " %d accesses in the past day (i.e., vnode references)\n",
546 } else if (pntr->status == VBUSY) {
548 qPut(&busyHead, pntr->volid);
550 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
551 (unsigned long)pntr->volid);
554 qPut(¬okHead, pntr->volid);
556 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
557 (unsigned long)pntr->volid);
559 fprintf(STDOUT, "\n");
560 } else { /* default listing */
561 if (pntr->status == VOK) {
562 fprintf(STDOUT, "%-32s ", pntr->name);
563 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
565 fprintf(STDOUT, "RW ");
567 fprintf(STDOUT, "RO ");
569 fprintf(STDOUT, "BK ");
570 fprintf(STDOUT, "%10d K ", pntr->size);
571 if (pntr->inUse == 1) {
572 fprintf(STDOUT, "On-line");
575 fprintf(STDOUT, "Off-line");
578 if (pntr->needsSalvaged == 1)
579 fprintf(STDOUT, "**needs salvage**");
580 fprintf(STDOUT, "\n");
581 } else if (pntr->status == VBUSY) {
583 qPut(&busyHead, pntr->volid);
585 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
586 (unsigned long)pntr->volid);
589 qPut(¬okHead, pntr->volid);
591 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
592 (unsigned long)pntr->volid);
597 /*------------------------------------------------------------------------
598 * PRIVATE XDisplayFormat
601 * Display the contents of one extended volume info structure.
604 * a_xInfoP : Ptr to extended volume info struct to print.
605 * a_servID : Server ID to print.
606 * a_partID : Partition ID to print.
607 * a_totalOKP : Ptr to total-OK counter.
608 * a_totalNotOKP : Ptr to total-screwed counter.
609 * a_totalBusyP : Ptr to total-busy counter.
610 * a_fast : Fast listing?
611 * a_int32 : Int32 listing?
612 * a_showProblems : Show volume problems?
618 * Nothing interesting.
622 *------------------------------------------------------------------------*/
625 XDisplayFormat(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
626 a_totalBusyP, a_fast, a_int32, a_showProblems)
627 volintXInfo *a_xInfoP;
637 { /*XDisplayFormat */
645 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
646 } else if (a_int32) {
648 * Fully-detailed listing.
650 if (a_xInfoP->status == VOK) {
652 * Volume's status is OK - all the fields are valid.
654 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
655 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
656 if (a_xInfoP->type == 0)
657 fprintf(STDOUT, "RW ");
658 if (a_xInfoP->type == 1)
659 fprintf(STDOUT, "RO ");
660 if (a_xInfoP->type == 2)
661 fprintf(STDOUT, "BK ");
662 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
663 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
664 if (a_xInfoP->inUse == 1) {
665 fprintf(STDOUT, "On-line");
668 fprintf(STDOUT, "Off-line");
671 fprintf(STDOUT, "\n");
672 MapPartIdIntoName(a_partID, pname);
673 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
675 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
676 (unsigned long)a_xInfoP->parentID,
677 (unsigned long)a_xInfoP->cloneID,
678 (unsigned long)a_xInfoP->backupID);
679 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
680 fprintf(STDOUT, " Creation %s",
681 vos_ctime( & a_xInfoP->creationDate));
682 #ifdef FULL_LISTVOL_SWITCH
683 fprintf(STDOUT, " Copy %s",
684 vos_ctime( & a_xInfoP->copyDate));
685 if (!a_xInfoP->backupDate)
686 fprintf(STDOUT, " Backup Never\n");
688 fprintf(STDOUT, " Backup %s",
689 vos_ctime( & a_xInfoP->backupDate));
690 if (a_xInfoP->accessDate)
691 fprintf(STDOUT, " Last Access %s",
692 vos_ctime( & a_xInfoP->accessDate));
694 if (!a_xInfoP->updateDate)
695 fprintf(STDOUT, " Last Update Never\n");
697 fprintf(STDOUT, " Last Update %s",
698 vos_ctime( & a_xInfoP->updateDate));
700 " %d accesses in the past day (i.e., vnode references)\n",
705 * Print all the read/write and authorship stats.
707 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
709 " |-------------------------------------------|\n");
711 " | Same Network | Diff Network |\n");
713 " |----------|----------|----------|----------|\n");
715 " | Total | Auth | Total | Auth |\n");
717 " |----------|----------|----------|----------|\n");
718 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
719 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
720 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
721 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
722 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
723 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
724 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
725 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
726 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
727 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
729 " |-------------------------------------------|\n\n");
732 " Writes Affecting Authorship\n");
734 " |-------------------------------------------|\n");
736 " | File Authorship | Directory Authorship|\n");
738 " |----------|----------|----------|----------|\n");
740 " | Same | Diff | Same | Diff |\n");
742 " |----------|----------|----------|----------|\n");
743 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
744 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
745 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
746 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
747 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
748 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
749 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
750 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
751 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
752 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
753 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
754 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
755 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
756 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
757 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
758 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
759 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
760 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
761 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
762 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
763 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
764 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
765 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
766 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
767 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
768 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
769 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
770 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
771 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
772 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
774 " |-------------------------------------------|\n");
775 } /*Volume status OK */
776 else if (a_xInfoP->status == VBUSY) {
778 qPut(&busyHead, a_xInfoP->volid);
780 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
781 (unsigned long)a_xInfoP->volid);
785 qPut(¬okHead, a_xInfoP->volid);
787 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
788 (unsigned long)a_xInfoP->volid);
789 } /*Screwed volume */
790 fprintf(STDOUT, "\n");
796 if (a_xInfoP->status == VOK) {
797 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
798 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
799 if (a_xInfoP->type == 0)
800 fprintf(STDOUT, "RW ");
801 if (a_xInfoP->type == 1)
802 fprintf(STDOUT, "RO ");
803 if (a_xInfoP->type == 2)
804 fprintf(STDOUT, "BK ");
805 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
806 if (a_xInfoP->inUse == 1) {
807 fprintf(STDOUT, "On-line");
810 fprintf(STDOUT, "Off-line");
813 fprintf(STDOUT, "\n");
815 else if (a_xInfoP->status == VBUSY) {
817 qPut(&busyHead, a_xInfoP->volid);
819 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
820 (unsigned long)a_xInfoP->volid);
824 qPut(¬okHead, a_xInfoP->volid);
826 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
827 (unsigned long)a_xInfoP->volid);
828 } /*Screwed volume */
829 } /*Default listing */
830 } /*XDisplayFormat */
832 #ifdef FULL_LISTVOL_SWITCH
833 /*------------------------------------------------------------------------
834 * PRIVATE XDisplayFormat2
837 * Display the formated contents of one extended volume info structure.
840 * a_xInfoP : Ptr to extended volume info struct to print.
841 * a_servID : Server ID to print.
842 * a_partID : Partition ID to print.
843 * a_totalOKP : Ptr to total-OK counter.
844 * a_totalNotOKP : Ptr to total-screwed counter.
845 * a_totalBusyP : Ptr to total-busy counter.
846 * a_fast : Fast listing?
847 * a_int32 : Int32 listing?
848 * a_showProblems : Show volume problems?
854 * Nothing interesting.
858 *------------------------------------------------------------------------*/
861 XDisplayFormat2(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
862 a_totalBusyP, a_fast, a_int32, a_showProblems)
863 volintXInfo *a_xInfoP;
873 { /*XDisplayFormat */
878 fprintf(STDOUT, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP->volid);
879 } else if (a_int32) {
881 * Fully-detailed listing.
883 if (a_xInfoP->status == VOK) {
885 * Volume's status is OK - all the fields are valid.
888 static long server_cache = -1, partition_cache = -1;
889 static char hostname[256], address[32], pname[16];
890 int i,ai[] = {VOLINT_STATS_TIME_IDX_0,VOLINT_STATS_TIME_IDX_1,VOLINT_STATS_TIME_IDX_2,
891 VOLINT_STATS_TIME_IDX_3,VOLINT_STATS_TIME_IDX_4,VOLINT_STATS_TIME_IDX_5};
893 if (a_servID != server_cache) {
897 strcpy(hostname, hostutil_GetNameByINet(a_servID));
898 strcpy(address, inet_ntoa(s));
899 server_cache = a_servID;
901 if (a_partID != partition_cache) {
902 MapPartIdIntoName(a_partID, pname);
903 partition_cache = a_partID;
906 fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name);
907 fprintf(STDOUT, "id\t\t%lu\n", afs_cast_uint32(a_xInfoP->volid));
908 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
909 fprintf(STDOUT, "part\t\t%s\n", pname);
910 switch (a_xInfoP->status) {
912 fprintf(STDOUT, "status\t\tOK\n");
915 fprintf(STDOUT, "status\t\tBUSY\n");
918 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
921 fprintf(STDOUT, "backupID\t%lu\n",
922 afs_cast_uint32(a_xInfoP->backupID));
923 fprintf(STDOUT, "parentID\t%lu\n",
924 afs_cast_uint32(a_xInfoP->parentID));
925 fprintf(STDOUT, "cloneID\t\t%lu\n",
926 afs_cast_uint32(a_xInfoP->cloneID));
927 fprintf(STDOUT, "inUse\t\t%s\n", a_xInfoP->inUse ? "Y" : "N");
928 switch (a_xInfoP->type) {
930 fprintf(STDOUT, "type\t\tRW\n");
933 fprintf(STDOUT, "type\t\tRO\n");
936 fprintf(STDOUT, "type\t\tBK\n");
939 fprintf(STDOUT, "type\t\t?\n");
942 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
943 afs_cast_uint32(a_xInfoP->creationDate),
944 vos_ctime(&a_xInfoP->creationDate));
945 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
946 afs_cast_uint32(a_xInfoP->accessDate),
947 vos_ctime(&a_xInfoP->accessDate));
948 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
949 afs_cast_uint32(a_xInfoP->updateDate),
950 vos_ctime(&a_xInfoP->updateDate));
951 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
952 afs_cast_uint32(a_xInfoP->backupDate),
953 vos_ctime(&a_xInfoP->backupDate));
954 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
955 afs_cast_uint32(a_xInfoP->copyDate),
956 vos_ctime(&a_xInfoP->copyDate));
958 fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
959 fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
961 fprintf(STDOUT, "filecount\t%u\n", a_xInfoP->filecount);
962 fprintf(STDOUT, "dayUse\t\t%u\n", a_xInfoP->dayUse);
966 fprintf(STDOUT,"reads_same_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]);
967 fprintf(STDOUT,"reads_same_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]);
968 fprintf(STDOUT,"reads_diff_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]);
969 fprintf(STDOUT,"reads_diff_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
971 fprintf(STDOUT,"writes_same_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]);
972 fprintf(STDOUT,"writes_same_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]);
973 fprintf(STDOUT,"writes_diff_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]);
974 fprintf(STDOUT,"writes_diff_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
978 fprintf(STDOUT,"file_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileSameAuthor[ai[i]]);
979 fprintf(STDOUT,"file_diff_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileDiffAuthor[ai[i]]);
980 fprintf(STDOUT,"dir_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirSameAuthor[ai[i]]);
981 fprintf(STDOUT,"dir_dif_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirDiffAuthor[ai[i]]);
984 } /*Volume status OK */
985 else if (a_xInfoP->status == VBUSY) {
987 qPut(&busyHead, a_xInfoP->volid);
989 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
990 (unsigned long)a_xInfoP->volid);
994 qPut(¬okHead, a_xInfoP->volid);
996 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
997 (unsigned long)a_xInfoP->volid);
998 } /*Screwed volume */
1004 if (a_xInfoP->status == VOK) {
1005 fprintf(STDOUT, "name\t%-32s\n", a_xInfoP->name);
1006 fprintf(STDOUT, "volID\t%10lu\n", (unsigned long)a_xInfoP->volid);
1007 if (a_xInfoP->type == 0)
1008 fprintf(STDOUT, "type\tRW\n");
1009 if (a_xInfoP->type == 1)
1010 fprintf(STDOUT, "type\tRO\n");
1011 if (a_xInfoP->type == 2)
1012 fprintf(STDOUT, "type\tBK\n");
1013 fprintf(STDOUT, "size\t%10dK\n", a_xInfoP->size);
1015 fprintf(STDOUT, "inUse\t%d\n",a_xInfoP->inUse);
1016 if (a_xInfoP->inUse == 1)
1022 else if (a_xInfoP->status == VBUSY) {
1024 qPut(&busyHead, a_xInfoP->volid);
1026 fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
1027 (unsigned long)a_xInfoP->volid);
1031 qPut(¬okHead, a_xInfoP->volid);
1033 fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
1034 (unsigned long)a_xInfoP->volid);
1035 } /*Screwed volume */
1036 } /*Default listing */
1037 } /*XDisplayFormat */
1038 #endif /*FULL_LISTVOL_SWITCH*/
1040 #ifdef FULL_LISTVOL_SWITCH
1042 DisplayFormat2(server, partition, pntr)
1043 long server, partition;
1046 static long server_cache = -1, partition_cache = -1;
1047 static char hostname[256], address[32], pname[16];
1049 if (server != server_cache) {
1053 strcpy(hostname, hostutil_GetNameByINet(server));
1054 strcpy(address, inet_ntoa(s));
1055 server_cache = server;
1057 if (partition != partition_cache) {
1058 MapPartIdIntoName(partition, pname);
1059 partition_cache = partition;
1061 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
1062 fprintf(STDOUT, "id\t\t%lu\n",
1063 afs_cast_uint32(pntr->volid));
1064 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
1065 fprintf(STDOUT, "part\t\t%s\n", pname);
1066 switch (pntr->status) {
1068 fprintf(STDOUT, "status\t\tOK\n");
1071 fprintf(STDOUT, "status\t\tBUSY\n");
1074 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
1077 fprintf(STDOUT, "backupID\t%lu\n",
1078 afs_cast_uint32(pntr->backupID));
1079 fprintf(STDOUT, "parentID\t%lu\n",
1080 afs_cast_uint32(pntr->parentID));
1081 fprintf(STDOUT, "cloneID\t\t%lu\n",
1082 afs_cast_uint32(pntr->cloneID));
1083 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
1084 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
1085 /* 0xD3 is from afs/volume.h since I had trouble including the file */
1086 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
1087 switch (pntr->type) {
1089 fprintf(STDOUT, "type\t\tRW\n");
1092 fprintf(STDOUT, "type\t\tRO\n");
1095 fprintf(STDOUT, "type\t\tBK\n");
1098 fprintf(STDOUT, "type\t\t?\n");
1101 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
1102 afs_cast_uint32(pntr->creationDate),
1103 vos_ctime(&pntr->creationDate));
1104 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
1105 afs_cast_uint32(pntr->accessDate),
1106 vos_ctime(&pntr->accessDate));
1107 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
1108 afs_cast_uint32(pntr->updateDate),
1109 vos_ctime(&pntr->updateDate));
1110 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
1111 afs_cast_uint32(pntr->backupDate),
1112 vos_ctime(&pntr->backupDate));
1113 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
1114 afs_cast_uint32(pntr->copyDate),
1115 vos_ctime(&pntr->copyDate));
1116 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n",
1117 afs_cast_uint32(pntr->flags));
1118 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
1119 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
1120 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n",
1121 afs_cast_uint32(pntr->spare0));
1122 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
1123 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
1124 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n",
1125 afs_cast_uint32(pntr->spare1));
1126 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n",
1127 afs_cast_uint32(pntr->spare2));
1128 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n",
1129 afs_cast_uint32(pntr->spare3));
1134 DisplayVolumes2(server, partition, pntr, count)
1136 long server, partition, count;
1140 for (i = 0; i < count; i++) {
1141 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1142 DisplayFormat2(server, partition, pntr);
1143 fprintf(STDOUT, "END_OF_ENTRY\n\n");
1148 #endif /* FULL_LISTVOL_SWITCH */
1151 DisplayVolumes(server, part, pntr, count, longlist, fast, quiet)
1152 afs_int32 server, part;
1154 afs_int32 count, longlist, fast;
1157 int totalOK, totalNotOK, totalBusy, i;
1158 afs_uint32 volid = 0;
1165 for (i = 0; i < count; i++) {
1166 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
1171 while (busyHead.count) {
1172 qGet(&busyHead, &volid);
1173 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1174 (unsigned long)volid);
1178 while (notokHead.count) {
1179 qGet(¬okHead, &volid);
1180 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1181 (unsigned long)volid);
1185 fprintf(STDOUT, "\n");
1188 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
1189 totalOK, totalNotOK, totalBusy);
1193 /*------------------------------------------------------------------------
1194 * PRIVATE XDisplayVolumes
1197 * Display extended volume information.
1200 * a_servID : Pointer to the Rx call we're performing.
1201 * a_partID : Partition for which we want the extended list.
1202 * a_xInfoP : Ptr to extended volume info.
1203 * a_count : Number of volume records contained above.
1204 * a_int32 : Int32 listing generated?
1205 * a_fast : Fast listing generated?
1206 * a_quiet : Quiet listing generated?
1212 * Nothing interesting.
1216 *------------------------------------------------------------------------*/
1219 XDisplayVolumes(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
1223 volintXInfo *a_xInfoP;
1229 { /*XDisplayVolumes */
1231 int totalOK; /*Total OK volumes */
1232 int totalNotOK; /*Total screwed volumes */
1233 int totalBusy; /*Total busy volumes */
1234 int i; /*Loop variable */
1235 afs_uint32 volid = 0; /*Current volume ID */
1238 * Initialize counters and (global!!) queues.
1247 * Display each volume in the list.
1249 for (i = 0; i < a_count; i++) {
1250 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1251 &totalBusy, a_fast, a_int32, 0);
1256 * If any volumes were found to be busy or screwed, display them.
1259 while (busyHead.count) {
1260 qGet(&busyHead, &volid);
1261 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1262 (unsigned long)volid);
1266 while (notokHead.count) {
1267 qGet(¬okHead, &volid);
1268 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1269 (unsigned long)volid);
1274 fprintf(STDOUT, "\n");
1277 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1278 totalOK, totalNotOK, totalBusy);
1282 } /*XDisplayVolumes */
1283 #ifdef FULL_LISTVOL_SWITCH
1284 /*------------------------------------------------------------------------
1285 * PRIVATE XDisplayVolumes2
1288 * Display extended formated volume information.
1291 * a_servID : Pointer to the Rx call we're performing.
1292 * a_partID : Partition for which we want the extended list.
1293 * a_xInfoP : Ptr to extended volume info.
1294 * a_count : Number of volume records contained above.
1295 * a_int32 : Int32 listing generated?
1296 * a_fast : Fast listing generated?
1297 * a_quiet : Quiet listing generated?
1303 * Nothing interesting.
1307 *------------------------------------------------------------------------*/
1310 XDisplayVolumes2(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
1314 volintXInfo *a_xInfoP;
1320 { /*XDisplayVolumes */
1322 int totalOK; /*Total OK volumes */
1323 int totalNotOK; /*Total screwed volumes */
1324 int totalBusy; /*Total busy volumes */
1325 int i; /*Loop variable */
1326 afs_uint32 volid = 0; /*Current volume ID */
1329 * Initialize counters and (global!!) queues.
1338 * Display each volume in the list.
1340 for (i = 0; i < a_count; i++) {
1341 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1342 XDisplayFormat2(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1343 &totalBusy, a_fast, a_int32, 0);
1344 fprintf(STDOUT, "END_OF_ENTRY\n");
1349 * If any volumes were found to be busy or screwed, display them.
1352 while (busyHead.count) {
1353 qGet(&busyHead, &volid);
1354 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1355 (unsigned long)volid);
1359 while (notokHead.count) {
1360 qGet(¬okHead, &volid);
1361 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1362 (unsigned long)volid);
1367 fprintf(STDOUT, "\n");
1370 "VOLUMES_ONLINE\t%d\nVOLUMES_OFFLINE\t%d\nVOLUMES_BUSY\t%d\n",
1371 totalOK, totalNotOK, totalBusy);
1375 } /*XDisplayVolumes2 */
1376 #endif /* FULL_LISTVOL_SWITCH */
1379 /* set <server> and <part> to the correct values depending on
1380 * <voltype> and <entry> */
1382 GetServerAndPart(entry, voltype, server, part, previdx)
1383 struct nvldbentry *entry;
1384 afs_int32 *server, *part;
1388 int i, istart, vtype;
1393 /* Doesn't check for non-existance of backup volume */
1394 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1396 istart = 0; /* seach the entire entry */
1399 /* Seach from beginning of entry or pick up where we left off */
1400 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1403 for (i = istart; i < entry->nServers; i++) {
1404 if (entry->serverFlags[i] & vtype) {
1405 *server = entry->serverNumber[i];
1406 *part = entry->serverPartition[i];
1412 /* Didn't find any, return -1 */
1418 PostVolumeStats(struct nvldbentry *entry)
1420 SubEnumerateEntry(entry);
1421 /* Check for VLOP_ALLOPERS */
1422 if (entry->flags & VLOP_ALLOPERS)
1423 fprintf(STDOUT, " Volume is currently LOCKED \n");
1427 /*------------------------------------------------------------------------
1428 * PRIVATE XVolumeStats
1431 * Display extended volume information.
1434 * a_xInfoP : Ptr to extended volume info.
1435 * a_entryP : Ptr to the volume's VLDB entry.
1436 * a_srvID : Server ID.
1437 * a_partID : Partition ID.
1438 * a_volType : Type of volume to print.
1444 * Nothing interesting.
1448 *------------------------------------------------------------------------*/
1451 XVolumeStats(a_xInfoP, a_entryP, a_srvID, a_partID, a_volType)
1452 volintXInfo *a_xInfoP;
1453 struct nvldbentry *a_entryP;
1460 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1462 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1463 a_srvID, /*Server ID to print */
1464 a_partID, /*Partition ID to print */
1465 &totalOK, /*Ptr to total-OK counter */
1466 &totalNotOK, /*Ptr to total-screwed counter */
1467 &totalBusy, /*Ptr to total-busy counter */
1468 0, /*Don't do a fast listing */
1469 1, /*Do a long listing */
1470 1); /*Show volume problems */
1476 VolumeStats_int(volintInfo *pntr, struct nvldbentry *entry, afs_int32 server,
1477 afs_int32 part, int voltype)
1479 int totalOK, totalNotOK, totalBusy;
1481 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1486 /* command to forcibly remove a volume */
1488 NukeVolume(register struct cmd_syndesc *as)
1490 register afs_int32 code;
1497 server = GetServer(tp = as->parms[0].items->data);
1499 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1503 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1505 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1509 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1512 PrintError("", err);
1515 "vos: could not parse '%s' as a numeric volume ID", tp);
1520 "vos: forcibly removing all traces of volume %d, please wait...",
1523 code = UV_NukeVolume(server, partID, volID);
1525 fprintf(STDOUT, "done.\n");
1527 fprintf(STDOUT, "failed with code %d.\n", code);
1532 /*------------------------------------------------------------------------
1533 * PRIVATE ExamineVolume
1536 * Routine used to examine a single volume, contacting the VLDB as
1537 * well as the Volume Server.
1540 * as : Ptr to parsed command line arguments.
1543 * 0 for a successful operation,
1544 * Otherwise, one of the ubik or VolServer error values.
1547 * Nothing interesting.
1551 *------------------------------------------------------------------------
1554 ExamineVolume(register struct cmd_syndesc *as, void *arock)
1556 struct nvldbentry entry;
1557 afs_int32 vcode = 0;
1558 volintInfo *pntr = (volintInfo *) 0;
1559 volintXInfo *xInfoP = (volintXInfo *) 0;
1561 afs_int32 code, err, error = 0;
1562 int voltype, foundserv = 0, foundentry = 0;
1563 afs_int32 aserver, apart;
1565 int wantExtendedInfo; /*Do we want extended vol info? */
1567 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1569 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1572 PrintError("", err);
1574 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1575 as->parms[0].items->data);
1580 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1581 (unsigned long)volid);
1584 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1587 "Could not fetch the entry for volume number %lu from VLDB \n",
1588 (unsigned long)volid);
1592 fprintf(STDOUT, "done\n");
1593 MapHostToNetwork(&entry);
1595 if (entry.volumeId[RWVOL] == volid)
1597 else if (entry.volumeId[BACKVOL] == volid)
1599 else /* (entry.volumeId[ROVOL] == volid) */
1602 do { /* do {...} while (voltype == ROVOL) */
1603 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1604 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1605 * If its a RO vol, get the next RO entry.
1607 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1608 &aserver, &apart, &previdx);
1609 if (previdx == -1) { /* searched all entries */
1611 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1612 as->parms[0].items->data);
1619 /* Get information about the volume from the server */
1621 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1622 hostutil_GetNameByINet(aserver));
1625 if (wantExtendedInfo)
1626 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1628 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1630 fprintf(STDOUT, "done\n");
1634 if (code == ENODEV) {
1635 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1636 /* The VLDB says there is no backup volume and its not on disk */
1637 fprintf(STDERR, "Volume %s does not exist\n",
1638 as->parms[0].items->data);
1642 "Volume does not exist on server %s as indicated by the VLDB\n",
1643 hostutil_GetNameByINet(aserver));
1646 PrintDiagnostics("examine", code);
1648 fprintf(STDOUT, "\n");
1651 if (wantExtendedInfo)
1652 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1654 #ifdef FULL_LISTVOL_SWITCH
1655 if (as->parms[2].items) {
1656 DisplayFormat2(aserver, apart, pntr);
1657 EnumerateEntry(&entry);
1659 #endif /* FULL_LISTVOL_SWITCH */
1660 VolumeStats_int(pntr, &entry, aserver, apart, voltype);
1662 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1663 /* The VLDB says there is no backup volume yet we found one on disk */
1664 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1665 as->parms[0].items->data);
1674 } while (voltype == ROVOL);
1677 fprintf(STDERR, "Dump only information from VLDB\n\n");
1678 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1680 PostVolumeStats(&entry);
1685 /*------------------------------------------------------------------------
1689 * Routine used to change the status of a single volume.
1692 * as : Ptr to parsed command line arguments.
1695 * 0 for a successful operation,
1696 * Otherwise, one of the ubik or VolServer error values.
1699 * Nothing interesting.
1703 *------------------------------------------------------------------------
1706 SetFields(register struct cmd_syndesc *as, void *arock)
1708 struct nvldbentry entry;
1709 afs_int32 vcode = 0;
1712 afs_int32 code, err;
1713 afs_int32 aserver, apart;
1716 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1719 PrintError("", err);
1721 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1722 as->parms[0].items->data);
1726 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1729 "Could not fetch the entry for volume number %lu from VLDB \n",
1730 (unsigned long)volid);
1733 MapHostToNetwork(&entry);
1735 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1736 if (previdx == -1) {
1737 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1738 as->parms[0].items->data);
1742 init_volintInfo(&info);
1746 if (as->parms[1].items) {
1748 code = util_GetInt32(as->parms[1].items->data, &info.maxquota);
1750 fprintf(STDERR, "invalid quota value\n");
1754 if (as->parms[2].items) {
1758 if (as->parms[3].items) {
1759 /* -clearVolUpCounter */
1762 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1765 "Could not update volume info fields for volume number %lu\n",
1766 (unsigned long)volid);
1770 /*------------------------------------------------------------------------
1774 * Brings a volume online.
1777 * as : Ptr to parsed command line arguments.
1780 * 0 for a successful operation,
1783 * Nothing interesting.
1787 *------------------------------------------------------------------------
1790 volOnline(register struct cmd_syndesc *as, void *arock)
1792 afs_int32 server, partition;
1794 afs_int32 code, err = 0;
1796 server = GetServer(as->parms[0].items->data);
1798 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1799 as->parms[0].items->data);
1803 partition = volutil_GetPartitionID(as->parms[1].items->data);
1804 if (partition < 0) {
1805 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1806 as->parms[1].items->data);
1810 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1813 PrintError("", err);
1815 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1816 as->parms[0].items->data);
1820 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1823 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1830 /*------------------------------------------------------------------------
1831 * PRIVATE volOffline
1834 * Brings a volume offline.
1837 * as : Ptr to parsed command line arguments.
1840 * 0 for a successful operation,
1843 * Nothing interesting.
1847 *------------------------------------------------------------------------
1850 volOffline(register struct cmd_syndesc *as, void *arock)
1852 afs_int32 server, partition;
1854 afs_int32 code, err = 0;
1855 afs_int32 transflag, sleeptime, transdone;
1857 server = GetServer(as->parms[0].items->data);
1859 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1860 as->parms[0].items->data);
1864 partition = volutil_GetPartitionID(as->parms[1].items->data);
1865 if (partition < 0) {
1866 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1867 as->parms[1].items->data);
1871 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1874 PrintError("", err);
1876 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1877 as->parms[0].items->data);
1881 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1882 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1883 transdone = (sleeptime ? 0 /*online */ : VTOutOfService);
1884 if (as->parms[4].items && !as->parms[3].items) {
1885 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1890 UV_SetVolume(server, partition, volid, transflag, transdone,
1893 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1901 CreateVolume(register struct cmd_syndesc *as, void *arock)
1907 struct nvldbentry entry;
1912 tserver = GetServer(as->parms[0].items->data);
1914 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1915 as->parms[0].items->data);
1918 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1920 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1921 as->parms[1].items->data);
1924 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1926 PrintError("", code);
1929 "vos : partition %s does not exist on the server\n",
1930 as->parms[1].items->data);
1933 if (!ISNAMEVALID(as->parms[2].items->data)) {
1935 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1936 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1939 if (!VolNameOK(as->parms[2].items->data)) {
1941 "Illegal volume name %s, should not end in .readonly or .backup\n",
1942 as->parms[2].items->data);
1945 if (IsNumeric(as->parms[2].items->data)) {
1946 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1947 as->parms[2].items->data);
1950 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1952 fprintf(STDERR, "Volume %s already exists\n",
1953 as->parms[2].items->data);
1954 PrintDiagnostics("create", code);
1958 if (as->parms[3].items) {
1959 if (!IsNumeric(as->parms[3].items->data)) {
1960 fprintf(STDERR, "Initial quota %s should be numeric.\n",
1961 as->parms[3].items->data);
1965 code = util_GetInt32(as->parms[3].items->data, "a);
1967 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1973 UV_CreateVolume2(tserver, pnum, as->parms[2].items->data, quota, 0,
1976 PrintDiagnostics("create", code);
1979 MapPartIdIntoName(pnum, part);
1980 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
1981 (unsigned long)volid, part, as->parms[0].items->data);
1988 struct nvldbentry *entry;
1991 afs_int32 error, code, curserver, curpart;
1994 MapHostToNetwork(entry);
1996 for (i = 0; i < entry->nServers; i++) {
1997 curserver = entry->serverNumber[i];
1998 curpart = entry->serverPartition[i];
1999 if (entry->serverFlags[i] & ITSROVOL) {
2000 volid = entry->volumeId[ROVOL];
2002 volid = entry->volumeId[RWVOL];
2004 code = UV_DeleteVolume(curserver, curpart, volid);
2012 DeleteVolume(struct cmd_syndesc *as, void *arock)
2014 afs_int32 err, code = 0;
2015 afs_int32 server = 0, partition = -1;
2020 if (as->parms[0].items) {
2021 server = GetServer(as->parms[0].items->data);
2023 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2024 as->parms[0].items->data);
2029 if (as->parms[1].items) {
2030 partition = volutil_GetPartitionID(as->parms[1].items->data);
2031 if (partition < 0) {
2032 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2033 as->parms[1].items->data);
2037 /* Check for validity of the partition */
2038 if (!IsPartValid(partition, server, &code)) {
2040 PrintError("", code);
2043 "vos : partition %s does not exist on the server\n",
2044 as->parms[1].items->data);
2050 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2052 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
2053 as->parms[2].items->data);
2055 PrintError("", err);
2059 /* If the server or partition option are not complete, try to fill
2060 * them in from the VLDB entry.
2062 if ((partition == -1) || !server) {
2063 struct nvldbentry entry;
2065 code = VLDB_GetEntryByID(volid, -1, &entry);
2068 "Could not fetch the entry for volume %lu from VLDB\n",
2069 (unsigned long)volid);
2070 PrintError("", code);
2074 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
2075 || ((volid == entry.volumeId[BACKVOL])
2076 && (entry.flags & BACK_EXISTS))) {
2077 idx = Lp_GetRwIndex(&entry);
2078 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2079 || ((partition != -1)
2080 && (partition != entry.serverPartition[idx]))) {
2081 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2082 as->parms[2].items->data);
2085 } else if ((volid == entry.volumeId[ROVOL])
2086 && (entry.flags & RO_EXISTS)) {
2087 for (idx = -1, j = 0; j < entry.nServers; j++) {
2088 if (entry.serverFlags[j] != ITSROVOL)
2091 if (((server == 0) || (server == entry.serverNumber[j]))
2092 && ((partition == -1)
2093 || (partition == entry.serverPartition[j]))) {
2096 "VLDB: Volume '%s' matches more than one RO\n",
2097 as->parms[2].items->data);
2104 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2105 as->parms[2].items->data);
2109 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2110 as->parms[2].items->data);
2114 server = htonl(entry.serverNumber[idx]);
2115 partition = entry.serverPartition[idx];
2119 code = UV_DeleteVolume(server, partition, volid);
2121 PrintDiagnostics("remove", code);
2125 MapPartIdIntoName(partition, pname);
2126 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2127 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2131 #define TESTM 0 /* set for move space tests, clear for production */
2133 MoveVolume(register struct cmd_syndesc *as, void *arock)
2137 afs_int32 fromserver, toserver, frompart, topart;
2138 afs_int32 flags, code, err;
2139 char fromPartName[10], toPartName[10];
2141 struct diskPartition64 partition; /* for space check */
2144 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2147 PrintError("", err);
2149 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2150 as->parms[0].items->data);
2153 fromserver = GetServer(as->parms[1].items->data);
2154 if (fromserver == 0) {
2155 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2156 as->parms[1].items->data);
2159 toserver = GetServer(as->parms[3].items->data);
2160 if (toserver == 0) {
2161 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2162 as->parms[3].items->data);
2165 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2167 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2168 as->parms[2].items->data);
2171 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2173 PrintError("", code);
2176 "vos : partition %s does not exist on the server\n",
2177 as->parms[2].items->data);
2180 topart = volutil_GetPartitionID(as->parms[4].items->data);
2182 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2183 as->parms[4].items->data);
2186 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2188 PrintError("", code);
2191 "vos : partition %s does not exist on the server\n",
2192 as->parms[4].items->data);
2197 if (as->parms[5].items) flags |= RV_NOCLONE;
2200 * check source partition for space to clone volume
2203 MapPartIdIntoName(topart, toPartName);
2204 MapPartIdIntoName(frompart, fromPartName);
2207 * check target partition for space to move volume
2210 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2212 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2216 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2219 p = (volintInfo *) 0;
2220 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2222 fprintf(STDERR, "vos:cannot access volume %lu\n",
2223 (unsigned long)volid);
2227 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2229 if (partition.free <= p->size) {
2231 "vos: no space on target partition %s to move volume %lu\n",
2232 toPartName, (unsigned long)volid);
2239 fprintf(STDOUT, "size test - don't do move\n");
2243 /* successful move still not guaranteed but shoot for it */
2246 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2248 PrintDiagnostics("move", code);
2251 MapPartIdIntoName(topart, toPartName);
2252 MapPartIdIntoName(frompart, fromPartName);
2253 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2254 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2255 as->parms[3].items->data, toPartName);
2261 CopyVolume(register struct cmd_syndesc *as, void *arock)
2264 afs_int32 fromserver, toserver, frompart, topart, code, err, flags;
2265 char fromPartName[10], toPartName[10], *tovolume;
2266 struct nvldbentry entry;
2267 struct diskPartition64 partition; /* for space check */
2270 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2273 PrintError("", err);
2275 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2276 as->parms[0].items->data);
2279 fromserver = GetServer(as->parms[1].items->data);
2280 if (fromserver == 0) {
2281 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2282 as->parms[1].items->data);
2286 toserver = GetServer(as->parms[4].items->data);
2287 if (toserver == 0) {
2288 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2289 as->parms[4].items->data);
2293 tovolume = as->parms[3].items->data;
2294 if (!ISNAMEVALID(tovolume)) {
2296 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2297 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2300 if (!VolNameOK(tovolume)) {
2302 "Illegal volume name %s, should not end in .readonly or .backup\n",
2306 if (IsNumeric(tovolume)) {
2307 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2311 code = VLDB_GetEntryByName(tovolume, &entry);
2313 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2314 PrintDiagnostics("copy", code);
2318 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2320 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2321 as->parms[2].items->data);
2324 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2326 PrintError("", code);
2329 "vos : partition %s does not exist on the server\n",
2330 as->parms[2].items->data);
2334 topart = volutil_GetPartitionID(as->parms[5].items->data);
2336 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2337 as->parms[5].items->data);
2340 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2342 PrintError("", code);
2345 "vos : partition %s does not exist on the server\n",
2346 as->parms[5].items->data);
2351 if (as->parms[6].items) flags |= RV_OFFLINE;
2352 if (as->parms[7].items) flags |= RV_RDONLY;
2353 if (as->parms[8].items) flags |= RV_NOCLONE;
2355 MapPartIdIntoName(topart, toPartName);
2356 MapPartIdIntoName(frompart, fromPartName);
2359 * check target partition for space to move volume
2362 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2364 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2368 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2371 p = (volintInfo *) 0;
2372 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2374 fprintf(STDERR, "vos:cannot access volume %lu\n",
2375 (unsigned long)volid);
2379 if (partition.free <= p->size) {
2381 "vos: no space on target partition %s to copy volume %lu\n",
2382 toPartName, (unsigned long)volid);
2388 /* successful copy still not guaranteed but shoot for it */
2391 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2394 PrintDiagnostics("copy", code);
2397 MapPartIdIntoName(topart, toPartName);
2398 MapPartIdIntoName(frompart, fromPartName);
2399 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2400 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2401 tovolume, as->parms[4].items->data, toPartName);
2408 ShadowVolume(register struct cmd_syndesc *as, void *arock)
2410 afs_uint32 volid, tovolid;
2411 afs_int32 fromserver, toserver, frompart, topart;
2412 afs_int32 code, err, flags;
2413 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2414 struct diskPartition64 partition; /* for space check */
2417 p = (volintInfo *) 0;
2418 q = (volintInfo *) 0;
2420 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2423 PrintError("", err);
2425 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2426 as->parms[0].items->data);
2429 fromserver = GetServer(as->parms[1].items->data);
2430 if (fromserver == 0) {
2431 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2432 as->parms[1].items->data);
2436 toserver = GetServer(as->parms[3].items->data);
2437 if (toserver == 0) {
2438 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2439 as->parms[3].items->data);
2443 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2445 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2446 as->parms[2].items->data);
2449 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2451 PrintError("", code);
2454 "vos : partition %s does not exist on the server\n",
2455 as->parms[2].items->data);
2459 topart = volutil_GetPartitionID(as->parms[4].items->data);
2461 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2462 as->parms[4].items->data);
2465 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2467 PrintError("", code);
2470 "vos : partition %s does not exist on the server\n",
2471 as->parms[4].items->data);
2475 if (as->parms[5].items) {
2476 tovolume = as->parms[5].items->data;
2477 if (!ISNAMEVALID(tovolume)) {
2479 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2480 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2483 if (!VolNameOK(tovolume)) {
2485 "Illegal volume name %s, should not end in .readonly or .backup\n",
2489 if (IsNumeric(tovolume)) {
2491 "Illegal volume name %s, should not be a number\n",
2496 /* use actual name of source volume */
2497 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2499 fprintf(STDERR, "vos:cannot access volume %lu\n",
2500 (unsigned long)volid);
2503 strcpy(toVolName, p->name);
2504 tovolume = toVolName;
2505 /* save p for size checks later */
2508 if (as->parms[6].items) {
2509 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2512 PrintError("", err);
2514 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2515 as->parms[6].items->data);
2521 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2524 PrintError("", err);
2526 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2535 if (as->parms[7].items) flags |= RV_OFFLINE;
2536 if (as->parms[8].items) flags |= RV_RDONLY;
2537 if (as->parms[9].items) flags |= RV_NOCLONE;
2538 if (as->parms[10].items) flags |= RV_CPINCR;
2540 MapPartIdIntoName(topart, toPartName);
2541 MapPartIdIntoName(frompart, fromPartName);
2544 * check target partition for space to move volume
2547 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2549 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2553 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2556 /* Don't do this again if we did it above */
2558 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2560 fprintf(STDERR, "vos:cannot access volume %lu\n",
2561 (unsigned long)volid);
2566 /* OK if this fails */
2567 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2569 /* Treat existing volume size as "free" */
2571 p->size = (q->size < p->size) ? p->size - q->size : 0;
2573 if (partition.free <= p->size) {
2575 "vos: no space on target partition %s to copy volume %lu\n",
2576 toPartName, (unsigned long)volid);
2584 /* successful copy still not guaranteed but shoot for it */
2587 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2588 topart, tovolid, flags);
2590 PrintDiagnostics("shadow", code);
2593 MapPartIdIntoName(topart, toPartName);
2594 MapPartIdIntoName(frompart, fromPartName);
2595 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2596 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2597 as->parms[3].items->data, toPartName);
2604 CloneVolume(register struct cmd_syndesc *as, void *arock)
2606 afs_uint32 volid, cloneid;
2607 afs_int32 server, part, voltype;
2608 char partName[10], *volname;
2609 afs_int32 code, err, flags;
2610 struct nvldbentry entry;
2612 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2615 PrintError("", err);
2617 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2618 as->parms[0].items->data);
2622 if (as->parms[1].items || as->parms[2].items) {
2623 if (!as->parms[1].items || !as->parms[2].items) {
2625 "Must specify both -server and -partition options\n");
2628 server = GetServer(as->parms[1].items->data);
2630 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2631 as->parms[1].items->data);
2634 part = volutil_GetPartitionID(as->parms[2].items->data);
2636 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2637 as->parms[2].items->data);
2640 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2642 PrintError("", code);
2645 "vos : partition %s does not exist on the server\n",
2646 as->parms[2].items->data);
2650 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2656 if (as->parms[3].items) {
2657 volname = as->parms[3].items->data;
2658 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2660 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2661 volname, VOLSER_OLDMAXVOLNAME - 1);
2666 * In order that you be able to make clones of RO or BK, this
2667 * check must be omitted.
2669 if (!VolNameOK(volname)) {
2671 "Illegal volume name %s, should not end in .readonly or .backup\n",
2676 if (IsNumeric(volname)) {
2678 "Illegal volume name %s, should not be a number\n",
2685 if (as->parms[4].items) {
2686 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2689 PrintError("", err);
2691 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2692 as->parms[4].items->data);
2698 if (as->parms[5].items) flags |= RV_OFFLINE;
2699 if (as->parms[6].items) flags |= RV_RDONLY;
2703 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2706 PrintDiagnostics("clone", code);
2709 MapPartIdIntoName(part, partName);
2710 fprintf(STDOUT, "Created clone for volume %s\n",
2711 as->parms[0].items->data);
2718 BackupVolume(register struct cmd_syndesc *as, void *arock)
2721 afs_int32 aserver, apart, vtype, code, err;
2722 struct nvldbentry entry;
2725 afs_int32 buserver, bupart, butype;
2726 struct nvldbentry buentry;
2728 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2731 PrintError("", err);
2733 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2734 as->parms[0].items->data);
2737 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2741 /* verify this is a readwrite volume */
2743 if (vtype != RWVOL) {
2744 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2748 /* is there a backup volume already? */
2750 if (entry.flags & BACK_EXISTS) {
2751 /* yep, where is it? */
2753 buvolid = entry.volumeId[BACKVOL];
2754 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2759 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2762 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2768 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2769 (unsigned long)buvolid, (unsigned long)buserver);
2774 /* nope, carry on */
2776 code = UV_BackupVolume(aserver, apart, avolid);
2779 PrintDiagnostics("backup", code);
2782 fprintf(STDOUT, "Created backup volume for %s \n",
2783 as->parms[0].items->data);
2788 ReleaseVolume(register struct cmd_syndesc *as, void *arock)
2791 struct nvldbentry entry;
2793 afs_int32 aserver, apart, vtype, code, err;
2796 if (as->parms[1].items)
2798 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2801 PrintError("", err);
2803 fprintf(STDERR, "vos: can't find volume '%s'\n",
2804 as->parms[0].items->data);
2807 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2811 if (vtype != RWVOL) {
2812 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2816 if (!ISNAMEVALID(entry.name)) {
2818 "Volume name %s is too long, rename before releasing\n",
2823 code = UV_ReleaseVolume(avolid, aserver, apart, force);
2825 PrintDiagnostics("release", code);
2828 fprintf(STDOUT, "Released volume %s successfully\n",
2829 as->parms[0].items->data);
2834 DumpVolume(register struct cmd_syndesc *as, void *arock)
2837 afs_int32 aserver, apart, voltype, fromdate = 0, code, err, i, flags;
2838 char filename[MAXPATHLEN];
2839 struct nvldbentry entry;
2841 rx_SetRxDeadTime(60 * 10);
2842 for (i = 0; i < MAXSERVERS; i++) {
2843 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2846 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2847 if (rxConn->service)
2848 rxConn->service->connDeadTime = rx_connDeadTime;
2851 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2854 PrintError("", err);
2856 fprintf(STDERR, "vos: can't find volume '%s'\n",
2857 as->parms[0].items->data);
2861 if (as->parms[3].items || as->parms[4].items) {
2862 if (!as->parms[3].items || !as->parms[4].items) {
2864 "Must specify both -server and -partition options\n");
2867 aserver = GetServer(as->parms[3].items->data);
2869 fprintf(STDERR, "Invalid server name\n");
2872 apart = volutil_GetPartitionID(as->parms[4].items->data);
2874 fprintf(STDERR, "Invalid partition name\n");
2878 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2883 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2884 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2886 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2887 as->parms[1].items->data, code);
2891 if (as->parms[2].items) {
2892 strcpy(filename, as->parms[2].items->data);
2894 strcpy(filename, "");
2897 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
2899 if (as->parms[5].items) {
2901 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2902 DumpFunction, filename, flags);
2905 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2908 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
2909 flags &= ~VOLDUMPV2_OMITDIRS;
2913 PrintDiagnostics("dump", code);
2916 if (strcmp(filename, ""))
2917 fprintf(STDERR, "Dumped volume %s in file %s\n",
2918 as->parms[0].items->data, filename);
2920 fprintf(STDERR, "Dumped volume %s in stdout \n",
2921 as->parms[0].items->data);
2935 RestoreVolume(register struct cmd_syndesc *as, void *arock)
2937 afs_uint32 avolid, aparentid;
2938 afs_int32 aserver, apart, code, vcode, err;
2939 afs_int32 aoverwrite = ASK;
2940 afs_int32 acreation = 0, alastupdate = 0;
2941 int restoreflags = 0;
2942 int readonly = 0, offline = 0, voltype = RWVOL;
2944 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
2945 char volname[VOLSER_MAXVOLNAME + 1];
2946 struct nvldbentry entry;
2951 if (as->parms[4].items) {
2952 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2955 PrintError("", err);
2957 fprintf(STDERR, "vos: can't find volume '%s'\n",
2958 as->parms[4].items->data);
2964 if (as->parms[5].items) {
2965 if ((strcmp(as->parms[5].items->data, "a") == 0)
2966 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
2968 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
2969 || (strcmp(as->parms[5].items->data, "full") == 0)) {
2971 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
2972 || (strcmp(as->parms[5].items->data, "inc") == 0)
2973 || (strcmp(as->parms[5].items->data, "increment") == 0)
2974 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
2977 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2978 as->parms[5].items->data);
2982 if (as->parms[6].items)
2984 if (as->parms[7].items) {
2989 if (as->parms[8].items) {
2990 if ((strcmp(as->parms[8].items->data, "d") == 0)
2991 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
2992 acreation = TS_DUMP;
2993 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
2994 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
2995 acreation = TS_KEEP;
2996 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
2997 || (strcmp(as->parms[8].items->data, "new") == 0)) {
3000 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
3001 as->parms[8].items->data);
3006 if (as->parms[9].items) {
3007 if ((strcmp(as->parms[9].items->data, "d") == 0)
3008 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
3009 alastupdate = TS_DUMP;
3010 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
3011 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
3012 alastupdate = TS_KEEP;
3013 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
3014 || (strcmp(as->parms[9].items->data, "new") == 0)) {
3015 alastupdate = TS_NEW;
3017 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
3018 as->parms[9].items->data);
3023 aserver = GetServer(as->parms[0].items->data);
3025 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3026 as->parms[0].items->data);
3029 apart = volutil_GetPartitionID(as->parms[1].items->data);
3031 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3032 as->parms[1].items->data);
3035 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3037 PrintError("", code);
3040 "vos : partition %s does not exist on the server\n",
3041 as->parms[1].items->data);
3044 strcpy(avolname, as->parms[2].items->data);
3045 if (!ISNAMEVALID(avolname)) {
3047 "vos: the name of the volume %s exceeds the size limit\n",
3051 if (!VolNameOK(avolname)) {
3053 "Illegal volume name %s, should not end in .readonly or .backup\n",
3057 if (as->parms[3].items) {
3058 strcpy(afilename, as->parms[3].items->data);
3059 if (!FileExists(afilename)) {
3060 fprintf(STDERR, "Can't access file %s\n", afilename);
3064 strcpy(afilename, "");
3067 /* Check if volume exists or not */
3069 vsu_ExtractName(volname, avolname);
3070 vcode = VLDB_GetEntryByName(volname, &entry);
3071 if (vcode) { /* no volume - do a full restore */
3072 restoreflags = RV_FULLRST;
3073 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3075 "Volume does not exist; Will perform a full restore\n");
3078 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3079 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3080 restoreflags = RV_FULLRST;
3081 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3083 "%s Volume does not exist; Will perform a full restore\n",
3084 readonly ? "RO" : "RW");
3087 avolid = entry.volumeId[voltype];
3088 } else if (entry.volumeId[voltype] != 0
3089 && entry.volumeId[voltype] != avolid) {
3090 avolid = entry.volumeId[voltype];
3092 aparentid = entry.volumeId[RWVOL];
3095 else { /* volume exists - do we do a full incremental or abort */
3096 int Oserver, Opart, Otype, vol_elsewhere = 0;
3097 struct nvldbentry Oentry;
3101 avolid = entry.volumeId[voltype];
3102 } else if (entry.volumeId[voltype] != 0
3103 && entry.volumeId[voltype] != avolid) {
3104 avolid = entry.volumeId[voltype];
3106 aparentid = entry.volumeId[RWVOL];
3108 /* A file name was specified - check if volume is on another partition */
3109 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3113 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3116 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3120 if (!vcode || (Opart != apart))
3123 if (aoverwrite == ASK) {
3124 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3126 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3130 /* Ask what to do */
3131 if (vol_elsewhere) {
3133 "The volume %s %u already exists on a different server/part\n",
3134 volname, entry.volumeId[voltype]);
3136 "Do you want to do a full restore or abort? [fa](a): ");
3139 "The volume %s %u already exists in the VLDB\n",
3140 volname, entry.volumeId[voltype]);
3142 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3145 while (!(dc == EOF || dc == '\n'))
3146 dc = getchar(); /* goto end of line */
3147 if ((c == 'f') || (c == 'F'))
3149 else if ((c == 'i') || (c == 'I'))
3155 if (aoverwrite == ABORT) {
3156 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3158 } else if (aoverwrite == FULL) {
3159 restoreflags = RV_FULLRST;
3161 "Volume exists; Will delete and perform full restore\n");
3162 } else if (aoverwrite == INC) {
3164 if (vol_elsewhere) {
3166 "%s volume %lu already exists on a different server/part; not allowed\n",
3167 readonly ? "RO" : "RW", (unsigned long)avolid);
3173 restoreflags |= RV_OFFLINE;
3175 restoreflags |= RV_RDONLY;
3177 switch (acreation) {
3179 restoreflags |= RV_CRDUMP;
3182 restoreflags |= RV_CRKEEP;
3185 restoreflags |= RV_CRNEW;
3188 if (aoverwrite == FULL)
3189 restoreflags |= RV_CRNEW;
3191 restoreflags |= RV_CRKEEP;
3194 switch (alastupdate) {
3196 restoreflags |= RV_LUDUMP;
3199 restoreflags |= RV_LUKEEP;
3202 restoreflags |= RV_LUNEW;
3205 restoreflags |= RV_LUDUMP;
3207 if (as->parms[10].items) {
3208 restoreflags |= RV_NODEL;
3213 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3214 avolname, restoreflags, WriteData, afilename);
3216 PrintDiagnostics("restore", code);
3219 MapPartIdIntoName(apart, apartName);
3222 * patch typo here - originally "parms[1]", should be "parms[0]"
3225 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3226 as->parms[0].items->data, apartName);
3231 LockReleaseCmd(register struct cmd_syndesc *as, void *arock)
3234 afs_int32 code, err;
3236 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3239 PrintError("", err);
3241 fprintf(STDERR, "vos: can't find volume '%s'\n",
3242 as->parms[0].items->data);
3246 code = UV_LockRelease(avolid);
3248 PrintDiagnostics("unlock", code);
3251 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3252 as->parms[0].items->data);
3257 AddSite(register struct cmd_syndesc *as, void *arock)
3260 afs_int32 aserver, apart, code, err, valid = 0;
3261 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3263 vsu_ExtractName(avolname, as->parms[2].items->data);;
3264 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3267 PrintError("", err);
3269 fprintf(STDERR, "vos: can't find volume '%s'\n",
3270 as->parms[2].items->data);
3273 aserver = GetServer(as->parms[0].items->data);
3275 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3276 as->parms[0].items->data);
3279 apart = volutil_GetPartitionID(as->parms[1].items->data);
3281 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3282 as->parms[1].items->data);
3285 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3287 PrintError("", code);
3290 "vos : partition %s does not exist on the server\n",
3291 as->parms[1].items->data);
3294 if (as->parms[3].items) {
3297 code = UV_AddSite(aserver, apart, avolid, valid);
3299 PrintDiagnostics("addsite", code);
3302 MapPartIdIntoName(apart, apartName);
3303 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3304 as->parms[0].items->data, apartName, as->parms[2].items->data);
3309 RemoveSite(register struct cmd_syndesc *as, void *arock)
3313 afs_int32 aserver, apart, code, err;
3314 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3316 vsu_ExtractName(avolname, as->parms[2].items->data);
3317 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3320 PrintError("", err);
3322 fprintf(STDERR, "vos: can't find volume '%s'\n",
3323 as->parms[2].items->data);
3326 aserver = GetServer(as->parms[0].items->data);
3328 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3329 as->parms[0].items->data);
3332 apart = volutil_GetPartitionID(as->parms[1].items->data);
3334 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3335 as->parms[1].items->data);
3339 *skip the partition validity check, since it is possible that the partition
3340 *has since been decomissioned.
3343 if (!IsPartValid(apart,aserver,&code)){
3344 if(code) PrintError("",code);
3345 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3349 code = UV_RemoveSite(aserver, apart, avolid);
3351 PrintDiagnostics("remsite", code);
3354 MapPartIdIntoName(apart, apartName);
3355 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3356 as->parms[0].items->data, apartName, as->parms[2].items->data);
3361 ChangeLocation(register struct cmd_syndesc *as, void *arock)
3364 afs_int32 aserver, apart, code, err;
3367 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3370 PrintError("", err);
3372 fprintf(STDERR, "vos: can't find volume '%s'\n",
3373 as->parms[2].items->data);
3376 aserver = GetServer(as->parms[0].items->data);
3378 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3379 as->parms[0].items->data);
3382 apart = volutil_GetPartitionID(as->parms[1].items->data);
3384 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3385 as->parms[1].items->data);
3388 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3390 PrintError("", code);
3393 "vos : partition %s does not exist on the server\n",
3394 as->parms[1].items->data);
3397 code = UV_ChangeLocation(aserver, apart, avolid);
3399 PrintDiagnostics("addsite", code);
3402 MapPartIdIntoName(apart, apartName);
3403 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3404 as->parms[0].items->data, apartName, as->parms[2].items->data);
3409 ListPartitions(register struct cmd_syndesc *as, void *arock)
3411 afs_int32 aserver, code;
3412 struct partList dummyPartList;
3417 aserver = GetServer(as->parms[0].items->data);
3419 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3420 as->parms[0].items->data);
3425 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3427 PrintDiagnostics("listpart", code);
3431 fprintf(STDOUT, "The partitions on the server are:\n");
3432 for (i = 0; i < cnt; i++) {
3433 if (dummyPartList.partFlags[i] & PARTVALID) {
3434 memset(pname, 0, sizeof(pname));
3435 MapPartIdIntoName(dummyPartList.partId[i], pname);
3436 fprintf(STDOUT, " %10s ", pname);
3438 if ((i % 5) == 0 && (i != 0))
3439 fprintf(STDOUT, "\n");
3442 fprintf(STDOUT, "\n");
3443 fprintf(STDOUT, "Total: %d\n", total);
3449 CompareVolName(p1, p2)
3452 volintInfo *arg1, *arg2;
3454 arg1 = (volintInfo *) p1;
3455 arg2 = (volintInfo *) p2;
3456 return (strcmp(arg1->name, arg2->name));
3460 /*------------------------------------------------------------------------
3461 * PRIVATE XCompareVolName
3464 * Comparison routine for volume names coming from an extended
3468 * a_obj1P : Char ptr to first extended vol info object
3469 * a_obj1P : Char ptr to second extended vol info object
3472 * The value of strcmp() on the volume names within the passed
3473 * objects (i,e., -1, 0, or 1).
3476 * Passed to qsort() as the designated comparison routine.
3480 *------------------------------------------------------------------------*/
3483 XCompareVolName(a_obj1P, a_obj2P)
3484 char *a_obj1P, *a_obj2P;
3486 { /*XCompareVolName */
3489 (((struct volintXInfo *)(a_obj1P))->name,
3490 ((struct volintXInfo *)(a_obj2P))->name));
3492 } /*XCompareVolName */
3495 CompareVolID(p1, p2)
3498 volintInfo *arg1, *arg2;
3500 arg1 = (volintInfo *) p1;
3501 arg2 = (volintInfo *) p2;
3502 if (arg1->volid == arg2->volid)
3504 if (arg1->volid > arg2->volid)
3511 /*------------------------------------------------------------------------
3512 * PRIVATE XCompareVolID
3515 * Comparison routine for volume IDs coming from an extended
3519 * a_obj1P : Char ptr to first extended vol info object
3520 * a_obj1P : Char ptr to second extended vol info object
3523 * The value of strcmp() on the volume names within the passed
3524 * objects (i,e., -1, 0, or 1).
3527 * Passed to qsort() as the designated comparison routine.
3531 *------------------------------------------------------------------------*/
3534 XCompareVolID(a_obj1P, a_obj2P)
3535 char *a_obj1P, *a_obj2P;
3537 { /*XCompareVolID */
3539 afs_int32 id1, id2; /*Volume IDs we're comparing */
3541 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3542 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3550 } /*XCompareVolID */
3552 /*------------------------------------------------------------------------
3553 * PRIVATE ListVolumes
3556 * Routine used to list volumes, contacting the Volume Server
3557 * directly, bypassing the VLDB.
3560 * as : Ptr to parsed command line arguments.
3563 * 0 Successful operation
3566 * Nothing interesting.
3570 *------------------------------------------------------------------------*/
3573 ListVolumes(register struct cmd_syndesc *as, void *arock)
3575 afs_int32 apart, int32list, fast;
3576 afs_int32 aserver, code;
3578 volintInfo *oldpntr = NULL;
3582 volintXInfo *xInfoP;
3583 volintXInfo *origxInfoP = NULL; /*Ptr to current/orig extended vol info */
3584 int wantExtendedInfo; /*Do we want extended vol info? */
3587 struct partList dummyPartList;
3595 if (as->parms[3].items)
3597 if (as->parms[4].items)
3601 if (as->parms[2].items)
3607 if (as->parms[5].items) {
3609 * We can't coexist with the fast flag.
3613 "vos: Can't use the -fast and -extended flags together\n");
3618 * We need to turn on ``long'' listings to get the full effect.
3620 wantExtendedInfo = 1;
3623 wantExtendedInfo = 0;
3624 if (as->parms[1].items) {
3625 apart = volutil_GetPartitionID(as->parms[1].items->data);
3627 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3628 as->parms[1].items->data);
3631 dummyPartList.partId[0] = apart;
3632 dummyPartList.partFlags[0] = PARTVALID;
3635 aserver = GetServer(as->parms[0].items->data);
3637 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3638 as->parms[0].items->data);
3643 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3645 PrintError("", code);
3648 "vos : partition %s does not exist on the server\n",
3649 as->parms[1].items->data);
3653 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3655 PrintDiagnostics("listvol", code);
3659 for (i = 0; i < cnt; i++) {
3660 if (dummyPartList.partFlags[i] & PARTVALID) {
3661 if (wantExtendedInfo)
3663 UV_XListVolumes(aserver, dummyPartList.partId[i], all,
3667 UV_ListVolumes(aserver, dummyPartList.partId[i], all,
3670 PrintDiagnostics("listvol", code);
3675 if (wantExtendedInfo) {
3676 origxInfoP = xInfoP;
3677 base = (char *)xInfoP;
3680 base = (char *)pntr;
3684 if (wantExtendedInfo)
3685 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
3687 qsort(base, count, sizeof(volintInfo), CompareVolName);
3689 if (wantExtendedInfo)
3690 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
3692 qsort(base, count, sizeof(volintInfo), CompareVolID);
3694 MapPartIdIntoName(dummyPartList.partId[i], pname);
3697 "Total number of volumes on server %s partition %s: %lu \n",
3698 as->parms[0].items->data, pname,
3699 (unsigned long)count);
3700 if (wantExtendedInfo) {
3701 #ifdef FULL_LISTVOL_SWITCH
3702 if (as->parms[6].items)
3703 XDisplayVolumes2(aserver, dummyPartList.partId[i], origxInfoP,
3704 count, int32list, fast, quiet);
3706 #endif /* FULL_LISTVOL_SWITCH */
3707 XDisplayVolumes(aserver, dummyPartList.partId[i], origxInfoP,
3708 count, int32list, fast, quiet);
3711 xInfoP = (volintXInfo *) 0;
3713 #ifdef FULL_LISTVOL_SWITCH
3714 if (as->parms[6].items)
3715 DisplayVolumes2(aserver, dummyPartList.partId[i], oldpntr,
3718 #endif /* FULL_LISTVOL_SWITCH */
3719 DisplayVolumes(aserver, dummyPartList.partId[i], oldpntr,
3720 count, int32list, fast, quiet);
3723 pntr = (volintInfo *) 0;
3731 SyncVldb(register struct cmd_syndesc *as, void *arock)
3733 afs_int32 pnum = 0, code; /* part name */
3739 if (as->parms[0].items) {
3740 tserver = GetServer(as->parms[0].items->data);
3742 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3743 as->parms[0].items->data);
3748 if (as->parms[1].items) {
3749 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3751 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3752 as->parms[1].items->data);
3755 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3757 PrintError("", code);
3760 "vos: partition %s does not exist on the server\n",
3761 as->parms[1].items->data);
3768 "The -partition option requires a -server option\n");
3773 if (as->parms[3].items) {
3774 flags |= 2; /* don't update */
3777 if (as->parms[2].items) {
3778 /* Synchronize an individual volume */
3779 volname = as->parms[2].items->data;
3780 code = UV_SyncVolume(tserver, pnum, volname, flags);
3784 "Without a -volume option, the -server option is required\n");
3787 code = UV_SyncVldb(tserver, pnum, flags, 0 /*unused */ );
3791 PrintDiagnostics("syncvldb", code);
3795 /* Print a summary of what we did */
3797 fprintf(STDOUT, "VLDB volume %s synchronized", volname);
3799 fprintf(STDOUT, "VLDB synchronized");
3801 fprintf(STDOUT, " with state of server %s", as->parms[0].items->data);
3804 MapPartIdIntoName(pnum, part);
3805 fprintf(STDOUT, " partition %s\n", part);
3807 fprintf(STDOUT, "\n");
3813 SyncServer(register struct cmd_syndesc *as, void *arock)
3815 afs_int32 pnum, code; /* part name */
3820 tserver = GetServer(as->parms[0].items->data);
3822 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3823 as->parms[0].items->data);
3826 if (as->parms[1].items) {
3827 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3829 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3830 as->parms[1].items->data);
3833 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3835 PrintError("", code);
3838 "vos : partition %s does not exist on the server\n",
3839 as->parms[1].items->data);
3847 if (as->parms[2].items) {
3848 flags |= 2; /* don't update */
3850 code = UV_SyncServer(tserver, pnum, flags, 0 /*unused */ );
3852 PrintDiagnostics("syncserv", code);
3856 MapPartIdIntoName(pnum, part);
3857 fprintf(STDOUT, "Server %s partition %s synchronized with VLDB\n",
3858 as->parms[0].items->data, part);
3860 fprintf(STDOUT, "Server %s synchronized with VLDB\n",
3861 as->parms[0].items->data);
3870 struct nvldbentry entry;
3873 /* The vlserver will handle names with the .readonly
3874 * and .backup extension as well as volume ids.
3876 vcode = VLDB_GetEntryByName(name, &entry);
3878 PrintError("", vcode);
3881 MapHostToNetwork(&entry);
3882 EnumerateEntry(&entry);
3884 /* Defect #3027: grubby check to handle locked volume.
3885 * If VLOP_ALLOPERS is set, the entry is locked.
3886 * Leave this routine as is, but put in correct check.
3888 if (entry.flags & VLOP_ALLOPERS)
3889 fprintf(STDOUT, " Volume is currently LOCKED \n");
3895 VolumeZap(register struct cmd_syndesc *as, void *arock)
3897 struct nvldbentry entry;
3898 afs_uint32 volid, zapbackupid = 0, backupid = 0;
3899 afs_int32 code, server, part, err;
3901 if (as->parms[3].items) {
3902 /* force flag is on, use the other version */
3903 return NukeVolume(as);
3906 if (as->parms[4].items) {
3910 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3913 PrintError("", err);
3915 fprintf(STDERR, "vos: can't find volume '%s'\n",
3916 as->parms[2].items->data);
3919 part = volutil_GetPartitionID(as->parms[1].items->data);
3921 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3922 as->parms[1].items->data);
3925 server = GetServer(as->parms[0].items->data);
3927 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3928 as->parms[0].items->data);
3931 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
3933 PrintError("", code);
3936 "vos : partition %s does not exist on the server\n",
3937 as->parms[1].items->data);
3940 code = VLDB_GetEntryByID(volid, -1, &entry);
3942 if (volid == entry.volumeId[RWVOL])
3943 backupid = entry.volumeId[BACKVOL];
3945 "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
3946 (unsigned long)volid);
3949 volintInfo *pntr = (volintInfo *) 0;
3952 code = UV_ListOneVolume(server, part, volid, &pntr);
3954 if (volid == pntr->parentID)
3955 backupid = pntr->backupID;
3961 code = UV_VolumeZap(server, part, backupid);
3963 PrintDiagnostics("zap", code);
3966 fprintf(STDOUT, "Backup Volume %lu deleted\n",
3967 (unsigned long)backupid);
3970 code = UV_VolumeZap(server, part, volid);
3972 PrintDiagnostics("zap", code);
3975 fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
3981 VolserStatus(register struct cmd_syndesc *as, void *arock)
3983 afs_int32 server, code;
3984 transDebugInfo *pntr, *oldpntr;
3989 server = GetServer(as->parms[0].items->data);
3991 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3992 as->parms[0].items->data);
3995 code = UV_VolserStatus(server, &pntr, &count);
3997 PrintDiagnostics("status", code);
4002 fprintf(STDOUT, "No active transactions on %s\n",
4003 as->parms[0].items->data);
4005 fprintf(STDOUT, "Total transactions: %d\n", count);
4007 for (i = 0; i < count; i++) {
4008 /*print out the relevant info */
4009 fprintf(STDOUT, "--------------------------------------\n");
4010 fprintf(STDOUT, "transaction: %lu created: %s",
4011 (unsigned long)pntr->tid, vos_ctime( & pntr->time));
4012 if (pntr->returnCode) {
4013 fprintf(STDOUT, "returnCode: %lu\n",
4014 (unsigned long)pntr->returnCode);
4017 fprintf(STDOUT, "attachFlags: ");
4018 switch (pntr->iflags) {
4020 fprintf(STDOUT, "offline ");
4023 fprintf(STDOUT, "busy ");
4026 fprintf(STDOUT, "readonly ");
4029 fprintf(STDOUT, "create ");
4032 fprintf(STDOUT, "create volid ");
4035 fprintf(STDOUT, "\n");
4038 fprintf(STDOUT, "volumeStatus: ");
4039 switch (pntr->vflags) {
4040 case VTDeleteOnSalvage:
4041 fprintf(STDOUT, "deleteOnSalvage ");
4042 case VTOutOfService:
4043 fprintf(STDOUT, "outOfService ");
4045 fprintf(STDOUT, "deleted ");
4047 fprintf(STDOUT, "\n");
4050 fprintf(STDOUT, "transactionFlags: ");
4051 fprintf(STDOUT, "delete\n");
4053 MapPartIdIntoName(pntr->partition, pname);
4054 fprintf(STDOUT, "volume: %lu partition: %s procedure: %s\n",
4055 (unsigned long)pntr->volid, pname, pntr->lastProcName);
4056 if (pntr->callValid) {
4058 "packetRead: %lu lastReceiveTime: %d packetSend: %lu lastSendTime: %d\n",
4059 (unsigned long)pntr->readNext, pntr->lastReceiveTime,
4060 (unsigned long)pntr->transmitNext, pntr->lastSendTime);
4063 fprintf(STDOUT, "--------------------------------------\n");
4064 fprintf(STDOUT, "\n");
4072 RenameVolume(register struct cmd_syndesc *as, void *arock)
4074 afs_int32 code1, code2, code;
4075 struct nvldbentry entry;
4077 code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
4079 fprintf(STDERR, "vos: Could not find entry for volume %s\n",
4080 as->parms[0].items->data);
4083 code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
4084 if ((!code1) && (!code2)) { /*the newname already exists */
4085 fprintf(STDERR, "vos: volume %s already exists\n",
4086 as->parms[1].items->data);
4090 if (code1 && code2) {
4091 fprintf(STDERR, "vos: Could not find entry for volume %s or %s\n",
4092 as->parms[0].items->data, as->parms[1].items->data);
4095 if (!VolNameOK(as->parms[0].items->data)) {
4097 "Illegal volume name %s, should not end in .readonly or .backup\n",
4098 as->parms[0].items->data);
4101 if (!ISNAMEVALID(as->parms[1].items->data)) {
4103 "vos: the new volume name %s exceeds the size limit of %d\n",
4104 as->parms[1].items->data, VOLSER_OLDMAXVOLNAME - 10);
4107 if (!VolNameOK(as->parms[1].items->data)) {
4109 "Illegal volume name %s, should not end in .readonly or .backup\n",
4110 as->parms[1].items->data);
4113 if (IsNumeric(as->parms[1].items->data)) {
4114 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
4115 as->parms[1].items->data);
4118 MapHostToNetwork(&entry);
4120 UV_RenameVolume(&entry, as->parms[0].items->data,
4121 as->parms[1].items->data);
4123 PrintDiagnostics("rename", code);
4126 fprintf(STDOUT, "Renamed volume %s to %s\n", as->parms[0].items->data,
4127 as->parms[1].items->data);
4132 GetVolumeInfo(afs_uint32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *voltype,
4133 struct nvldbentry *rentry)
4138 vcode = VLDB_GetEntryByID(volid, -1, rentry);
4141 "Could not fetch the entry for volume %lu from VLDB \n",
4142 (unsigned long)volid);
4143 PrintError("", vcode);
4146 MapHostToNetwork(rentry);
4147 if (volid == rentry->volumeId[ROVOL]) {
4149 for (i = 0; i < rentry->nServers; i++) {
4150 if ((index == -1) && (rentry->serverFlags[i] & ITSROVOL)
4151 && !(rentry->serverFlags[i] & RO_DONTUSE))
4156 "RO volume is not found in VLDB entry for volume %lu\n",
4157 (unsigned long)volid);
4161 *server = rentry->serverNumber[index];
4162 *part = rentry->serverPartition[index];
4166 index = Lp_GetRwIndex(rentry);
4169 "RW Volume is not found in VLDB entry for volume %lu\n",
4170 (unsigned long)volid);
4173 if (volid == rentry->volumeId[RWVOL]) {
4175 *server = rentry->serverNumber[index];
4176 *part = rentry->serverPartition[index];
4179 if (volid == rentry->volumeId[BACKVOL]) {
4181 *server = rentry->serverNumber[index];
4182 *part = rentry->serverPartition[index];
4186 "unexpected volume type for volume %lu\n",
4187 (unsigned long)volid);
4192 DeleteEntry(register struct cmd_syndesc *as, void *arock)
4194 afs_int32 apart = 0;
4197 struct VldbListByAttributes attributes;
4198 nbulkentries arrayEntries;
4199 register struct nvldbentry *vllist;
4200 struct cmd_item *itp;
4203 char prefix[VOLSER_MAXVOLNAME + 1];
4205 afs_int32 totalBack = 0, totalFail = 0, err;
4207 if (as->parms[0].items) { /* -id */
4208 if (as->parms[1].items || as->parms[2].items || as->parms[3].items) {
4210 "You cannot use -server, -partition, or -prefix with the -id argument\n");
4213 for (itp = as->parms[0].items; itp; itp = itp->next) {
4214 avolid = vsu_GetVolumeID(itp->data, cstruct, &err);
4217 PrintError("", err);
4219 fprintf(STDERR, "vos: can't find volume '%s'\n",
4223 if (as->parms[4].items) { /* -noexecute */
4224 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4229 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4231 fprintf(STDERR, "Could not delete entry for volume %s\n",
4234 "You must specify a RW volume name or ID "
4235 "(the entire VLDB entry will be deleted)\n");
4236 PrintError("", vcode);
4242 fprintf(STDOUT, "Deleted %d VLDB entries\n", totalBack);
4246 if (!as->parms[1].items && !as->parms[2].items && !as->parms[3].items) {
4247 fprintf(STDERR, "You must specify an option\n");
4251 /* Zero out search attributes */
4252 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4254 if (as->parms[1].items) { /* -prefix */
4255 strncpy(prefix, as->parms[1].items->data, VOLSER_MAXVOLNAME);
4257 if (!as->parms[2].items && !as->parms[3].items) { /* a single entry only */
4259 "You must provide -server with the -prefix argument\n");
4264 if (as->parms[2].items) { /* -server */
4266 aserver = GetServer(as->parms[2].items->data);
4268 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4269 as->parms[2].items->data);
4272 attributes.server = ntohl(aserver);
4273 attributes.Mask |= VLLIST_SERVER;
4276 if (as->parms[3].items) { /* -partition */
4277 if (!as->parms[2].items) {
4279 "You must provide -server with the -partition argument\n");
4282 apart = volutil_GetPartitionID(as->parms[3].items->data);
4284 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4285 as->parms[3].items->data);
4288 attributes.partition = apart;
4289 attributes.Mask |= VLLIST_PARTITION;
4292 /* Print status line of what we are doing */
4293 fprintf(STDOUT, "Deleting VLDB entries for ");
4294 if (as->parms[2].items) {
4295 fprintf(STDOUT, "server %s ", as->parms[2].items->data);
4297 if (as->parms[3].items) {
4299 MapPartIdIntoName(apart, pname);
4300 fprintf(STDOUT, "partition %s ", pname);
4303 fprintf(STDOUT, "which are prefixed with %s ", prefix);
4305 fprintf(STDOUT, "\n");
4308 /* Get all the VLDB entries on a server and/or partition */
4309 memset(&arrayEntries, 0, sizeof(arrayEntries));
4310 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4312 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4313 PrintError("", vcode);
4317 /* Process each entry */
4318 for (j = 0; j < nentries; j++) {
4319 vllist = &arrayEntries.nbulkentries_val[j];
4321 /* It only deletes the RW volumes */
4322 if (strncmp(vllist->name, prefix, strlen(prefix))) {
4325 "Omitting to delete %s due to prefix %s mismatch\n",
4326 vllist->name, prefix);
4333 if (as->parms[4].items) { /* -noexecute */
4334 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4340 /* Only matches the RW volume name */
4341 avolid = vllist->volumeId[RWVOL];
4342 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4344 fprintf(STDOUT, "Could not delete VDLB entry for %s\n",
4347 PrintError("", vcode);
4352 fprintf(STDOUT, "Deleted VLDB entry for %s \n", vllist->name);
4357 fprintf(STDOUT, "----------------------\n");
4359 "Total VLDB entries deleted: %lu; failed to delete: %lu\n",
4360 (unsigned long)totalBack, (unsigned long)totalFail);
4361 if (arrayEntries.nbulkentries_val)
4362 free(arrayEntries.nbulkentries_val);
4368 CompareVldbEntryByName(p1, p2)
4371 struct nvldbentry *arg1, *arg2;
4373 arg1 = (struct nvldbentry *)p1;
4374 arg2 = (struct nvldbentry *)p2;
4375 return (strcmp(arg1->name, arg2->name));
4379 static int CompareVldbEntry(p1,p2)
4382 struct nvldbentry *arg1,*arg2;
4385 char comp1[100],comp2[100];
4386 char temp1[20],temp2[20];
4388 arg1 = (struct nvldbentry *)p1;
4389 arg2 = (struct nvldbentry *)p2;
4393 for(i = 0; i < arg1->nServers; i++)
4394 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
4395 for(i = 0; i < arg2->nServers; i++)
4396 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
4397 if(pos1 == -1 || pos2 == -1){
4401 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
4402 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
4403 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
4404 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
4405 strcat(comp1,temp1);
4406 strcat(comp2,temp2);
4407 strcat(comp1,arg1->name);
4408 strcat(comp1,arg2->name);
4409 return(strcmp(comp1,comp2));
4415 ListVLDB(struct cmd_syndesc *as, void *arock)
4418 afs_int32 aserver, code;
4420 struct VldbListByAttributes attributes;
4421 nbulkentries arrayEntries;
4422 struct nvldbentry *vllist, *tarray = 0, *ttarray;
4423 afs_int32 centries, nentries = 0;
4424 afs_int32 tarraysize = 0;
4425 afs_int32 parraysize;
4428 int quiet, sort, lock;
4429 afs_int32 thisindex, nextindex;
4434 attributes.Mask = 0;
4435 lock = (as->parms[3].items ? 1 : 0); /* -lock flag */
4436 quiet = (as->parms[4].items ? 1 : 0); /* -quit flag */
4437 sort = (as->parms[5].items ? 0 : 1); /* -nosort flag */
4439 /* If the volume name is given, Use VolumeInfoCmd to look it up
4440 * and not ListAttributes.
4442 if (as->parms[0].items) {
4445 "vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
4448 code = VolumeInfoCmd(as->parms[0].items->data);
4450 PrintError("", code);
4456 /* Server specified */
4457 if (as->parms[1].items) {
4458 aserver = GetServer(as->parms[1].items->data);
4460 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4461 as->parms[1].items->data);
4464 attributes.server = ntohl(aserver);
4465 attributes.Mask |= VLLIST_SERVER;
4468 /* Partition specified */
4469 if (as->parms[2].items) {
4470 apart = volutil_GetPartitionID(as->parms[2].items->data);
4472 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4473 as->parms[2].items->data);
4476 attributes.partition = apart;
4477 attributes.Mask |= VLLIST_PARTITION;
4481 attributes.Mask |= VLLIST_FLAG;
4482 attributes.flag = VLOP_ALLOPERS;
4485 /* Print header information */
4487 MapPartIdIntoName(apart, pname);
4488 fprintf(STDOUT, "VLDB entries for %s %s%s%s %s\n",
4489 (as->parms[1].items ? "server" : "all"),
4490 (as->parms[1].items ? as->parms[1].items->data : "servers"),
4491 (as->parms[2].items ? " partition " : ""),
4492 (as->parms[2].items ? pname : ""),
4493 (lock ? "which are locked:" : ""));
4496 for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
4497 memset(&arrayEntries, 0, sizeof(arrayEntries));
4502 VLDB_ListAttributesN2(&attributes, 0, thisindex, ¢ries,
4503 &arrayEntries, &nextindex);
4504 if (vcode == RXGEN_OPCODE) {
4505 /* Vlserver not running with ListAttributesN2. Fall back */
4507 VLDB_ListAttributes(&attributes, ¢ries, &arrayEntries);
4511 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4512 PrintError("", vcode);
4515 nentries += centries;
4517 /* We don't sort, so just print the entries now */
4519 for (j = 0; j < centries; j++) { /* process each entry */
4520 vllist = &arrayEntries.nbulkentries_val[j];
4521 MapHostToNetwork(vllist);
4522 EnumerateEntry(vllist);
4524 if (vllist->flags & VLOP_ALLOPERS)
4525 fprintf(STDOUT, " Volume is currently LOCKED \n");
4529 /* So we sort. First we must collect all the entries and keep
4532 else if (centries > 0) {
4534 /* steal away the first bulk entries array */
4535 tarray = (struct nvldbentry *)arrayEntries.nbulkentries_val;
4536 tarraysize = centries * sizeof(struct nvldbentry);
4537 arrayEntries.nbulkentries_val = 0;
4539 /* Grow the tarray to keep the extra entries */
4540 parraysize = (centries * sizeof(struct nvldbentry));
4542 (struct nvldbentry *)realloc(tarray,
4543 tarraysize + parraysize);
4546 "Could not allocate enough space for the VLDB entries\n");
4552 memcpy(((char *)tarray) + tarraysize,
4553 (char *)arrayEntries.nbulkentries_val, parraysize);
4554 tarraysize += parraysize;
4558 /* Free the bulk array */
4559 if (arrayEntries.nbulkentries_val) {
4560 free(arrayEntries.nbulkentries_val);
4561 arrayEntries.nbulkentries_val = 0;
4565 /* Here is where we now sort all the entries and print them */
4566 if (sort && (nentries > 0)) {
4567 qsort((char *)tarray, nentries, sizeof(struct nvldbentry),
4568 CompareVldbEntryByName);
4569 for (vllist = tarray, j = 0; j < nentries; j++, vllist++) {
4570 MapHostToNetwork(vllist);
4571 EnumerateEntry(vllist);
4573 if (vllist->flags & VLOP_ALLOPERS)
4574 fprintf(STDOUT, " Volume is currently LOCKED \n");
4580 fprintf(STDOUT, "\nTotal entries: %lu\n", (unsigned long)nentries);
4587 BackSys(register struct cmd_syndesc *as, void *arock)
4590 afs_int32 apart = 0;
4591 afs_int32 aserver = 0, code, aserver1, apart1;
4593 struct VldbListByAttributes attributes;
4594 nbulkentries arrayEntries;
4595 register struct nvldbentry *vllist;
4599 int seenprefix, seenxprefix, exclude, ex, exp, noaction;
4600 afs_int32 totalBack = 0;
4601 afs_int32 totalFail = 0;
4602 int previdx = -1, error, same;
4604 struct cmd_item *ti;
4608 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4609 attributes.Mask = 0;
4611 seenprefix = (as->parms[0].items ? 1 : 0);
4612 exclude = (as->parms[3].items ? 1 : 0);
4613 seenxprefix = (as->parms[4].items ? 1 : 0);
4614 noaction = (as->parms[5].items ? 1 : 0);
4616 if (as->parms[1].items) { /* -server */
4617 aserver = GetServer(as->parms[1].items->data);
4619 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4620 as->parms[1].items->data);
4623 attributes.server = ntohl(aserver);
4624 attributes.Mask |= VLLIST_SERVER;
4627 if (as->parms[2].items) { /* -partition */
4628 apart = volutil_GetPartitionID(as->parms[2].items->data);
4630 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4631 as->parms[2].items->data);
4634 attributes.partition = apart;
4635 attributes.Mask |= VLLIST_PARTITION;
4638 /* Check to make sure the prefix and xprefix expressions compile ok */
4640 for (ti = as->parms[0].items; ti; ti = ti->next) {
4641 if (strncmp(ti->data, "^", 1) == 0) {
4642 #ifdef HAVE_POSIX_REGEX
4646 code = regcomp(&re, ti->data, REG_NOSUB);
4648 regerror(code, &re, errbuf, sizeof errbuf);
4650 "Unrecognizable -prefix regular expression: '%s': %s\n",
4656 ccode = (char *)re_comp(ti->data);
4659 "Unrecognizable -prefix regular expression: '%s': %s\n",
4668 for (ti = as->parms[4].items; ti; ti = ti->next) {
4669 if (strncmp(ti->data, "^", 1) == 0) {
4670 #ifdef HAVE_POSIX_REGEX
4674 code = regcomp(&re, ti->data, REG_NOSUB);
4676 regerror(code, &re, errbuf, sizeof errbuf);
4678 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4684 ccode = (char *)re_comp(ti->data);
4687 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4696 memset(&arrayEntries, 0, sizeof(arrayEntries)); /* initialize to hint the stub to alloc space */
4697 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4699 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4700 PrintError("", vcode);
4704 if (as->parms[1].items || as->parms[2].items || verbose) {
4705 fprintf(STDOUT, "%s up volumes",
4706 (noaction ? "Would have backed" : "Backing"));
4708 if (as->parms[1].items) {
4709 fprintf(STDOUT, " on server %s", as->parms[1].items->data);
4710 } else if (as->parms[2].items) {
4711 fprintf(STDOUT, " for all servers");
4714 if (as->parms[2].items) {
4715 MapPartIdIntoName(apart, pname);
4716 fprintf(STDOUT, " partition %s", pname);
4719 if (seenprefix || (!seenprefix && seenxprefix)) {
4720 ti = (seenprefix ? as->parms[0].items : as->parms[4].items);
4721 ex = (seenprefix ? exclude : !exclude);
4722 exp = (strncmp(ti->data, "^", 1) == 0);
4723 fprintf(STDOUT, " which %smatch %s '%s'", (ex ? "do not " : ""),
4724 (exp ? "expression" : "prefix"), ti->data);
4725 for (ti = ti->next; ti; ti = ti->next) {
4726 exp = (strncmp(ti->data, "^", 1) == 0);
4727 printf(" %sor %s '%s'", (ex ? "n" : ""),
4728 (exp ? "expression" : "prefix"), ti->data);
4732 if (seenprefix && seenxprefix) {
4733 ti = as->parms[4].items;
4734 exp = (strncmp(ti->data, "^", 1) == 0);
4735 fprintf(STDOUT, " %swhich match %s '%s'",
4736 (exclude ? "adding those " : "removing those "),
4737 (exp ? "expression" : "prefix"), ti->data);
4738 for (ti = ti->next; ti; ti = ti->next) {
4739 exp = (strncmp(ti->data, "^", 1) == 0);
4740 printf(" or %s '%s'", (exp ? "expression" : "prefix"),
4744 fprintf(STDOUT, " .. ");
4746 fprintf(STDOUT, "\n");
4750 for (j = 0; j < nentries; j++) { /* process each vldb entry */
4751 vllist = &arrayEntries.nbulkentries_val[j];
4754 for (ti = as->parms[0].items; ti; ti = ti->next) {
4755 if (strncmp(ti->data, "^", 1) == 0) {
4756 #ifdef HAVE_POSIX_REGEX
4760 /* XXX -- should just do the compile once! */
4761 code = regcomp(&re, ti->data, REG_NOSUB);
4763 regerror(code, &re, errbuf, sizeof errbuf);
4765 "Error in -prefix regular expression: '%s': %s\n",
4769 match = (regexec(&re, vllist->name, 0, NULL, 0) == 0);
4772 ccode = (char *)re_comp(ti->data);
4775 "Error in -prefix regular expression: '%s': %s\n",
4779 match = (re_exec(vllist->name) == 1);
4783 (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4793 /* Without the -exclude flag: If it matches the prefix, then
4794 * check if we want to exclude any from xprefix.
4795 * With the -exclude flag: If it matches the prefix, then
4796 * check if we want to add any from xprefix.
4798 if (match && seenxprefix) {
4799 for (ti = as->parms[4].items; ti; ti = ti->next) {
4800 if (strncmp(ti->data, "^", 1) == 0) {
4801 #ifdef HAVE_POSIX_REGEX
4805 /* XXX -- should just do the compile once! */
4806 code = regcomp(&re, ti->data, REG_NOSUB);
4808 regerror(code, &re, errbuf, sizeof errbuf);
4810 "Error in -xprefix regular expression: '%s': %s\n",
4814 if (regexec(&re, vllist->name, 0, NULL, 0) == 0)
4818 ccode = (char *)re_comp(ti->data);
4821 "Error in -xprefix regular expression: '%s': %s\n",
4825 if (re_exec(vllist->name) == 1) {
4831 if (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4841 match = !match; /* -exclude will reverse the match */
4843 continue; /* Skip if no match */
4845 /* Print list of volumes to backup */
4847 fprintf(STDOUT, " %s\n", vllist->name);
4851 if (!(vllist->flags & RW_EXISTS)) {
4854 "Omitting to backup %s since RW volume does not exist \n",
4856 fprintf(STDOUT, "\n");
4862 avolid = vllist->volumeId[RWVOL];
4863 MapHostToNetwork(vllist);
4864 GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
4865 if (aserver1 == -1 || apart1 == -1) {
4866 fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n",
4872 same = VLDB_IsSameAddrs(aserver, aserver1, &error);
4875 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4881 if ((aserver && !same) || (apart && (apart != apart1))) {
4884 "Omitting to backup %s since the RW is in a different location\n",
4890 time_t now = time(0);
4891 fprintf(STDOUT, "Creating backup volume for %s on %s",
4892 vllist->name, ctime(&now));
4896 code = UV_BackupVolume(aserver1, apart1, avolid);
4898 fprintf(STDOUT, "Could not backup %s\n", vllist->name);
4904 fprintf(STDOUT, "\n");
4906 } /* process each vldb entry */
4907 fprintf(STDOUT, "done\n");
4908 fprintf(STDOUT, "Total volumes backed up: %lu; failed to backup: %lu\n",
4909 (unsigned long)totalBack, (unsigned long)totalFail);
4911 if (arrayEntries.nbulkentries_val)
4912 free(arrayEntries.nbulkentries_val);
4917 UnlockVLDB(register struct cmd_syndesc *as, void *arock)
4920 afs_int32 aserver = NULL;
4923 struct VldbListByAttributes attributes;
4924 nbulkentries arrayEntries;
4925 register struct nvldbentry *vllist;
4934 attributes.Mask = 0;
4936 if (as->parms[0].items) { /* server specified */
4937 aserver = GetServer(as->parms[0].items->data);
4939 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4940 as->parms[0].items->data);
4943 attributes.server = ntohl(aserver);
4944 attributes.Mask |= VLLIST_SERVER;
4946 if (as->parms[1].items) { /* partition specified */
4947 apart = volutil_GetPartitionID(as->parms[1].items->data);
4949 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4950 as->parms[1].items->data);
4953 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4955 PrintError("", code);
4958 "vos : partition %s does not exist on the server\n",
4959 as->parms[1].items->data);
4962 attributes.partition = apart;
4963 attributes.Mask |= VLLIST_PARTITION;
4965 attributes.flag = VLOP_ALLOPERS;
4966 attributes.Mask |= VLLIST_FLAG;
4967 memset(&arrayEntries, 0, sizeof(arrayEntries)); /*initialize to hint the stub to alloc space */
4968 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4970 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4971 PrintError("", vcode);
4974 for (j = 0; j < nentries; j++) { /* process each entry */
4975 vllist = &arrayEntries.nbulkentries_val[j];
4976 volid = vllist->volumeId[RWVOL];
4978 ubik_VL_ReleaseLock(cstruct, 0, volid, -1,
4979 LOCKREL_OPCODE | LOCKREL_AFSID |
4982 fprintf(STDERR, "Could not unlock entry for volume %s\n",
4984 PrintError("", vcode);
4989 MapPartIdIntoName(apart, pname);
4992 "Could not lock %lu VLDB entries of %lu locked entries\n",
4993 (unsigned long)totalE, (unsigned long)nentries);
4995 if (as->parms[0].items) {
4997 "Unlocked all the VLDB entries for volumes on server %s ",
4998 as->parms[0].items->data);
4999 if (as->parms[1].items) {
5000 MapPartIdIntoName(apart, pname);
5001 fprintf(STDOUT, "partition %s\n", pname);
5003 fprintf(STDOUT, "\n");
5005 } else if (as->parms[1].items) {
5006 MapPartIdIntoName(apart, pname);
5008 "Unlocked all the VLDB entries for volumes on partition %s on all servers\n",
5013 if (arrayEntries.nbulkentries_val)
5014 free(arrayEntries.nbulkentries_val);
5019 PrintInt64Size(afs_uint64 in)
5021 register afs_uint32 hi, lo;
5022 register char * units;
5023 static char output[16];
5025 SplitInt64(in,hi,lo);
5029 } else if (!(hi & 0xFFFFFC00)) {
5031 lo = (hi << 22) | (lo >> 10);
5032 } else if (!(hi & 0xFFF00000)) {
5034 lo = (hi << 12) | (lo >> 20);
5035 } else if (!(hi & 0xC0000000)) {
5037 lo = (hi << 2) | (lo >> 30);
5042 sprintf(output,"%u %s", lo, units);
5047 PartitionInfo(register struct cmd_syndesc *as, void *arock)
5050 afs_int32 aserver, code;
5052 struct diskPartition64 partition;
5053 struct partList dummyPartList;
5055 int printSummary=0, sumPartitions=0;
5056 afs_uint64 sumFree, sumStorage;
5059 ZeroInt64(sumStorage);
5061 aserver = GetServer(as->parms[0].items->data);
5063 fprintf(STDERR, "vos: server '%s' not found in host table\n",
5064 as->parms[0].items->data);
5067 if (as->parms[1].items) {
5068 apart = volutil_GetPartitionID(as->parms[1].items->data);
5070 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5071 as->parms[1].items->data);
5074 dummyPartList.partId[0] = apart;
5075 dummyPartList.partFlags[0] = PARTVALID;
5078 if (as->parms[2].items) {
5082 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
5084 PrintError("", code);
5087 "vos : partition %s does not exist on the server\n",
5088 as->parms[1].items->data);
5092 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
5094 PrintDiagnostics("listpart", code);
5098 for (i = 0; i < cnt; i++) {
5099 if (dummyPartList.partFlags[i] & PARTVALID) {
5100 MapPartIdIntoName(dummyPartList.partId[i], pname);
5101 code = UV_PartitionInfo64(aserver, pname, &partition);
5103 fprintf(STDERR, "Could not get information on partition %s\n",
5105 PrintError("", code);
5109 "Free space on partition %s: %" AFS_INT64_FMT " K blocks out of total %" AFS_INT64_FMT "\n",
5110 pname, partition.free, partition.minFree);
5112 AddUInt64(sumFree,partition.free,&sumFree);
5113 AddUInt64(sumStorage,partition.minFree,&sumStorage);
5118 "Summary: %s free out of ",
5119 PrintInt64Size(sumFree));
5121 "%s on %d partitions\n",
5122 PrintInt64Size(sumStorage),
5129 ChangeAddr(register struct cmd_syndesc *as, void *arock)
5131 afs_int32 ip1, ip2, vcode;
5134 ip1 = GetServer(as->parms[0].items->data);
5136 fprintf(STDERR, "vos: invalid host address\n");
5140 if ((as->parms[1].items && as->parms[2].items)
5141 || (!as->parms[1].items && !as->parms[2].items)) {
5143 "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
5147 if (as->parms[1].items) {
5148 ip2 = GetServer(as->parms[1].items->data);
5150 fprintf(STDERR, "vos: invalid host address\n");
5154 /* Play a trick here. If we are removing an address, ip1 will be -1
5155 * and ip2 will be the original address. This switch prevents an
5156 * older revision vlserver from removing the IP address.
5163 vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
5166 fprintf(STDERR, "Could not remove server %s from the VLDB\n",
5167 as->parms[0].items->data);
5168 if (vcode == VL_NOENT) {
5170 "vlserver does not support the remove flag or ");
5173 fprintf(STDERR, "Could not change server %s to server %s\n",
5174 as->parms[0].items->data, as->parms[1].items->data);
5176 PrintError("", vcode);
5181 fprintf(STDOUT, "Removed server %s from the VLDB\n",
5182 as->parms[0].items->data);
5184 fprintf(STDOUT, "Changed server %s to server %s\n",
5185 as->parms[0].items->data, as->parms[1].items->data);
5191 print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
5196 struct VLCallBack vlcb;
5199 ListAddrByAttributes m_attrs;
5200 afs_int32 m_nentries, *m_addrp;
5201 afs_int32 base, index;
5205 afsUUID_to_string(m_uuid, buf, sizeof(buf));
5206 printf("UUID: %s\n", buf);
5209 /* print out the list of all the server */
5210 addrp = (afs_int32 *) addrs->bulkaddrs_val;
5211 for (i = 0; i < nentries; i++, addrp++) {
5212 /* If it is a multihomed address, then we will need to
5213 * get the addresses for this multihomed server from
5214 * the vlserver and print them.
5216 if (((*addrp & 0xff000000) == 0xff000000) && ((*addrp) & 0xffff)) {
5217 /* Get the list of multihomed fileservers */
5218 base = (*addrp >> 16) & 0xff;
5219 index = (*addrp) & 0xffff;
5221 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
5222 && (index <= VL_MHSRV_PERBLK)) {
5223 m_attrs.Mask = VLADDR_INDEX;
5224 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
5226 m_addrs.bulkaddrs_val = 0;
5227 m_addrs.bulkaddrs_len = 0;
5229 ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, &m_uuid,
5230 (afs_int32 *)&vlcb, &m_nentries, &m_addrs);
5233 "vos: could not list the multi-homed server addresses\n");
5234 PrintError("", vcode);
5237 /* Print the list */
5238 m_addrp = (afs_int32 *) m_addrs.bulkaddrs_val;
5239 for (j = 0; j < m_nentries; j++, m_addrp++) {
5240 *m_addrp = htonl(*m_addrp);
5243 printf("%s ", afs_inet_ntoa_r(*m_addrp, hoststr));
5245 printf("%s ", hostutil_GetNameByINet(*m_addrp));
5249 printf("<unknown>\n");
5258 /* Otherwise, it is a non-multihomed entry and contains
5259 * the IP address of the server - print it.
5261 *addrp = htonl(*addrp);
5264 printf("%s\n", afs_inet_ntoa_r(*addrp, hoststr));
5266 printf("%s\n", hostutil_GetNameByINet(*addrp));
5277 ListAddrs(register struct cmd_syndesc *as, void *arock)
5280 afs_int32 i, printuuid = 0;
5281 struct VLCallBack vlcb;
5284 ListAddrByAttributes m_attrs;
5285 afsUUID m_uuid, askuuid;
5286 afs_int32 m_nentries;
5288 memset(&m_attrs, 0, sizeof(struct ListAddrByAttributes));
5289 m_attrs.Mask = VLADDR_INDEX;
5291 memset(&m_addrs, 0, sizeof(bulkaddrs));
5292 memset(&askuuid, 0, sizeof(afsUUID));
5293 if (as->parms[0].items) {
5295 if (afsUUID_from_string(as->parms[0].items->data, &askuuid) < 0) {
5296 fprintf(STDERR, "vos: invalid UUID '%s'\n",
5297 as->parms[0].items->data);
5300 m_attrs.Mask = VLADDR_UUID;
5301 m_attrs.uuid = askuuid;
5303 if (as->parms[1].items) {
5307 he = hostutil_GetHostByName((char *)as->parms[1].items->data);
5309 fprintf(STDERR, "vos: Can't get host info for '%s'\n",
5310 as->parms[1].items->data);
5313 memcpy(&saddr, he->h_addr, 4);
5314 m_attrs.Mask = VLADDR_IPADDR;
5315 m_attrs.ipaddr = ntohl(saddr);
5317 if (as->parms[2].items) {
5321 m_addrs.bulkaddrs_val = 0;
5322 m_addrs.bulkaddrs_len = 0;
5325 ubik_Call_New(VL_GetAddrs, cstruct, 0, 0, 0, &vlcb, &nentries,
5328 fprintf(STDERR, "vos: could not list the server addresses\n");
5329 PrintError("", vcode);
5334 m_addrs.bulkaddrs_val = 0;
5335 m_addrs.bulkaddrs_len = 0;
5341 ubik_Call_New(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
5342 &vlcb, &m_nentries, &m_addrs);
5344 if (vcode == VL_NOENT) {
5345 if (m_attrs.Mask == VLADDR_UUID) {
5346 fprintf(STDERR, "vos: no entry for UUID '%s' found in VLDB\n",
5347 as->parms[0].items->data);
5349 } else if (m_attrs.Mask == VLADDR_IPADDR) {
5350 fprintf(STDERR, "vos: no entry for host '%s' [0x%08x] found in VLDB\n",
5351 as->parms[1].items->data, m_attrs.ipaddr);
5360 if (vcode == VL_INDEXERANGE) {
5365 fprintf(STDERR, "vos: could not list the server addresses\n");
5366 PrintError("", vcode);
5370 print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid);
5373 if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
5381 LockEntry(register struct cmd_syndesc *as, void *arock)
5384 afs_int32 vcode, err;
5386 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5389 PrintError("", err);
5391 fprintf(STDERR, "vos: can't find volume '%s'\n",
5392 as->parms[0].items->data);
5395 vcode = ubik_VL_SetLock(cstruct, 0, avolid, -1, VLOP_DELETE);
5397 fprintf(STDERR, "Could not lock VLDB entry for volume %s\n",
5398 as->parms[0].items->data);
5399 PrintError("", vcode);
5402 fprintf(STDOUT, "Locked VLDB entry for volume %s\n",
5403 as->parms[0].items->data);
5408 ConvertRO(register struct cmd_syndesc *as, void *arock)
5410 afs_int32 partition = -1;
5412 afs_int32 server, code, i, same;
5413 struct nvldbentry entry, storeEntry;
5415 afs_int32 rwindex = 0;
5416 afs_int32 rwserver = 0;
5417 afs_int32 rwpartition = 0;
5418 afs_int32 roindex = 0;
5419 afs_int32 roserver = 0;
5420 afs_int32 ropartition = 0;
5422 struct rx_connection *aconn;
5425 server = GetServer(as->parms[0].items->data);
5427 fprintf(STDERR, "vos: host '%s' not found in host table\n",
5428 as->parms[0].items->data);
5431 partition = volutil_GetPartitionID(as->parms[1].items->data);
5432 if (partition < 0) {
5433 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5434 as->parms[1].items->data);
5437 if (!IsPartValid(partition, server, &code)) {
5439 PrintError("", code);
5442 "vos : partition %s does not exist on the server\n",
5443 as->parms[1].items->data);
5446 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &code);
5449 PrintError("", code);
5451 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
5452 as->parms[0].items->data);
5455 if (as->parms[3].items)
5458 vcode = VLDB_GetEntryByID(volid, -1, &entry);
5461 "Could not fetch the entry for volume %lu from VLDB\n",
5462 (unsigned long)volid);
5463 PrintError("convertROtoRW", code);
5467 /* use RO volid even if user specified RW or BK volid */
5469 if (volid != entry.volumeId[ROVOL])
5470 volid = entry.volumeId[ROVOL];
5472 MapHostToNetwork(&entry);
5473 for (i = 0; i < entry.nServers; i++) {
5474 if (entry.serverFlags[i] & ITSRWVOL) {
5476 rwserver = entry.serverNumber[i];
5477 rwpartition = entry.serverPartition[i];
5479 if (entry.serverFlags[i] & ITSROVOL) {
5480 same = VLDB_IsSameAddrs(server, entry.serverNumber[i], &code);
5483 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
5489 roserver = entry.serverNumber[i];
5490 ropartition = entry.serverPartition[i];
5496 fprintf(STDERR, "Warning: RO volume didn't exist in vldb!\n");
5498 if (ropartition != partition) {
5500 "Warning: RO volume should be in partition %d instead of %d (vldb)\n",
5501 ropartition, partition);
5506 "VLDB indicates that a RW volume exists already on %s in partition %s.\n",
5507 hostutil_GetNameByINet(rwserver),
5508 volutil_PartitionName(rwpartition));
5510 fprintf(STDERR, "Overwrite this VLDB entry? [y|n] (n)\n");
5512 while (!(dc == EOF || dc == '\n'))
5513 dc = getchar(); /* goto end of line */
5514 if ((c != 'y') && (c != 'Y')) {
5515 fprintf(STDERR, "aborted.\n");
5522 ubik_VL_SetLock(cstruct, 0, entry.volumeId[RWVOL], RWVOL,
5524 aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
5525 code = AFSVolConvertROtoRWvolume(aconn, partition, volid);
5528 "Converting RO volume %lu to RW volume failed with code %d\n",
5529 (unsigned long)volid, code);
5530 PrintError("convertROtoRW ", code);
5533 entry.serverFlags[roindex] = ITSRWVOL;
5534 entry.flags |= RW_EXISTS;
5535 entry.flags &= ~BACK_EXISTS;
5538 if (rwindex != entry.nServers) {
5539 entry.serverNumber[rwindex] = entry.serverNumber[entry.nServers];
5540 entry.serverPartition[rwindex] =
5541 entry.serverPartition[entry.nServers];
5542 entry.serverFlags[rwindex] = entry.serverFlags[entry.nServers];
5543 entry.serverNumber[entry.nServers] = 0;
5544 entry.serverPartition[entry.nServers] = 0;
5545 entry.serverFlags[entry.nServers] = 0;
5548 entry.flags &= ~RO_EXISTS;
5549 for (i = 0; i < entry.nServers; i++) {
5550 if (entry.serverFlags[i] & ITSROVOL) {
5551 if (!(entry.serverFlags[i] & (RO_DONTUSE | NEW_REPSITE)))
5552 entry.flags |= RO_EXISTS;
5555 MapNetworkToHost(&entry, &storeEntry);
5557 VLDB_ReplaceEntry(entry.volumeId[RWVOL], RWVOL, &storeEntry,
5558 (LOCKREL_OPCODE | LOCKREL_AFSID |
5559 LOCKREL_TIMESTAMP));
5562 "Warning: volume converted, but vldb update failed with code %d!\n",
5565 vcode = UV_LockRelease(entry.volumeId[RWVOL]);
5567 PrintDiagnostics("unlock", vcode);
5573 Sizes(register struct cmd_syndesc *as, void *arock)
5576 afs_int32 aserver, apart, voltype, fromdate = 0, code, err, i;
5577 struct nvldbentry entry;
5578 volintSize vol_size;
5580 rx_SetRxDeadTime(60 * 10);
5581 for (i = 0; i < MAXSERVERS; i++) {
5582 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
5585 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
5586 if (rxConn->service)
5587 rxConn->service->connDeadTime = rx_connDeadTime;
5590 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5593 PrintError("", err);
5595 fprintf(STDERR, "vos: can't find volume '%s'\n",
5596 as->parms[0].items->data);
5600 if (as->parms[1].items || as->parms[2].items) {
5601 if (!as->parms[1].items || !as->parms[2].items) {
5603 "Must specify both -server and -partition options\n");
5606 aserver = GetServer(as->parms[2].items->data);
5608 fprintf(STDERR, "Invalid server name\n");
5611 apart = volutil_GetPartitionID(as->parms[1].items->data);
5613 fprintf(STDERR, "Invalid partition name\n");
5617 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
5624 if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
5625 code = ktime_DateToInt32(as->parms[4].items->data, &fromdate);
5627 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
5628 as->parms[4].items->data, code);
5633 fprintf(STDOUT, "Volume: %s\n", as->parms[0].items->data);
5635 if (as->parms[3].items) { /* do the dump estimate */
5636 #ifdef AFS_64BIT_ENV
5637 vol_size.dump_size = 0;
5639 FillInt64(vol_size.dump_size,0, 1);
5641 code = UV_GetSize(avolid, aserver, apart, fromdate, &vol_size);
5643 PrintDiagnostics("size", code);
5646 /* presumably the size info is now gathered in pntr */
5647 /* now we display it */
5649 fprintf(STDOUT, "dump_size: %llu\n", vol_size.dump_size);
5658 PrintDiagnostics(char *astring, afs_int32 acode)
5660 if (acode == EACCES) {
5662 "You are not authorized to perform the 'vos %s' command (%d)\n",
5665 fprintf(STDERR, "Error in vos %s command.\n", astring);
5666 PrintError("", acode);
5673 MyBeforeProc(struct cmd_syndesc *as, void *arock)
5675 register char *tcell;
5676 register afs_int32 code;
5677 register afs_int32 sauth;
5679 /* Initialize the ubik_client connection */
5680 rx_SetRxDeadTime(90);
5681 cstruct = (struct ubik_client *)0;
5685 if (as->parms[12].items) /* if -cell specified */
5686 tcell = as->parms[12].items->data;
5687 if (as->parms[14].items) /* -serverauth specified */
5689 if (as->parms[16].items) /* -crypt specified */
5692 vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
5693 &cstruct, UV_SetSecurity))) {
5694 fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
5695 (unsigned long)code);
5699 if (as->parms[15].items) /* -verbose flag set */
5703 if (as->parms[17].items) /* -noresolve flag set */
5713 /* this sucks but it works for now.
5718 #include "AFS_component_version_number.c"
5724 register afs_int32 code;
5726 register struct cmd_syndesc *ts;
5728 #ifdef AFS_AIX32_ENV
5730 * The following signal action for AIX is necessary so that in case of a
5731 * crash (i.e. core is generated) we can include the user's data section
5732 * in the core dump. Unfortunately, by default, only a partial core is
5733 * generated which, in many cases, isn't too useful.
5735 struct sigaction nsa;
5737 sigemptyset(&nsa.sa_mask);
5738 nsa.sa_handler = SIG_DFL;
5739 nsa.sa_flags = SA_FULLDUMP;
5740 sigaction(SIGSEGV, &nsa, NULL);
5743 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
5745 cmd_SetBeforeProc(MyBeforeProc, NULL);
5747 ts = cmd_CreateSyntax("create", CreateVolume, NULL, "create a new volume");
5748 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5749 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5750 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "volume name");
5751 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL,
5752 "initial quota (KB)");
5754 cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
5758 ts = cmd_CreateSyntax("remove", DeleteVolume, NULL, "delete a volume");
5759 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5760 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5761 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5765 ts = cmd_CreateSyntax("move", MoveVolume, NULL, "move a volume");
5766 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5767 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5768 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5769 "partition name on source");
5770 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5771 "machine name on destination");
5772 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5773 "partition name on destination");
5774 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5775 "copy live volume without cloning");
5778 ts = cmd_CreateSyntax("copy", CopyVolume, NULL, "copy a volume");
5779 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5780 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5781 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5782 "partition name on source");
5783 cmd_AddParm(ts, "-toname", CMD_SINGLE, 0, "volume name on destination");
5784 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5785 "machine name on destination");
5786 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5787 "partition name on destination");
5788 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5789 "leave new volume offline");
5790 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5791 "make new volume read-only");
5792 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5793 "copy live volume without cloning");
5796 ts = cmd_CreateSyntax("shadow", ShadowVolume, NULL,
5797 "make or update a shadow volume");
5798 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5799 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5800 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5801 "partition name on source");
5802 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5803 "machine name on destination");
5804 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5805 "partition name on destination");
5806 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5807 "volume name on destination");
5808 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5809 "volume ID on destination");
5810 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5811 "leave shadow volume offline");
5812 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5813 "make shadow volume read-only");
5814 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5815 "copy live volume without cloning");
5816 cmd_AddParm(ts, "-incremental", CMD_FLAG, CMD_OPTIONAL,
5817 "do incremental update if target exists");
5820 ts = cmd_CreateSyntax("backup", BackupVolume, NULL,
5821 "make backup of a volume");
5822 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5825 ts = cmd_CreateSyntax("clone", CloneVolume, NULL,
5826 "make clone of a volume");
5827 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5828 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5829 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5830 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5831 "volume name on destination");
5832 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5833 "volume ID on destination");
5834 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5835 "leave clone volume offline");
5836 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5837 "make clone volume read-only, not readwrite");
5840 ts = cmd_CreateSyntax("release", ReleaseVolume, NULL, "release a volume");
5841 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5842 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5843 "force a complete release");
5846 ts = cmd_CreateSyntax("dump", DumpVolume, NULL, "dump a volume");
5847 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5848 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5849 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5850 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5851 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5852 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL,
5853 "dump a clone of the volume");
5854 cmd_AddParm(ts, "-omitdirs", CMD_FLAG, CMD_OPTIONAL,
5855 "omit unchanged directories from an incremental dump");
5858 ts = cmd_CreateSyntax("restore", RestoreVolume, NULL, "restore a volume");
5859 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5860 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5861 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of volume to be restored");
5862 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5863 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
5864 cmd_AddParm(ts, "-overwrite", CMD_SINGLE, CMD_OPTIONAL,
5865 "abort | full | incremental");
5866 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5867 "leave restored volume offline");
5868 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5869 "make restored volume read-only");
5870 cmd_AddParm(ts, "-creation", CMD_SINGLE, CMD_OPTIONAL,
5871 "dump | keep | new");
5872 cmd_AddParm(ts, "-lastupdate", CMD_SINGLE, CMD_OPTIONAL,
5873 "dump | keep | new");
5874 cmd_AddParm(ts, "-nodelete", CMD_FLAG, CMD_OPTIONAL,
5875 "do not delete old site when restoring to a new site");
5878 ts = cmd_CreateSyntax("unlock", LockReleaseCmd, NULL,
5879 "release lock on VLDB entry for a volume");
5880 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5883 ts = cmd_CreateSyntax("changeloc", ChangeLocation, NULL,
5884 "change an RW volume's location in the VLDB");
5885 cmd_AddParm(ts, "-server", CMD_SINGLE, 0,
5886 "machine name for new location");
5887 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5888 "partition name for new location");
5889 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5892 ts = cmd_CreateSyntax("addsite", AddSite, NULL, "add a replication site");
5893 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new site");
5894 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5895 "partition name for new site");
5896 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5897 cmd_AddParm(ts, "-valid", CMD_FLAG, CMD_OPTIONAL, "publish as an up-to-date site in VLDB");
5900 ts = cmd_CreateSyntax("remsite", RemoveSite, NULL,
5901 "remove a replication site");
5902 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5903 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5904 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5907 ts = cmd_CreateSyntax("listpart", ListPartitions, NULL, "list partitions");
5908 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5911 ts = cmd_CreateSyntax("listvol", ListVolumes, NULL,
5912 "list volumes on server (bypass VLDB)");
5913 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5914 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5915 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "minimal listing");
5916 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
5917 "list all normal volume fields");
5918 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5919 "generate minimal information");
5920 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5921 "list extended volume fields");
5922 #ifdef FULL_LISTVOL_SWITCH
5923 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5924 "machine readable format");
5925 #endif /* FULL_LISTVOL_SWITCH */
5928 ts = cmd_CreateSyntax("syncvldb", SyncVldb, NULL,
5929 "synchronize VLDB with server");
5930 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5931 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5932 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5933 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5936 ts = cmd_CreateSyntax("syncserv", SyncServer, NULL,
5937 "synchronize server with VLDB");
5938 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5939 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5940 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5943 ts = cmd_CreateSyntax("examine", ExamineVolume, NULL,
5944 "everything about the volume");
5945 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5946 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5947 "list extended volume fields");
5948 #ifdef FULL_LISTVOL_SWITCH
5949 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5950 "machine readable format");
5951 #endif /* FULL_LISTVOL_SWITCH */
5953 cmd_CreateAlias(ts, "volinfo");
5955 ts = cmd_CreateSyntax("setfields", SetFields, NULL,
5956 "change volume info fields");
5957 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5958 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "quota (KB)");
5959 cmd_AddParm(ts, "-clearuse", CMD_FLAG, CMD_OPTIONAL, "clear dayUse");
5960 cmd_AddParm(ts, "-clearVolUpCounter", CMD_FLAG, CMD_OPTIONAL, "clear volUpdateCounter");
5963 ts = cmd_CreateSyntax("offline", volOffline, NULL, "force the volume status to offline");
5964 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5965 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5966 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5967 cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds to sleep");
5968 cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "busy volume");
5971 ts = cmd_CreateSyntax("online", volOnline, NULL, "force the volume status to online");
5972 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5973 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5974 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5977 ts = cmd_CreateSyntax("zap", VolumeZap, NULL,
5978 "delete the volume, don't bother with VLDB");
5979 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5980 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5981 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume ID");
5982 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5983 "force deletion of bad volumes");
5984 cmd_AddParm(ts, "-backup", CMD_FLAG, CMD_OPTIONAL,
5985 "also delete backup volume if one is found");
5988 ts = cmd_CreateSyntax("status", VolserStatus, NULL,
5989 "report on volser status");
5990 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5993 ts = cmd_CreateSyntax("rename", RenameVolume, NULL, "rename a volume");
5994 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old volume name ");
5995 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new volume name ");
5998 ts = cmd_CreateSyntax("listvldb", ListVLDB, NULL,
5999 "list volumes in the VLDB");
6000 cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
6001 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6002 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6003 cmd_AddParm(ts, "-locked", CMD_FLAG, CMD_OPTIONAL, "locked volumes only");
6004 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
6005 "generate minimal information");
6006 cmd_AddParm(ts, "-nosort", CMD_FLAG, CMD_OPTIONAL,
6007 "do not alphabetically sort the volume names");
6010 ts = cmd_CreateSyntax("backupsys", BackSys, NULL, "en masse backups");
6011 cmd_AddParm(ts, "-prefix", CMD_LIST, CMD_OPTIONAL,
6012 "common prefix on volume(s)");
6013 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6014 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6015 cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL,
6016 "exclude common prefix volumes");
6017 cmd_AddParm(ts, "-xprefix", CMD_LIST, CMD_OPTIONAL,
6018 "negative prefix on volume(s)");
6019 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "no action");
6022 ts = cmd_CreateSyntax("delentry", DeleteEntry, NULL,
6023 "delete VLDB entry for a volume");
6024 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "volume name or ID");
6025 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL,
6026 "prefix of the volume whose VLDB entry is to be deleted");
6027 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6028 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6029 cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL,
6033 ts = cmd_CreateSyntax("partinfo", PartitionInfo, NULL,
6034 "list partition information");
6035 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6036 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6037 cmd_AddParm(ts, "-summary", CMD_FLAG, CMD_OPTIONAL,
6038 "print storage summary");
6041 ts = cmd_CreateSyntax("unlockvldb", UnlockVLDB, NULL,
6042 "unlock all the locked entries in the VLDB");
6043 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6044 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6047 ts = cmd_CreateSyntax("lock", LockEntry, NULL,
6048 "lock VLDB entry for a volume");
6049 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6052 ts = cmd_CreateSyntax("changeaddr", ChangeAddr, NULL,
6053 "change the IP address of a file server");
6054 cmd_AddParm(ts, "-oldaddr", CMD_SINGLE, 0, "original IP address");
6055 cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
6056 cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL,
6057 "remove the IP address from the VLDB");
6060 ts = cmd_CreateSyntax("listaddrs", ListAddrs, NULL,
6061 "list the IP address of all file servers registered in the VLDB");
6062 cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
6063 cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
6064 cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
6065 "print uuid of hosts");
6068 ts = cmd_CreateSyntax("convertROtoRW", ConvertRO, NULL,
6069 "convert a RO volume into a RW volume (after loss of old RW volume)");
6070 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6071 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
6072 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6073 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "don't ask");
6076 ts = cmd_CreateSyntax("size", Sizes, NULL,
6077 "obtain various sizes of the volume.");
6078 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6079 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6080 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6081 cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL,
6082 "Obtain the size of the dump");
6083 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
6086 code = cmd_Dispatch(argc, argv);
6088 /* Shut down the ubik_client and rx connections */
6090 (void)ubik_ClientDestroy(cstruct);
6096 exit((code ? -1 : 0));