2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
16 #include <sys/types.h>
26 #include <netinet/in.h>
27 #include <arpa/inet.h>
31 #include <sys/statfs.h>
39 #include <rx/rx_globals.h>
41 #include <afs/vlserver.h>
42 #include <afs/cellconfig.h>
44 #include <afs/afsutil.h>
46 #include <afs/afsint.h>
51 #include <afs/ihandle.h>
52 #include <afs/vnode.h>
53 #include <afs/volume.h>
60 #include "volser_prototypes.h"
61 #include "vsutils_prototypes.h"
62 #include "lockprocs_prototypes.h"
64 #ifdef HAVE_POSIX_REGEX
68 /* Local Prototypes */
69 int PrintDiagnostics(char *astring, afs_int32 acode);
70 int GetVolumeInfo(afs_int32 volid, afs_int32 *server, afs_int32 *part,
71 afs_int32 *voltype, struct nvldbentry *rentry);
83 #define COMMONPARMS cmd_Seek(ts, 12);\
84 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
85 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");\
86 cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
87 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
88 cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
89 cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL, "don't resolve addresses"); \
91 #define ERROR_EXIT(code) {error=(code); goto error_exit;}
94 struct rx_connection *tconn;
96 extern struct ubik_client *cstruct;
99 static struct tqHead busyHead, notokHead;
102 qInit(struct tqHead *ahead)
104 memset((char *)ahead, 0, sizeof(struct tqHead));
110 qPut(struct tqHead *ahead, afs_int32 volid)
114 elem = (struct tqElem *)malloc(sizeof(struct tqElem));
115 elem->next = ahead->next;
123 qGet(struct tqHead *ahead, afs_int32 *volid)
127 if (ahead->count <= 0)
129 *volid = ahead->next->volid;
131 ahead->next = tmp->next;
137 /* returns 1 if <filename> exists else 0 */
139 FileExists(char *filename)
145 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
149 code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
157 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
159 VolNameOK(char *name)
164 total = strlen(name);
165 if (!strcmp(&name[total - 9], ".readonly")) {
167 } else if (!strcmp(&name[total - 7], ".backup")) {
174 /* return 1 if name is a number else 0 */
176 IsNumeric(char *name)
184 for (i = 0; i < len; i++) {
185 if (*ptr < '0' || *ptr > '9') {
197 * Parse a server name/address and return the address in HOST BYTE order
200 GetServer(char *aname)
202 register struct hostent *th;
205 register afs_int32 code;
206 char hostname[MAXHOSTCHARS];
208 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
210 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
211 addr = ntohl(addr); /* convert to host order */
213 th = gethostbyname(aname);
216 memcpy(&addr, th->h_addr, sizeof(addr));
219 if (addr == htonl(0x7f000001)) { /* local host */
220 code = gethostname(hostname, MAXHOSTCHARS);
223 th = gethostbyname(hostname); /* returns host byte order */
226 memcpy(&addr, th->h_addr, sizeof(addr));
233 GetVolumeType(char *aname)
236 if (!strcmp(aname, "ro"))
238 else if (!strcmp(aname, "rw"))
240 else if (!strcmp(aname, "bk"))
247 IsPartValid(afs_int32 partId, afs_int32 server, afs_int32 *code)
249 struct partList dummyPartList;
255 *code = UV_ListPartitions(server, &dummyPartList, &cnt);
258 for (i = 0; i < cnt; i++) {
259 if (dummyPartList.partFlags[i] & PARTVALID)
260 if (dummyPartList.partId[i] == partId)
268 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
269 * associated with <call> */
271 SendFile(usd_handle_t ufd, register struct rx_call *call, long blksize)
273 char *buffer = (char *)0;
278 buffer = (char *)malloc(blksize);
280 fprintf(STDERR, "malloc failed\n");
284 while (!error && !done) {
285 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
288 FD_SET((int)(ufd->handle), &in);
289 /* don't timeout if read blocks */
290 #if defined(AFS_PTHREAD_ENV)
291 select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
293 IOMGR_Select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
296 error = USD_READ(ufd, buffer, blksize, &nbytes);
298 fprintf(STDERR, "File system read failed\n");
305 if (rx_Write(call, buffer, nbytes) != nbytes) {
315 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
316 * writes it out to the volume. */
318 WriteData(struct rx_call *call, char *rock)
323 afs_int32 error, code;
325 afs_hyper_t filesize, currOffset;
332 if (!filename || !*filename) {
333 usd_StandardInput(&ufd);
337 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
340 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
343 fprintf(STDERR, "Could not access file '%s'\n", filename);
347 /* test if we have a valid dump */
348 hset64(filesize, 0, 0);
349 USD_SEEK(ufd, filesize, SEEK_END, &currOffset);
350 hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32));
351 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
352 USD_READ(ufd, (char *)&buffer, sizeof(afs_uint32), &got);
353 if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
354 fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
358 /* rewind, we are done */
359 hset64(filesize, 0, 0);
360 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
362 code = SendFile(ufd, call, blksize);
369 code = USD_CLOSE(ufd);
371 fprintf(STDERR, "Could not close dump file %s\n",
372 (filename && *filename) ? filename : "STDOUT");
380 /* Receive data from <call> stream into file associated
381 * with <fd> <blksize>
384 ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize)
388 afs_uint32 bytesleft, w;
391 buffer = (char *)malloc(blksize);
393 fprintf(STDERR, "memory allocation failed\n");
397 while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {
398 for (bytesleft = bytesread; bytesleft; bytesleft -= w) {
399 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
402 FD_SET((int)(ufd->handle), &out);
403 /* don't timeout if write blocks */
404 #if defined(AFS_PTHREAD_ENV)
405 select(((int)(ufd->handle)) + 1, &out, 0, 0, 0);
407 IOMGR_Select(((int)(ufd->handle)) + 1, 0, &out, 0, 0);
411 USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
413 fprintf(STDERR, "File system write failed\n");
426 DumpFunction(struct rx_call *call, char *filename)
428 usd_handle_t ufd; /* default is to stdout */
429 afs_int32 error = 0, code;
434 /* Open the output file */
435 if (!filename || !*filename) {
436 usd_StandardOutput(&ufd);
441 usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
445 code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
448 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
451 fprintf(STDERR, "Could not create file '%s'\n", filename);
452 ERROR_EXIT(VOLSERBADOP);
456 code = ReceiveFile(ufd, call, blksize);
461 /* Close the output file */
463 code = USD_CLOSE(ufd);
465 fprintf(STDERR, "Could not close dump file %s\n",
466 (filename && *filename) ? filename : "STDIN");
476 vos_ctime(afs_int32 *timep)
483 DisplayFormat(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
486 afs_int32 server, part;
487 int *totalOK, *totalNotOK, *totalBusy;
488 int fast, longlist, disp;
493 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
494 } else if (longlist) {
495 if (pntr->status == VOK) {
496 fprintf(STDOUT, "%-32s ", pntr->name);
497 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
499 fprintf(STDOUT, "RW ");
501 fprintf(STDOUT, "RO ");
503 fprintf(STDOUT, "BK ");
504 fprintf(STDOUT, "%10d K ", pntr->size);
505 if (pntr->inUse == 1) {
506 fprintf(STDOUT, "On-line");
509 fprintf(STDOUT, "Off-line");
512 if (pntr->needsSalvaged == 1)
513 fprintf(STDOUT, "**needs salvage**");
514 fprintf(STDOUT, "\n");
515 MapPartIdIntoName(part, pname);
516 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
518 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
519 (unsigned long)pntr->parentID,
520 (unsigned long)pntr->cloneID,
521 (unsigned long)pntr->backupID);
522 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
523 fprintf(STDOUT, " Creation %s",
524 vos_ctime(& pntr->creationDate));
525 #ifdef FULL_LISTVOL_SWITCH
526 fprintf(STDOUT, " Copy %s",
527 vos_ctime( & pntr->copyDate));
528 if (!pntr->backupDate)
529 fprintf(STDOUT, " Backup Never\n");
531 fprintf(STDOUT, " Backup %s",
532 vos_ctime( & pntr->backupDate));
533 if (pntr->accessDate)
534 fprintf(STDOUT, " Last Access %s",
535 vos_ctime( & pntr->accessDate));
537 if (!pntr->updateDate)
538 fprintf(STDOUT, " Last Update Never\n");
540 fprintf(STDOUT, " Last Update %s",
541 vos_ctime( & pntr->updateDate));
543 " %d accesses in the past day (i.e., vnode references)\n",
546 } else if (pntr->status == VBUSY) {
548 qPut(&busyHead, pntr->volid);
550 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
551 (unsigned long)pntr->volid);
554 qPut(¬okHead, pntr->volid);
556 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
557 (unsigned long)pntr->volid);
559 fprintf(STDOUT, "\n");
560 } else { /* default listing */
561 if (pntr->status == VOK) {
562 fprintf(STDOUT, "%-32s ", pntr->name);
563 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
565 fprintf(STDOUT, "RW ");
567 fprintf(STDOUT, "RO ");
569 fprintf(STDOUT, "BK ");
570 fprintf(STDOUT, "%10d K ", pntr->size);
571 if (pntr->inUse == 1) {
572 fprintf(STDOUT, "On-line");
575 fprintf(STDOUT, "Off-line");
578 if (pntr->needsSalvaged == 1)
579 fprintf(STDOUT, "**needs salvage**");
580 fprintf(STDOUT, "\n");
581 } else if (pntr->status == VBUSY) {
583 qPut(&busyHead, pntr->volid);
585 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
586 (unsigned long)pntr->volid);
589 qPut(¬okHead, pntr->volid);
591 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
592 (unsigned long)pntr->volid);
597 /*------------------------------------------------------------------------
598 * PRIVATE XDisplayFormat
601 * Display the contents of one extended volume info structure.
604 * a_xInfoP : Ptr to extended volume info struct to print.
605 * a_servID : Server ID to print.
606 * a_partID : Partition ID to print.
607 * a_totalOKP : Ptr to total-OK counter.
608 * a_totalNotOKP : Ptr to total-screwed counter.
609 * a_totalBusyP : Ptr to total-busy counter.
610 * a_fast : Fast listing?
611 * a_int32 : Int32 listing?
612 * a_showProblems : Show volume problems?
618 * Nothing interesting.
622 *------------------------------------------------------------------------*/
625 XDisplayFormat(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
626 a_totalBusyP, a_fast, a_int32, a_showProblems)
627 volintXInfo *a_xInfoP;
637 { /*XDisplayFormat */
645 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
646 } else if (a_int32) {
648 * Fully-detailed listing.
650 if (a_xInfoP->status == VOK) {
652 * Volume's status is OK - all the fields are valid.
654 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
655 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
656 if (a_xInfoP->type == 0)
657 fprintf(STDOUT, "RW ");
658 if (a_xInfoP->type == 1)
659 fprintf(STDOUT, "RO ");
660 if (a_xInfoP->type == 2)
661 fprintf(STDOUT, "BK ");
662 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
663 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
664 if (a_xInfoP->inUse == 1) {
665 fprintf(STDOUT, "On-line");
668 fprintf(STDOUT, "Off-line");
671 fprintf(STDOUT, "\n");
672 MapPartIdIntoName(a_partID, pname);
673 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
675 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
676 (unsigned long)a_xInfoP->parentID,
677 (unsigned long)a_xInfoP->cloneID,
678 (unsigned long)a_xInfoP->backupID);
679 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
680 fprintf(STDOUT, " Creation %s",
681 vos_ctime( & a_xInfoP->creationDate));
682 #ifdef FULL_LISTVOL_SWITCH
683 fprintf(STDOUT, " Copy %s",
684 vos_ctime( & a_xInfoP->copyDate));
685 if (!a_xInfoP->backupDate)
686 fprintf(STDOUT, " Backup Never\n");
688 fprintf(STDOUT, " Backup %s",
689 vos_ctime( & a_xInfoP->backupDate));
690 if (a_xInfoP->accessDate)
691 fprintf(STDOUT, " Last Access %s",
692 vos_ctime( & a_xInfoP->accessDate));
694 if (!a_xInfoP->updateDate)
695 fprintf(STDOUT, " Last Update Never\n");
697 fprintf(STDOUT, " Last Update %s",
698 vos_ctime( & a_xInfoP->updateDate));
700 " %d accesses in the past day (i.e., vnode references)\n",
705 * Print all the read/write and authorship stats.
707 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
709 " |-------------------------------------------|\n");
711 " | Same Network | Diff Network |\n");
713 " |----------|----------|----------|----------|\n");
715 " | Total | Auth | Total | Auth |\n");
717 " |----------|----------|----------|----------|\n");
718 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
719 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
720 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
721 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
722 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
723 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
724 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
725 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
726 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
727 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
729 " |-------------------------------------------|\n\n");
732 " Writes Affecting Authorship\n");
734 " |-------------------------------------------|\n");
736 " | File Authorship | Directory Authorship|\n");
738 " |----------|----------|----------|----------|\n");
740 " | Same | Diff | Same | Diff |\n");
742 " |----------|----------|----------|----------|\n");
743 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
744 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
745 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
746 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
747 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
748 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
749 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
750 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
751 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
752 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
753 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
754 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
755 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
756 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
757 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
758 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
759 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
760 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
761 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
762 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
763 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
764 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
765 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
766 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
767 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
768 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
769 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
770 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
771 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
772 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
774 " |-------------------------------------------|\n");
775 } /*Volume status OK */
776 else if (a_xInfoP->status == VBUSY) {
778 qPut(&busyHead, a_xInfoP->volid);
780 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
781 (unsigned long)a_xInfoP->volid);
785 qPut(¬okHead, a_xInfoP->volid);
787 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
788 (unsigned long)a_xInfoP->volid);
789 } /*Screwed volume */
790 fprintf(STDOUT, "\n");
796 if (a_xInfoP->status == VOK) {
797 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
798 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
799 if (a_xInfoP->type == 0)
800 fprintf(STDOUT, "RW ");
801 if (a_xInfoP->type == 1)
802 fprintf(STDOUT, "RO ");
803 if (a_xInfoP->type == 2)
804 fprintf(STDOUT, "BK ");
805 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
806 if (a_xInfoP->inUse == 1) {
807 fprintf(STDOUT, "On-line");
810 fprintf(STDOUT, "Off-line");
813 fprintf(STDOUT, "\n");
815 else if (a_xInfoP->status == VBUSY) {
817 qPut(&busyHead, a_xInfoP->volid);
819 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
820 (unsigned long)a_xInfoP->volid);
824 qPut(¬okHead, a_xInfoP->volid);
826 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
827 (unsigned long)a_xInfoP->volid);
828 } /*Screwed volume */
829 } /*Default listing */
830 } /*XDisplayFormat */
832 #ifdef FULL_LISTVOL_SWITCH
833 /*------------------------------------------------------------------------
834 * PRIVATE XDisplayFormat2
837 * Display the formated contents of one extended volume info structure.
840 * a_xInfoP : Ptr to extended volume info struct to print.
841 * a_servID : Server ID to print.
842 * a_partID : Partition ID to print.
843 * a_totalOKP : Ptr to total-OK counter.
844 * a_totalNotOKP : Ptr to total-screwed counter.
845 * a_totalBusyP : Ptr to total-busy counter.
846 * a_fast : Fast listing?
847 * a_int32 : Int32 listing?
848 * a_showProblems : Show volume problems?
854 * Nothing interesting.
858 *------------------------------------------------------------------------*/
861 XDisplayFormat2(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
862 a_totalBusyP, a_fast, a_int32, a_showProblems)
863 volintXInfo *a_xInfoP;
873 { /*XDisplayFormat */
878 fprintf(STDOUT, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP->volid);
879 } else if (a_int32) {
881 * Fully-detailed listing.
883 if (a_xInfoP->status == VOK) {
885 * Volume's status is OK - all the fields are valid.
888 static long server_cache = -1, partition_cache = -1;
889 static char hostname[256], address[32], pname[16];
890 int i,ai[] = {VOLINT_STATS_TIME_IDX_0,VOLINT_STATS_TIME_IDX_1,VOLINT_STATS_TIME_IDX_2,
891 VOLINT_STATS_TIME_IDX_3,VOLINT_STATS_TIME_IDX_4,VOLINT_STATS_TIME_IDX_5};
893 if (a_servID != server_cache) {
897 strcpy(hostname, hostutil_GetNameByINet(a_servID));
898 strcpy(address, inet_ntoa(s));
899 server_cache = a_servID;
901 if (a_partID != partition_cache) {
902 MapPartIdIntoName(a_partID, pname);
903 partition_cache = a_partID;
906 fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name);
907 fprintf(STDOUT, "id\t\t%lu\n", 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_int32 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_int32 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_int32 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;
1491 afs_int32 volID, err;
1496 server = GetServer(tp = as->parms[0].items->data);
1498 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1502 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1504 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1508 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1511 PrintError("", err);
1514 "vos: could not parse '%s' as a numeric volume ID", tp);
1519 "vos: forcibly removing all traces of volume %d, please wait...",
1522 code = UV_NukeVolume(server, partID, volID);
1524 fprintf(STDOUT, "done.\n");
1526 fprintf(STDOUT, "failed with code %d.\n", code);
1531 /*------------------------------------------------------------------------
1532 * PRIVATE ExamineVolume
1535 * Routine used to examine a single volume, contacting the VLDB as
1536 * well as the Volume Server.
1539 * as : Ptr to parsed command line arguments.
1542 * 0 for a successful operation,
1543 * Otherwise, one of the ubik or VolServer error values.
1546 * Nothing interesting.
1550 *------------------------------------------------------------------------
1553 ExamineVolume(register struct cmd_syndesc *as, void *arock)
1555 struct nvldbentry entry;
1556 afs_int32 vcode = 0;
1557 volintInfo *pntr = (volintInfo *) 0;
1558 volintXInfo *xInfoP = (volintXInfo *) 0;
1560 afs_int32 code, err, error = 0;
1561 int voltype, foundserv = 0, foundentry = 0;
1562 afs_int32 aserver, apart;
1564 int wantExtendedInfo; /*Do we want extended vol info? */
1566 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1568 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1571 PrintError("", err);
1573 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1574 as->parms[0].items->data);
1579 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1580 (unsigned long)volid);
1583 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1586 "Could not fetch the entry for volume number %lu from VLDB \n",
1587 (unsigned long)volid);
1591 fprintf(STDOUT, "done\n");
1592 MapHostToNetwork(&entry);
1594 if (entry.volumeId[RWVOL] == volid)
1596 else if (entry.volumeId[BACKVOL] == volid)
1598 else /* (entry.volumeId[ROVOL] == volid) */
1601 do { /* do {...} while (voltype == ROVOL) */
1602 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1603 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1604 * If its a RO vol, get the next RO entry.
1606 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1607 &aserver, &apart, &previdx);
1608 if (previdx == -1) { /* searched all entries */
1610 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1611 as->parms[0].items->data);
1618 /* Get information about the volume from the server */
1620 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1621 hostutil_GetNameByINet(aserver));
1624 if (wantExtendedInfo)
1625 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1627 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1629 fprintf(STDOUT, "done\n");
1633 if (code == ENODEV) {
1634 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1635 /* The VLDB says there is no backup volume and its not on disk */
1636 fprintf(STDERR, "Volume %s does not exist\n",
1637 as->parms[0].items->data);
1641 "Volume does not exist on server %s as indicated by the VLDB\n",
1642 hostutil_GetNameByINet(aserver));
1645 PrintDiagnostics("examine", code);
1647 fprintf(STDOUT, "\n");
1650 if (wantExtendedInfo)
1651 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1653 #ifdef FULL_LISTVOL_SWITCH
1654 if (as->parms[2].items) {
1655 DisplayFormat2(aserver, apart, pntr);
1656 EnumerateEntry(&entry);
1658 #endif /* FULL_LISTVOL_SWITCH */
1659 VolumeStats_int(pntr, &entry, aserver, apart, voltype);
1661 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1662 /* The VLDB says there is no backup volume yet we found one on disk */
1663 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1664 as->parms[0].items->data);
1673 } while (voltype == ROVOL);
1676 fprintf(STDERR, "Dump only information from VLDB\n\n");
1677 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1679 PostVolumeStats(&entry);
1684 /*------------------------------------------------------------------------
1688 * Routine used to change the status of a single volume.
1691 * as : Ptr to parsed command line arguments.
1694 * 0 for a successful operation,
1695 * Otherwise, one of the ubik or VolServer error values.
1698 * Nothing interesting.
1702 *------------------------------------------------------------------------
1705 SetFields(register struct cmd_syndesc *as, void *arock)
1707 struct nvldbentry entry;
1708 afs_int32 vcode = 0;
1711 afs_int32 code, err;
1712 afs_int32 aserver, apart;
1715 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1718 PrintError("", err);
1720 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1721 as->parms[0].items->data);
1725 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1728 "Could not fetch the entry for volume number %lu from VLDB \n",
1729 (unsigned long)volid);
1732 MapHostToNetwork(&entry);
1734 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1735 if (previdx == -1) {
1736 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1737 as->parms[0].items->data);
1741 init_volintInfo(&info);
1745 if (as->parms[1].items) {
1747 code = util_GetInt32(as->parms[1].items->data, &info.maxquota);
1749 fprintf(STDERR, "invalid quota value\n");
1753 if (as->parms[2].items) {
1757 if (as->parms[3].items) {
1758 /* -clearVolUpCounter */
1761 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1764 "Could not update volume info fields for volume number %lu\n",
1765 (unsigned long)volid);
1769 /*------------------------------------------------------------------------
1773 * Brings a volume online.
1776 * as : Ptr to parsed command line arguments.
1779 * 0 for a successful operation,
1782 * Nothing interesting.
1786 *------------------------------------------------------------------------
1789 volOnline(register struct cmd_syndesc *as, void *arock)
1791 afs_int32 server, partition, volid;
1792 afs_int32 code, err = 0;
1794 server = GetServer(as->parms[0].items->data);
1796 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1797 as->parms[0].items->data);
1801 partition = volutil_GetPartitionID(as->parms[1].items->data);
1802 if (partition < 0) {
1803 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1804 as->parms[1].items->data);
1808 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1811 PrintError("", err);
1813 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1814 as->parms[0].items->data);
1818 code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ ,
1821 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1828 /*------------------------------------------------------------------------
1829 * PRIVATE volOffline
1832 * Brings a volume offline.
1835 * as : Ptr to parsed command line arguments.
1838 * 0 for a successful operation,
1841 * Nothing interesting.
1845 *------------------------------------------------------------------------
1848 volOffline(register struct cmd_syndesc *as, void *arock)
1850 afs_int32 server, partition, volid;
1851 afs_int32 code, err = 0;
1852 afs_int32 transflag, sleeptime, transdone;
1854 server = GetServer(as->parms[0].items->data);
1856 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1857 as->parms[0].items->data);
1861 partition = volutil_GetPartitionID(as->parms[1].items->data);
1862 if (partition < 0) {
1863 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1864 as->parms[1].items->data);
1868 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1871 PrintError("", err);
1873 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1874 as->parms[0].items->data);
1878 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1879 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1880 transdone = (sleeptime ? 0 /*online */ : VTOutOfService);
1881 if (as->parms[4].items && !as->parms[3].items) {
1882 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1887 UV_SetVolume(server, partition, volid, transflag, transdone,
1890 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1898 CreateVolume(register struct cmd_syndesc *as, void *arock)
1902 afs_int32 volid, code;
1903 struct nvldbentry entry;
1908 tserver = GetServer(as->parms[0].items->data);
1910 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1911 as->parms[0].items->data);
1914 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1916 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1917 as->parms[1].items->data);
1920 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1922 PrintError("", code);
1925 "vos : partition %s does not exist on the server\n",
1926 as->parms[1].items->data);
1929 if (!ISNAMEVALID(as->parms[2].items->data)) {
1931 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1932 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1935 if (!VolNameOK(as->parms[2].items->data)) {
1937 "Illegal volume name %s, should not end in .readonly or .backup\n",
1938 as->parms[2].items->data);
1941 if (IsNumeric(as->parms[2].items->data)) {
1942 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1943 as->parms[2].items->data);
1946 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1948 fprintf(STDERR, "Volume %s already exists\n",
1949 as->parms[2].items->data);
1950 PrintDiagnostics("create", code);
1954 if (as->parms[3].items) {
1955 if (!IsNumeric(as->parms[3].items->data)) {
1956 fprintf(STDERR, "Initial quota %s should be numeric.\n",
1957 as->parms[3].items->data);
1961 code = util_GetInt32(as->parms[3].items->data, "a);
1963 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1969 UV_CreateVolume2(tserver, pnum, as->parms[2].items->data, quota, 0,
1972 PrintDiagnostics("create", code);
1975 MapPartIdIntoName(pnum, part);
1976 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
1977 (unsigned long)volid, part, as->parms[0].items->data);
1984 struct nvldbentry *entry;
1987 afs_int32 error, code, curserver, curpart, volid;
1989 MapHostToNetwork(entry);
1991 for (i = 0; i < entry->nServers; i++) {
1992 curserver = entry->serverNumber[i];
1993 curpart = entry->serverPartition[i];
1994 if (entry->serverFlags[i] & ITSROVOL) {
1995 volid = entry->volumeId[ROVOL];
1997 volid = entry->volumeId[RWVOL];
1999 code = UV_DeleteVolume(curserver, curpart, volid);
2007 DeleteVolume(struct cmd_syndesc *as, void *arock)
2009 afs_int32 err, code = 0;
2010 afs_int32 server = 0, partition = -1, volid;
2014 if (as->parms[0].items) {
2015 server = GetServer(as->parms[0].items->data);
2017 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2018 as->parms[0].items->data);
2023 if (as->parms[1].items) {
2024 partition = volutil_GetPartitionID(as->parms[1].items->data);
2025 if (partition < 0) {
2026 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2027 as->parms[1].items->data);
2031 /* Check for validity of the partition */
2032 if (!IsPartValid(partition, server, &code)) {
2034 PrintError("", code);
2037 "vos : partition %s does not exist on the server\n",
2038 as->parms[1].items->data);
2044 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2046 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
2047 as->parms[2].items->data);
2049 PrintError("", err);
2053 /* If the server or partition option are not complete, try to fill
2054 * them in from the VLDB entry.
2056 if ((partition == -1) || !server) {
2057 struct nvldbentry entry;
2059 code = VLDB_GetEntryByID(volid, -1, &entry);
2062 "Could not fetch the entry for volume %lu from VLDB\n",
2063 (unsigned long)volid);
2064 PrintError("", code);
2068 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
2069 || ((volid == entry.volumeId[BACKVOL])
2070 && (entry.flags & BACK_EXISTS))) {
2071 idx = Lp_GetRwIndex(&entry);
2072 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2073 || ((partition != -1)
2074 && (partition != entry.serverPartition[idx]))) {
2075 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2076 as->parms[2].items->data);
2079 } else if ((volid == entry.volumeId[ROVOL])
2080 && (entry.flags & RO_EXISTS)) {
2081 for (idx = -1, j = 0; j < entry.nServers; j++) {
2082 if (entry.serverFlags[j] != ITSROVOL)
2085 if (((server == 0) || (server == entry.serverNumber[j]))
2086 && ((partition == -1)
2087 || (partition == entry.serverPartition[j]))) {
2090 "VLDB: Volume '%s' matches more than one RO\n",
2091 as->parms[2].items->data);
2098 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2099 as->parms[2].items->data);
2103 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2104 as->parms[2].items->data);
2108 server = htonl(entry.serverNumber[idx]);
2109 partition = entry.serverPartition[idx];
2113 code = UV_DeleteVolume(server, partition, volid);
2115 PrintDiagnostics("remove", code);
2119 MapPartIdIntoName(partition, pname);
2120 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2121 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2125 #define TESTM 0 /* set for move space tests, clear for production */
2127 MoveVolume(register struct cmd_syndesc *as, void *arock)
2130 afs_int32 volid, fromserver, toserver, frompart, topart;
2131 afs_int32 flags, code, err;
2132 char fromPartName[10], toPartName[10];
2134 struct diskPartition64 partition; /* for space check */
2137 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2140 PrintError("", err);
2142 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2143 as->parms[0].items->data);
2146 fromserver = GetServer(as->parms[1].items->data);
2147 if (fromserver == 0) {
2148 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2149 as->parms[1].items->data);
2152 toserver = GetServer(as->parms[3].items->data);
2153 if (toserver == 0) {
2154 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2155 as->parms[3].items->data);
2158 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2160 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2161 as->parms[2].items->data);
2164 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2166 PrintError("", code);
2169 "vos : partition %s does not exist on the server\n",
2170 as->parms[2].items->data);
2173 topart = volutil_GetPartitionID(as->parms[4].items->data);
2175 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2176 as->parms[4].items->data);
2179 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2181 PrintError("", code);
2184 "vos : partition %s does not exist on the server\n",
2185 as->parms[4].items->data);
2190 if (as->parms[5].items) flags |= RV_NOCLONE;
2193 * check source partition for space to clone volume
2196 MapPartIdIntoName(topart, toPartName);
2197 MapPartIdIntoName(frompart, fromPartName);
2200 * check target partition for space to move volume
2203 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2205 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2209 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2212 p = (volintInfo *) 0;
2213 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2215 fprintf(STDERR, "vos:cannot access volume %lu\n",
2216 (unsigned long)volid);
2220 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2222 if (partition.free <= p->size) {
2224 "vos: no space on target partition %s to move volume %lu\n",
2225 toPartName, (unsigned long)volid);
2232 fprintf(STDOUT, "size test - don't do move\n");
2236 /* successful move still not guaranteed but shoot for it */
2239 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2241 PrintDiagnostics("move", code);
2244 MapPartIdIntoName(topart, toPartName);
2245 MapPartIdIntoName(frompart, fromPartName);
2246 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2247 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2248 as->parms[3].items->data, toPartName);
2254 CopyVolume(register struct cmd_syndesc *as, void *arock)
2256 afs_int32 volid, fromserver, toserver, frompart, topart, code, err, flags;
2257 char fromPartName[10], toPartName[10], *tovolume;
2258 struct nvldbentry entry;
2259 struct diskPartition64 partition; /* for space check */
2262 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2265 PrintError("", err);
2267 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2268 as->parms[0].items->data);
2271 fromserver = GetServer(as->parms[1].items->data);
2272 if (fromserver == 0) {
2273 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2274 as->parms[1].items->data);
2278 toserver = GetServer(as->parms[4].items->data);
2279 if (toserver == 0) {
2280 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2281 as->parms[4].items->data);
2285 tovolume = as->parms[3].items->data;
2286 if (!ISNAMEVALID(tovolume)) {
2288 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2289 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2292 if (!VolNameOK(tovolume)) {
2294 "Illegal volume name %s, should not end in .readonly or .backup\n",
2298 if (IsNumeric(tovolume)) {
2299 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2303 code = VLDB_GetEntryByName(tovolume, &entry);
2305 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2306 PrintDiagnostics("copy", code);
2310 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2312 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2313 as->parms[2].items->data);
2316 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2318 PrintError("", code);
2321 "vos : partition %s does not exist on the server\n",
2322 as->parms[2].items->data);
2326 topart = volutil_GetPartitionID(as->parms[5].items->data);
2328 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2329 as->parms[5].items->data);
2332 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2334 PrintError("", code);
2337 "vos : partition %s does not exist on the server\n",
2338 as->parms[5].items->data);
2343 if (as->parms[6].items) flags |= RV_OFFLINE;
2344 if (as->parms[7].items) flags |= RV_RDONLY;
2345 if (as->parms[8].items) flags |= RV_NOCLONE;
2347 MapPartIdIntoName(topart, toPartName);
2348 MapPartIdIntoName(frompart, fromPartName);
2351 * check target partition for space to move volume
2354 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2356 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2360 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2363 p = (volintInfo *) 0;
2364 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2366 fprintf(STDERR, "vos:cannot access volume %lu\n",
2367 (unsigned long)volid);
2371 if (partition.free <= p->size) {
2373 "vos: no space on target partition %s to copy volume %lu\n",
2374 toPartName, (unsigned long)volid);
2380 /* successful copy still not guaranteed but shoot for it */
2383 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2386 PrintDiagnostics("copy", code);
2389 MapPartIdIntoName(topart, toPartName);
2390 MapPartIdIntoName(frompart, fromPartName);
2391 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2392 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2393 tovolume, as->parms[4].items->data, toPartName);
2400 ShadowVolume(register struct cmd_syndesc *as, void *arock)
2402 afs_int32 volid, fromserver, toserver, frompart, topart, tovolid;
2403 afs_int32 code, err, flags;
2404 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2405 struct diskPartition64 partition; /* for space check */
2408 p = (volintInfo *) 0;
2409 q = (volintInfo *) 0;
2411 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2414 PrintError("", err);
2416 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2417 as->parms[0].items->data);
2420 fromserver = GetServer(as->parms[1].items->data);
2421 if (fromserver == 0) {
2422 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2423 as->parms[1].items->data);
2427 toserver = GetServer(as->parms[3].items->data);
2428 if (toserver == 0) {
2429 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2430 as->parms[3].items->data);
2434 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2436 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2437 as->parms[2].items->data);
2440 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2442 PrintError("", code);
2445 "vos : partition %s does not exist on the server\n",
2446 as->parms[2].items->data);
2450 topart = volutil_GetPartitionID(as->parms[4].items->data);
2452 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2453 as->parms[4].items->data);
2456 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2458 PrintError("", code);
2461 "vos : partition %s does not exist on the server\n",
2462 as->parms[4].items->data);
2466 if (as->parms[5].items) {
2467 tovolume = as->parms[5].items->data;
2468 if (!ISNAMEVALID(tovolume)) {
2470 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2471 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2474 if (!VolNameOK(tovolume)) {
2476 "Illegal volume name %s, should not end in .readonly or .backup\n",
2480 if (IsNumeric(tovolume)) {
2482 "Illegal volume name %s, should not be a number\n",
2487 /* use actual name of source volume */
2488 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2490 fprintf(STDERR, "vos:cannot access volume %lu\n",
2491 (unsigned long)volid);
2494 strcpy(toVolName, p->name);
2495 tovolume = toVolName;
2496 /* save p for size checks later */
2499 if (as->parms[6].items) {
2500 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2503 PrintError("", err);
2505 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2506 as->parms[6].items->data);
2512 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2515 PrintError("", err);
2517 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2526 if (as->parms[7].items) flags |= RV_OFFLINE;
2527 if (as->parms[8].items) flags |= RV_RDONLY;
2528 if (as->parms[9].items) flags |= RV_NOCLONE;
2529 if (as->parms[10].items) flags |= RV_CPINCR;
2531 MapPartIdIntoName(topart, toPartName);
2532 MapPartIdIntoName(frompart, fromPartName);
2535 * check target partition for space to move volume
2538 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2540 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2544 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2547 /* Don't do this again if we did it above */
2549 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2551 fprintf(STDERR, "vos:cannot access volume %lu\n",
2552 (unsigned long)volid);
2557 /* OK if this fails */
2558 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2560 /* Treat existing volume size as "free" */
2562 p->size = (q->size < p->size) ? p->size - q->size : 0;
2564 if (partition.free <= p->size) {
2566 "vos: no space on target partition %s to copy volume %lu\n",
2567 toPartName, (unsigned long)volid);
2575 /* successful copy still not guaranteed but shoot for it */
2578 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2579 topart, tovolid, flags);
2581 PrintDiagnostics("shadow", code);
2584 MapPartIdIntoName(topart, toPartName);
2585 MapPartIdIntoName(frompart, fromPartName);
2586 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2587 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2588 as->parms[3].items->data, toPartName);
2595 CloneVolume(register struct cmd_syndesc *as, void *arock)
2597 afs_int32 server, part, volid, cloneid, voltype;
2598 char partName[10], *volname;
2599 afs_int32 code, err, flags;
2600 struct nvldbentry entry;
2602 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2605 PrintError("", err);
2607 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2608 as->parms[0].items->data);
2612 if (as->parms[1].items || as->parms[2].items) {
2613 if (!as->parms[1].items || !as->parms[2].items) {
2615 "Must specify both -server and -partition options\n");
2618 server = GetServer(as->parms[1].items->data);
2620 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2621 as->parms[1].items->data);
2624 part = volutil_GetPartitionID(as->parms[2].items->data);
2626 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2627 as->parms[2].items->data);
2630 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2632 PrintError("", code);
2635 "vos : partition %s does not exist on the server\n",
2636 as->parms[2].items->data);
2640 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2646 if (as->parms[3].items) {
2647 volname = as->parms[3].items->data;
2648 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2650 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2651 volname, VOLSER_OLDMAXVOLNAME - 1);
2656 * In order that you be able to make clones of RO or BK, this
2657 * check must be omitted.
2659 if (!VolNameOK(volname)) {
2661 "Illegal volume name %s, should not end in .readonly or .backup\n",
2666 if (IsNumeric(volname)) {
2668 "Illegal volume name %s, should not be a number\n",
2675 if (as->parms[4].items) {
2676 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2679 PrintError("", err);
2681 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2682 as->parms[4].items->data);
2688 if (as->parms[5].items) flags |= RV_OFFLINE;
2689 if (as->parms[6].items) flags |= RV_RDONLY;
2693 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2696 PrintDiagnostics("clone", code);
2699 MapPartIdIntoName(part, partName);
2700 fprintf(STDOUT, "Created clone for volume %s\n",
2701 as->parms[0].items->data);
2708 BackupVolume(register struct cmd_syndesc *as, void *arock)
2710 afs_int32 avolid, aserver, apart, vtype, code, err;
2711 struct nvldbentry entry;
2713 afs_int32 buvolid, buserver, bupart, butype;
2714 struct nvldbentry buentry;
2716 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2719 PrintError("", err);
2721 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2722 as->parms[0].items->data);
2725 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2729 /* verify this is a readwrite volume */
2731 if (vtype != RWVOL) {
2732 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2736 /* is there a backup volume already? */
2738 if (entry.flags & BACK_EXISTS) {
2739 /* yep, where is it? */
2741 buvolid = entry.volumeId[BACKVOL];
2742 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2747 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2750 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2756 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2757 (unsigned long)buvolid, (unsigned long)buserver);
2762 /* nope, carry on */
2764 code = UV_BackupVolume(aserver, apart, avolid);
2767 PrintDiagnostics("backup", code);
2770 fprintf(STDOUT, "Created backup volume for %s \n",
2771 as->parms[0].items->data);
2776 ReleaseVolume(register struct cmd_syndesc *as, void *arock)
2779 struct nvldbentry entry;
2780 afs_int32 avolid, aserver, apart, vtype, code, err;
2783 if (as->parms[1].items)
2785 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2788 PrintError("", err);
2790 fprintf(STDERR, "vos: can't find volume '%s'\n",
2791 as->parms[0].items->data);
2794 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2798 if (vtype != RWVOL) {
2799 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2803 if (!ISNAMEVALID(entry.name)) {
2805 "Volume name %s is too long, rename before releasing\n",
2810 code = UV_ReleaseVolume(avolid, aserver, apart, force);
2812 PrintDiagnostics("release", code);
2815 fprintf(STDOUT, "Released volume %s successfully\n",
2816 as->parms[0].items->data);
2821 DumpVolume(register struct cmd_syndesc *as, void *arock)
2823 afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i, flags;
2824 char filename[MAXPATHLEN];
2825 struct nvldbentry entry;
2827 rx_SetRxDeadTime(60 * 10);
2828 for (i = 0; i < MAXSERVERS; i++) {
2829 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2832 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2833 if (rxConn->service)
2834 rxConn->service->connDeadTime = rx_connDeadTime;
2837 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2840 PrintError("", err);
2842 fprintf(STDERR, "vos: can't find volume '%s'\n",
2843 as->parms[0].items->data);
2847 if (as->parms[3].items || as->parms[4].items) {
2848 if (!as->parms[3].items || !as->parms[4].items) {
2850 "Must specify both -server and -partition options\n");
2853 aserver = GetServer(as->parms[3].items->data);
2855 fprintf(STDERR, "Invalid server name\n");
2858 apart = volutil_GetPartitionID(as->parms[4].items->data);
2860 fprintf(STDERR, "Invalid partition name\n");
2864 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2869 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2870 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2872 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2873 as->parms[1].items->data, code);
2877 if (as->parms[2].items) {
2878 strcpy(filename, as->parms[2].items->data);
2880 strcpy(filename, "");
2883 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
2885 if (as->parms[5].items) {
2887 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2888 DumpFunction, filename, flags);
2891 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2894 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
2895 flags &= ~VOLDUMPV2_OMITDIRS;
2899 PrintDiagnostics("dump", code);
2902 if (strcmp(filename, ""))
2903 fprintf(STDERR, "Dumped volume %s in file %s\n",
2904 as->parms[0].items->data, filename);
2906 fprintf(STDERR, "Dumped volume %s in stdout \n",
2907 as->parms[0].items->data);
2921 RestoreVolume(register struct cmd_syndesc *as, void *arock)
2923 afs_int32 avolid, aparentid, aserver, apart, code, vcode, err;
2924 afs_int32 aoverwrite = ASK;
2925 afs_int32 acreation = 0, alastupdate = 0;
2926 int restoreflags = 0;
2927 int readonly = 0, offline = 0, voltype = RWVOL;
2929 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
2930 char volname[VOLSER_MAXVOLNAME + 1];
2931 struct nvldbentry entry;
2936 if (as->parms[4].items) {
2937 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2940 PrintError("", err);
2942 fprintf(STDERR, "vos: can't find volume '%s'\n",
2943 as->parms[4].items->data);
2949 if (as->parms[5].items) {
2950 if ((strcmp(as->parms[5].items->data, "a") == 0)
2951 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
2953 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
2954 || (strcmp(as->parms[5].items->data, "full") == 0)) {
2956 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
2957 || (strcmp(as->parms[5].items->data, "inc") == 0)
2958 || (strcmp(as->parms[5].items->data, "increment") == 0)
2959 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
2962 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2963 as->parms[5].items->data);
2967 if (as->parms[6].items)
2969 if (as->parms[7].items) {
2974 if (as->parms[8].items) {
2975 if ((strcmp(as->parms[8].items->data, "d") == 0)
2976 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
2977 acreation = TS_DUMP;
2978 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
2979 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
2980 acreation = TS_KEEP;
2981 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
2982 || (strcmp(as->parms[8].items->data, "new") == 0)) {
2985 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
2986 as->parms[8].items->data);
2991 if (as->parms[9].items) {
2992 if ((strcmp(as->parms[9].items->data, "d") == 0)
2993 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
2994 alastupdate = TS_DUMP;
2995 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
2996 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
2997 alastupdate = TS_KEEP;
2998 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
2999 || (strcmp(as->parms[9].items->data, "new") == 0)) {
3000 alastupdate = TS_NEW;
3002 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
3003 as->parms[9].items->data);
3008 aserver = GetServer(as->parms[0].items->data);
3010 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3011 as->parms[0].items->data);
3014 apart = volutil_GetPartitionID(as->parms[1].items->data);
3016 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3017 as->parms[1].items->data);
3020 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3022 PrintError("", code);
3025 "vos : partition %s does not exist on the server\n",
3026 as->parms[1].items->data);
3029 strcpy(avolname, as->parms[2].items->data);
3030 if (!ISNAMEVALID(avolname)) {
3032 "vos: the name of the volume %s exceeds the size limit\n",
3036 if (!VolNameOK(avolname)) {
3038 "Illegal volume name %s, should not end in .readonly or .backup\n",
3042 if (as->parms[3].items) {
3043 strcpy(afilename, as->parms[3].items->data);
3044 if (!FileExists(afilename)) {
3045 fprintf(STDERR, "Can't access file %s\n", afilename);
3049 strcpy(afilename, "");
3052 /* Check if volume exists or not */
3054 vsu_ExtractName(volname, avolname);
3055 vcode = VLDB_GetEntryByName(volname, &entry);
3056 if (vcode) { /* no volume - do a full restore */
3057 restoreflags = RV_FULLRST;
3058 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3060 "Volume does not exist; Will perform a full restore\n");
3063 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3064 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3065 restoreflags = RV_FULLRST;
3066 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3068 "%s Volume does not exist; Will perform a full restore\n",
3069 readonly ? "RO" : "RW");
3072 avolid = entry.volumeId[voltype];
3073 } else if (entry.volumeId[voltype] != 0
3074 && entry.volumeId[voltype] != avolid) {
3075 avolid = entry.volumeId[voltype];
3077 aparentid = entry.volumeId[RWVOL];
3080 else { /* volume exists - do we do a full incremental or abort */
3081 int Oserver, Opart, Otype, vol_elsewhere = 0;
3082 struct nvldbentry Oentry;
3086 avolid = entry.volumeId[voltype];
3087 } else if (entry.volumeId[voltype] != 0
3088 && entry.volumeId[voltype] != avolid) {
3089 avolid = entry.volumeId[voltype];
3091 aparentid = entry.volumeId[RWVOL];
3093 /* A file name was specified - check if volume is on another partition */
3094 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3098 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3101 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3105 if (!vcode || (Opart != apart))
3108 if (aoverwrite == ASK) {
3109 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3111 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3115 /* Ask what to do */
3116 if (vol_elsewhere) {
3118 "The volume %s %u already exists on a different server/part\n",
3119 volname, entry.volumeId[voltype]);
3121 "Do you want to do a full restore or abort? [fa](a): ");
3124 "The volume %s %u already exists in the VLDB\n",
3125 volname, entry.volumeId[voltype]);
3127 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3130 while (!(dc == EOF || dc == '\n'))
3131 dc = getchar(); /* goto end of line */
3132 if ((c == 'f') || (c == 'F'))
3134 else if ((c == 'i') || (c == 'I'))
3140 if (aoverwrite == ABORT) {
3141 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3143 } else if (aoverwrite == FULL) {
3144 restoreflags = RV_FULLRST;
3146 "Volume exists; Will delete and perform full restore\n");
3147 } else if (aoverwrite == INC) {
3149 if (vol_elsewhere) {
3151 "%s volume %lu already exists on a different server/part; not allowed\n",
3152 readonly ? "RO" : "RW", (unsigned long)avolid);
3158 restoreflags |= RV_OFFLINE;
3160 restoreflags |= RV_RDONLY;
3162 switch (acreation) {
3164 restoreflags |= RV_CRDUMP;
3167 restoreflags |= RV_CRKEEP;
3170 restoreflags |= RV_CRNEW;
3173 if (aoverwrite == FULL)
3174 restoreflags |= RV_CRNEW;
3176 restoreflags |= RV_CRKEEP;
3179 switch (alastupdate) {
3181 restoreflags |= RV_LUDUMP;
3184 restoreflags |= RV_LUKEEP;
3187 restoreflags |= RV_LUNEW;
3190 restoreflags |= RV_LUDUMP;
3192 if (as->parms[10].items) {
3193 restoreflags |= RV_NODEL;
3198 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3199 avolname, restoreflags, WriteData, afilename);
3201 PrintDiagnostics("restore", code);
3204 MapPartIdIntoName(apart, apartName);
3207 * patch typo here - originally "parms[1]", should be "parms[0]"
3210 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3211 as->parms[0].items->data, apartName);
3216 LockReleaseCmd(register struct cmd_syndesc *as, void *arock)
3218 afs_int32 avolid, code, err;
3220 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3223 PrintError("", err);
3225 fprintf(STDERR, "vos: can't find volume '%s'\n",
3226 as->parms[0].items->data);
3230 code = UV_LockRelease(avolid);
3232 PrintDiagnostics("unlock", code);
3235 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3236 as->parms[0].items->data);
3241 AddSite(register struct cmd_syndesc *as, void *arock)
3243 afs_int32 avolid, aserver, apart, code, err, valid = 0;
3244 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3246 vsu_ExtractName(avolname, as->parms[2].items->data);;
3247 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3250 PrintError("", err);
3252 fprintf(STDERR, "vos: can't find volume '%s'\n",
3253 as->parms[2].items->data);
3256 aserver = GetServer(as->parms[0].items->data);
3258 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3259 as->parms[0].items->data);
3262 apart = volutil_GetPartitionID(as->parms[1].items->data);
3264 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3265 as->parms[1].items->data);
3268 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3270 PrintError("", code);
3273 "vos : partition %s does not exist on the server\n",
3274 as->parms[1].items->data);
3277 if (as->parms[3].items) {
3280 code = UV_AddSite(aserver, apart, avolid, valid);
3282 PrintDiagnostics("addsite", code);
3285 MapPartIdIntoName(apart, apartName);
3286 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3287 as->parms[0].items->data, apartName, as->parms[2].items->data);
3292 RemoveSite(register struct cmd_syndesc *as, void *arock)
3295 afs_int32 avolid, aserver, apart, code, err;
3296 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3298 vsu_ExtractName(avolname, as->parms[2].items->data);
3299 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3302 PrintError("", err);
3304 fprintf(STDERR, "vos: can't find volume '%s'\n",
3305 as->parms[2].items->data);
3308 aserver = GetServer(as->parms[0].items->data);
3310 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3311 as->parms[0].items->data);
3314 apart = volutil_GetPartitionID(as->parms[1].items->data);
3316 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3317 as->parms[1].items->data);
3321 *skip the partition validity check, since it is possible that the partition
3322 *has since been decomissioned.
3325 if (!IsPartValid(apart,aserver,&code)){
3326 if(code) PrintError("",code);
3327 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3331 code = UV_RemoveSite(aserver, apart, avolid);
3333 PrintDiagnostics("remsite", code);
3336 MapPartIdIntoName(apart, apartName);
3337 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3338 as->parms[0].items->data, apartName, as->parms[2].items->data);
3343 ChangeLocation(register struct cmd_syndesc *as, void *arock)
3345 afs_int32 avolid, aserver, apart, code, err;
3348 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3351 PrintError("", err);
3353 fprintf(STDERR, "vos: can't find volume '%s'\n",
3354 as->parms[2].items->data);
3357 aserver = GetServer(as->parms[0].items->data);
3359 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3360 as->parms[0].items->data);
3363 apart = volutil_GetPartitionID(as->parms[1].items->data);
3365 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3366 as->parms[1].items->data);
3369 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3371 PrintError("", code);
3374 "vos : partition %s does not exist on the server\n",
3375 as->parms[1].items->data);
3378 code = UV_ChangeLocation(aserver, apart, avolid);
3380 PrintDiagnostics("addsite", code);
3383 MapPartIdIntoName(apart, apartName);
3384 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3385 as->parms[0].items->data, apartName, as->parms[2].items->data);
3390 ListPartitions(register struct cmd_syndesc *as, void *arock)
3392 afs_int32 aserver, code;
3393 struct partList dummyPartList;
3398 aserver = GetServer(as->parms[0].items->data);
3400 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3401 as->parms[0].items->data);
3406 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3408 PrintDiagnostics("listpart", code);
3412 fprintf(STDOUT, "The partitions on the server are:\n");
3413 for (i = 0; i < cnt; i++) {
3414 if (dummyPartList.partFlags[i] & PARTVALID) {
3415 memset(pname, 0, sizeof(pname));
3416 MapPartIdIntoName(dummyPartList.partId[i], pname);
3417 fprintf(STDOUT, " %10s ", pname);
3419 if ((i % 5) == 0 && (i != 0))
3420 fprintf(STDOUT, "\n");
3423 fprintf(STDOUT, "\n");
3424 fprintf(STDOUT, "Total: %d\n", total);
3430 CompareVolName(p1, p2)
3433 volintInfo *arg1, *arg2;
3435 arg1 = (volintInfo *) p1;
3436 arg2 = (volintInfo *) p2;
3437 return (strcmp(arg1->name, arg2->name));
3441 /*------------------------------------------------------------------------
3442 * PRIVATE XCompareVolName
3445 * Comparison routine for volume names coming from an extended
3449 * a_obj1P : Char ptr to first extended vol info object
3450 * a_obj1P : Char ptr to second extended vol info object
3453 * The value of strcmp() on the volume names within the passed
3454 * objects (i,e., -1, 0, or 1).
3457 * Passed to qsort() as the designated comparison routine.
3461 *------------------------------------------------------------------------*/
3464 XCompareVolName(a_obj1P, a_obj2P)
3465 char *a_obj1P, *a_obj2P;
3467 { /*XCompareVolName */
3470 (((struct volintXInfo *)(a_obj1P))->name,
3471 ((struct volintXInfo *)(a_obj2P))->name));
3473 } /*XCompareVolName */
3476 CompareVolID(p1, p2)
3479 volintInfo *arg1, *arg2;
3481 arg1 = (volintInfo *) p1;
3482 arg2 = (volintInfo *) p2;
3483 if (arg1->volid == arg2->volid)
3485 if (arg1->volid > arg2->volid)
3492 /*------------------------------------------------------------------------
3493 * PRIVATE XCompareVolID
3496 * Comparison routine for volume IDs coming from an extended
3500 * a_obj1P : Char ptr to first extended vol info object
3501 * a_obj1P : Char ptr to second extended vol info object
3504 * The value of strcmp() on the volume names within the passed
3505 * objects (i,e., -1, 0, or 1).
3508 * Passed to qsort() as the designated comparison routine.
3512 *------------------------------------------------------------------------*/
3515 XCompareVolID(a_obj1P, a_obj2P)
3516 char *a_obj1P, *a_obj2P;
3518 { /*XCompareVolID */
3520 afs_int32 id1, id2; /*Volume IDs we're comparing */
3522 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3523 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3531 } /*XCompareVolID */
3533 /*------------------------------------------------------------------------
3534 * PRIVATE ListVolumes
3537 * Routine used to list volumes, contacting the Volume Server
3538 * directly, bypassing the VLDB.
3541 * as : Ptr to parsed command line arguments.
3544 * 0 Successful operation
3547 * Nothing interesting.
3551 *------------------------------------------------------------------------*/
3554 ListVolumes(register struct cmd_syndesc *as, void *arock)
3556 afs_int32 apart, int32list, fast;
3557 afs_int32 aserver, code;
3559 volintInfo *oldpntr = NULL;
3563 volintXInfo *xInfoP;
3564 volintXInfo *origxInfoP = NULL; /*Ptr to current/orig extended vol info */
3565 int wantExtendedInfo; /*Do we want extended vol info? */
3568 struct partList dummyPartList;
3576 if (as->parms[3].items)
3578 if (as->parms[4].items)
3582 if (as->parms[2].items)
3588 if (as->parms[5].items) {
3590 * We can't coexist with the fast flag.
3594 "vos: Can't use the -fast and -extended flags together\n");
3599 * We need to turn on ``long'' listings to get the full effect.
3601 wantExtendedInfo = 1;
3604 wantExtendedInfo = 0;
3605 if (as->parms[1].items) {
3606 apart = volutil_GetPartitionID(as->parms[1].items->data);
3608 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3609 as->parms[1].items->data);
3612 dummyPartList.partId[0] = apart;
3613 dummyPartList.partFlags[0] = PARTVALID;
3616 aserver = GetServer(as->parms[0].items->data);
3618 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3619 as->parms[0].items->data);
3624 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3626 PrintError("", code);
3629 "vos : partition %s does not exist on the server\n",
3630 as->parms[1].items->data);
3634 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3636 PrintDiagnostics("listvol", code);
3640 for (i = 0; i < cnt; i++) {
3641 if (dummyPartList.partFlags[i] & PARTVALID) {
3642 if (wantExtendedInfo)
3644 UV_XListVolumes(aserver, dummyPartList.partId[i], all,
3648 UV_ListVolumes(aserver, dummyPartList.partId[i], all,
3651 PrintDiagnostics("listvol", code);
3656 if (wantExtendedInfo) {
3657 origxInfoP = xInfoP;
3658 base = (char *)xInfoP;
3661 base = (char *)pntr;
3665 if (wantExtendedInfo)
3666 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
3668 qsort(base, count, sizeof(volintInfo), CompareVolName);
3670 if (wantExtendedInfo)
3671 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
3673 qsort(base, count, sizeof(volintInfo), CompareVolID);
3675 MapPartIdIntoName(dummyPartList.partId[i], pname);
3678 "Total number of volumes on server %s partition %s: %lu \n",
3679 as->parms[0].items->data, pname,
3680 (unsigned long)count);
3681 if (wantExtendedInfo) {
3682 #ifdef FULL_LISTVOL_SWITCH
3683 if (as->parms[6].items)
3684 XDisplayVolumes2(aserver, dummyPartList.partId[i], origxInfoP,
3685 count, int32list, fast, quiet);
3687 #endif /* FULL_LISTVOL_SWITCH */
3688 XDisplayVolumes(aserver, dummyPartList.partId[i], origxInfoP,
3689 count, int32list, fast, quiet);
3692 xInfoP = (volintXInfo *) 0;
3694 #ifdef FULL_LISTVOL_SWITCH
3695 if (as->parms[6].items)
3696 DisplayVolumes2(aserver, dummyPartList.partId[i], oldpntr,
3699 #endif /* FULL_LISTVOL_SWITCH */
3700 DisplayVolumes(aserver, dummyPartList.partId[i], oldpntr,
3701 count, int32list, fast, quiet);
3704 pntr = (volintInfo *) 0;
3712 SyncVldb(register struct cmd_syndesc *as, void *arock)
3714 afs_int32 pnum = 0, code; /* part name */
3720 if (as->parms[0].items) {
3721 tserver = GetServer(as->parms[0].items->data);
3723 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3724 as->parms[0].items->data);
3729 if (as->parms[1].items) {
3730 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3732 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3733 as->parms[1].items->data);
3736 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3738 PrintError("", code);
3741 "vos: partition %s does not exist on the server\n",
3742 as->parms[1].items->data);
3749 "The -partition option requires a -server option\n");
3754 if (as->parms[3].items) {
3755 flags |= 2; /* don't update */
3758 if (as->parms[2].items) {
3759 /* Synchronize an individual volume */
3760 volname = as->parms[2].items->data;
3761 code = UV_SyncVolume(tserver, pnum, volname, flags);
3765 "Without a -volume option, the -server option is required\n");
3768 code = UV_SyncVldb(tserver, pnum, flags, 0 /*unused */ );
3772 PrintDiagnostics("syncvldb", code);
3776 /* Print a summary of what we did */
3778 fprintf(STDOUT, "VLDB volume %s synchronized", volname);
3780 fprintf(STDOUT, "VLDB synchronized");
3782 fprintf(STDOUT, " with state of server %s", as->parms[0].items->data);
3785 MapPartIdIntoName(pnum, part);
3786 fprintf(STDOUT, " partition %s\n", part);
3788 fprintf(STDOUT, "\n");
3794 SyncServer(register struct cmd_syndesc *as, void *arock)
3796 afs_int32 pnum, code; /* part name */
3801 tserver = GetServer(as->parms[0].items->data);
3803 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3804 as->parms[0].items->data);
3807 if (as->parms[1].items) {
3808 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3810 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3811 as->parms[1].items->data);
3814 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3816 PrintError("", code);
3819 "vos : partition %s does not exist on the server\n",
3820 as->parms[1].items->data);
3828 if (as->parms[2].items) {
3829 flags |= 2; /* don't update */
3831 code = UV_SyncServer(tserver, pnum, flags, 0 /*unused */ );
3833 PrintDiagnostics("syncserv", code);
3837 MapPartIdIntoName(pnum, part);
3838 fprintf(STDOUT, "Server %s partition %s synchronized with VLDB\n",
3839 as->parms[0].items->data, part);
3841 fprintf(STDOUT, "Server %s synchronized with VLDB\n",
3842 as->parms[0].items->data);
3851 struct nvldbentry entry;
3854 /* The vlserver will handle names with the .readonly
3855 * and .backup extension as well as volume ids.
3857 vcode = VLDB_GetEntryByName(name, &entry);
3859 PrintError("", vcode);
3862 MapHostToNetwork(&entry);
3863 EnumerateEntry(&entry);
3865 /* Defect #3027: grubby check to handle locked volume.
3866 * If VLOP_ALLOPERS is set, the entry is locked.
3867 * Leave this routine as is, but put in correct check.
3869 if (entry.flags & VLOP_ALLOPERS)
3870 fprintf(STDOUT, " Volume is currently LOCKED \n");
3876 VolumeZap(register struct cmd_syndesc *as, void *arock)
3878 struct nvldbentry entry;
3879 afs_int32 volid, code, server, part, zapbackupid = 0, backupid = 0, err;
3881 if (as->parms[3].items) {
3882 /* force flag is on, use the other version */
3883 return NukeVolume(as);
3886 if (as->parms[4].items) {
3890 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3893 PrintError("", err);
3895 fprintf(STDERR, "vos: can't find volume '%s'\n",
3896 as->parms[2].items->data);
3899 part = volutil_GetPartitionID(as->parms[1].items->data);
3901 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3902 as->parms[1].items->data);
3905 server = GetServer(as->parms[0].items->data);
3907 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3908 as->parms[0].items->data);
3911 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
3913 PrintError("", code);
3916 "vos : partition %s does not exist on the server\n",
3917 as->parms[1].items->data);
3920 code = VLDB_GetEntryByID(volid, -1, &entry);
3922 if (volid == entry.volumeId[RWVOL])
3923 backupid = entry.volumeId[BACKVOL];
3925 "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
3926 (unsigned long)volid);
3929 volintInfo *pntr = (volintInfo *) 0;
3932 code = UV_ListOneVolume(server, part, volid, &pntr);
3934 if (volid == pntr->parentID)
3935 backupid = pntr->backupID;
3941 code = UV_VolumeZap(server, part, backupid);
3943 PrintDiagnostics("zap", code);
3946 fprintf(STDOUT, "Backup Volume %lu deleted\n",
3947 (unsigned long)backupid);
3950 code = UV_VolumeZap(server, part, volid);
3952 PrintDiagnostics("zap", code);
3955 fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
3961 VolserStatus(register struct cmd_syndesc *as, void *arock)
3963 afs_int32 server, code;
3964 transDebugInfo *pntr, *oldpntr;
3969 server = GetServer(as->parms[0].items->data);
3971 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3972 as->parms[0].items->data);
3975 code = UV_VolserStatus(server, &pntr, &count);
3977 PrintDiagnostics("status", code);
3982 fprintf(STDOUT, "No active transactions on %s\n",
3983 as->parms[0].items->data);
3985 fprintf(STDOUT, "Total transactions: %d\n", count);
3987 for (i = 0; i < count; i++) {
3988 /*print out the relevant info */
3989 fprintf(STDOUT, "--------------------------------------\n");
3990 fprintf(STDOUT, "transaction: %lu created: %s",
3991 (unsigned long)pntr->tid, vos_ctime( & pntr->time));
3992 if (pntr->returnCode) {
3993 fprintf(STDOUT, "returnCode: %lu\n",
3994 (unsigned long)pntr->returnCode);
3997 fprintf(STDOUT, "attachFlags: ");
3998 switch (pntr->iflags) {
4000 fprintf(STDOUT, "offline ");
4003 fprintf(STDOUT, "busy ");
4006 fprintf(STDOUT, "readonly ");
4009 fprintf(STDOUT, "create ");
4012 fprintf(STDOUT, "create volid ");
4015 fprintf(STDOUT, "\n");
4018 fprintf(STDOUT, "volumeStatus: ");
4019 switch (pntr->vflags) {
4020 case VTDeleteOnSalvage:
4021 fprintf(STDOUT, "deleteOnSalvage ");
4022 case VTOutOfService:
4023 fprintf(STDOUT, "outOfService ");
4025 fprintf(STDOUT, "deleted ");
4027 fprintf(STDOUT, "\n");
4030 fprintf(STDOUT, "transactionFlags: ");
4031 fprintf(STDOUT, "delete\n");
4033 MapPartIdIntoName(pntr->partition, pname);
4034 fprintf(STDOUT, "volume: %lu partition: %s procedure: %s\n",
4035 (unsigned long)pntr->volid, pname, pntr->lastProcName);
4036 if (pntr->callValid) {
4038 "packetRead: %lu lastReceiveTime: %d packetSend: %lu lastSendTime: %d\n",
4039 (unsigned long)pntr->readNext, pntr->lastReceiveTime,
4040 (unsigned long)pntr->transmitNext, pntr->lastSendTime);
4043 fprintf(STDOUT, "--------------------------------------\n");
4044 fprintf(STDOUT, "\n");
4052 RenameVolume(register struct cmd_syndesc *as, void *arock)
4054 afs_int32 code1, code2, code;
4055 struct nvldbentry entry;
4057 code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
4059 fprintf(STDERR, "vos: Could not find entry for volume %s\n",
4060 as->parms[0].items->data);
4063 code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
4064 if ((!code1) && (!code2)) { /*the newname already exists */
4065 fprintf(STDERR, "vos: volume %s already exists\n",
4066 as->parms[1].items->data);
4070 if (code1 && code2) {
4071 fprintf(STDERR, "vos: Could not find entry for volume %s or %s\n",
4072 as->parms[0].items->data, as->parms[1].items->data);
4075 if (!VolNameOK(as->parms[0].items->data)) {
4077 "Illegal volume name %s, should not end in .readonly or .backup\n",
4078 as->parms[0].items->data);
4081 if (!ISNAMEVALID(as->parms[1].items->data)) {
4083 "vos: the new volume name %s exceeds the size limit of %d\n",
4084 as->parms[1].items->data, VOLSER_OLDMAXVOLNAME - 10);
4087 if (!VolNameOK(as->parms[1].items->data)) {
4089 "Illegal volume name %s, should not end in .readonly or .backup\n",
4090 as->parms[1].items->data);
4093 if (IsNumeric(as->parms[1].items->data)) {
4094 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
4095 as->parms[1].items->data);
4098 MapHostToNetwork(&entry);
4100 UV_RenameVolume(&entry, as->parms[0].items->data,
4101 as->parms[1].items->data);
4103 PrintDiagnostics("rename", code);
4106 fprintf(STDOUT, "Renamed volume %s to %s\n", as->parms[0].items->data,
4107 as->parms[1].items->data);
4112 GetVolumeInfo(afs_int32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *voltype,
4113 struct nvldbentry *rentry)
4118 vcode = VLDB_GetEntryByID(volid, -1, rentry);
4121 "Could not fetch the entry for volume %lu from VLDB \n",
4122 (unsigned long)volid);
4123 PrintError("", vcode);
4126 MapHostToNetwork(rentry);
4127 if (volid == rentry->volumeId[ROVOL]) {
4129 for (i = 0; i < rentry->nServers; i++) {
4130 if ((index == -1) && (rentry->serverFlags[i] & ITSROVOL)
4131 && !(rentry->serverFlags[i] & RO_DONTUSE))
4136 "RO volume is not found in VLDB entry for volume %lu\n",
4137 (unsigned long)volid);
4141 *server = rentry->serverNumber[index];
4142 *part = rentry->serverPartition[index];
4146 index = Lp_GetRwIndex(rentry);
4149 "RW Volume is not found in VLDB entry for volume %lu\n",
4150 (unsigned long)volid);
4153 if (volid == rentry->volumeId[RWVOL]) {
4155 *server = rentry->serverNumber[index];
4156 *part = rentry->serverPartition[index];
4159 if (volid == rentry->volumeId[BACKVOL]) {
4161 *server = rentry->serverNumber[index];
4162 *part = rentry->serverPartition[index];
4166 "unexpected volume type for volume %lu\n",
4167 (unsigned long)volid);
4172 DeleteEntry(register struct cmd_syndesc *as, void *arock)
4174 afs_int32 apart = 0;
4177 struct VldbListByAttributes attributes;
4178 nbulkentries arrayEntries;
4179 register struct nvldbentry *vllist;
4180 struct cmd_item *itp;
4183 char prefix[VOLSER_MAXVOLNAME + 1];
4185 afs_int32 totalBack = 0, totalFail = 0, err;
4187 if (as->parms[0].items) { /* -id */
4188 if (as->parms[1].items || as->parms[2].items || as->parms[3].items) {
4190 "You cannot use -server, -partition, or -prefix with the -id argument\n");
4193 for (itp = as->parms[0].items; itp; itp = itp->next) {
4194 avolid = vsu_GetVolumeID(itp->data, cstruct, &err);
4197 PrintError("", err);
4199 fprintf(STDERR, "vos: can't find volume '%s'\n",
4203 if (as->parms[4].items) { /* -noexecute */
4204 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4209 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4211 fprintf(STDERR, "Could not delete entry for volume %s\n",
4214 "You must specify a RW volume name or ID "
4215 "(the entire VLDB entry will be deleted)\n");
4216 PrintError("", vcode);
4222 fprintf(STDOUT, "Deleted %d VLDB entries\n", totalBack);
4226 if (!as->parms[1].items && !as->parms[2].items && !as->parms[3].items) {
4227 fprintf(STDERR, "You must specify an option\n");
4231 /* Zero out search attributes */
4232 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4234 if (as->parms[1].items) { /* -prefix */
4235 strncpy(prefix, as->parms[1].items->data, VOLSER_MAXVOLNAME);
4237 if (!as->parms[2].items && !as->parms[3].items) { /* a single entry only */
4239 "You must provide -server with the -prefix argument\n");
4244 if (as->parms[2].items) { /* -server */
4246 aserver = GetServer(as->parms[2].items->data);
4248 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4249 as->parms[2].items->data);
4252 attributes.server = ntohl(aserver);
4253 attributes.Mask |= VLLIST_SERVER;
4256 if (as->parms[3].items) { /* -partition */
4257 if (!as->parms[2].items) {
4259 "You must provide -server with the -partition argument\n");
4262 apart = volutil_GetPartitionID(as->parms[3].items->data);
4264 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4265 as->parms[3].items->data);
4268 attributes.partition = apart;
4269 attributes.Mask |= VLLIST_PARTITION;
4272 /* Print status line of what we are doing */
4273 fprintf(STDOUT, "Deleting VLDB entries for ");
4274 if (as->parms[2].items) {
4275 fprintf(STDOUT, "server %s ", as->parms[2].items->data);
4277 if (as->parms[3].items) {
4279 MapPartIdIntoName(apart, pname);
4280 fprintf(STDOUT, "partition %s ", pname);
4283 fprintf(STDOUT, "which are prefixed with %s ", prefix);
4285 fprintf(STDOUT, "\n");
4288 /* Get all the VLDB entries on a server and/or partition */
4289 memset(&arrayEntries, 0, sizeof(arrayEntries));
4290 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4292 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4293 PrintError("", vcode);
4297 /* Process each entry */
4298 for (j = 0; j < nentries; j++) {
4299 vllist = &arrayEntries.nbulkentries_val[j];
4301 /* It only deletes the RW volumes */
4302 if (strncmp(vllist->name, prefix, strlen(prefix))) {
4305 "Omitting to delete %s due to prefix %s mismatch\n",
4306 vllist->name, prefix);
4313 if (as->parms[4].items) { /* -noexecute */
4314 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4320 /* Only matches the RW volume name */
4321 avolid = vllist->volumeId[RWVOL];
4322 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4324 fprintf(STDOUT, "Could not delete VDLB entry for %s\n",
4327 PrintError("", vcode);
4332 fprintf(STDOUT, "Deleted VLDB entry for %s \n", vllist->name);
4337 fprintf(STDOUT, "----------------------\n");
4339 "Total VLDB entries deleted: %lu; failed to delete: %lu\n",
4340 (unsigned long)totalBack, (unsigned long)totalFail);
4341 if (arrayEntries.nbulkentries_val)
4342 free(arrayEntries.nbulkentries_val);
4348 CompareVldbEntryByName(p1, p2)
4351 struct nvldbentry *arg1, *arg2;
4353 arg1 = (struct nvldbentry *)p1;
4354 arg2 = (struct nvldbentry *)p2;
4355 return (strcmp(arg1->name, arg2->name));
4359 static int CompareVldbEntry(p1,p2)
4362 struct nvldbentry *arg1,*arg2;
4365 char comp1[100],comp2[100];
4366 char temp1[20],temp2[20];
4368 arg1 = (struct nvldbentry *)p1;
4369 arg2 = (struct nvldbentry *)p2;
4373 for(i = 0; i < arg1->nServers; i++)
4374 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
4375 for(i = 0; i < arg2->nServers; i++)
4376 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
4377 if(pos1 == -1 || pos2 == -1){
4381 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
4382 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
4383 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
4384 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
4385 strcat(comp1,temp1);
4386 strcat(comp2,temp2);
4387 strcat(comp1,arg1->name);
4388 strcat(comp1,arg2->name);
4389 return(strcmp(comp1,comp2));
4395 ListVLDB(struct cmd_syndesc *as, void *arock)
4398 afs_int32 aserver, code;
4400 struct VldbListByAttributes attributes;
4401 nbulkentries arrayEntries;
4402 struct nvldbentry *vllist, *tarray = 0, *ttarray;
4403 afs_int32 centries, nentries = 0;
4404 afs_int32 tarraysize = 0;
4405 afs_int32 parraysize;
4408 int quiet, sort, lock;
4409 afs_int32 thisindex, nextindex;
4414 attributes.Mask = 0;
4415 lock = (as->parms[3].items ? 1 : 0); /* -lock flag */
4416 quiet = (as->parms[4].items ? 1 : 0); /* -quit flag */
4417 sort = (as->parms[5].items ? 0 : 1); /* -nosort flag */
4419 /* If the volume name is given, Use VolumeInfoCmd to look it up
4420 * and not ListAttributes.
4422 if (as->parms[0].items) {
4425 "vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
4428 code = VolumeInfoCmd(as->parms[0].items->data);
4430 PrintError("", code);
4436 /* Server specified */
4437 if (as->parms[1].items) {
4438 aserver = GetServer(as->parms[1].items->data);
4440 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4441 as->parms[1].items->data);
4444 attributes.server = ntohl(aserver);
4445 attributes.Mask |= VLLIST_SERVER;
4448 /* Partition specified */
4449 if (as->parms[2].items) {
4450 apart = volutil_GetPartitionID(as->parms[2].items->data);
4452 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4453 as->parms[2].items->data);
4456 attributes.partition = apart;
4457 attributes.Mask |= VLLIST_PARTITION;
4461 attributes.Mask |= VLLIST_FLAG;
4462 attributes.flag = VLOP_ALLOPERS;
4465 /* Print header information */
4467 MapPartIdIntoName(apart, pname);
4468 fprintf(STDOUT, "VLDB entries for %s %s%s%s %s\n",
4469 (as->parms[1].items ? "server" : "all"),
4470 (as->parms[1].items ? as->parms[1].items->data : "servers"),
4471 (as->parms[2].items ? " partition " : ""),
4472 (as->parms[2].items ? pname : ""),
4473 (lock ? "which are locked:" : ""));
4476 for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
4477 memset(&arrayEntries, 0, sizeof(arrayEntries));
4482 VLDB_ListAttributesN2(&attributes, 0, thisindex, ¢ries,
4483 &arrayEntries, &nextindex);
4484 if (vcode == RXGEN_OPCODE) {
4485 /* Vlserver not running with ListAttributesN2. Fall back */
4487 VLDB_ListAttributes(&attributes, ¢ries, &arrayEntries);
4491 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4492 PrintError("", vcode);
4495 nentries += centries;
4497 /* We don't sort, so just print the entries now */
4499 for (j = 0; j < centries; j++) { /* process each entry */
4500 vllist = &arrayEntries.nbulkentries_val[j];
4501 MapHostToNetwork(vllist);
4502 EnumerateEntry(vllist);
4504 if (vllist->flags & VLOP_ALLOPERS)
4505 fprintf(STDOUT, " Volume is currently LOCKED \n");
4509 /* So we sort. First we must collect all the entries and keep
4512 else if (centries > 0) {
4514 /* steal away the first bulk entries array */
4515 tarray = (struct nvldbentry *)arrayEntries.nbulkentries_val;
4516 tarraysize = centries * sizeof(struct nvldbentry);
4517 arrayEntries.nbulkentries_val = 0;
4519 /* Grow the tarray to keep the extra entries */
4520 parraysize = (centries * sizeof(struct nvldbentry));
4522 (struct nvldbentry *)realloc(tarray,
4523 tarraysize + parraysize);
4526 "Could not allocate enough space for the VLDB entries\n");
4532 memcpy(((char *)tarray) + tarraysize,
4533 (char *)arrayEntries.nbulkentries_val, parraysize);
4534 tarraysize += parraysize;
4538 /* Free the bulk array */
4539 if (arrayEntries.nbulkentries_val) {
4540 free(arrayEntries.nbulkentries_val);
4541 arrayEntries.nbulkentries_val = 0;
4545 /* Here is where we now sort all the entries and print them */
4546 if (sort && (nentries > 0)) {
4547 qsort((char *)tarray, nentries, sizeof(struct nvldbentry),
4548 CompareVldbEntryByName);
4549 for (vllist = tarray, j = 0; j < nentries; j++, vllist++) {
4550 MapHostToNetwork(vllist);
4551 EnumerateEntry(vllist);
4553 if (vllist->flags & VLOP_ALLOPERS)
4554 fprintf(STDOUT, " Volume is currently LOCKED \n");
4560 fprintf(STDOUT, "\nTotal entries: %lu\n", (unsigned long)nentries);
4567 BackSys(register struct cmd_syndesc *as, void *arock)
4569 afs_int32 apart = 0, avolid;
4570 afs_int32 aserver = 0, code, aserver1, apart1;
4572 struct VldbListByAttributes attributes;
4573 nbulkentries arrayEntries;
4574 register struct nvldbentry *vllist;
4578 int seenprefix, seenxprefix, exclude, ex, exp, noaction;
4579 afs_int32 totalBack = 0;
4580 afs_int32 totalFail = 0;
4581 int previdx = -1, error, same;
4583 struct cmd_item *ti;
4587 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4588 attributes.Mask = 0;
4590 seenprefix = (as->parms[0].items ? 1 : 0);
4591 exclude = (as->parms[3].items ? 1 : 0);
4592 seenxprefix = (as->parms[4].items ? 1 : 0);
4593 noaction = (as->parms[5].items ? 1 : 0);
4595 if (as->parms[1].items) { /* -server */
4596 aserver = GetServer(as->parms[1].items->data);
4598 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4599 as->parms[1].items->data);
4602 attributes.server = ntohl(aserver);
4603 attributes.Mask |= VLLIST_SERVER;
4606 if (as->parms[2].items) { /* -partition */
4607 apart = volutil_GetPartitionID(as->parms[2].items->data);
4609 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4610 as->parms[2].items->data);
4613 attributes.partition = apart;
4614 attributes.Mask |= VLLIST_PARTITION;
4617 /* Check to make sure the prefix and xprefix expressions compile ok */
4619 for (ti = as->parms[0].items; ti; ti = ti->next) {
4620 if (strncmp(ti->data, "^", 1) == 0) {
4621 #ifdef HAVE_POSIX_REGEX
4625 code = regcomp(&re, ti->data, REG_NOSUB);
4627 regerror(code, &re, errbuf, sizeof errbuf);
4629 "Unrecognizable -prefix regular expression: '%s': %s\n",
4635 ccode = (char *)re_comp(ti->data);
4638 "Unrecognizable -prefix regular expression: '%s': %s\n",
4647 for (ti = as->parms[4].items; ti; ti = ti->next) {
4648 if (strncmp(ti->data, "^", 1) == 0) {
4649 #ifdef HAVE_POSIX_REGEX
4653 code = regcomp(&re, ti->data, REG_NOSUB);
4655 regerror(code, &re, errbuf, sizeof errbuf);
4657 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4663 ccode = (char *)re_comp(ti->data);
4666 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4675 memset(&arrayEntries, 0, sizeof(arrayEntries)); /* initialize to hint the stub to alloc space */
4676 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4678 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4679 PrintError("", vcode);
4683 if (as->parms[1].items || as->parms[2].items || verbose) {
4684 fprintf(STDOUT, "%s up volumes",
4685 (noaction ? "Would have backed" : "Backing"));
4687 if (as->parms[1].items) {
4688 fprintf(STDOUT, " on server %s", as->parms[1].items->data);
4689 } else if (as->parms[2].items) {
4690 fprintf(STDOUT, " for all servers");
4693 if (as->parms[2].items) {
4694 MapPartIdIntoName(apart, pname);
4695 fprintf(STDOUT, " partition %s", pname);
4698 if (seenprefix || (!seenprefix && seenxprefix)) {
4699 ti = (seenprefix ? as->parms[0].items : as->parms[4].items);
4700 ex = (seenprefix ? exclude : !exclude);
4701 exp = (strncmp(ti->data, "^", 1) == 0);
4702 fprintf(STDOUT, " which %smatch %s '%s'", (ex ? "do not " : ""),
4703 (exp ? "expression" : "prefix"), ti->data);
4704 for (ti = ti->next; ti; ti = ti->next) {
4705 exp = (strncmp(ti->data, "^", 1) == 0);
4706 printf(" %sor %s '%s'", (ex ? "n" : ""),
4707 (exp ? "expression" : "prefix"), ti->data);
4711 if (seenprefix && seenxprefix) {
4712 ti = as->parms[4].items;
4713 exp = (strncmp(ti->data, "^", 1) == 0);
4714 fprintf(STDOUT, " %swhich match %s '%s'",
4715 (exclude ? "adding those " : "removing those "),
4716 (exp ? "expression" : "prefix"), ti->data);
4717 for (ti = ti->next; ti; ti = ti->next) {
4718 exp = (strncmp(ti->data, "^", 1) == 0);
4719 printf(" or %s '%s'", (exp ? "expression" : "prefix"),
4723 fprintf(STDOUT, " .. ");
4725 fprintf(STDOUT, "\n");
4729 for (j = 0; j < nentries; j++) { /* process each vldb entry */
4730 vllist = &arrayEntries.nbulkentries_val[j];
4733 for (ti = as->parms[0].items; ti; ti = ti->next) {
4734 if (strncmp(ti->data, "^", 1) == 0) {
4735 #ifdef HAVE_POSIX_REGEX
4739 /* XXX -- should just do the compile once! */
4740 code = regcomp(&re, ti->data, REG_NOSUB);
4742 regerror(code, &re, errbuf, sizeof errbuf);
4744 "Error in -prefix regular expression: '%s': %s\n",
4748 match = (regexec(&re, vllist->name, 0, NULL, 0) == 0);
4751 ccode = (char *)re_comp(ti->data);
4754 "Error in -prefix regular expression: '%s': %s\n",
4758 match = (re_exec(vllist->name) == 1);
4762 (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4772 /* Without the -exclude flag: If it matches the prefix, then
4773 * check if we want to exclude any from xprefix.
4774 * With the -exclude flag: If it matches the prefix, then
4775 * check if we want to add any from xprefix.
4777 if (match && seenxprefix) {
4778 for (ti = as->parms[4].items; ti; ti = ti->next) {
4779 if (strncmp(ti->data, "^", 1) == 0) {
4780 #ifdef HAVE_POSIX_REGEX
4784 /* XXX -- should just do the compile once! */
4785 code = regcomp(&re, ti->data, REG_NOSUB);
4787 regerror(code, &re, errbuf, sizeof errbuf);
4789 "Error in -xprefix regular expression: '%s': %s\n",
4793 if (regexec(&re, vllist->name, 0, NULL, 0) == 0)
4797 ccode = (char *)re_comp(ti->data);
4800 "Error in -xprefix regular expression: '%s': %s\n",
4804 if (re_exec(vllist->name) == 1) {
4810 if (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4820 match = !match; /* -exclude will reverse the match */
4822 continue; /* Skip if no match */
4824 /* Print list of volumes to backup */
4826 fprintf(STDOUT, " %s\n", vllist->name);
4830 if (!(vllist->flags & RW_EXISTS)) {
4833 "Omitting to backup %s since RW volume does not exist \n",
4835 fprintf(STDOUT, "\n");
4841 avolid = vllist->volumeId[RWVOL];
4842 MapHostToNetwork(vllist);
4843 GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
4844 if (aserver1 == -1 || apart1 == -1) {
4845 fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n",
4851 same = VLDB_IsSameAddrs(aserver, aserver1, &error);
4854 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4860 if ((aserver && !same) || (apart && (apart != apart1))) {
4863 "Omitting to backup %s since the RW is in a different location\n",
4869 time_t now = time(0);
4870 fprintf(STDOUT, "Creating backup volume for %s on %s",
4871 vllist->name, ctime(&now));
4875 code = UV_BackupVolume(aserver1, apart1, avolid);
4877 fprintf(STDOUT, "Could not backup %s\n", vllist->name);
4883 fprintf(STDOUT, "\n");
4885 } /* process each vldb entry */
4886 fprintf(STDOUT, "done\n");
4887 fprintf(STDOUT, "Total volumes backed up: %lu; failed to backup: %lu\n",
4888 (unsigned long)totalBack, (unsigned long)totalFail);
4890 if (arrayEntries.nbulkentries_val)
4891 free(arrayEntries.nbulkentries_val);
4896 UnlockVLDB(register struct cmd_syndesc *as, void *arock)
4899 afs_int32 aserver = NULL;
4902 struct VldbListByAttributes attributes;
4903 nbulkentries arrayEntries;
4904 register struct nvldbentry *vllist;
4913 attributes.Mask = 0;
4915 if (as->parms[0].items) { /* server specified */
4916 aserver = GetServer(as->parms[0].items->data);
4918 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4919 as->parms[0].items->data);
4922 attributes.server = ntohl(aserver);
4923 attributes.Mask |= VLLIST_SERVER;
4925 if (as->parms[1].items) { /* partition specified */
4926 apart = volutil_GetPartitionID(as->parms[1].items->data);
4928 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4929 as->parms[1].items->data);
4932 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4934 PrintError("", code);
4937 "vos : partition %s does not exist on the server\n",
4938 as->parms[1].items->data);
4941 attributes.partition = apart;
4942 attributes.Mask |= VLLIST_PARTITION;
4944 attributes.flag = VLOP_ALLOPERS;
4945 attributes.Mask |= VLLIST_FLAG;
4946 memset(&arrayEntries, 0, sizeof(arrayEntries)); /*initialize to hint the stub to alloc space */
4947 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4949 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4950 PrintError("", vcode);
4953 for (j = 0; j < nentries; j++) { /* process each entry */
4954 vllist = &arrayEntries.nbulkentries_val[j];
4955 volid = vllist->volumeId[RWVOL];
4957 ubik_VL_ReleaseLock(cstruct, 0, volid, -1,
4958 LOCKREL_OPCODE | LOCKREL_AFSID |
4961 fprintf(STDERR, "Could not unlock entry for volume %s\n",
4963 PrintError("", vcode);
4968 MapPartIdIntoName(apart, pname);
4971 "Could not lock %lu VLDB entries of %lu locked entries\n",
4972 (unsigned long)totalE, (unsigned long)nentries);
4974 if (as->parms[0].items) {
4976 "Unlocked all the VLDB entries for volumes on server %s ",
4977 as->parms[0].items->data);
4978 if (as->parms[1].items) {
4979 MapPartIdIntoName(apart, pname);
4980 fprintf(STDOUT, "partition %s\n", pname);
4982 fprintf(STDOUT, "\n");
4984 } else if (as->parms[1].items) {
4985 MapPartIdIntoName(apart, pname);
4987 "Unlocked all the VLDB entries for volumes on partition %s on all servers\n",
4992 if (arrayEntries.nbulkentries_val)
4993 free(arrayEntries.nbulkentries_val);
4998 PrintInt64Size(afs_uint64 in)
5000 register afs_uint32 hi, lo;
5001 register char * units;
5002 static char output[16];
5004 SplitInt64(in,hi,lo);
5008 } else if (!(hi & 0xFFFFFC00)) {
5010 lo = (hi << 22) | (lo >> 10);
5011 } else if (!(hi & 0xFFF00000)) {
5013 lo = (hi << 12) | (lo >> 20);
5014 } else if (!(hi & 0xC0000000)) {
5016 lo = (hi << 2) | (lo >> 30);
5021 sprintf(output,"%u %s", lo, units);
5026 PartitionInfo(register struct cmd_syndesc *as, void *arock)
5029 afs_int32 aserver, code;
5031 struct diskPartition64 partition;
5032 struct partList dummyPartList;
5034 int printSummary=0, sumPartitions=0;
5035 afs_uint64 sumFree, sumStorage;
5038 ZeroInt64(sumStorage);
5040 aserver = GetServer(as->parms[0].items->data);
5042 fprintf(STDERR, "vos: server '%s' not found in host table\n",
5043 as->parms[0].items->data);
5046 if (as->parms[1].items) {
5047 apart = volutil_GetPartitionID(as->parms[1].items->data);
5049 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5050 as->parms[1].items->data);
5053 dummyPartList.partId[0] = apart;
5054 dummyPartList.partFlags[0] = PARTVALID;
5057 if (as->parms[2].items) {
5061 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
5063 PrintError("", code);
5066 "vos : partition %s does not exist on the server\n",
5067 as->parms[1].items->data);
5071 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
5073 PrintDiagnostics("listpart", code);
5077 for (i = 0; i < cnt; i++) {
5078 if (dummyPartList.partFlags[i] & PARTVALID) {
5079 MapPartIdIntoName(dummyPartList.partId[i], pname);
5080 code = UV_PartitionInfo64(aserver, pname, &partition);
5082 fprintf(STDERR, "Could not get information on partition %s\n",
5084 PrintError("", code);
5088 "Free space on partition %s: %" AFS_INT64_FMT " K blocks out of total %" AFS_INT64_FMT "\n",
5089 pname, partition.free, partition.minFree);
5091 AddUInt64(sumFree,partition.free,&sumFree);
5092 AddUInt64(sumStorage,partition.minFree,&sumStorage);
5097 "Summary: %s free out of ",
5098 PrintInt64Size(sumFree));
5100 "%s on %d partitions\n",
5101 PrintInt64Size(sumStorage),
5108 ChangeAddr(register struct cmd_syndesc *as, void *arock)
5110 afs_int32 ip1, ip2, vcode;
5113 ip1 = GetServer(as->parms[0].items->data);
5115 fprintf(STDERR, "vos: invalid host address\n");
5119 if ((as->parms[1].items && as->parms[2].items)
5120 || (!as->parms[1].items && !as->parms[2].items)) {
5122 "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
5126 if (as->parms[1].items) {
5127 ip2 = GetServer(as->parms[1].items->data);
5129 fprintf(STDERR, "vos: invalid host address\n");
5133 /* Play a trick here. If we are removing an address, ip1 will be -1
5134 * and ip2 will be the original address. This switch prevents an
5135 * older revision vlserver from removing the IP address.
5142 vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
5145 fprintf(STDERR, "Could not remove server %s from the VLDB\n",
5146 as->parms[0].items->data);
5147 if (vcode == VL_NOENT) {
5149 "vlserver does not support the remove flag or ");
5152 fprintf(STDERR, "Could not change server %s to server %s\n",
5153 as->parms[0].items->data, as->parms[1].items->data);
5155 PrintError("", vcode);
5160 fprintf(STDOUT, "Removed server %s from the VLDB\n",
5161 as->parms[0].items->data);
5163 fprintf(STDOUT, "Changed server %s to server %s\n",
5164 as->parms[0].items->data, as->parms[1].items->data);
5170 print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
5175 struct VLCallBack vlcb;
5178 ListAddrByAttributes m_attrs;
5179 afs_int32 m_nentries, *m_addrp;
5180 afs_int32 base, index;
5184 afsUUID_to_string(m_uuid, buf, sizeof(buf));
5185 printf("UUID: %s\n", buf);
5188 /* print out the list of all the server */
5189 addrp = (afs_int32 *) addrs->bulkaddrs_val;
5190 for (i = 0; i < nentries; i++, addrp++) {
5191 /* If it is a multihomed address, then we will need to
5192 * get the addresses for this multihomed server from
5193 * the vlserver and print them.
5195 if (((*addrp & 0xff000000) == 0xff000000) && ((*addrp) & 0xffff)) {
5196 /* Get the list of multihomed fileservers */
5197 base = (*addrp >> 16) & 0xff;
5198 index = (*addrp) & 0xffff;
5200 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
5201 && (index <= VL_MHSRV_PERBLK)) {
5202 m_attrs.Mask = VLADDR_INDEX;
5203 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
5205 m_addrs.bulkaddrs_val = 0;
5206 m_addrs.bulkaddrs_len = 0;
5208 ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, &m_uuid,
5209 (afs_int32 *)&vlcb, &m_nentries, &m_addrs);
5212 "vos: could not list the multi-homed server addresses\n");
5213 PrintError("", vcode);
5216 /* Print the list */
5217 m_addrp = (afs_int32 *) m_addrs.bulkaddrs_val;
5218 for (j = 0; j < m_nentries; j++, m_addrp++) {
5219 *m_addrp = htonl(*m_addrp);
5222 printf("%s ", afs_inet_ntoa_r(*m_addrp, hoststr));
5224 printf("%s ", hostutil_GetNameByINet(*m_addrp));
5228 printf("<unknown>\n");
5237 /* Otherwise, it is a non-multihomed entry and contains
5238 * the IP address of the server - print it.
5240 *addrp = htonl(*addrp);
5243 printf("%s\n", afs_inet_ntoa_r(*addrp, hoststr));
5245 printf("%s\n", hostutil_GetNameByINet(*addrp));
5256 ListAddrs(register struct cmd_syndesc *as, void *arock)
5259 afs_int32 i, printuuid = 0;
5260 struct VLCallBack vlcb;
5263 ListAddrByAttributes m_attrs;
5264 afsUUID m_uuid, askuuid;
5265 afs_int32 m_nentries;
5267 memset(&m_attrs, 0, sizeof(struct ListAddrByAttributes));
5268 m_attrs.Mask = VLADDR_INDEX;
5270 memset(&m_addrs, 0, sizeof(bulkaddrs));
5271 memset(&askuuid, 0, sizeof(afsUUID));
5272 if (as->parms[0].items) {
5274 if (afsUUID_from_string(as->parms[0].items->data, &askuuid) < 0) {
5275 fprintf(STDERR, "vos: invalid UUID '%s'\n",
5276 as->parms[0].items->data);
5279 m_attrs.Mask = VLADDR_UUID;
5280 m_attrs.uuid = askuuid;
5282 if (as->parms[1].items) {
5286 he = hostutil_GetHostByName((char *)as->parms[1].items->data);
5288 fprintf(STDERR, "vos: Can't get host info for '%s'\n",
5289 as->parms[1].items->data);
5292 memcpy(&saddr, he->h_addr, 4);
5293 m_attrs.Mask = VLADDR_IPADDR;
5294 m_attrs.ipaddr = ntohl(saddr);
5296 if (as->parms[2].items) {
5300 m_addrs.bulkaddrs_val = 0;
5301 m_addrs.bulkaddrs_len = 0;
5304 ubik_Call_New(VL_GetAddrs, cstruct, 0, 0, 0, &vlcb, &nentries,
5307 fprintf(STDERR, "vos: could not list the server addresses\n");
5308 PrintError("", vcode);
5313 m_addrs.bulkaddrs_val = 0;
5314 m_addrs.bulkaddrs_len = 0;
5320 ubik_Call_New(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
5321 &vlcb, &m_nentries, &m_addrs);
5323 if (vcode == VL_NOENT) {
5324 if (m_attrs.Mask == VLADDR_UUID) {
5325 fprintf(STDERR, "vos: no entry for UUID '%s' found in VLDB\n",
5326 as->parms[0].items->data);
5328 } else if (m_attrs.Mask == VLADDR_IPADDR) {
5329 fprintf(STDERR, "vos: no entry for host '%s' [0x%08x] found in VLDB\n",
5330 as->parms[1].items->data, m_attrs.ipaddr);
5339 if (vcode == VL_INDEXERANGE) {
5344 fprintf(STDERR, "vos: could not list the server addresses\n");
5345 PrintError("", vcode);
5349 print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid);
5352 if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
5360 LockEntry(register struct cmd_syndesc *as, void *arock)
5362 afs_int32 avolid, vcode, err;
5364 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5367 PrintError("", err);
5369 fprintf(STDERR, "vos: can't find volume '%s'\n",
5370 as->parms[0].items->data);
5373 vcode = ubik_VL_SetLock(cstruct, 0, avolid, -1, VLOP_DELETE);
5375 fprintf(STDERR, "Could not lock VLDB entry for volume %s\n",
5376 as->parms[0].items->data);
5377 PrintError("", vcode);
5380 fprintf(STDOUT, "Locked VLDB entry for volume %s\n",
5381 as->parms[0].items->data);
5386 ConvertRO(register struct cmd_syndesc *as, void *arock)
5388 afs_int32 partition = -1;
5389 afs_int32 server, volid, code, i, same;
5390 struct nvldbentry entry, storeEntry;
5392 afs_int32 rwindex = 0;
5393 afs_int32 rwserver = 0;
5394 afs_int32 rwpartition = 0;
5395 afs_int32 roindex = 0;
5396 afs_int32 roserver = 0;
5397 afs_int32 ropartition = 0;
5399 struct rx_connection *aconn;
5402 server = GetServer(as->parms[0].items->data);
5404 fprintf(STDERR, "vos: host '%s' not found in host table\n",
5405 as->parms[0].items->data);
5408 partition = volutil_GetPartitionID(as->parms[1].items->data);
5409 if (partition < 0) {
5410 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5411 as->parms[1].items->data);
5414 if (!IsPartValid(partition, server, &code)) {
5416 PrintError("", code);
5419 "vos : partition %s does not exist on the server\n",
5420 as->parms[1].items->data);
5423 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &code);
5426 PrintError("", code);
5428 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
5429 as->parms[0].items->data);
5432 if (as->parms[3].items)
5435 vcode = VLDB_GetEntryByID(volid, -1, &entry);
5438 "Could not fetch the entry for volume %lu from VLDB\n",
5439 (unsigned long)volid);
5440 PrintError("convertROtoRW", code);
5444 /* use RO volid even if user specified RW or BK volid */
5446 if (volid != entry.volumeId[ROVOL])
5447 volid = entry.volumeId[ROVOL];
5449 MapHostToNetwork(&entry);
5450 for (i = 0; i < entry.nServers; i++) {
5451 if (entry.serverFlags[i] & ITSRWVOL) {
5453 rwserver = entry.serverNumber[i];
5454 rwpartition = entry.serverPartition[i];
5456 if (entry.serverFlags[i] & ITSROVOL) {
5457 same = VLDB_IsSameAddrs(server, entry.serverNumber[i], &code);
5460 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
5466 roserver = entry.serverNumber[i];
5467 ropartition = entry.serverPartition[i];
5473 fprintf(STDERR, "Warning: RO volume didn't exist in vldb!\n");
5475 if (ropartition != partition) {
5477 "Warning: RO volume should be in partition %d instead of %d (vldb)\n",
5478 ropartition, partition);
5483 "VLDB indicates that a RW volume exists already on %s in partition %s.\n",
5484 hostutil_GetNameByINet(rwserver),
5485 volutil_PartitionName(rwpartition));
5487 fprintf(STDERR, "Overwrite this VLDB entry? [y|n] (n)\n");
5489 while (!(dc == EOF || dc == '\n'))
5490 dc = getchar(); /* goto end of line */
5491 if ((c != 'y') && (c != 'Y')) {
5492 fprintf(STDERR, "aborted.\n");
5499 ubik_VL_SetLock(cstruct, 0, entry.volumeId[RWVOL], RWVOL,
5501 aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
5502 code = AFSVolConvertROtoRWvolume(aconn, partition, volid);
5505 "Converting RO volume %lu to RW volume failed with code %d\n",
5506 (unsigned long)volid, code);
5507 PrintError("convertROtoRW ", code);
5510 entry.serverFlags[roindex] = ITSRWVOL;
5511 entry.flags |= RW_EXISTS;
5512 entry.flags &= ~BACK_EXISTS;
5515 if (rwindex != entry.nServers) {
5516 entry.serverNumber[rwindex] = entry.serverNumber[entry.nServers];
5517 entry.serverPartition[rwindex] =
5518 entry.serverPartition[entry.nServers];
5519 entry.serverFlags[rwindex] = entry.serverFlags[entry.nServers];
5520 entry.serverNumber[entry.nServers] = 0;
5521 entry.serverPartition[entry.nServers] = 0;
5522 entry.serverFlags[entry.nServers] = 0;
5525 entry.flags &= ~RO_EXISTS;
5526 for (i = 0; i < entry.nServers; i++) {
5527 if (entry.serverFlags[i] & ITSROVOL) {
5528 if (!(entry.serverFlags[i] & (RO_DONTUSE | NEW_REPSITE)))
5529 entry.flags |= RO_EXISTS;
5532 MapNetworkToHost(&entry, &storeEntry);
5534 VLDB_ReplaceEntry(entry.volumeId[RWVOL], RWVOL, &storeEntry,
5535 (LOCKREL_OPCODE | LOCKREL_AFSID |
5536 LOCKREL_TIMESTAMP));
5539 "Warning: volume converted, but vldb update failed with code %d!\n",
5542 vcode = UV_LockRelease(entry.volumeId[RWVOL]);
5544 PrintDiagnostics("unlock", vcode);
5550 Sizes(register struct cmd_syndesc *as, void *arock)
5552 afs_int32 avolid, aserver, apart, voltype, fromdate = 0, code, err, i;
5553 struct nvldbentry entry;
5554 volintSize vol_size;
5556 rx_SetRxDeadTime(60 * 10);
5557 for (i = 0; i < MAXSERVERS; i++) {
5558 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
5561 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
5562 if (rxConn->service)
5563 rxConn->service->connDeadTime = rx_connDeadTime;
5566 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5569 PrintError("", err);
5571 fprintf(STDERR, "vos: can't find volume '%s'\n",
5572 as->parms[0].items->data);
5576 if (as->parms[1].items || as->parms[2].items) {
5577 if (!as->parms[1].items || !as->parms[2].items) {
5579 "Must specify both -server and -partition options\n");
5582 aserver = GetServer(as->parms[2].items->data);
5584 fprintf(STDERR, "Invalid server name\n");
5587 apart = volutil_GetPartitionID(as->parms[1].items->data);
5589 fprintf(STDERR, "Invalid partition name\n");
5593 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
5600 if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
5601 code = ktime_DateToInt32(as->parms[4].items->data, &fromdate);
5603 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
5604 as->parms[4].items->data, code);
5609 fprintf(STDOUT, "Volume: %s\n", as->parms[0].items->data);
5611 if (as->parms[3].items) { /* do the dump estimate */
5612 #ifdef AFS_64BIT_ENV
5613 vol_size.dump_size = 0;
5615 FillInt64(vol_size.dump_size,0, 1);
5617 code = UV_GetSize(avolid, aserver, apart, fromdate, &vol_size);
5619 PrintDiagnostics("size", code);
5622 /* presumably the size info is now gathered in pntr */
5623 /* now we display it */
5625 fprintf(STDOUT, "dump_size: %llu\n", vol_size.dump_size);
5634 PrintDiagnostics(char *astring, afs_int32 acode)
5636 if (acode == EACCES) {
5638 "You are not authorized to perform the 'vos %s' command (%d)\n",
5641 fprintf(STDERR, "Error in vos %s command.\n", astring);
5642 PrintError("", acode);
5649 MyBeforeProc(struct cmd_syndesc *as, void *arock)
5651 register char *tcell;
5652 register afs_int32 code;
5653 register afs_int32 sauth;
5655 /* Initialize the ubik_client connection */
5656 rx_SetRxDeadTime(90);
5657 cstruct = (struct ubik_client *)0;
5661 if (as->parms[12].items) /* if -cell specified */
5662 tcell = as->parms[12].items->data;
5663 if (as->parms[14].items) /* -serverauth specified */
5665 if (as->parms[16].items) /* -crypt specified */
5668 vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
5669 &cstruct, UV_SetSecurity))) {
5670 fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
5671 (unsigned long)code);
5675 if (as->parms[15].items) /* -verbose flag set */
5679 if (as->parms[17].items) /* -noresolve flag set */
5689 /* this sucks but it works for now.
5694 #include "AFS_component_version_number.c"
5700 register afs_int32 code;
5702 register struct cmd_syndesc *ts;
5704 #ifdef AFS_AIX32_ENV
5706 * The following signal action for AIX is necessary so that in case of a
5707 * crash (i.e. core is generated) we can include the user's data section
5708 * in the core dump. Unfortunately, by default, only a partial core is
5709 * generated which, in many cases, isn't too useful.
5711 struct sigaction nsa;
5713 sigemptyset(&nsa.sa_mask);
5714 nsa.sa_handler = SIG_DFL;
5715 nsa.sa_flags = SA_FULLDUMP;
5716 sigaction(SIGSEGV, &nsa, NULL);
5719 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
5721 cmd_SetBeforeProc(MyBeforeProc, NULL);
5723 ts = cmd_CreateSyntax("create", CreateVolume, NULL, "create a new volume");
5724 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5725 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5726 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "volume name");
5727 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL,
5728 "initial quota (KB)");
5730 cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
5734 ts = cmd_CreateSyntax("remove", DeleteVolume, NULL, "delete a volume");
5735 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5736 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5737 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5741 ts = cmd_CreateSyntax("move", MoveVolume, NULL, "move a volume");
5742 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5743 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5744 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5745 "partition name on source");
5746 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5747 "machine name on destination");
5748 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5749 "partition name on destination");
5750 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5751 "copy live volume without cloning");
5754 ts = cmd_CreateSyntax("copy", CopyVolume, NULL, "copy a volume");
5755 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5756 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5757 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5758 "partition name on source");
5759 cmd_AddParm(ts, "-toname", CMD_SINGLE, 0, "volume name on destination");
5760 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5761 "machine name on destination");
5762 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5763 "partition name on destination");
5764 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5765 "leave new volume offline");
5766 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5767 "make new volume read-only");
5768 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5769 "copy live volume without cloning");
5772 ts = cmd_CreateSyntax("shadow", ShadowVolume, NULL,
5773 "make or update a shadow volume");
5774 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5775 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5776 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5777 "partition name on source");
5778 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5779 "machine name on destination");
5780 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5781 "partition name on destination");
5782 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5783 "volume name on destination");
5784 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5785 "volume ID on destination");
5786 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5787 "leave shadow volume offline");
5788 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5789 "make shadow volume read-only");
5790 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5791 "copy live volume without cloning");
5792 cmd_AddParm(ts, "-incremental", CMD_FLAG, CMD_OPTIONAL,
5793 "do incremental update if target exists");
5796 ts = cmd_CreateSyntax("backup", BackupVolume, NULL,
5797 "make backup of a volume");
5798 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5801 ts = cmd_CreateSyntax("clone", CloneVolume, NULL,
5802 "make clone of a volume");
5803 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5804 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5805 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
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 clone volume offline");
5812 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5813 "make clone volume read-only, not readwrite");
5816 ts = cmd_CreateSyntax("release", ReleaseVolume, NULL, "release a volume");
5817 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5818 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5819 "force a complete release");
5822 ts = cmd_CreateSyntax("dump", DumpVolume, NULL, "dump a volume");
5823 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5824 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5825 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5826 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5827 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5828 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL,
5829 "dump a clone of the volume");
5830 cmd_AddParm(ts, "-omitdirs", CMD_FLAG, CMD_OPTIONAL,
5831 "omit unchanged directories from an incremental dump");
5834 ts = cmd_CreateSyntax("restore", RestoreVolume, NULL, "restore a volume");
5835 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5836 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5837 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of volume to be restored");
5838 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5839 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
5840 cmd_AddParm(ts, "-overwrite", CMD_SINGLE, CMD_OPTIONAL,
5841 "abort | full | incremental");
5842 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5843 "leave restored volume offline");
5844 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5845 "make restored volume read-only");
5846 cmd_AddParm(ts, "-creation", CMD_SINGLE, CMD_OPTIONAL,
5847 "dump | keep | new");
5848 cmd_AddParm(ts, "-lastupdate", CMD_SINGLE, CMD_OPTIONAL,
5849 "dump | keep | new");
5850 cmd_AddParm(ts, "-nodelete", CMD_FLAG, CMD_OPTIONAL,
5851 "do not delete old site when restoring to a new site");
5854 ts = cmd_CreateSyntax("unlock", LockReleaseCmd, NULL,
5855 "release lock on VLDB entry for a volume");
5856 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5859 ts = cmd_CreateSyntax("changeloc", ChangeLocation, NULL,
5860 "change an RW volume's location in the VLDB");
5861 cmd_AddParm(ts, "-server", CMD_SINGLE, 0,
5862 "machine name for new location");
5863 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5864 "partition name for new location");
5865 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5868 ts = cmd_CreateSyntax("addsite", AddSite, NULL, "add a replication site");
5869 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new site");
5870 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5871 "partition name for new site");
5872 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5873 cmd_AddParm(ts, "-valid", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE, "publish as an up-to-date site in VLDB");
5876 ts = cmd_CreateSyntax("remsite", RemoveSite, NULL,
5877 "remove a replication site");
5878 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5879 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5880 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5883 ts = cmd_CreateSyntax("listpart", ListPartitions, NULL, "list partitions");
5884 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5887 ts = cmd_CreateSyntax("listvol", ListVolumes, NULL,
5888 "list volumes on server (bypass VLDB)");
5889 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5890 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5891 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "minimal listing");
5892 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
5893 "list all normal volume fields");
5894 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5895 "generate minimal information");
5896 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5897 "list extended volume fields");
5898 #ifdef FULL_LISTVOL_SWITCH
5899 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5900 "machine readable format");
5901 #endif /* FULL_LISTVOL_SWITCH */
5904 ts = cmd_CreateSyntax("syncvldb", SyncVldb, NULL,
5905 "synchronize VLDB with server");
5906 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5907 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5908 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5909 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5912 ts = cmd_CreateSyntax("syncserv", SyncServer, NULL,
5913 "synchronize server with VLDB");
5914 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5915 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5916 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5919 ts = cmd_CreateSyntax("examine", ExamineVolume, NULL,
5920 "everything about the volume");
5921 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5922 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5923 "list extended volume fields");
5924 #ifdef FULL_LISTVOL_SWITCH
5925 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5926 "machine readable format");
5927 #endif /* FULL_LISTVOL_SWITCH */
5929 cmd_CreateAlias(ts, "volinfo");
5931 ts = cmd_CreateSyntax("setfields", SetFields, NULL,
5932 "change volume info fields");
5933 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5934 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "quota (KB)");
5935 cmd_AddParm(ts, "-clearuse", CMD_FLAG, CMD_OPTIONAL, "clear dayUse");
5936 cmd_AddParm(ts, "-clearVolUpCounter", CMD_FLAG, CMD_OPTIONAL, "clear volUpdateCounter");
5939 ts = cmd_CreateSyntax("offline", volOffline, NULL, (char *)CMD_HIDDEN);
5940 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5941 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5942 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5943 cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds to sleep");
5944 cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "busy volume");
5947 ts = cmd_CreateSyntax("online", volOnline, NULL, (char *)CMD_HIDDEN);
5948 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5949 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5950 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5953 ts = cmd_CreateSyntax("zap", VolumeZap, NULL,
5954 "delete the volume, don't bother with VLDB");
5955 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5956 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5957 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume ID");
5958 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5959 "force deletion of bad volumes");
5960 cmd_AddParm(ts, "-backup", CMD_FLAG, CMD_OPTIONAL,
5961 "also delete backup volume if one is found");
5964 ts = cmd_CreateSyntax("status", VolserStatus, NULL,
5965 "report on volser status");
5966 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5969 ts = cmd_CreateSyntax("rename", RenameVolume, NULL, "rename a volume");
5970 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old volume name ");
5971 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new volume name ");
5974 ts = cmd_CreateSyntax("listvldb", ListVLDB, NULL,
5975 "list volumes in the VLDB");
5976 cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5977 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5978 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5979 cmd_AddParm(ts, "-locked", CMD_FLAG, CMD_OPTIONAL, "locked volumes only");
5980 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5981 "generate minimal information");
5982 cmd_AddParm(ts, "-nosort", CMD_FLAG, CMD_OPTIONAL,
5983 "do not alphabetically sort the volume names");
5986 ts = cmd_CreateSyntax("backupsys", BackSys, NULL, "en masse backups");
5987 cmd_AddParm(ts, "-prefix", CMD_LIST, CMD_OPTIONAL,
5988 "common prefix on volume(s)");
5989 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5990 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5991 cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL,
5992 "exclude common prefix volumes");
5993 cmd_AddParm(ts, "-xprefix", CMD_LIST, CMD_OPTIONAL,
5994 "negative prefix on volume(s)");
5995 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "no action");
5998 ts = cmd_CreateSyntax("delentry", DeleteEntry, NULL,
5999 "delete VLDB entry for a volume");
6000 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "volume name or ID");
6001 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL,
6002 "prefix of the volume whose VLDB entry is to be deleted");
6003 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6004 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6005 cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE,
6009 ts = cmd_CreateSyntax("partinfo", PartitionInfo, NULL,
6010 "list partition information");
6011 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6012 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6013 cmd_AddParm(ts, "-summary", CMD_FLAG, CMD_OPTIONAL,
6014 "print storage summary");
6017 ts = cmd_CreateSyntax("unlockvldb", UnlockVLDB, NULL,
6018 "unlock all the locked entries in the VLDB");
6019 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6020 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6023 ts = cmd_CreateSyntax("lock", LockEntry, NULL,
6024 "lock VLDB entry for a volume");
6025 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6028 ts = cmd_CreateSyntax("changeaddr", ChangeAddr, NULL,
6029 "change the IP address of a file server");
6030 cmd_AddParm(ts, "-oldaddr", CMD_SINGLE, 0, "original IP address");
6031 cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
6032 cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL,
6033 "remove the IP address from the VLDB");
6036 ts = cmd_CreateSyntax("listaddrs", ListAddrs, NULL,
6037 "list the IP address of all file servers registered in the VLDB");
6038 cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
6039 cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
6040 cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
6041 "print uuid of hosts");
6044 ts = cmd_CreateSyntax("convertROtoRW", ConvertRO, NULL,
6045 "convert a RO volume into a RW volume (after loss of old RW volume)");
6046 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6047 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
6048 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6049 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "don't ask");
6052 ts = cmd_CreateSyntax("size", Sizes, NULL,
6053 "obtain various sizes of the volume.");
6054 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6055 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6056 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6057 cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL,
6058 "Obtain the size of the dump");
6059 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
6062 code = cmd_Dispatch(argc, argv);
6064 /* Shut down the ubik_client and rx connections */
6066 (void)ubik_ClientDestroy(cstruct);
6072 exit((code ? -1 : 0));