2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
16 #include <sys/types.h>
26 #include <netinet/in.h>
27 #include <arpa/inet.h>
31 #include <sys/statfs.h>
39 #include <rx/rx_globals.h>
41 #include <afs/vlserver.h>
42 #include <afs/cellconfig.h>
44 #include <afs/afsutil.h>
46 #include <afs/afsint.h>
51 #include <afs/ihandle.h>
52 #include <afs/vnode.h>
53 #include <afs/volume.h>
60 #include "volser_prototypes.h"
61 #include "vsutils_prototypes.h"
62 #include "lockprocs_prototypes.h"
64 #ifdef HAVE_POSIX_REGEX
68 /* Local Prototypes */
69 int PrintDiagnostics(char *astring, afs_int32 acode);
70 int GetVolumeInfo(afs_uint32 volid, afs_int32 *server, afs_int32 *part,
71 afs_int32 *voltype, struct nvldbentry *rentry);
83 #define COMMONPARMS cmd_Seek(ts, 12);\
84 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");\
85 cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");\
86 cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
87 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
88 cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
89 cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL, "don't resolve addresses"); \
91 #define ERROR_EXIT(code) {error=(code); goto error_exit;}
94 struct rx_connection *tconn;
96 extern struct ubik_client *cstruct;
99 static struct tqHead busyHead, notokHead;
102 qInit(struct tqHead *ahead)
104 memset((char *)ahead, 0, sizeof(struct tqHead));
110 qPut(struct tqHead *ahead, afs_uint32 volid)
114 elem = (struct tqElem *)malloc(sizeof(struct tqElem));
115 elem->next = ahead->next;
123 qGet(struct tqHead *ahead, afs_int32 *volid)
127 if (ahead->count <= 0)
129 *volid = ahead->next->volid;
131 ahead->next = tmp->next;
137 /* returns 1 if <filename> exists else 0 */
139 FileExists(char *filename)
145 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
149 code = USD_IOCTL(ufd, USD_IOCTL_GETSIZE, &size);
157 /* returns 1 if <name> doesnot end in .readonly or .backup, else 0 */
159 VolNameOK(char *name)
164 total = strlen(name);
165 if (!strcmp(&name[total - 9], ".readonly")) {
167 } else if (!strcmp(&name[total - 7], ".backup")) {
174 /* return 1 if name is a number else 0 */
176 IsNumeric(char *name)
184 for (i = 0; i < len; i++) {
185 if (*ptr < '0' || *ptr > '9') {
197 * Parse a server name/address and return the address in HOST BYTE order
200 GetServer(char *aname)
202 register struct hostent *th;
205 register afs_int32 code;
206 char hostname[MAXHOSTCHARS];
208 code = sscanf(aname, "%d.%d.%d.%d", &b1, &b2, &b3, &b4);
210 addr = (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
211 addr = ntohl(addr); /* convert to host order */
213 th = gethostbyname(aname);
216 memcpy(&addr, th->h_addr, sizeof(addr));
219 if (addr == htonl(0x7f000001)) { /* local host */
220 code = gethostname(hostname, MAXHOSTCHARS);
223 th = gethostbyname(hostname); /* returns host byte order */
226 memcpy(&addr, th->h_addr, sizeof(addr));
233 GetVolumeType(char *aname)
236 if (!strcmp(aname, "ro"))
238 else if (!strcmp(aname, "rw"))
240 else if (!strcmp(aname, "bk"))
247 IsPartValid(afs_int32 partId, afs_int32 server, afs_int32 *code)
249 struct partList dummyPartList;
255 *code = UV_ListPartitions(server, &dummyPartList, &cnt);
258 for (i = 0; i < cnt; i++) {
259 if (dummyPartList.partFlags[i] & PARTVALID)
260 if (dummyPartList.partId[i] == partId)
268 /*sends the contents of file associated with <fd> and <blksize> to Rx Stream
269 * associated with <call> */
271 SendFile(usd_handle_t ufd, register struct rx_call *call, long blksize)
273 char *buffer = (char *)0;
278 buffer = (char *)malloc(blksize);
280 fprintf(STDERR, "malloc failed\n");
284 while (!error && !done) {
285 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
288 FD_SET((int)(ufd->handle), &in);
289 /* don't timeout if read blocks */
290 #if defined(AFS_PTHREAD_ENV)
291 select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
293 IOMGR_Select(((int)(ufd->handle)) + 1, &in, 0, 0, 0);
296 error = USD_READ(ufd, buffer, blksize, &nbytes);
298 fprintf(STDERR, "File system read failed\n");
305 if (rx_Write(call, buffer, nbytes) != nbytes) {
315 /* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
316 * writes it out to the volume. */
318 WriteData(struct rx_call *call, char *rock)
323 afs_int32 error, code;
325 afs_hyper_t filesize, currOffset;
332 if (!filename || !*filename) {
333 usd_StandardInput(&ufd);
337 code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
340 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
343 fprintf(STDERR, "Could not access file '%s'\n", filename);
347 /* test if we have a valid dump */
348 hset64(filesize, 0, 0);
349 USD_SEEK(ufd, filesize, SEEK_END, &currOffset);
350 hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32));
351 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
352 USD_READ(ufd, (char *)&buffer, sizeof(afs_uint32), &got);
353 if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
354 fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
358 /* rewind, we are done */
359 hset64(filesize, 0, 0);
360 USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
362 code = SendFile(ufd, call, blksize);
369 code = USD_CLOSE(ufd);
371 fprintf(STDERR, "Could not close dump file %s\n",
372 (filename && *filename) ? filename : "STDOUT");
380 /* Receive data from <call> stream into file associated
381 * with <fd> <blksize>
384 ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize)
388 afs_uint32 bytesleft, w;
391 buffer = (char *)malloc(blksize);
393 fprintf(STDERR, "memory allocation failed\n");
397 while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {
398 for (bytesleft = bytesread; bytesleft; bytesleft -= w) {
399 #ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */
402 FD_SET((int)(ufd->handle), &out);
403 /* don't timeout if write blocks */
404 #if defined(AFS_PTHREAD_ENV)
405 select(((int)(ufd->handle)) + 1, &out, 0, 0, 0);
407 IOMGR_Select(((int)(ufd->handle)) + 1, 0, &out, 0, 0);
411 USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
413 fprintf(STDERR, "File system write failed\n");
426 DumpFunction(struct rx_call *call, char *filename)
428 usd_handle_t ufd; /* default is to stdout */
429 afs_int32 error = 0, code;
434 /* Open the output file */
435 if (!filename || !*filename) {
436 usd_StandardOutput(&ufd);
441 usd_Open(filename, USD_OPEN_CREATE | USD_OPEN_RDWR, 0666, &ufd);
445 code = USD_IOCTL(ufd, USD_IOCTL_SETSIZE, &size);
448 code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
451 fprintf(STDERR, "Could not create file '%s'\n", filename);
452 ERROR_EXIT(VOLSERBADOP);
456 code = ReceiveFile(ufd, call, blksize);
461 /* Close the output file */
463 code = USD_CLOSE(ufd);
465 fprintf(STDERR, "Could not close dump file %s\n",
466 (filename && *filename) ? filename : "STDIN");
476 vos_ctime(afs_int32 *timep)
483 DisplayFormat(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
486 afs_int32 server, part;
487 int *totalOK, *totalNotOK, *totalBusy;
488 int fast, longlist, disp;
493 fprintf(STDOUT, "%-10lu\n", (unsigned long)pntr->volid);
494 } else if (longlist) {
495 if (pntr->status == VOK) {
496 fprintf(STDOUT, "%-32s ", pntr->name);
497 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
499 fprintf(STDOUT, "RW ");
501 fprintf(STDOUT, "RO ");
503 fprintf(STDOUT, "BK ");
504 fprintf(STDOUT, "%10d K ", pntr->size);
505 if (pntr->inUse == 1) {
506 fprintf(STDOUT, "On-line");
509 fprintf(STDOUT, "Off-line");
512 if (pntr->needsSalvaged == 1)
513 fprintf(STDOUT, "**needs salvage**");
514 fprintf(STDOUT, "\n");
515 MapPartIdIntoName(part, pname);
516 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(server),
518 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
519 (unsigned long)pntr->parentID,
520 (unsigned long)pntr->cloneID,
521 (unsigned long)pntr->backupID);
522 fprintf(STDOUT, " MaxQuota %10d K \n", pntr->maxquota);
523 fprintf(STDOUT, " Creation %s",
524 vos_ctime(& pntr->creationDate));
525 #ifdef FULL_LISTVOL_SWITCH
526 fprintf(STDOUT, " Copy %s",
527 vos_ctime( & pntr->copyDate));
528 if (!pntr->backupDate)
529 fprintf(STDOUT, " Backup Never\n");
531 fprintf(STDOUT, " Backup %s",
532 vos_ctime( & pntr->backupDate));
533 if (pntr->accessDate)
534 fprintf(STDOUT, " Last Access %s",
535 vos_ctime( & pntr->accessDate));
537 if (!pntr->updateDate)
538 fprintf(STDOUT, " Last Update Never\n");
540 fprintf(STDOUT, " Last Update %s",
541 vos_ctime( & pntr->updateDate));
543 " %d accesses in the past day (i.e., vnode references)\n",
545 } else if (pntr->status == VBUSY) {
547 qPut(&busyHead, pntr->volid);
549 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
550 (unsigned long)pntr->volid);
553 qPut(¬okHead, pntr->volid);
555 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
556 (unsigned long)pntr->volid);
558 fprintf(STDOUT, "\n");
559 } else { /* default listing */
560 if (pntr->status == VOK) {
561 fprintf(STDOUT, "%-32s ", pntr->name);
562 fprintf(STDOUT, "%10lu ", (unsigned long)pntr->volid);
564 fprintf(STDOUT, "RW ");
566 fprintf(STDOUT, "RO ");
568 fprintf(STDOUT, "BK ");
569 fprintf(STDOUT, "%10d K ", pntr->size);
570 if (pntr->inUse == 1) {
571 fprintf(STDOUT, "On-line");
574 fprintf(STDOUT, "Off-line");
577 if (pntr->needsSalvaged == 1)
578 fprintf(STDOUT, "**needs salvage**");
579 fprintf(STDOUT, "\n");
580 } else if (pntr->status == VBUSY) {
582 qPut(&busyHead, pntr->volid);
584 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
585 (unsigned long)pntr->volid);
588 qPut(¬okHead, pntr->volid);
590 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
591 (unsigned long)pntr->volid);
596 /*------------------------------------------------------------------------
597 * PRIVATE XDisplayFormat
600 * Display the contents of one extended volume info structure.
603 * a_xInfoP : Ptr to extended volume info struct to print.
604 * a_servID : Server ID to print.
605 * a_partID : Partition ID to print.
606 * a_totalOKP : Ptr to total-OK counter.
607 * a_totalNotOKP : Ptr to total-screwed counter.
608 * a_totalBusyP : Ptr to total-busy counter.
609 * a_fast : Fast listing?
610 * a_int32 : Int32 listing?
611 * a_showProblems : Show volume problems?
617 * Nothing interesting.
621 *------------------------------------------------------------------------*/
624 XDisplayFormat(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
625 a_totalBusyP, a_fast, a_int32, a_showProblems)
626 volintXInfo *a_xInfoP;
636 { /*XDisplayFormat */
644 fprintf(STDOUT, "%-10lu\n", (unsigned long)a_xInfoP->volid);
645 } else if (a_int32) {
647 * Fully-detailed listing.
649 if (a_xInfoP->status == VOK) {
651 * Volume's status is OK - all the fields are valid.
653 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
654 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
655 if (a_xInfoP->type == 0)
656 fprintf(STDOUT, "RW ");
657 if (a_xInfoP->type == 1)
658 fprintf(STDOUT, "RO ");
659 if (a_xInfoP->type == 2)
660 fprintf(STDOUT, "BK ");
661 fprintf(STDOUT, "%10d K used ", a_xInfoP->size);
662 fprintf(STDOUT, "%d files ", a_xInfoP->filecount);
663 if (a_xInfoP->inUse == 1) {
664 fprintf(STDOUT, "On-line");
667 fprintf(STDOUT, "Off-line");
670 fprintf(STDOUT, "\n");
671 MapPartIdIntoName(a_partID, pname);
672 fprintf(STDOUT, " %s %s \n", hostutil_GetNameByINet(a_servID),
674 fprintf(STDOUT, " RWrite %10lu ROnly %10lu Backup %10lu \n",
675 (unsigned long)a_xInfoP->parentID,
676 (unsigned long)a_xInfoP->cloneID,
677 (unsigned long)a_xInfoP->backupID);
678 fprintf(STDOUT, " MaxQuota %10d K \n", a_xInfoP->maxquota);
679 fprintf(STDOUT, " Creation %s",
680 vos_ctime( & a_xInfoP->creationDate));
681 #ifdef FULL_LISTVOL_SWITCH
682 fprintf(STDOUT, " Copy %s",
683 vos_ctime( & a_xInfoP->copyDate));
684 if (!a_xInfoP->backupDate)
685 fprintf(STDOUT, " Backup Never\n");
687 fprintf(STDOUT, " Backup %s",
688 vos_ctime( & a_xInfoP->backupDate));
689 if (a_xInfoP->accessDate)
690 fprintf(STDOUT, " Last Access %s",
691 vos_ctime( & a_xInfoP->accessDate));
693 if (!a_xInfoP->updateDate)
694 fprintf(STDOUT, " Last Update Never\n");
696 fprintf(STDOUT, " Last Update %s",
697 vos_ctime( & a_xInfoP->updateDate));
699 " %d accesses in the past day (i.e., vnode references)\n",
703 * Print all the read/write and authorship stats.
705 fprintf(STDOUT, "\n Raw Read/Write Stats\n");
707 " |-------------------------------------------|\n");
709 " | Same Network | Diff Network |\n");
711 " |----------|----------|----------|----------|\n");
713 " | Total | Auth | Total | Auth |\n");
715 " |----------|----------|----------|----------|\n");
716 fprintf(STDOUT, "Reads | %8d | %8d | %8d | %8d |\n",
717 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET],
718 a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH],
719 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET],
720 a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
721 fprintf(STDOUT, "Writes | %8d | %8d | %8d | %8d |\n",
722 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET],
723 a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH],
724 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET],
725 a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
727 " |-------------------------------------------|\n\n");
730 " Writes Affecting Authorship\n");
732 " |-------------------------------------------|\n");
734 " | File Authorship | Directory Authorship|\n");
736 " |----------|----------|----------|----------|\n");
738 " | Same | Diff | Same | Diff |\n");
740 " |----------|----------|----------|----------|\n");
741 fprintf(STDOUT, "0-60 sec | %8d | %8d | %8d | %8d |\n",
742 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_0],
743 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_0],
744 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_0],
745 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_0]);
746 fprintf(STDOUT, "1-10 min | %8d | %8d | %8d | %8d |\n",
747 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_1],
748 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_1],
749 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_1],
750 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_1]);
751 fprintf(STDOUT, "10min-1hr | %8d | %8d | %8d | %8d |\n",
752 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_2],
753 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_2],
754 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_2],
755 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_2]);
756 fprintf(STDOUT, "1hr-1day | %8d | %8d | %8d | %8d |\n",
757 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_3],
758 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_3],
759 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_3],
760 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_3]);
761 fprintf(STDOUT, "1day-1wk | %8d | %8d | %8d | %8d |\n",
762 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_4],
763 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_4],
764 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_4],
765 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_4]);
766 fprintf(STDOUT, "> 1wk | %8d | %8d | %8d | %8d |\n",
767 a_xInfoP->stat_fileSameAuthor[VOLINT_STATS_TIME_IDX_5],
768 a_xInfoP->stat_fileDiffAuthor[VOLINT_STATS_TIME_IDX_5],
769 a_xInfoP->stat_dirSameAuthor[VOLINT_STATS_TIME_IDX_5],
770 a_xInfoP->stat_dirDiffAuthor[VOLINT_STATS_TIME_IDX_5]);
772 " |-------------------------------------------|\n");
773 } /*Volume status OK */
774 else if (a_xInfoP->status == VBUSY) {
776 qPut(&busyHead, a_xInfoP->volid);
778 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
779 (unsigned long)a_xInfoP->volid);
783 qPut(¬okHead, a_xInfoP->volid);
785 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
786 (unsigned long)a_xInfoP->volid);
787 } /*Screwed volume */
788 fprintf(STDOUT, "\n");
794 if (a_xInfoP->status == VOK) {
795 fprintf(STDOUT, "%-32s ", a_xInfoP->name);
796 fprintf(STDOUT, "%10lu ", (unsigned long)a_xInfoP->volid);
797 if (a_xInfoP->type == 0)
798 fprintf(STDOUT, "RW ");
799 if (a_xInfoP->type == 1)
800 fprintf(STDOUT, "RO ");
801 if (a_xInfoP->type == 2)
802 fprintf(STDOUT, "BK ");
803 fprintf(STDOUT, "%10d K ", a_xInfoP->size);
804 if (a_xInfoP->inUse == 1) {
805 fprintf(STDOUT, "On-line");
808 fprintf(STDOUT, "Off-line");
811 fprintf(STDOUT, "\n");
813 else if (a_xInfoP->status == VBUSY) {
815 qPut(&busyHead, a_xInfoP->volid);
817 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
818 (unsigned long)a_xInfoP->volid);
822 qPut(¬okHead, a_xInfoP->volid);
824 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
825 (unsigned long)a_xInfoP->volid);
826 } /*Screwed volume */
827 } /*Default listing */
828 } /*XDisplayFormat */
830 #ifdef FULL_LISTVOL_SWITCH
831 /*------------------------------------------------------------------------
832 * PRIVATE XDisplayFormat2
835 * Display the formated contents of one extended volume info structure.
838 * a_xInfoP : Ptr to extended volume info struct to print.
839 * a_servID : Server ID to print.
840 * a_partID : Partition ID to print.
841 * a_totalOKP : Ptr to total-OK counter.
842 * a_totalNotOKP : Ptr to total-screwed counter.
843 * a_totalBusyP : Ptr to total-busy counter.
844 * a_fast : Fast listing?
845 * a_int32 : Int32 listing?
846 * a_showProblems : Show volume problems?
852 * Nothing interesting.
856 *------------------------------------------------------------------------*/
859 XDisplayFormat2(a_xInfoP, a_servID, a_partID, a_totalOKP, a_totalNotOKP,
860 a_totalBusyP, a_fast, a_int32, a_showProblems)
861 volintXInfo *a_xInfoP;
871 { /*XDisplayFormat */
876 fprintf(STDOUT, "vold_id\t%-10lu\n", (unsigned long)a_xInfoP->volid);
877 } else if (a_int32) {
879 * Fully-detailed listing.
881 if (a_xInfoP->status == VOK) {
883 * Volume's status is OK - all the fields are valid.
886 static long server_cache = -1, partition_cache = -1;
887 static char hostname[256], address[32], pname[16];
888 int i,ai[] = {VOLINT_STATS_TIME_IDX_0,VOLINT_STATS_TIME_IDX_1,VOLINT_STATS_TIME_IDX_2,
889 VOLINT_STATS_TIME_IDX_3,VOLINT_STATS_TIME_IDX_4,VOLINT_STATS_TIME_IDX_5};
891 if (a_servID != server_cache) {
895 strcpy(hostname, hostutil_GetNameByINet(a_servID));
896 strcpy(address, inet_ntoa(s));
897 server_cache = a_servID;
899 if (a_partID != partition_cache) {
900 MapPartIdIntoName(a_partID, pname);
901 partition_cache = a_partID;
904 fprintf(STDOUT, "name\t\t%s\n", a_xInfoP->name);
905 fprintf(STDOUT, "id\t\t%lu\n", afs_cast_uint32(a_xInfoP->volid));
906 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
907 fprintf(STDOUT, "part\t\t%s\n", pname);
908 switch (a_xInfoP->status) {
910 fprintf(STDOUT, "status\t\tOK\n");
913 fprintf(STDOUT, "status\t\tBUSY\n");
916 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
919 fprintf(STDOUT, "backupID\t%lu\n",
920 afs_cast_uint32(a_xInfoP->backupID));
921 fprintf(STDOUT, "parentID\t%lu\n",
922 afs_cast_uint32(a_xInfoP->parentID));
923 fprintf(STDOUT, "cloneID\t\t%lu\n",
924 afs_cast_uint32(a_xInfoP->cloneID));
925 fprintf(STDOUT, "inUse\t\t%s\n", a_xInfoP->inUse ? "Y" : "N");
926 switch (a_xInfoP->type) {
928 fprintf(STDOUT, "type\t\tRW\n");
931 fprintf(STDOUT, "type\t\tRO\n");
934 fprintf(STDOUT, "type\t\tBK\n");
937 fprintf(STDOUT, "type\t\t?\n");
940 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
941 afs_cast_uint32(a_xInfoP->creationDate),
942 vos_ctime(&a_xInfoP->creationDate));
943 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
944 afs_cast_uint32(a_xInfoP->accessDate),
945 vos_ctime(&a_xInfoP->accessDate));
946 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
947 afs_cast_uint32(a_xInfoP->updateDate),
948 vos_ctime(&a_xInfoP->updateDate));
949 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
950 afs_cast_uint32(a_xInfoP->backupDate),
951 vos_ctime(&a_xInfoP->backupDate));
952 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
953 afs_cast_uint32(a_xInfoP->copyDate),
954 vos_ctime(&a_xInfoP->copyDate));
956 fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
957 fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
959 fprintf(STDOUT, "filecount\t%u\n", a_xInfoP->filecount);
960 fprintf(STDOUT, "dayUse\t\t%u\n", a_xInfoP->dayUse);
964 fprintf(STDOUT,"reads_same_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET]);
965 fprintf(STDOUT,"reads_same_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_SAME_NET_AUTH]);
966 fprintf(STDOUT,"reads_diff_net\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET]);
967 fprintf(STDOUT,"reads_diff_net_auth\t%8d\n",a_xInfoP->stat_reads[VOLINT_STATS_DIFF_NET_AUTH]);
969 fprintf(STDOUT,"writes_same_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET]);
970 fprintf(STDOUT,"writes_same_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_SAME_NET_AUTH]);
971 fprintf(STDOUT,"writes_diff_net\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET]);
972 fprintf(STDOUT,"writes_diff_net_auth\t%8d\n",a_xInfoP->stat_writes[VOLINT_STATS_DIFF_NET_AUTH]);
976 fprintf(STDOUT,"file_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileSameAuthor[ai[i]]);
977 fprintf(STDOUT,"file_diff_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_fileDiffAuthor[ai[i]]);
978 fprintf(STDOUT,"dir_same_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirSameAuthor[ai[i]]);
979 fprintf(STDOUT,"dir_dif_author_idx_%d\t%8d\n",i+1,a_xInfoP->stat_dirDiffAuthor[ai[i]]);
982 } /*Volume status OK */
983 else if (a_xInfoP->status == VBUSY) {
985 qPut(&busyHead, a_xInfoP->volid);
987 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
988 (unsigned long)a_xInfoP->volid);
992 qPut(¬okHead, a_xInfoP->volid);
994 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
995 (unsigned long)a_xInfoP->volid);
996 } /*Screwed volume */
1002 if (a_xInfoP->status == VOK) {
1003 fprintf(STDOUT, "name\t%-32s\n", a_xInfoP->name);
1004 fprintf(STDOUT, "volID\t%10lu\n", (unsigned long)a_xInfoP->volid);
1005 if (a_xInfoP->type == 0)
1006 fprintf(STDOUT, "type\tRW\n");
1007 if (a_xInfoP->type == 1)
1008 fprintf(STDOUT, "type\tRO\n");
1009 if (a_xInfoP->type == 2)
1010 fprintf(STDOUT, "type\tBK\n");
1011 fprintf(STDOUT, "size\t%10dK\n", a_xInfoP->size);
1013 fprintf(STDOUT, "inUse\t%d\n",a_xInfoP->inUse);
1014 if (a_xInfoP->inUse == 1)
1020 else if (a_xInfoP->status == VBUSY) {
1022 qPut(&busyHead, a_xInfoP->volid);
1024 fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
1025 (unsigned long)a_xInfoP->volid);
1029 qPut(¬okHead, a_xInfoP->volid);
1031 fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
1032 (unsigned long)a_xInfoP->volid);
1033 } /*Screwed volume */
1034 } /*Default listing */
1035 } /*XDisplayFormat */
1036 #endif /*FULL_LISTVOL_SWITCH*/
1038 #ifdef FULL_LISTVOL_SWITCH
1040 DisplayFormat2(server, partition, pntr)
1041 long server, partition;
1044 static long server_cache = -1, partition_cache = -1;
1045 static char hostname[256], address[32], pname[16];
1047 if (server != server_cache) {
1051 strcpy(hostname, hostutil_GetNameByINet(server));
1052 strcpy(address, inet_ntoa(s));
1053 server_cache = server;
1055 if (partition != partition_cache) {
1056 MapPartIdIntoName(partition, pname);
1057 partition_cache = partition;
1059 fprintf(STDOUT, "name\t\t%s\n", pntr->name);
1060 fprintf(STDOUT, "id\t\t%lu\n",
1061 afs_cast_uint32(pntr->volid));
1062 fprintf(STDOUT, "serv\t\t%s\t%s\n", address, hostname);
1063 fprintf(STDOUT, "part\t\t%s\n", pname);
1064 switch (pntr->status) {
1066 fprintf(STDOUT, "status\t\tOK\n");
1069 fprintf(STDOUT, "status\t\tBUSY\n");
1072 fprintf(STDOUT, "status\t\tUNATTACHABLE\n");
1075 fprintf(STDOUT, "backupID\t%lu\n",
1076 afs_cast_uint32(pntr->backupID));
1077 fprintf(STDOUT, "parentID\t%lu\n",
1078 afs_cast_uint32(pntr->parentID));
1079 fprintf(STDOUT, "cloneID\t\t%lu\n",
1080 afs_cast_uint32(pntr->cloneID));
1081 fprintf(STDOUT, "inUse\t\t%s\n", pntr->inUse ? "Y" : "N");
1082 fprintf(STDOUT, "needsSalvaged\t%s\n", pntr->needsSalvaged ? "Y" : "N");
1083 /* 0xD3 is from afs/volume.h since I had trouble including the file */
1084 fprintf(STDOUT, "destroyMe\t%s\n", pntr->destroyMe == 0xD3 ? "Y" : "N");
1085 switch (pntr->type) {
1087 fprintf(STDOUT, "type\t\tRW\n");
1090 fprintf(STDOUT, "type\t\tRO\n");
1093 fprintf(STDOUT, "type\t\tBK\n");
1096 fprintf(STDOUT, "type\t\t?\n");
1099 fprintf(STDOUT, "creationDate\t%-9lu\t%s",
1100 afs_cast_uint32(pntr->creationDate),
1101 vos_ctime(&pntr->creationDate));
1102 fprintf(STDOUT, "accessDate\t%-9lu\t%s",
1103 afs_cast_uint32(pntr->accessDate),
1104 vos_ctime(&pntr->accessDate));
1105 fprintf(STDOUT, "updateDate\t%-9lu\t%s",
1106 afs_cast_uint32(pntr->updateDate),
1107 vos_ctime(&pntr->updateDate));
1108 fprintf(STDOUT, "backupDate\t%-9lu\t%s",
1109 afs_cast_uint32(pntr->backupDate),
1110 vos_ctime(&pntr->backupDate));
1111 fprintf(STDOUT, "copyDate\t%-9lu\t%s",
1112 afs_cast_uint32(pntr->copyDate),
1113 vos_ctime(&pntr->copyDate));
1114 fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n",
1115 afs_cast_uint32(pntr->flags));
1116 fprintf(STDOUT, "diskused\t%u\n", pntr->size);
1117 fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
1118 fprintf(STDOUT, "minquota\t%lu\t(Optional)\n",
1119 afs_cast_uint32(pntr->spare0));
1120 fprintf(STDOUT, "filecount\t%u\n", pntr->filecount);
1121 fprintf(STDOUT, "dayUse\t\t%u\n", pntr->dayUse);
1122 fprintf(STDOUT, "weekUse\t\t%lu\t(Optional)\n",
1123 afs_cast_uint32(pntr->spare1));
1124 fprintf(STDOUT, "spare2\t\t%lu\t(Optional)\n",
1125 afs_cast_uint32(pntr->spare2));
1126 fprintf(STDOUT, "spare3\t\t%lu\t(Optional)\n",
1127 afs_cast_uint32(pntr->spare3));
1132 DisplayVolumes2(server, partition, pntr, count)
1134 long server, partition, count;
1138 for (i = 0; i < count; i++) {
1139 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1140 DisplayFormat2(server, partition, pntr);
1141 fprintf(STDOUT, "END_OF_ENTRY\n\n");
1146 #endif /* FULL_LISTVOL_SWITCH */
1149 DisplayVolumes(server, part, pntr, count, longlist, fast, quiet)
1150 afs_int32 server, part;
1152 afs_int32 count, longlist, fast;
1155 int totalOK, totalNotOK, totalBusy, i;
1156 afs_uint32 volid = 0;
1163 for (i = 0; i < count; i++) {
1164 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy,
1169 while (busyHead.count) {
1170 qGet(&busyHead, &volid);
1171 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1172 (unsigned long)volid);
1176 while (notokHead.count) {
1177 qGet(¬okHead, &volid);
1178 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1179 (unsigned long)volid);
1183 fprintf(STDOUT, "\n");
1186 "Total volumes onLine %d ; Total volumes offLine %d ; Total busy %d\n\n",
1187 totalOK, totalNotOK, totalBusy);
1191 /*------------------------------------------------------------------------
1192 * PRIVATE XDisplayVolumes
1195 * Display extended volume information.
1198 * a_servID : Pointer to the Rx call we're performing.
1199 * a_partID : Partition for which we want the extended list.
1200 * a_xInfoP : Ptr to extended volume info.
1201 * a_count : Number of volume records contained above.
1202 * a_int32 : Int32 listing generated?
1203 * a_fast : Fast listing generated?
1204 * a_quiet : Quiet listing generated?
1210 * Nothing interesting.
1214 *------------------------------------------------------------------------*/
1217 XDisplayVolumes(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
1221 volintXInfo *a_xInfoP;
1227 { /*XDisplayVolumes */
1229 int totalOK; /*Total OK volumes */
1230 int totalNotOK; /*Total screwed volumes */
1231 int totalBusy; /*Total busy volumes */
1232 int i; /*Loop variable */
1233 afs_uint32 volid = 0; /*Current volume ID */
1236 * Initialize counters and (global!!) queues.
1245 * Display each volume in the list.
1247 for (i = 0; i < a_count; i++) {
1248 XDisplayFormat(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1249 &totalBusy, a_fast, a_int32, 0);
1254 * If any volumes were found to be busy or screwed, display them.
1257 while (busyHead.count) {
1258 qGet(&busyHead, &volid);
1259 fprintf(STDOUT, "**** Volume %lu is busy ****\n",
1260 (unsigned long)volid);
1264 while (notokHead.count) {
1265 qGet(¬okHead, &volid);
1266 fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
1267 (unsigned long)volid);
1272 fprintf(STDOUT, "\n");
1275 "Total volumes: %d on-line, %d off-line, %d busyd\n\n",
1276 totalOK, totalNotOK, totalBusy);
1280 } /*XDisplayVolumes */
1281 #ifdef FULL_LISTVOL_SWITCH
1282 /*------------------------------------------------------------------------
1283 * PRIVATE XDisplayVolumes2
1286 * Display extended formated volume information.
1289 * a_servID : Pointer to the Rx call we're performing.
1290 * a_partID : Partition for which we want the extended list.
1291 * a_xInfoP : Ptr to extended volume info.
1292 * a_count : Number of volume records contained above.
1293 * a_int32 : Int32 listing generated?
1294 * a_fast : Fast listing generated?
1295 * a_quiet : Quiet listing generated?
1301 * Nothing interesting.
1305 *------------------------------------------------------------------------*/
1308 XDisplayVolumes2(a_servID, a_partID, a_xInfoP, a_count, a_int32, a_fast,
1312 volintXInfo *a_xInfoP;
1318 { /*XDisplayVolumes */
1320 int totalOK; /*Total OK volumes */
1321 int totalNotOK; /*Total screwed volumes */
1322 int totalBusy; /*Total busy volumes */
1323 int i; /*Loop variable */
1324 afs_uint32 volid = 0; /*Current volume ID */
1327 * Initialize counters and (global!!) queues.
1336 * Display each volume in the list.
1338 for (i = 0; i < a_count; i++) {
1339 fprintf(STDOUT, "BEGIN_OF_ENTRY\n");
1340 XDisplayFormat2(a_xInfoP, a_servID, a_partID, &totalOK, &totalNotOK,
1341 &totalBusy, a_fast, a_int32, 0);
1342 fprintf(STDOUT, "END_OF_ENTRY\n");
1347 * If any volumes were found to be busy or screwed, display them.
1350 while (busyHead.count) {
1351 qGet(&busyHead, &volid);
1352 fprintf(STDOUT, "BUSY_VOL\t%lu\n",
1353 (unsigned long)volid);
1357 while (notokHead.count) {
1358 qGet(¬okHead, &volid);
1359 fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
1360 (unsigned long)volid);
1365 fprintf(STDOUT, "\n");
1368 "VOLUMES_ONLINE\t%d\nVOLUMES_OFFLINE\t%d\nVOLUMES_BUSY\t%d\n",
1369 totalOK, totalNotOK, totalBusy);
1373 } /*XDisplayVolumes2 */
1374 #endif /* FULL_LISTVOL_SWITCH */
1377 /* set <server> and <part> to the correct values depending on
1378 * <voltype> and <entry> */
1380 GetServerAndPart(entry, voltype, server, part, previdx)
1381 struct nvldbentry *entry;
1382 afs_int32 *server, *part;
1386 int i, istart, vtype;
1391 /* Doesn't check for non-existance of backup volume */
1392 if ((voltype == RWVOL) || (voltype == BACKVOL)) {
1394 istart = 0; /* seach the entire entry */
1397 /* Seach from beginning of entry or pick up where we left off */
1398 istart = ((*previdx < 0) ? 0 : *previdx + 1);
1401 for (i = istart; i < entry->nServers; i++) {
1402 if (entry->serverFlags[i] & vtype) {
1403 *server = entry->serverNumber[i];
1404 *part = entry->serverPartition[i];
1410 /* Didn't find any, return -1 */
1416 PostVolumeStats(struct nvldbentry *entry)
1418 SubEnumerateEntry(entry);
1419 /* Check for VLOP_ALLOPERS */
1420 if (entry->flags & VLOP_ALLOPERS)
1421 fprintf(STDOUT, " Volume is currently LOCKED \n");
1425 /*------------------------------------------------------------------------
1426 * PRIVATE XVolumeStats
1429 * Display extended volume information.
1432 * a_xInfoP : Ptr to extended volume info.
1433 * a_entryP : Ptr to the volume's VLDB entry.
1434 * a_srvID : Server ID.
1435 * a_partID : Partition ID.
1436 * a_volType : Type of volume to print.
1442 * Nothing interesting.
1446 *------------------------------------------------------------------------*/
1449 XVolumeStats(a_xInfoP, a_entryP, a_srvID, a_partID, a_volType)
1450 volintXInfo *a_xInfoP;
1451 struct nvldbentry *a_entryP;
1458 int totalOK, totalNotOK, totalBusy; /*Dummies - we don't really count here */
1460 XDisplayFormat(a_xInfoP, /*Ptr to extended volume info */
1461 a_srvID, /*Server ID to print */
1462 a_partID, /*Partition ID to print */
1463 &totalOK, /*Ptr to total-OK counter */
1464 &totalNotOK, /*Ptr to total-screwed counter */
1465 &totalBusy, /*Ptr to total-busy counter */
1466 0, /*Don't do a fast listing */
1467 1, /*Do a long listing */
1468 1); /*Show volume problems */
1474 VolumeStats_int(volintInfo *pntr, struct nvldbentry *entry, afs_int32 server,
1475 afs_int32 part, int voltype)
1477 int totalOK, totalNotOK, totalBusy;
1479 DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
1484 /* command to forcibly remove a volume */
1486 NukeVolume(register struct cmd_syndesc *as)
1488 register afs_int32 code;
1495 server = GetServer(tp = as->parms[0].items->data);
1497 fprintf(STDERR, "vos: server '%s' not found in host table\n", tp);
1501 partID = volutil_GetPartitionID(tp = as->parms[1].items->data);
1503 fprintf(STDERR, "vos: could not parse '%s' as a partition name", tp);
1507 volID = vsu_GetVolumeID(tp = as->parms[2].items->data, cstruct, &err);
1510 PrintError("", err);
1513 "vos: could not parse '%s' as a numeric volume ID", tp);
1518 "vos: forcibly removing all traces of volume %d, please wait...",
1521 code = UV_NukeVolume(server, partID, volID);
1523 fprintf(STDOUT, "done.\n");
1525 fprintf(STDOUT, "failed with code %d.\n", code);
1530 /*------------------------------------------------------------------------
1531 * PRIVATE ExamineVolume
1534 * Routine used to examine a single volume, contacting the VLDB as
1535 * well as the Volume Server.
1538 * as : Ptr to parsed command line arguments.
1541 * 0 for a successful operation,
1542 * Otherwise, one of the ubik or VolServer error values.
1545 * Nothing interesting.
1549 *------------------------------------------------------------------------
1552 ExamineVolume(register struct cmd_syndesc *as, void *arock)
1554 struct nvldbentry entry;
1555 afs_int32 vcode = 0;
1556 volintInfo *pntr = (volintInfo *) 0;
1557 volintXInfo *xInfoP = (volintXInfo *) 0;
1559 afs_int32 code, err, error = 0;
1560 int voltype, foundserv = 0, foundentry = 0;
1561 afs_int32 aserver, apart;
1563 int wantExtendedInfo; /*Do we want extended vol info? */
1565 wantExtendedInfo = (as->parms[1].items ? 1 : 0); /* -extended */
1567 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1570 PrintError("", err);
1572 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1573 as->parms[0].items->data);
1578 fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
1579 (unsigned long)volid);
1582 vcode = VLDB_GetEntryByID(volid, -1, &entry);
1585 "Could not fetch the entry for volume number %lu from VLDB \n",
1586 (unsigned long)volid);
1590 fprintf(STDOUT, "done\n");
1591 MapHostToNetwork(&entry);
1593 if (entry.volumeId[RWVOL] == volid)
1595 else if (entry.volumeId[BACKVOL] == volid)
1597 else /* (entry.volumeId[ROVOL] == volid) */
1600 do { /* do {...} while (voltype == ROVOL) */
1601 /* Get the entry for the volume. If its a RW vol, get the RW entry.
1602 * It its a BK vol, get the RW entry (even if VLDB may say the BK doen't exist).
1603 * If its a RO vol, get the next RO entry.
1605 GetServerAndPart(&entry, ((voltype == ROVOL) ? ROVOL : RWVOL),
1606 &aserver, &apart, &previdx);
1607 if (previdx == -1) { /* searched all entries */
1609 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1610 as->parms[0].items->data);
1617 /* Get information about the volume from the server */
1619 fprintf(STDOUT, "Getting volume listing from the server %s .. ",
1620 hostutil_GetNameByINet(aserver));
1623 if (wantExtendedInfo)
1624 code = UV_XListOneVolume(aserver, apart, volid, &xInfoP);
1626 code = UV_ListOneVolume(aserver, apart, volid, &pntr);
1628 fprintf(STDOUT, "done\n");
1632 if (code == ENODEV) {
1633 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1634 /* The VLDB says there is no backup volume and its not on disk */
1635 fprintf(STDERR, "Volume %s does not exist\n",
1636 as->parms[0].items->data);
1640 "Volume does not exist on server %s as indicated by the VLDB\n",
1641 hostutil_GetNameByINet(aserver));
1644 PrintDiagnostics("examine", code);
1646 fprintf(STDOUT, "\n");
1649 if (wantExtendedInfo)
1650 XVolumeStats(xInfoP, &entry, aserver, apart, voltype);
1652 #ifdef FULL_LISTVOL_SWITCH
1653 if (as->parms[2].items) {
1654 DisplayFormat2(aserver, apart, pntr);
1655 EnumerateEntry(&entry);
1657 #endif /* FULL_LISTVOL_SWITCH */
1658 VolumeStats_int(pntr, &entry, aserver, apart, voltype);
1660 if ((voltype == BACKVOL) && !(entry.flags & BACK_EXISTS)) {
1661 /* The VLDB says there is no backup volume yet we found one on disk */
1662 fprintf(STDERR, "Volume %s does not exist in VLDB\n",
1663 as->parms[0].items->data);
1672 } while (voltype == ROVOL);
1675 fprintf(STDERR, "Dump only information from VLDB\n\n");
1676 fprintf(STDOUT, "%s \n", entry.name); /* PostVolumeStats doesn't print name */
1678 PostVolumeStats(&entry);
1683 /*------------------------------------------------------------------------
1687 * Routine used to change the status of a single volume.
1690 * as : Ptr to parsed command line arguments.
1693 * 0 for a successful operation,
1694 * Otherwise, one of the ubik or VolServer error values.
1697 * Nothing interesting.
1701 *------------------------------------------------------------------------
1704 SetFields(register struct cmd_syndesc *as, void *arock)
1706 struct nvldbentry entry;
1707 afs_int32 vcode = 0;
1710 afs_int32 code, err;
1711 afs_int32 aserver, apart;
1714 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err); /* -id */
1717 PrintError("", err);
1719 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1720 as->parms[0].items->data);
1724 code = VLDB_GetEntryByID(volid, RWVOL, &entry);
1727 "Could not fetch the entry for volume number %lu from VLDB \n",
1728 (unsigned long)volid);
1731 MapHostToNetwork(&entry);
1733 GetServerAndPart(&entry, RWVOL, &aserver, &apart, &previdx);
1734 if (previdx == -1) {
1735 fprintf(STDERR, "Volume %s does not exist in VLDB\n\n",
1736 as->parms[0].items->data);
1740 init_volintInfo(&info);
1744 if (as->parms[1].items) {
1746 code = util_GetInt32(as->parms[1].items->data, &info.maxquota);
1748 fprintf(STDERR, "invalid quota value\n");
1752 if (as->parms[2].items) {
1756 if (as->parms[3].items) {
1757 /* -clearVolUpCounter */
1760 code = UV_SetVolumeInfo(aserver, apart, volid, &info);
1763 "Could not update volume info fields for volume number %lu\n",
1764 (unsigned long)volid);
1768 /*------------------------------------------------------------------------
1772 * Brings a volume online.
1775 * as : Ptr to parsed command line arguments.
1778 * 0 for a successful operation,
1781 * Nothing interesting.
1785 *------------------------------------------------------------------------
1788 volOnline(register struct cmd_syndesc *as, void *arock)
1790 afs_int32 server, partition;
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;
1852 afs_int32 code, err = 0;
1853 afs_int32 transflag, sleeptime, transdone;
1855 server = GetServer(as->parms[0].items->data);
1857 fprintf(STDERR, "vos: server '%s' not found in host table\n",
1858 as->parms[0].items->data);
1862 partition = volutil_GetPartitionID(as->parms[1].items->data);
1863 if (partition < 0) {
1864 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1865 as->parms[1].items->data);
1869 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); /* -id */
1872 PrintError("", err);
1874 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
1875 as->parms[0].items->data);
1879 transflag = (as->parms[4].items ? ITBusy : ITOffline);
1880 sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
1881 transdone = (sleeptime ? 0 /*online */ : VTOutOfService);
1882 if (as->parms[4].items && !as->parms[3].items) {
1883 fprintf(STDERR, "-sleep option must be used with -busy flag\n");
1888 UV_SetVolume(server, partition, volid, transflag, transdone,
1891 fprintf(STDERR, "Failed to set volume. Code = %d\n", code);
1899 CreateVolume(register struct cmd_syndesc *as, void *arock)
1905 struct nvldbentry entry;
1910 tserver = GetServer(as->parms[0].items->data);
1912 fprintf(STDERR, "vos: host '%s' not found in host table\n",
1913 as->parms[0].items->data);
1916 pnum = volutil_GetPartitionID(as->parms[1].items->data);
1918 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
1919 as->parms[1].items->data);
1922 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
1924 PrintError("", code);
1927 "vos : partition %s does not exist on the server\n",
1928 as->parms[1].items->data);
1931 if (!ISNAMEVALID(as->parms[2].items->data)) {
1933 "vos: the name of the root volume %s exceeds the size limit of %d\n",
1934 as->parms[2].items->data, VOLSER_OLDMAXVOLNAME - 10);
1937 if (!VolNameOK(as->parms[2].items->data)) {
1939 "Illegal volume name %s, should not end in .readonly or .backup\n",
1940 as->parms[2].items->data);
1943 if (IsNumeric(as->parms[2].items->data)) {
1944 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
1945 as->parms[2].items->data);
1948 vcode = VLDB_GetEntryByName(as->parms[2].items->data, &entry);
1950 fprintf(STDERR, "Volume %s already exists\n",
1951 as->parms[2].items->data);
1952 PrintDiagnostics("create", code);
1956 if (as->parms[3].items) {
1957 if (!IsNumeric(as->parms[3].items->data)) {
1958 fprintf(STDERR, "Initial quota %s should be numeric.\n",
1959 as->parms[3].items->data);
1963 code = util_GetInt32(as->parms[3].items->data, "a);
1965 fprintf(STDERR, "vos: bad integer specified for quota.\n");
1971 UV_CreateVolume2(tserver, pnum, as->parms[2].items->data, quota, 0,
1974 PrintDiagnostics("create", code);
1977 MapPartIdIntoName(pnum, part);
1978 fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
1979 (unsigned long)volid, part, as->parms[0].items->data);
1986 struct nvldbentry *entry;
1989 afs_int32 error, code, curserver, curpart;
1992 MapHostToNetwork(entry);
1994 for (i = 0; i < entry->nServers; i++) {
1995 curserver = entry->serverNumber[i];
1996 curpart = entry->serverPartition[i];
1997 if (entry->serverFlags[i] & ITSROVOL) {
1998 volid = entry->volumeId[ROVOL];
2000 volid = entry->volumeId[RWVOL];
2002 code = UV_DeleteVolume(curserver, curpart, volid);
2010 DeleteVolume(struct cmd_syndesc *as, void *arock)
2012 afs_int32 err, code = 0;
2013 afs_int32 server = 0, partition = -1;
2018 if (as->parms[0].items) {
2019 server = GetServer(as->parms[0].items->data);
2021 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2022 as->parms[0].items->data);
2027 if (as->parms[1].items) {
2028 partition = volutil_GetPartitionID(as->parms[1].items->data);
2029 if (partition < 0) {
2030 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2031 as->parms[1].items->data);
2035 /* Check for validity of the partition */
2036 if (!IsPartValid(partition, server, &code)) {
2038 PrintError("", code);
2041 "vos : partition %s does not exist on the server\n",
2042 as->parms[1].items->data);
2048 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
2050 fprintf(STDERR, "Can't find volume name '%s' in VLDB\n",
2051 as->parms[2].items->data);
2053 PrintError("", err);
2057 /* If the server or partition option are not complete, try to fill
2058 * them in from the VLDB entry.
2060 if ((partition == -1) || !server) {
2061 struct nvldbentry entry;
2063 code = VLDB_GetEntryByID(volid, -1, &entry);
2066 "Could not fetch the entry for volume %lu from VLDB\n",
2067 (unsigned long)volid);
2068 PrintError("", code);
2072 if (((volid == entry.volumeId[RWVOL]) && (entry.flags & RW_EXISTS))
2073 || ((volid == entry.volumeId[BACKVOL])
2074 && (entry.flags & BACK_EXISTS))) {
2075 idx = Lp_GetRwIndex(&entry);
2076 if ((idx == -1) || (server && (server != entry.serverNumber[idx]))
2077 || ((partition != -1)
2078 && (partition != entry.serverPartition[idx]))) {
2079 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2080 as->parms[2].items->data);
2083 } else if ((volid == entry.volumeId[ROVOL])
2084 && (entry.flags & RO_EXISTS)) {
2085 for (idx = -1, j = 0; j < entry.nServers; j++) {
2086 if (entry.serverFlags[j] != ITSROVOL)
2089 if (((server == 0) || (server == entry.serverNumber[j]))
2090 && ((partition == -1)
2091 || (partition == entry.serverPartition[j]))) {
2094 "VLDB: Volume '%s' matches more than one RO\n",
2095 as->parms[2].items->data);
2102 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2103 as->parms[2].items->data);
2107 fprintf(STDERR, "VLDB: Volume '%s' no match\n",
2108 as->parms[2].items->data);
2112 server = htonl(entry.serverNumber[idx]);
2113 partition = entry.serverPartition[idx];
2117 code = UV_DeleteVolume(server, partition, volid);
2119 PrintDiagnostics("remove", code);
2123 MapPartIdIntoName(partition, pname);
2124 fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
2125 (unsigned long)volid, pname, hostutil_GetNameByINet(server));
2129 #define TESTM 0 /* set for move space tests, clear for production */
2131 MoveVolume(register struct cmd_syndesc *as, void *arock)
2135 afs_int32 fromserver, toserver, frompart, topart;
2136 afs_int32 flags, code, err;
2137 char fromPartName[10], toPartName[10];
2139 struct diskPartition64 partition; /* for space check */
2142 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2145 PrintError("", err);
2147 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2148 as->parms[0].items->data);
2151 fromserver = GetServer(as->parms[1].items->data);
2152 if (fromserver == 0) {
2153 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2154 as->parms[1].items->data);
2157 toserver = GetServer(as->parms[3].items->data);
2158 if (toserver == 0) {
2159 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2160 as->parms[3].items->data);
2163 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2165 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2166 as->parms[2].items->data);
2169 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2171 PrintError("", code);
2174 "vos : partition %s does not exist on the server\n",
2175 as->parms[2].items->data);
2178 topart = volutil_GetPartitionID(as->parms[4].items->data);
2180 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2181 as->parms[4].items->data);
2184 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2186 PrintError("", code);
2189 "vos : partition %s does not exist on the server\n",
2190 as->parms[4].items->data);
2195 if (as->parms[5].items) flags |= RV_NOCLONE;
2198 * check source partition for space to clone volume
2201 MapPartIdIntoName(topart, toPartName);
2202 MapPartIdIntoName(frompart, fromPartName);
2205 * check target partition for space to move volume
2208 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2210 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2214 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2217 p = (volintInfo *) 0;
2218 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2220 fprintf(STDERR, "vos:cannot access volume %lu\n",
2221 (unsigned long)volid);
2225 fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
2227 if (partition.free <= p->size) {
2229 "vos: no space on target partition %s to move volume %lu\n",
2230 toPartName, (unsigned long)volid);
2237 fprintf(STDOUT, "size test - don't do move\n");
2241 /* successful move still not guaranteed but shoot for it */
2244 UV_MoveVolume2(volid, fromserver, frompart, toserver, topart, flags);
2246 PrintDiagnostics("move", code);
2249 MapPartIdIntoName(topart, toPartName);
2250 MapPartIdIntoName(frompart, fromPartName);
2251 fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
2252 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2253 as->parms[3].items->data, toPartName);
2259 CopyVolume(register struct cmd_syndesc *as, void *arock)
2262 afs_int32 fromserver, toserver, frompart, topart, code, err, flags;
2263 char fromPartName[10], toPartName[10], *tovolume;
2264 struct nvldbentry entry;
2265 struct diskPartition64 partition; /* for space check */
2268 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2271 PrintError("", err);
2273 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2274 as->parms[0].items->data);
2277 fromserver = GetServer(as->parms[1].items->data);
2278 if (fromserver == 0) {
2279 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2280 as->parms[1].items->data);
2284 toserver = GetServer(as->parms[4].items->data);
2285 if (toserver == 0) {
2286 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2287 as->parms[4].items->data);
2291 tovolume = as->parms[3].items->data;
2292 if (!ISNAMEVALID(tovolume)) {
2294 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2295 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2298 if (!VolNameOK(tovolume)) {
2300 "Illegal volume name %s, should not end in .readonly or .backup\n",
2304 if (IsNumeric(tovolume)) {
2305 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
2309 code = VLDB_GetEntryByName(tovolume, &entry);
2311 fprintf(STDERR, "Volume %s already exists\n", tovolume);
2312 PrintDiagnostics("copy", code);
2316 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2318 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2319 as->parms[2].items->data);
2322 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2324 PrintError("", code);
2327 "vos : partition %s does not exist on the server\n",
2328 as->parms[2].items->data);
2332 topart = volutil_GetPartitionID(as->parms[5].items->data);
2334 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2335 as->parms[5].items->data);
2338 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2340 PrintError("", code);
2343 "vos : partition %s does not exist on the server\n",
2344 as->parms[5].items->data);
2349 if (as->parms[6].items) flags |= RV_OFFLINE;
2350 if (as->parms[7].items) flags |= RV_RDONLY;
2351 if (as->parms[8].items) flags |= RV_NOCLONE;
2353 MapPartIdIntoName(topart, toPartName);
2354 MapPartIdIntoName(frompart, fromPartName);
2357 * check target partition for space to move volume
2360 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2362 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2366 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2369 p = (volintInfo *) 0;
2370 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2372 fprintf(STDERR, "vos:cannot access volume %lu\n",
2373 (unsigned long)volid);
2377 if (partition.free <= p->size) {
2379 "vos: no space on target partition %s to copy volume %lu\n",
2380 toPartName, (unsigned long)volid);
2386 /* successful copy still not guaranteed but shoot for it */
2389 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2392 PrintDiagnostics("copy", code);
2395 MapPartIdIntoName(topart, toPartName);
2396 MapPartIdIntoName(frompart, fromPartName);
2397 fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
2398 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2399 tovolume, as->parms[4].items->data, toPartName);
2406 ShadowVolume(register struct cmd_syndesc *as, void *arock)
2408 afs_uint32 volid, tovolid;
2409 afs_int32 fromserver, toserver, frompart, topart;
2410 afs_int32 code, err, flags;
2411 char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
2412 struct diskPartition64 partition; /* for space check */
2415 p = (volintInfo *) 0;
2416 q = (volintInfo *) 0;
2418 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2421 PrintError("", err);
2423 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2424 as->parms[0].items->data);
2427 fromserver = GetServer(as->parms[1].items->data);
2428 if (fromserver == 0) {
2429 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2430 as->parms[1].items->data);
2434 toserver = GetServer(as->parms[3].items->data);
2435 if (toserver == 0) {
2436 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2437 as->parms[3].items->data);
2441 frompart = volutil_GetPartitionID(as->parms[2].items->data);
2443 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2444 as->parms[2].items->data);
2447 if (!IsPartValid(frompart, fromserver, &code)) { /*check for validity of the partition */
2449 PrintError("", code);
2452 "vos : partition %s does not exist on the server\n",
2453 as->parms[2].items->data);
2457 topart = volutil_GetPartitionID(as->parms[4].items->data);
2459 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2460 as->parms[4].items->data);
2463 if (!IsPartValid(topart, toserver, &code)) { /*check for validity of the partition */
2465 PrintError("", code);
2468 "vos : partition %s does not exist on the server\n",
2469 as->parms[4].items->data);
2473 if (as->parms[5].items) {
2474 tovolume = as->parms[5].items->data;
2475 if (!ISNAMEVALID(tovolume)) {
2477 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2478 tovolume, VOLSER_OLDMAXVOLNAME - 10);
2481 if (!VolNameOK(tovolume)) {
2483 "Illegal volume name %s, should not end in .readonly or .backup\n",
2487 if (IsNumeric(tovolume)) {
2489 "Illegal volume name %s, should not be a number\n",
2494 /* use actual name of source volume */
2495 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2497 fprintf(STDERR, "vos:cannot access volume %lu\n",
2498 (unsigned long)volid);
2501 strcpy(toVolName, p->name);
2502 tovolume = toVolName;
2503 /* save p for size checks later */
2506 if (as->parms[6].items) {
2507 tovolid = vsu_GetVolumeID(as->parms[6].items->data, cstruct, &err);
2510 PrintError("", err);
2512 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2513 as->parms[6].items->data);
2519 tovolid = vsu_GetVolumeID(tovolume, cstruct, &err);
2522 PrintError("", err);
2524 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2533 if (as->parms[7].items) flags |= RV_OFFLINE;
2534 if (as->parms[8].items) flags |= RV_RDONLY;
2535 if (as->parms[9].items) flags |= RV_NOCLONE;
2536 if (as->parms[10].items) flags |= RV_CPINCR;
2538 MapPartIdIntoName(topart, toPartName);
2539 MapPartIdIntoName(frompart, fromPartName);
2542 * check target partition for space to move volume
2545 code = UV_PartitionInfo64(toserver, toPartName, &partition);
2547 fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
2551 fprintf(STDOUT, "target partition %s free space %" AFS_INT64_FMT "\n", toPartName,
2554 /* Don't do this again if we did it above */
2556 code = UV_ListOneVolume(fromserver, frompart, volid, &p);
2558 fprintf(STDERR, "vos:cannot access volume %lu\n",
2559 (unsigned long)volid);
2564 /* OK if this fails */
2565 code = UV_ListOneVolume(toserver, topart, tovolid, &q);
2567 /* Treat existing volume size as "free" */
2569 p->size = (q->size < p->size) ? p->size - q->size : 0;
2571 if (partition.free <= p->size) {
2573 "vos: no space on target partition %s to copy volume %lu\n",
2574 toPartName, (unsigned long)volid);
2582 /* successful copy still not guaranteed but shoot for it */
2585 UV_CopyVolume2(volid, fromserver, frompart, tovolume, toserver,
2586 topart, tovolid, flags);
2588 PrintDiagnostics("shadow", code);
2591 MapPartIdIntoName(topart, toPartName);
2592 MapPartIdIntoName(frompart, fromPartName);
2593 fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
2594 (unsigned long)volid, as->parms[1].items->data, fromPartName,
2595 as->parms[3].items->data, toPartName);
2602 CloneVolume(register struct cmd_syndesc *as, void *arock)
2604 afs_uint32 volid, cloneid;
2605 afs_int32 server, part, voltype;
2606 char partName[10], *volname;
2607 afs_int32 code, err, flags;
2608 struct nvldbentry entry;
2610 volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2613 PrintError("", err);
2615 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2616 as->parms[0].items->data);
2620 if (as->parms[1].items || as->parms[2].items) {
2621 if (!as->parms[1].items || !as->parms[2].items) {
2623 "Must specify both -server and -partition options\n");
2626 server = GetServer(as->parms[1].items->data);
2628 fprintf(STDERR, "vos: server '%s' not found in host table\n",
2629 as->parms[1].items->data);
2632 part = volutil_GetPartitionID(as->parms[2].items->data);
2634 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
2635 as->parms[2].items->data);
2638 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
2640 PrintError("", code);
2643 "vos : partition %s does not exist on the server\n",
2644 as->parms[2].items->data);
2648 code = GetVolumeInfo(volid, &server, &part, &voltype, &entry);
2654 if (as->parms[3].items) {
2655 volname = as->parms[3].items->data;
2656 if (strlen(volname) > VOLSER_OLDMAXVOLNAME - 1) {
2658 "vos: the name of the root volume %s exceeds the size limit of %d\n",
2659 volname, VOLSER_OLDMAXVOLNAME - 1);
2664 * In order that you be able to make clones of RO or BK, this
2665 * check must be omitted.
2667 if (!VolNameOK(volname)) {
2669 "Illegal volume name %s, should not end in .readonly or .backup\n",
2674 if (IsNumeric(volname)) {
2676 "Illegal volume name %s, should not be a number\n",
2683 if (as->parms[4].items) {
2684 cloneid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2687 PrintError("", err);
2689 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2690 as->parms[4].items->data);
2696 if (as->parms[5].items) flags |= RV_OFFLINE;
2697 if (as->parms[6].items) flags |= RV_RDONLY;
2701 UV_CloneVolume(server, part, volid, cloneid, volname, flags);
2704 PrintDiagnostics("clone", code);
2707 MapPartIdIntoName(part, partName);
2708 fprintf(STDOUT, "Created clone for volume %s\n",
2709 as->parms[0].items->data);
2716 BackupVolume(register struct cmd_syndesc *as, void *arock)
2719 afs_int32 aserver, apart, vtype, code, err;
2720 struct nvldbentry entry;
2723 afs_int32 buserver, bupart, butype;
2724 struct nvldbentry buentry;
2726 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2729 PrintError("", err);
2731 fprintf(STDERR, "vos: can't find volume ID or name '%s'\n",
2732 as->parms[0].items->data);
2735 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2739 /* verify this is a readwrite volume */
2741 if (vtype != RWVOL) {
2742 fprintf(STDERR, "%s not RW volume\n", as->parms[0].items->data);
2746 /* is there a backup volume already? */
2748 if (entry.flags & BACK_EXISTS) {
2749 /* yep, where is it? */
2751 buvolid = entry.volumeId[BACKVOL];
2752 code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
2757 code = VLDB_IsSameAddrs(buserver, aserver, &err);
2760 "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
2766 "FATAL ERROR: backup volume %lu exists on server %lu\n",
2767 (unsigned long)buvolid, (unsigned long)buserver);
2772 /* nope, carry on */
2774 code = UV_BackupVolume(aserver, apart, avolid);
2777 PrintDiagnostics("backup", code);
2780 fprintf(STDOUT, "Created backup volume for %s \n",
2781 as->parms[0].items->data);
2786 ReleaseVolume(register struct cmd_syndesc *as, void *arock)
2789 struct nvldbentry entry;
2791 afs_int32 aserver, apart, vtype, code, err;
2794 if (as->parms[1].items)
2796 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2799 PrintError("", err);
2801 fprintf(STDERR, "vos: can't find volume '%s'\n",
2802 as->parms[0].items->data);
2805 code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
2809 if (vtype != RWVOL) {
2810 fprintf(STDERR, "%s not a RW volume\n", as->parms[0].items->data);
2814 if (!ISNAMEVALID(entry.name)) {
2816 "Volume name %s is too long, rename before releasing\n",
2821 code = UV_ReleaseVolume(avolid, aserver, apart, force);
2823 PrintDiagnostics("release", code);
2826 fprintf(STDOUT, "Released volume %s successfully\n",
2827 as->parms[0].items->data);
2832 DumpVolume(register struct cmd_syndesc *as, void *arock)
2835 afs_int32 aserver, apart, voltype, fromdate = 0, code, err, i, flags;
2836 char filename[MAXPATHLEN];
2837 struct nvldbentry entry;
2839 rx_SetRxDeadTime(60 * 10);
2840 for (i = 0; i < MAXSERVERS; i++) {
2841 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
2844 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
2845 if (rxConn->service)
2846 rxConn->service->connDeadTime = rx_connDeadTime;
2849 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
2852 PrintError("", err);
2854 fprintf(STDERR, "vos: can't find volume '%s'\n",
2855 as->parms[0].items->data);
2859 if (as->parms[3].items || as->parms[4].items) {
2860 if (!as->parms[3].items || !as->parms[4].items) {
2862 "Must specify both -server and -partition options\n");
2865 aserver = GetServer(as->parms[3].items->data);
2867 fprintf(STDERR, "Invalid server name\n");
2870 apart = volutil_GetPartitionID(as->parms[4].items->data);
2872 fprintf(STDERR, "Invalid partition name\n");
2876 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
2881 if (as->parms[1].items && strcmp(as->parms[1].items->data, "0")) {
2882 code = ktime_DateToInt32(as->parms[1].items->data, &fromdate);
2884 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
2885 as->parms[1].items->data, code);
2889 if (as->parms[2].items) {
2890 strcpy(filename, as->parms[2].items->data);
2892 strcpy(filename, "");
2895 flags = as->parms[6].items ? VOLDUMPV2_OMITDIRS : 0;
2897 if (as->parms[5].items) {
2899 UV_DumpClonedVolume(avolid, aserver, apart, fromdate,
2900 DumpFunction, filename, flags);
2903 UV_DumpVolume(avolid, aserver, apart, fromdate, DumpFunction,
2906 if ((code == RXGEN_OPCODE) && (as->parms[6].items)) {
2907 flags &= ~VOLDUMPV2_OMITDIRS;
2911 PrintDiagnostics("dump", code);
2914 if (strcmp(filename, ""))
2915 fprintf(STDERR, "Dumped volume %s in file %s\n",
2916 as->parms[0].items->data, filename);
2918 fprintf(STDERR, "Dumped volume %s in stdout \n",
2919 as->parms[0].items->data);
2933 RestoreVolume(register struct cmd_syndesc *as, void *arock)
2935 afs_uint32 avolid, aparentid;
2936 afs_int32 aserver, apart, code, vcode, err;
2937 afs_int32 aoverwrite = ASK;
2938 afs_int32 acreation = 0, alastupdate = 0;
2939 int restoreflags = 0;
2940 int readonly = 0, offline = 0, voltype = RWVOL;
2942 char afilename[MAXPATHLEN], avolname[VOLSER_MAXVOLNAME + 1], apartName[10];
2943 char volname[VOLSER_MAXVOLNAME + 1];
2944 struct nvldbentry entry;
2949 if (as->parms[4].items) {
2950 avolid = vsu_GetVolumeID(as->parms[4].items->data, cstruct, &err);
2953 PrintError("", err);
2955 fprintf(STDERR, "vos: can't find volume '%s'\n",
2956 as->parms[4].items->data);
2962 if (as->parms[5].items) {
2963 if ((strcmp(as->parms[5].items->data, "a") == 0)
2964 || (strcmp(as->parms[5].items->data, "abort") == 0)) {
2966 } else if ((strcmp(as->parms[5].items->data, "f") == 0)
2967 || (strcmp(as->parms[5].items->data, "full") == 0)) {
2969 } else if ((strcmp(as->parms[5].items->data, "i") == 0)
2970 || (strcmp(as->parms[5].items->data, "inc") == 0)
2971 || (strcmp(as->parms[5].items->data, "increment") == 0)
2972 || (strcmp(as->parms[5].items->data, "incremental") == 0)) {
2975 fprintf(STDERR, "vos: %s is not a valid argument to -overwrite\n",
2976 as->parms[5].items->data);
2980 if (as->parms[6].items)
2982 if (as->parms[7].items) {
2987 if (as->parms[8].items) {
2988 if ((strcmp(as->parms[8].items->data, "d") == 0)
2989 || (strcmp(as->parms[8].items->data, "dump") == 0)) {
2990 acreation = TS_DUMP;
2991 } else if ((strcmp(as->parms[8].items->data, "k") == 0)
2992 || (strcmp(as->parms[8].items->data, "keep") == 0)) {
2993 acreation = TS_KEEP;
2994 } else if ((strcmp(as->parms[8].items->data, "n") == 0)
2995 || (strcmp(as->parms[8].items->data, "new") == 0)) {
2998 fprintf(STDERR, "vos: %s is not a valid argument to -creation\n",
2999 as->parms[8].items->data);
3004 if (as->parms[9].items) {
3005 if ((strcmp(as->parms[9].items->data, "d") == 0)
3006 || (strcmp(as->parms[9].items->data, "dump") == 0)) {
3007 alastupdate = TS_DUMP;
3008 } else if ((strcmp(as->parms[9].items->data, "k") == 0)
3009 || (strcmp(as->parms[9].items->data, "keep") == 0)) {
3010 alastupdate = TS_KEEP;
3011 } else if ((strcmp(as->parms[9].items->data, "n") == 0)
3012 || (strcmp(as->parms[9].items->data, "new") == 0)) {
3013 alastupdate = TS_NEW;
3015 fprintf(STDERR, "vos: %s is not a valid argument to -lastupdate\n",
3016 as->parms[9].items->data);
3021 aserver = GetServer(as->parms[0].items->data);
3023 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3024 as->parms[0].items->data);
3027 apart = volutil_GetPartitionID(as->parms[1].items->data);
3029 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3030 as->parms[1].items->data);
3033 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3035 PrintError("", code);
3038 "vos : partition %s does not exist on the server\n",
3039 as->parms[1].items->data);
3042 strcpy(avolname, as->parms[2].items->data);
3043 if (!ISNAMEVALID(avolname)) {
3045 "vos: the name of the volume %s exceeds the size limit\n",
3049 if (!VolNameOK(avolname)) {
3051 "Illegal volume name %s, should not end in .readonly or .backup\n",
3055 if (as->parms[3].items) {
3056 strcpy(afilename, as->parms[3].items->data);
3057 if (!FileExists(afilename)) {
3058 fprintf(STDERR, "Can't access file %s\n", afilename);
3062 strcpy(afilename, "");
3065 /* Check if volume exists or not */
3067 vsu_ExtractName(volname, avolname);
3068 vcode = VLDB_GetEntryByName(volname, &entry);
3069 if (vcode) { /* no volume - do a full restore */
3070 restoreflags = RV_FULLRST;
3071 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3073 "Volume does not exist; Will perform a full restore\n");
3076 else if ((!readonly && Lp_GetRwIndex(&entry) == -1) /* RW volume does not exist - do a full */
3077 ||(readonly && !Lp_ROMatch(0, 0, &entry))) { /* RO volume does not exist - do a full */
3078 restoreflags = RV_FULLRST;
3079 if ((aoverwrite == INC) || (aoverwrite == ABORT))
3081 "%s Volume does not exist; Will perform a full restore\n",
3082 readonly ? "RO" : "RW");
3085 avolid = entry.volumeId[voltype];
3086 } else if (entry.volumeId[voltype] != 0
3087 && entry.volumeId[voltype] != avolid) {
3088 avolid = entry.volumeId[voltype];
3090 aparentid = entry.volumeId[RWVOL];
3093 else { /* volume exists - do we do a full incremental or abort */
3094 int Oserver, Opart, Otype, vol_elsewhere = 0;
3095 struct nvldbentry Oentry;
3099 avolid = entry.volumeId[voltype];
3100 } else if (entry.volumeId[voltype] != 0
3101 && entry.volumeId[voltype] != avolid) {
3102 avolid = entry.volumeId[voltype];
3104 aparentid = entry.volumeId[RWVOL];
3106 /* A file name was specified - check if volume is on another partition */
3107 vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
3111 vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
3114 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
3118 if (!vcode || (Opart != apart))
3121 if (aoverwrite == ASK) {
3122 if (strcmp(afilename, "") == 0) { /* The file is from standard in */
3124 "Volume exists and no -overwrite option specified; Aborting restore command\n");
3128 /* Ask what to do */
3129 if (vol_elsewhere) {
3131 "The volume %s %u already exists on a different server/part\n",
3132 volname, entry.volumeId[voltype]);
3134 "Do you want to do a full restore or abort? [fa](a): ");
3137 "The volume %s %u already exists in the VLDB\n",
3138 volname, entry.volumeId[voltype]);
3140 "Do you want to do a full/incremental restore or abort? [fia](a): ");
3143 while (!(dc == EOF || dc == '\n'))
3144 dc = getchar(); /* goto end of line */
3145 if ((c == 'f') || (c == 'F'))
3147 else if ((c == 'i') || (c == 'I'))
3153 if (aoverwrite == ABORT) {
3154 fprintf(STDERR, "Volume exists; Aborting restore command\n");
3156 } else if (aoverwrite == FULL) {
3157 restoreflags = RV_FULLRST;
3159 "Volume exists; Will delete and perform full restore\n");
3160 } else if (aoverwrite == INC) {
3162 if (vol_elsewhere) {
3164 "%s volume %lu already exists on a different server/part; not allowed\n",
3165 readonly ? "RO" : "RW", (unsigned long)avolid);
3171 restoreflags |= RV_OFFLINE;
3173 restoreflags |= RV_RDONLY;
3175 switch (acreation) {
3177 restoreflags |= RV_CRDUMP;
3180 restoreflags |= RV_CRKEEP;
3183 restoreflags |= RV_CRNEW;
3186 if (aoverwrite == FULL)
3187 restoreflags |= RV_CRNEW;
3189 restoreflags |= RV_CRKEEP;
3192 switch (alastupdate) {
3194 restoreflags |= RV_LUDUMP;
3197 restoreflags |= RV_LUKEEP;
3200 restoreflags |= RV_LUNEW;
3203 restoreflags |= RV_LUDUMP;
3205 if (as->parms[10].items) {
3206 restoreflags |= RV_NODEL;
3211 UV_RestoreVolume2(aserver, apart, avolid, aparentid,
3212 avolname, restoreflags, WriteData, afilename);
3214 PrintDiagnostics("restore", code);
3217 MapPartIdIntoName(apart, apartName);
3220 * patch typo here - originally "parms[1]", should be "parms[0]"
3223 fprintf(STDOUT, "Restored volume %s on %s %s\n", avolname,
3224 as->parms[0].items->data, apartName);
3229 LockReleaseCmd(register struct cmd_syndesc *as, void *arock)
3232 afs_int32 code, err;
3234 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
3237 PrintError("", err);
3239 fprintf(STDERR, "vos: can't find volume '%s'\n",
3240 as->parms[0].items->data);
3244 code = UV_LockRelease(avolid);
3246 PrintDiagnostics("unlock", code);
3249 fprintf(STDOUT, "Released lock on vldb entry for volume %s\n",
3250 as->parms[0].items->data);
3255 AddSite(register struct cmd_syndesc *as, void *arock)
3258 afs_int32 aserver, apart, code, err, valid = 0;
3259 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3261 vsu_ExtractName(avolname, as->parms[2].items->data);;
3262 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3265 PrintError("", err);
3267 fprintf(STDERR, "vos: can't find volume '%s'\n",
3268 as->parms[2].items->data);
3271 aserver = GetServer(as->parms[0].items->data);
3273 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3274 as->parms[0].items->data);
3277 apart = volutil_GetPartitionID(as->parms[1].items->data);
3279 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3280 as->parms[1].items->data);
3283 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3285 PrintError("", code);
3288 "vos : partition %s does not exist on the server\n",
3289 as->parms[1].items->data);
3292 if (as->parms[3].items) {
3295 code = UV_AddSite(aserver, apart, avolid, valid);
3297 PrintDiagnostics("addsite", code);
3300 MapPartIdIntoName(apart, apartName);
3301 fprintf(STDOUT, "Added replication site %s %s for volume %s\n",
3302 as->parms[0].items->data, apartName, as->parms[2].items->data);
3307 RemoveSite(register struct cmd_syndesc *as, void *arock)
3311 afs_int32 aserver, apart, code, err;
3312 char apartName[10], avolname[VOLSER_MAXVOLNAME + 1];
3314 vsu_ExtractName(avolname, as->parms[2].items->data);
3315 avolid = vsu_GetVolumeID(avolname, cstruct, &err);
3318 PrintError("", err);
3320 fprintf(STDERR, "vos: can't find volume '%s'\n",
3321 as->parms[2].items->data);
3324 aserver = GetServer(as->parms[0].items->data);
3326 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3327 as->parms[0].items->data);
3330 apart = volutil_GetPartitionID(as->parms[1].items->data);
3332 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3333 as->parms[1].items->data);
3337 *skip the partition validity check, since it is possible that the partition
3338 *has since been decomissioned.
3341 if (!IsPartValid(apart,aserver,&code)){
3342 if(code) PrintError("",code);
3343 else fprintf(STDERR,"vos : partition %s does not exist on the server\n",as->parms[1].items->data);
3347 code = UV_RemoveSite(aserver, apart, avolid);
3349 PrintDiagnostics("remsite", code);
3352 MapPartIdIntoName(apart, apartName);
3353 fprintf(STDOUT, "Removed replication site %s %s for volume %s\n",
3354 as->parms[0].items->data, apartName, as->parms[2].items->data);
3359 ChangeLocation(register struct cmd_syndesc *as, void *arock)
3362 afs_int32 aserver, apart, code, err;
3365 avolid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3368 PrintError("", err);
3370 fprintf(STDERR, "vos: can't find volume '%s'\n",
3371 as->parms[2].items->data);
3374 aserver = GetServer(as->parms[0].items->data);
3376 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3377 as->parms[0].items->data);
3380 apart = volutil_GetPartitionID(as->parms[1].items->data);
3382 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3383 as->parms[1].items->data);
3386 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3388 PrintError("", code);
3391 "vos : partition %s does not exist on the server\n",
3392 as->parms[1].items->data);
3395 code = UV_ChangeLocation(aserver, apart, avolid);
3397 PrintDiagnostics("addsite", code);
3400 MapPartIdIntoName(apart, apartName);
3401 fprintf(STDOUT, "Changed location to %s %s for volume %s\n",
3402 as->parms[0].items->data, apartName, as->parms[2].items->data);
3407 ListPartitions(register struct cmd_syndesc *as, void *arock)
3409 afs_int32 aserver, code;
3410 struct partList dummyPartList;
3415 aserver = GetServer(as->parms[0].items->data);
3417 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3418 as->parms[0].items->data);
3423 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3425 PrintDiagnostics("listpart", code);
3429 fprintf(STDOUT, "The partitions on the server are:\n");
3430 for (i = 0; i < cnt; i++) {
3431 if (dummyPartList.partFlags[i] & PARTVALID) {
3432 memset(pname, 0, sizeof(pname));
3433 MapPartIdIntoName(dummyPartList.partId[i], pname);
3434 fprintf(STDOUT, " %10s ", pname);
3436 if ((i % 5) == 0 && (i != 0))
3437 fprintf(STDOUT, "\n");
3440 fprintf(STDOUT, "\n");
3441 fprintf(STDOUT, "Total: %d\n", total);
3447 CompareVolName(p1, p2)
3450 volintInfo *arg1, *arg2;
3452 arg1 = (volintInfo *) p1;
3453 arg2 = (volintInfo *) p2;
3454 return (strcmp(arg1->name, arg2->name));
3458 /*------------------------------------------------------------------------
3459 * PRIVATE XCompareVolName
3462 * Comparison routine for volume names coming from an extended
3466 * a_obj1P : Char ptr to first extended vol info object
3467 * a_obj1P : Char ptr to second extended vol info object
3470 * The value of strcmp() on the volume names within the passed
3471 * objects (i,e., -1, 0, or 1).
3474 * Passed to qsort() as the designated comparison routine.
3478 *------------------------------------------------------------------------*/
3481 XCompareVolName(a_obj1P, a_obj2P)
3482 char *a_obj1P, *a_obj2P;
3484 { /*XCompareVolName */
3487 (((struct volintXInfo *)(a_obj1P))->name,
3488 ((struct volintXInfo *)(a_obj2P))->name));
3490 } /*XCompareVolName */
3493 CompareVolID(p1, p2)
3496 volintInfo *arg1, *arg2;
3498 arg1 = (volintInfo *) p1;
3499 arg2 = (volintInfo *) p2;
3500 if (arg1->volid == arg2->volid)
3502 if (arg1->volid > arg2->volid)
3509 /*------------------------------------------------------------------------
3510 * PRIVATE XCompareVolID
3513 * Comparison routine for volume IDs coming from an extended
3517 * a_obj1P : Char ptr to first extended vol info object
3518 * a_obj1P : Char ptr to second extended vol info object
3521 * The value of strcmp() on the volume names within the passed
3522 * objects (i,e., -1, 0, or 1).
3525 * Passed to qsort() as the designated comparison routine.
3529 *------------------------------------------------------------------------*/
3532 XCompareVolID(a_obj1P, a_obj2P)
3533 char *a_obj1P, *a_obj2P;
3535 { /*XCompareVolID */
3537 afs_int32 id1, id2; /*Volume IDs we're comparing */
3539 id1 = ((struct volintXInfo *)(a_obj1P))->volid;
3540 id2 = ((struct volintXInfo *)(a_obj2P))->volid;
3548 } /*XCompareVolID */
3550 /*------------------------------------------------------------------------
3551 * PRIVATE ListVolumes
3554 * Routine used to list volumes, contacting the Volume Server
3555 * directly, bypassing the VLDB.
3558 * as : Ptr to parsed command line arguments.
3561 * 0 Successful operation
3564 * Nothing interesting.
3568 *------------------------------------------------------------------------*/
3571 ListVolumes(register struct cmd_syndesc *as, void *arock)
3573 afs_int32 apart, int32list, fast;
3574 afs_int32 aserver, code;
3576 volintInfo *oldpntr = NULL;
3580 volintXInfo *xInfoP;
3581 volintXInfo *origxInfoP = NULL; /*Ptr to current/orig extended vol info */
3582 int wantExtendedInfo; /*Do we want extended vol info? */
3585 struct partList dummyPartList;
3593 if (as->parms[3].items)
3595 if (as->parms[4].items)
3599 if (as->parms[2].items)
3605 if (as->parms[5].items) {
3607 * We can't coexist with the fast flag.
3611 "vos: Can't use the -fast and -extended flags together\n");
3616 * We need to turn on ``long'' listings to get the full effect.
3618 wantExtendedInfo = 1;
3621 wantExtendedInfo = 0;
3622 if (as->parms[1].items) {
3623 apart = volutil_GetPartitionID(as->parms[1].items->data);
3625 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3626 as->parms[1].items->data);
3629 dummyPartList.partId[0] = apart;
3630 dummyPartList.partFlags[0] = PARTVALID;
3633 aserver = GetServer(as->parms[0].items->data);
3635 fprintf(STDERR, "vos: server '%s' not found in host table\n",
3636 as->parms[0].items->data);
3641 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
3643 PrintError("", code);
3646 "vos : partition %s does not exist on the server\n",
3647 as->parms[1].items->data);
3651 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
3653 PrintDiagnostics("listvol", code);
3657 for (i = 0; i < cnt; i++) {
3658 if (dummyPartList.partFlags[i] & PARTVALID) {
3659 if (wantExtendedInfo)
3661 UV_XListVolumes(aserver, dummyPartList.partId[i], all,
3665 UV_ListVolumes(aserver, dummyPartList.partId[i], all,
3668 PrintDiagnostics("listvol", code);
3673 if (wantExtendedInfo) {
3674 origxInfoP = xInfoP;
3675 base = (char *)xInfoP;
3678 base = (char *)pntr;
3682 if (wantExtendedInfo)
3683 qsort(base, count, sizeof(volintXInfo), XCompareVolName);
3685 qsort(base, count, sizeof(volintInfo), CompareVolName);
3687 if (wantExtendedInfo)
3688 qsort(base, count, sizeof(volintXInfo), XCompareVolID);
3690 qsort(base, count, sizeof(volintInfo), CompareVolID);
3692 MapPartIdIntoName(dummyPartList.partId[i], pname);
3695 "Total number of volumes on server %s partition %s: %lu \n",
3696 as->parms[0].items->data, pname,
3697 (unsigned long)count);
3698 if (wantExtendedInfo) {
3699 #ifdef FULL_LISTVOL_SWITCH
3700 if (as->parms[6].items)
3701 XDisplayVolumes2(aserver, dummyPartList.partId[i], origxInfoP,
3702 count, int32list, fast, quiet);
3704 #endif /* FULL_LISTVOL_SWITCH */
3705 XDisplayVolumes(aserver, dummyPartList.partId[i], origxInfoP,
3706 count, int32list, fast, quiet);
3709 xInfoP = (volintXInfo *) 0;
3711 #ifdef FULL_LISTVOL_SWITCH
3712 if (as->parms[6].items)
3713 DisplayVolumes2(aserver, dummyPartList.partId[i], oldpntr,
3716 #endif /* FULL_LISTVOL_SWITCH */
3717 DisplayVolumes(aserver, dummyPartList.partId[i], oldpntr,
3718 count, int32list, fast, quiet);
3721 pntr = (volintInfo *) 0;
3729 SyncVldb(register struct cmd_syndesc *as, void *arock)
3731 afs_int32 pnum = 0, code; /* part name */
3737 if (as->parms[0].items) {
3738 tserver = GetServer(as->parms[0].items->data);
3740 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3741 as->parms[0].items->data);
3746 if (as->parms[1].items) {
3747 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3749 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3750 as->parms[1].items->data);
3753 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3755 PrintError("", code);
3758 "vos: partition %s does not exist on the server\n",
3759 as->parms[1].items->data);
3766 "The -partition option requires a -server option\n");
3771 if (as->parms[3].items) {
3772 flags |= 2; /* don't update */
3775 if (as->parms[2].items) {
3776 /* Synchronize an individual volume */
3777 volname = as->parms[2].items->data;
3778 code = UV_SyncVolume(tserver, pnum, volname, flags);
3782 "Without a -volume option, the -server option is required\n");
3785 code = UV_SyncVldb(tserver, pnum, flags, 0 /*unused */ );
3789 PrintDiagnostics("syncvldb", code);
3793 /* Print a summary of what we did */
3795 fprintf(STDOUT, "VLDB volume %s synchronized", volname);
3797 fprintf(STDOUT, "VLDB synchronized");
3799 fprintf(STDOUT, " with state of server %s", as->parms[0].items->data);
3802 MapPartIdIntoName(pnum, part);
3803 fprintf(STDOUT, " partition %s\n", part);
3805 fprintf(STDOUT, "\n");
3811 SyncServer(register struct cmd_syndesc *as, void *arock)
3813 afs_int32 pnum, code; /* part name */
3818 tserver = GetServer(as->parms[0].items->data);
3820 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3821 as->parms[0].items->data);
3824 if (as->parms[1].items) {
3825 pnum = volutil_GetPartitionID(as->parms[1].items->data);
3827 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3828 as->parms[1].items->data);
3831 if (!IsPartValid(pnum, tserver, &code)) { /*check for validity of the partition */
3833 PrintError("", code);
3836 "vos : partition %s does not exist on the server\n",
3837 as->parms[1].items->data);
3845 if (as->parms[2].items) {
3846 flags |= 2; /* don't update */
3848 code = UV_SyncServer(tserver, pnum, flags, 0 /*unused */ );
3850 PrintDiagnostics("syncserv", code);
3854 MapPartIdIntoName(pnum, part);
3855 fprintf(STDOUT, "Server %s partition %s synchronized with VLDB\n",
3856 as->parms[0].items->data, part);
3858 fprintf(STDOUT, "Server %s synchronized with VLDB\n",
3859 as->parms[0].items->data);
3868 struct nvldbentry entry;
3871 /* The vlserver will handle names with the .readonly
3872 * and .backup extension as well as volume ids.
3874 vcode = VLDB_GetEntryByName(name, &entry);
3876 PrintError("", vcode);
3879 MapHostToNetwork(&entry);
3880 EnumerateEntry(&entry);
3882 /* Defect #3027: grubby check to handle locked volume.
3883 * If VLOP_ALLOPERS is set, the entry is locked.
3884 * Leave this routine as is, but put in correct check.
3886 if (entry.flags & VLOP_ALLOPERS)
3887 fprintf(STDOUT, " Volume is currently LOCKED \n");
3893 VolumeZap(register struct cmd_syndesc *as, void *arock)
3895 struct nvldbentry entry;
3896 afs_uint32 volid, zapbackupid = 0, backupid = 0;
3897 afs_int32 code, server, part, err;
3899 if (as->parms[3].items) {
3900 /* force flag is on, use the other version */
3901 return NukeVolume(as);
3904 if (as->parms[4].items) {
3908 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
3911 PrintError("", err);
3913 fprintf(STDERR, "vos: can't find volume '%s'\n",
3914 as->parms[2].items->data);
3917 part = volutil_GetPartitionID(as->parms[1].items->data);
3919 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
3920 as->parms[1].items->data);
3923 server = GetServer(as->parms[0].items->data);
3925 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3926 as->parms[0].items->data);
3929 if (!IsPartValid(part, server, &code)) { /*check for validity of the partition */
3931 PrintError("", code);
3934 "vos : partition %s does not exist on the server\n",
3935 as->parms[1].items->data);
3938 code = VLDB_GetEntryByID(volid, -1, &entry);
3940 if (volid == entry.volumeId[RWVOL])
3941 backupid = entry.volumeId[BACKVOL];
3943 "Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
3944 (unsigned long)volid);
3947 volintInfo *pntr = (volintInfo *) 0;
3950 code = UV_ListOneVolume(server, part, volid, &pntr);
3952 if (volid == pntr->parentID)
3953 backupid = pntr->backupID;
3959 code = UV_VolumeZap(server, part, backupid);
3961 PrintDiagnostics("zap", code);
3964 fprintf(STDOUT, "Backup Volume %lu deleted\n",
3965 (unsigned long)backupid);
3968 code = UV_VolumeZap(server, part, volid);
3970 PrintDiagnostics("zap", code);
3973 fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
3979 VolserStatus(register struct cmd_syndesc *as, void *arock)
3981 afs_int32 server, code;
3982 transDebugInfo *pntr, *oldpntr;
3987 server = GetServer(as->parms[0].items->data);
3989 fprintf(STDERR, "vos: host '%s' not found in host table\n",
3990 as->parms[0].items->data);
3993 code = UV_VolserStatus(server, &pntr, &count);
3995 PrintDiagnostics("status", code);
4000 fprintf(STDOUT, "No active transactions on %s\n",
4001 as->parms[0].items->data);
4003 fprintf(STDOUT, "Total transactions: %d\n", count);
4005 for (i = 0; i < count; i++) {
4006 /*print out the relevant info */
4007 fprintf(STDOUT, "--------------------------------------\n");
4008 fprintf(STDOUT, "transaction: %lu created: %s",
4009 (unsigned long)pntr->tid, vos_ctime( & pntr->time));
4010 if (pntr->returnCode) {
4011 fprintf(STDOUT, "returnCode: %lu\n",
4012 (unsigned long)pntr->returnCode);
4015 fprintf(STDOUT, "attachFlags: ");
4016 switch (pntr->iflags) {
4018 fprintf(STDOUT, "offline ");
4021 fprintf(STDOUT, "busy ");
4024 fprintf(STDOUT, "readonly ");
4027 fprintf(STDOUT, "create ");
4030 fprintf(STDOUT, "create volid ");
4033 fprintf(STDOUT, "\n");
4036 fprintf(STDOUT, "volumeStatus: ");
4037 switch (pntr->vflags) {
4038 case VTDeleteOnSalvage:
4039 fprintf(STDOUT, "deleteOnSalvage ");
4040 case VTOutOfService:
4041 fprintf(STDOUT, "outOfService ");
4043 fprintf(STDOUT, "deleted ");
4045 fprintf(STDOUT, "\n");
4048 fprintf(STDOUT, "transactionFlags: ");
4049 fprintf(STDOUT, "delete\n");
4051 MapPartIdIntoName(pntr->partition, pname);
4052 fprintf(STDOUT, "volume: %lu partition: %s procedure: %s\n",
4053 (unsigned long)pntr->volid, pname, pntr->lastProcName);
4054 if (pntr->callValid) {
4056 "packetRead: %lu lastReceiveTime: %d packetSend: %lu lastSendTime: %d\n",
4057 (unsigned long)pntr->readNext, pntr->lastReceiveTime,
4058 (unsigned long)pntr->transmitNext, pntr->lastSendTime);
4061 fprintf(STDOUT, "--------------------------------------\n");
4062 fprintf(STDOUT, "\n");
4070 RenameVolume(register struct cmd_syndesc *as, void *arock)
4072 afs_int32 code1, code2, code;
4073 struct nvldbentry entry;
4075 code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
4077 fprintf(STDERR, "vos: Could not find entry for volume %s\n",
4078 as->parms[0].items->data);
4081 code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
4082 if ((!code1) && (!code2)) { /*the newname already exists */
4083 fprintf(STDERR, "vos: volume %s already exists\n",
4084 as->parms[1].items->data);
4088 if (code1 && code2) {
4089 fprintf(STDERR, "vos: Could not find entry for volume %s or %s\n",
4090 as->parms[0].items->data, as->parms[1].items->data);
4093 if (!VolNameOK(as->parms[0].items->data)) {
4095 "Illegal volume name %s, should not end in .readonly or .backup\n",
4096 as->parms[0].items->data);
4099 if (!ISNAMEVALID(as->parms[1].items->data)) {
4101 "vos: the new volume name %s exceeds the size limit of %d\n",
4102 as->parms[1].items->data, VOLSER_OLDMAXVOLNAME - 10);
4105 if (!VolNameOK(as->parms[1].items->data)) {
4107 "Illegal volume name %s, should not end in .readonly or .backup\n",
4108 as->parms[1].items->data);
4111 if (IsNumeric(as->parms[1].items->data)) {
4112 fprintf(STDERR, "Illegal volume name %s, should not be a number\n",
4113 as->parms[1].items->data);
4116 MapHostToNetwork(&entry);
4118 UV_RenameVolume(&entry, as->parms[0].items->data,
4119 as->parms[1].items->data);
4121 PrintDiagnostics("rename", code);
4124 fprintf(STDOUT, "Renamed volume %s to %s\n", as->parms[0].items->data,
4125 as->parms[1].items->data);
4130 GetVolumeInfo(afs_uint32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *voltype,
4131 struct nvldbentry *rentry)
4136 vcode = VLDB_GetEntryByID(volid, -1, rentry);
4139 "Could not fetch the entry for volume %lu from VLDB \n",
4140 (unsigned long)volid);
4141 PrintError("", vcode);
4144 MapHostToNetwork(rentry);
4145 if (volid == rentry->volumeId[ROVOL]) {
4147 for (i = 0; i < rentry->nServers; i++) {
4148 if ((index == -1) && (rentry->serverFlags[i] & ITSROVOL)
4149 && !(rentry->serverFlags[i] & RO_DONTUSE))
4154 "RO volume is not found in VLDB entry for volume %lu\n",
4155 (unsigned long)volid);
4159 *server = rentry->serverNumber[index];
4160 *part = rentry->serverPartition[index];
4164 index = Lp_GetRwIndex(rentry);
4167 "RW Volume is not found in VLDB entry for volume %lu\n",
4168 (unsigned long)volid);
4171 if (volid == rentry->volumeId[RWVOL]) {
4173 *server = rentry->serverNumber[index];
4174 *part = rentry->serverPartition[index];
4177 if (volid == rentry->volumeId[BACKVOL]) {
4179 *server = rentry->serverNumber[index];
4180 *part = rentry->serverPartition[index];
4184 "unexpected volume type for volume %lu\n",
4185 (unsigned long)volid);
4190 DeleteEntry(register struct cmd_syndesc *as, void *arock)
4192 afs_int32 apart = 0;
4195 struct VldbListByAttributes attributes;
4196 nbulkentries arrayEntries;
4197 register struct nvldbentry *vllist;
4198 struct cmd_item *itp;
4201 char prefix[VOLSER_MAXVOLNAME + 1];
4203 afs_int32 totalBack = 0, totalFail = 0, err;
4205 if (as->parms[0].items) { /* -id */
4206 if (as->parms[1].items || as->parms[2].items || as->parms[3].items) {
4208 "You cannot use -server, -partition, or -prefix with the -id argument\n");
4211 for (itp = as->parms[0].items; itp; itp = itp->next) {
4212 avolid = vsu_GetVolumeID(itp->data, cstruct, &err);
4215 PrintError("", err);
4217 fprintf(STDERR, "vos: can't find volume '%s'\n",
4221 if (as->parms[4].items) { /* -noexecute */
4222 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4227 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4229 fprintf(STDERR, "Could not delete entry for volume %s\n",
4232 "You must specify a RW volume name or ID "
4233 "(the entire VLDB entry will be deleted)\n");
4234 PrintError("", vcode);
4240 fprintf(STDOUT, "Deleted %d VLDB entries\n", totalBack);
4244 if (!as->parms[1].items && !as->parms[2].items && !as->parms[3].items) {
4245 fprintf(STDERR, "You must specify an option\n");
4249 /* Zero out search attributes */
4250 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4252 if (as->parms[1].items) { /* -prefix */
4253 strncpy(prefix, as->parms[1].items->data, VOLSER_MAXVOLNAME);
4255 if (!as->parms[2].items && !as->parms[3].items) { /* a single entry only */
4257 "You must provide -server with the -prefix argument\n");
4262 if (as->parms[2].items) { /* -server */
4264 aserver = GetServer(as->parms[2].items->data);
4266 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4267 as->parms[2].items->data);
4270 attributes.server = ntohl(aserver);
4271 attributes.Mask |= VLLIST_SERVER;
4274 if (as->parms[3].items) { /* -partition */
4275 if (!as->parms[2].items) {
4277 "You must provide -server with the -partition argument\n");
4280 apart = volutil_GetPartitionID(as->parms[3].items->data);
4282 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4283 as->parms[3].items->data);
4286 attributes.partition = apart;
4287 attributes.Mask |= VLLIST_PARTITION;
4290 /* Print status line of what we are doing */
4291 fprintf(STDOUT, "Deleting VLDB entries for ");
4292 if (as->parms[2].items) {
4293 fprintf(STDOUT, "server %s ", as->parms[2].items->data);
4295 if (as->parms[3].items) {
4297 MapPartIdIntoName(apart, pname);
4298 fprintf(STDOUT, "partition %s ", pname);
4301 fprintf(STDOUT, "which are prefixed with %s ", prefix);
4303 fprintf(STDOUT, "\n");
4306 /* Get all the VLDB entries on a server and/or partition */
4307 memset(&arrayEntries, 0, sizeof(arrayEntries));
4308 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4310 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4311 PrintError("", vcode);
4315 /* Process each entry */
4316 for (j = 0; j < nentries; j++) {
4317 vllist = &arrayEntries.nbulkentries_val[j];
4319 /* It only deletes the RW volumes */
4320 if (strncmp(vllist->name, prefix, strlen(prefix))) {
4323 "Omitting to delete %s due to prefix %s mismatch\n",
4324 vllist->name, prefix);
4331 if (as->parms[4].items) { /* -noexecute */
4332 fprintf(STDOUT, "Would have deleted VLDB entry for %s \n",
4338 /* Only matches the RW volume name */
4339 avolid = vllist->volumeId[RWVOL];
4340 vcode = ubik_VL_DeleteEntry(cstruct, 0, avolid, RWVOL);
4342 fprintf(STDOUT, "Could not delete VDLB entry for %s\n",
4345 PrintError("", vcode);
4350 fprintf(STDOUT, "Deleted VLDB entry for %s \n", vllist->name);
4355 fprintf(STDOUT, "----------------------\n");
4357 "Total VLDB entries deleted: %lu; failed to delete: %lu\n",
4358 (unsigned long)totalBack, (unsigned long)totalFail);
4359 if (arrayEntries.nbulkentries_val)
4360 free(arrayEntries.nbulkentries_val);
4366 CompareVldbEntryByName(p1, p2)
4369 struct nvldbentry *arg1, *arg2;
4371 arg1 = (struct nvldbentry *)p1;
4372 arg2 = (struct nvldbentry *)p2;
4373 return (strcmp(arg1->name, arg2->name));
4377 static int CompareVldbEntry(p1,p2)
4380 struct nvldbentry *arg1,*arg2;
4383 char comp1[100],comp2[100];
4384 char temp1[20],temp2[20];
4386 arg1 = (struct nvldbentry *)p1;
4387 arg2 = (struct nvldbentry *)p2;
4391 for(i = 0; i < arg1->nServers; i++)
4392 if(arg1->serverFlags[i] & ITSRWVOL) pos1 = i;
4393 for(i = 0; i < arg2->nServers; i++)
4394 if(arg2->serverFlags[i] & ITSRWVOL) pos2 = i;
4395 if(pos1 == -1 || pos2 == -1){
4399 sprintf(comp1,"%10u",arg1->serverNumber[pos1]);
4400 sprintf(comp2,"%10u",arg2->serverNumber[pos2]);
4401 sprintf(temp1,"%10u",arg1->serverPartition[pos1]);
4402 sprintf(temp2,"%10u",arg2->serverPartition[pos2]);
4403 strcat(comp1,temp1);
4404 strcat(comp2,temp2);
4405 strcat(comp1,arg1->name);
4406 strcat(comp1,arg2->name);
4407 return(strcmp(comp1,comp2));
4413 ListVLDB(struct cmd_syndesc *as, void *arock)
4416 afs_int32 aserver, code;
4418 struct VldbListByAttributes attributes;
4419 nbulkentries arrayEntries;
4420 struct nvldbentry *vllist, *tarray = 0, *ttarray;
4421 afs_int32 centries, nentries = 0;
4422 afs_int32 tarraysize = 0;
4423 afs_int32 parraysize;
4426 int quiet, sort, lock;
4427 afs_int32 thisindex, nextindex;
4432 attributes.Mask = 0;
4433 lock = (as->parms[3].items ? 1 : 0); /* -lock flag */
4434 quiet = (as->parms[4].items ? 1 : 0); /* -quit flag */
4435 sort = (as->parms[5].items ? 0 : 1); /* -nosort flag */
4437 /* If the volume name is given, Use VolumeInfoCmd to look it up
4438 * and not ListAttributes.
4440 if (as->parms[0].items) {
4443 "vos: illegal use of '-locked' switch, need to specify server and/or partition\n");
4446 code = VolumeInfoCmd(as->parms[0].items->data);
4448 PrintError("", code);
4454 /* Server specified */
4455 if (as->parms[1].items) {
4456 aserver = GetServer(as->parms[1].items->data);
4458 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4459 as->parms[1].items->data);
4462 attributes.server = ntohl(aserver);
4463 attributes.Mask |= VLLIST_SERVER;
4466 /* Partition specified */
4467 if (as->parms[2].items) {
4468 apart = volutil_GetPartitionID(as->parms[2].items->data);
4470 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4471 as->parms[2].items->data);
4474 attributes.partition = apart;
4475 attributes.Mask |= VLLIST_PARTITION;
4479 attributes.Mask |= VLLIST_FLAG;
4480 attributes.flag = VLOP_ALLOPERS;
4483 /* Print header information */
4485 MapPartIdIntoName(apart, pname);
4486 fprintf(STDOUT, "VLDB entries for %s %s%s%s %s\n",
4487 (as->parms[1].items ? "server" : "all"),
4488 (as->parms[1].items ? as->parms[1].items->data : "servers"),
4489 (as->parms[2].items ? " partition " : ""),
4490 (as->parms[2].items ? pname : ""),
4491 (lock ? "which are locked:" : ""));
4494 for (thisindex = 0; (thisindex != -1); thisindex = nextindex) {
4495 memset(&arrayEntries, 0, sizeof(arrayEntries));
4500 VLDB_ListAttributesN2(&attributes, 0, thisindex, ¢ries,
4501 &arrayEntries, &nextindex);
4502 if (vcode == RXGEN_OPCODE) {
4503 /* Vlserver not running with ListAttributesN2. Fall back */
4505 VLDB_ListAttributes(&attributes, ¢ries, &arrayEntries);
4509 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4510 PrintError("", vcode);
4513 nentries += centries;
4515 /* We don't sort, so just print the entries now */
4517 for (j = 0; j < centries; j++) { /* process each entry */
4518 vllist = &arrayEntries.nbulkentries_val[j];
4519 MapHostToNetwork(vllist);
4520 EnumerateEntry(vllist);
4522 if (vllist->flags & VLOP_ALLOPERS)
4523 fprintf(STDOUT, " Volume is currently LOCKED \n");
4527 /* So we sort. First we must collect all the entries and keep
4530 else if (centries > 0) {
4532 /* steal away the first bulk entries array */
4533 tarray = (struct nvldbentry *)arrayEntries.nbulkentries_val;
4534 tarraysize = centries * sizeof(struct nvldbentry);
4535 arrayEntries.nbulkentries_val = 0;
4537 /* Grow the tarray to keep the extra entries */
4538 parraysize = (centries * sizeof(struct nvldbentry));
4540 (struct nvldbentry *)realloc(tarray,
4541 tarraysize + parraysize);
4544 "Could not allocate enough space for the VLDB entries\n");
4550 memcpy(((char *)tarray) + tarraysize,
4551 (char *)arrayEntries.nbulkentries_val, parraysize);
4552 tarraysize += parraysize;
4556 /* Free the bulk array */
4557 if (arrayEntries.nbulkentries_val) {
4558 free(arrayEntries.nbulkentries_val);
4559 arrayEntries.nbulkentries_val = 0;
4563 /* Here is where we now sort all the entries and print them */
4564 if (sort && (nentries > 0)) {
4565 qsort((char *)tarray, nentries, sizeof(struct nvldbentry),
4566 CompareVldbEntryByName);
4567 for (vllist = tarray, j = 0; j < nentries; j++, vllist++) {
4568 MapHostToNetwork(vllist);
4569 EnumerateEntry(vllist);
4571 if (vllist->flags & VLOP_ALLOPERS)
4572 fprintf(STDOUT, " Volume is currently LOCKED \n");
4578 fprintf(STDOUT, "\nTotal entries: %lu\n", (unsigned long)nentries);
4585 BackSys(register struct cmd_syndesc *as, void *arock)
4588 afs_int32 apart = 0;
4589 afs_int32 aserver = 0, code, aserver1, apart1;
4591 struct VldbListByAttributes attributes;
4592 nbulkentries arrayEntries;
4593 register struct nvldbentry *vllist;
4597 int seenprefix, seenxprefix, exclude, ex, exp, noaction;
4598 afs_int32 totalBack = 0;
4599 afs_int32 totalFail = 0;
4600 int previdx = -1, error, same;
4602 struct cmd_item *ti;
4606 memset(&attributes, 0, sizeof(struct VldbListByAttributes));
4607 attributes.Mask = 0;
4609 seenprefix = (as->parms[0].items ? 1 : 0);
4610 exclude = (as->parms[3].items ? 1 : 0);
4611 seenxprefix = (as->parms[4].items ? 1 : 0);
4612 noaction = (as->parms[5].items ? 1 : 0);
4614 if (as->parms[1].items) { /* -server */
4615 aserver = GetServer(as->parms[1].items->data);
4617 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4618 as->parms[1].items->data);
4621 attributes.server = ntohl(aserver);
4622 attributes.Mask |= VLLIST_SERVER;
4625 if (as->parms[2].items) { /* -partition */
4626 apart = volutil_GetPartitionID(as->parms[2].items->data);
4628 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4629 as->parms[2].items->data);
4632 attributes.partition = apart;
4633 attributes.Mask |= VLLIST_PARTITION;
4636 /* Check to make sure the prefix and xprefix expressions compile ok */
4638 for (ti = as->parms[0].items; ti; ti = ti->next) {
4639 if (strncmp(ti->data, "^", 1) == 0) {
4640 #ifdef HAVE_POSIX_REGEX
4644 code = regcomp(&re, ti->data, REG_NOSUB);
4646 regerror(code, &re, errbuf, sizeof errbuf);
4648 "Unrecognizable -prefix regular expression: '%s': %s\n",
4654 ccode = (char *)re_comp(ti->data);
4657 "Unrecognizable -prefix regular expression: '%s': %s\n",
4666 for (ti = as->parms[4].items; ti; ti = ti->next) {
4667 if (strncmp(ti->data, "^", 1) == 0) {
4668 #ifdef HAVE_POSIX_REGEX
4672 code = regcomp(&re, ti->data, REG_NOSUB);
4674 regerror(code, &re, errbuf, sizeof errbuf);
4676 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4682 ccode = (char *)re_comp(ti->data);
4685 "Unrecognizable -xprefix regular expression: '%s': %s\n",
4694 memset(&arrayEntries, 0, sizeof(arrayEntries)); /* initialize to hint the stub to alloc space */
4695 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4697 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4698 PrintError("", vcode);
4702 if (as->parms[1].items || as->parms[2].items || verbose) {
4703 fprintf(STDOUT, "%s up volumes",
4704 (noaction ? "Would have backed" : "Backing"));
4706 if (as->parms[1].items) {
4707 fprintf(STDOUT, " on server %s", as->parms[1].items->data);
4708 } else if (as->parms[2].items) {
4709 fprintf(STDOUT, " for all servers");
4712 if (as->parms[2].items) {
4713 MapPartIdIntoName(apart, pname);
4714 fprintf(STDOUT, " partition %s", pname);
4717 if (seenprefix || (!seenprefix && seenxprefix)) {
4718 ti = (seenprefix ? as->parms[0].items : as->parms[4].items);
4719 ex = (seenprefix ? exclude : !exclude);
4720 exp = (strncmp(ti->data, "^", 1) == 0);
4721 fprintf(STDOUT, " which %smatch %s '%s'", (ex ? "do not " : ""),
4722 (exp ? "expression" : "prefix"), ti->data);
4723 for (ti = ti->next; ti; ti = ti->next) {
4724 exp = (strncmp(ti->data, "^", 1) == 0);
4725 printf(" %sor %s '%s'", (ex ? "n" : ""),
4726 (exp ? "expression" : "prefix"), ti->data);
4730 if (seenprefix && seenxprefix) {
4731 ti = as->parms[4].items;
4732 exp = (strncmp(ti->data, "^", 1) == 0);
4733 fprintf(STDOUT, " %swhich match %s '%s'",
4734 (exclude ? "adding those " : "removing those "),
4735 (exp ? "expression" : "prefix"), ti->data);
4736 for (ti = ti->next; ti; ti = ti->next) {
4737 exp = (strncmp(ti->data, "^", 1) == 0);
4738 printf(" or %s '%s'", (exp ? "expression" : "prefix"),
4742 fprintf(STDOUT, " .. ");
4744 fprintf(STDOUT, "\n");
4748 for (j = 0; j < nentries; j++) { /* process each vldb entry */
4749 vllist = &arrayEntries.nbulkentries_val[j];
4752 for (ti = as->parms[0].items; ti; ti = ti->next) {
4753 if (strncmp(ti->data, "^", 1) == 0) {
4754 #ifdef HAVE_POSIX_REGEX
4758 /* XXX -- should just do the compile once! */
4759 code = regcomp(&re, ti->data, REG_NOSUB);
4761 regerror(code, &re, errbuf, sizeof errbuf);
4763 "Error in -prefix regular expression: '%s': %s\n",
4767 match = (regexec(&re, vllist->name, 0, NULL, 0) == 0);
4770 ccode = (char *)re_comp(ti->data);
4773 "Error in -prefix regular expression: '%s': %s\n",
4777 match = (re_exec(vllist->name) == 1);
4781 (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4791 /* Without the -exclude flag: If it matches the prefix, then
4792 * check if we want to exclude any from xprefix.
4793 * With the -exclude flag: If it matches the prefix, then
4794 * check if we want to add any from xprefix.
4796 if (match && seenxprefix) {
4797 for (ti = as->parms[4].items; ti; ti = ti->next) {
4798 if (strncmp(ti->data, "^", 1) == 0) {
4799 #ifdef HAVE_POSIX_REGEX
4803 /* XXX -- should just do the compile once! */
4804 code = regcomp(&re, ti->data, REG_NOSUB);
4806 regerror(code, &re, errbuf, sizeof errbuf);
4808 "Error in -xprefix regular expression: '%s': %s\n",
4812 if (regexec(&re, vllist->name, 0, NULL, 0) == 0)
4816 ccode = (char *)re_comp(ti->data);
4819 "Error in -xprefix regular expression: '%s': %s\n",
4823 if (re_exec(vllist->name) == 1) {
4829 if (strncmp(vllist->name, ti->data, strlen(ti->data)) ==
4839 match = !match; /* -exclude will reverse the match */
4841 continue; /* Skip if no match */
4843 /* Print list of volumes to backup */
4845 fprintf(STDOUT, " %s\n", vllist->name);
4849 if (!(vllist->flags & RW_EXISTS)) {
4852 "Omitting to backup %s since RW volume does not exist \n",
4854 fprintf(STDOUT, "\n");
4860 avolid = vllist->volumeId[RWVOL];
4861 MapHostToNetwork(vllist);
4862 GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
4863 if (aserver1 == -1 || apart1 == -1) {
4864 fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n",
4870 same = VLDB_IsSameAddrs(aserver, aserver1, &error);
4873 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
4879 if ((aserver && !same) || (apart && (apart != apart1))) {
4882 "Omitting to backup %s since the RW is in a different location\n",
4888 time_t now = time(0);
4889 fprintf(STDOUT, "Creating backup volume for %s on %s",
4890 vllist->name, ctime(&now));
4894 code = UV_BackupVolume(aserver1, apart1, avolid);
4896 fprintf(STDOUT, "Could not backup %s\n", vllist->name);
4902 fprintf(STDOUT, "\n");
4904 } /* process each vldb entry */
4905 fprintf(STDOUT, "done\n");
4906 fprintf(STDOUT, "Total volumes backed up: %lu; failed to backup: %lu\n",
4907 (unsigned long)totalBack, (unsigned long)totalFail);
4909 if (arrayEntries.nbulkentries_val)
4910 free(arrayEntries.nbulkentries_val);
4915 UnlockVLDB(register struct cmd_syndesc *as, void *arock)
4918 afs_int32 aserver = NULL;
4921 struct VldbListByAttributes attributes;
4922 nbulkentries arrayEntries;
4923 register struct nvldbentry *vllist;
4932 attributes.Mask = 0;
4934 if (as->parms[0].items) { /* server specified */
4935 aserver = GetServer(as->parms[0].items->data);
4937 fprintf(STDERR, "vos: server '%s' not found in host table\n",
4938 as->parms[0].items->data);
4941 attributes.server = ntohl(aserver);
4942 attributes.Mask |= VLLIST_SERVER;
4944 if (as->parms[1].items) { /* partition specified */
4945 apart = volutil_GetPartitionID(as->parms[1].items->data);
4947 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
4948 as->parms[1].items->data);
4951 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
4953 PrintError("", code);
4956 "vos : partition %s does not exist on the server\n",
4957 as->parms[1].items->data);
4960 attributes.partition = apart;
4961 attributes.Mask |= VLLIST_PARTITION;
4963 attributes.flag = VLOP_ALLOPERS;
4964 attributes.Mask |= VLLIST_FLAG;
4965 memset(&arrayEntries, 0, sizeof(arrayEntries)); /*initialize to hint the stub to alloc space */
4966 vcode = VLDB_ListAttributes(&attributes, &nentries, &arrayEntries);
4968 fprintf(STDERR, "Could not access the VLDB for attributes\n");
4969 PrintError("", vcode);
4972 for (j = 0; j < nentries; j++) { /* process each entry */
4973 vllist = &arrayEntries.nbulkentries_val[j];
4974 volid = vllist->volumeId[RWVOL];
4976 ubik_VL_ReleaseLock(cstruct, 0, volid, -1,
4977 LOCKREL_OPCODE | LOCKREL_AFSID |
4980 fprintf(STDERR, "Could not unlock entry for volume %s\n",
4982 PrintError("", vcode);
4987 MapPartIdIntoName(apart, pname);
4990 "Could not lock %lu VLDB entries of %lu locked entries\n",
4991 (unsigned long)totalE, (unsigned long)nentries);
4993 if (as->parms[0].items) {
4995 "Unlocked all the VLDB entries for volumes on server %s ",
4996 as->parms[0].items->data);
4997 if (as->parms[1].items) {
4998 MapPartIdIntoName(apart, pname);
4999 fprintf(STDOUT, "partition %s\n", pname);
5001 fprintf(STDOUT, "\n");
5003 } else if (as->parms[1].items) {
5004 MapPartIdIntoName(apart, pname);
5006 "Unlocked all the VLDB entries for volumes on partition %s on all servers\n",
5011 if (arrayEntries.nbulkentries_val)
5012 free(arrayEntries.nbulkentries_val);
5017 PrintInt64Size(afs_uint64 in)
5019 register afs_uint32 hi, lo;
5020 register char * units;
5021 static char output[16];
5023 SplitInt64(in,hi,lo);
5027 } else if (!(hi & 0xFFFFFC00)) {
5029 lo = (hi << 22) | (lo >> 10);
5030 } else if (!(hi & 0xFFF00000)) {
5032 lo = (hi << 12) | (lo >> 20);
5033 } else if (!(hi & 0xC0000000)) {
5035 lo = (hi << 2) | (lo >> 30);
5040 sprintf(output,"%u %s", lo, units);
5045 PartitionInfo(register struct cmd_syndesc *as, void *arock)
5048 afs_int32 aserver, code;
5050 struct diskPartition64 partition;
5051 struct partList dummyPartList;
5053 int printSummary=0, sumPartitions=0;
5054 afs_uint64 sumFree, sumStorage;
5057 ZeroInt64(sumStorage);
5059 aserver = GetServer(as->parms[0].items->data);
5061 fprintf(STDERR, "vos: server '%s' not found in host table\n",
5062 as->parms[0].items->data);
5065 if (as->parms[1].items) {
5066 apart = volutil_GetPartitionID(as->parms[1].items->data);
5068 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5069 as->parms[1].items->data);
5072 dummyPartList.partId[0] = apart;
5073 dummyPartList.partFlags[0] = PARTVALID;
5076 if (as->parms[2].items) {
5080 if (!IsPartValid(apart, aserver, &code)) { /*check for validity of the partition */
5082 PrintError("", code);
5085 "vos : partition %s does not exist on the server\n",
5086 as->parms[1].items->data);
5090 code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
5092 PrintDiagnostics("listpart", code);
5096 for (i = 0; i < cnt; i++) {
5097 if (dummyPartList.partFlags[i] & PARTVALID) {
5098 MapPartIdIntoName(dummyPartList.partId[i], pname);
5099 code = UV_PartitionInfo64(aserver, pname, &partition);
5101 fprintf(STDERR, "Could not get information on partition %s\n",
5103 PrintError("", code);
5107 "Free space on partition %s: %" AFS_INT64_FMT " K blocks out of total %" AFS_INT64_FMT "\n",
5108 pname, partition.free, partition.minFree);
5110 AddUInt64(sumFree,partition.free,&sumFree);
5111 AddUInt64(sumStorage,partition.minFree,&sumStorage);
5116 "Summary: %s free out of ",
5117 PrintInt64Size(sumFree));
5119 "%s on %d partitions\n",
5120 PrintInt64Size(sumStorage),
5127 ChangeAddr(register struct cmd_syndesc *as, void *arock)
5129 afs_int32 ip1, ip2, vcode;
5132 ip1 = GetServer(as->parms[0].items->data);
5134 fprintf(STDERR, "vos: invalid host address\n");
5138 if ((as->parms[1].items && as->parms[2].items)
5139 || (!as->parms[1].items && !as->parms[2].items)) {
5141 "vos: Must specify either '-newaddr <addr>' or '-remove' flag\n");
5145 if (as->parms[1].items) {
5146 ip2 = GetServer(as->parms[1].items->data);
5148 fprintf(STDERR, "vos: invalid host address\n");
5152 /* Play a trick here. If we are removing an address, ip1 will be -1
5153 * and ip2 will be the original address. This switch prevents an
5154 * older revision vlserver from removing the IP address.
5161 vcode = ubik_Call_New(VL_ChangeAddr, cstruct, 0, ntohl(ip1), ntohl(ip2));
5164 fprintf(STDERR, "Could not remove server %s from the VLDB\n",
5165 as->parms[0].items->data);
5166 if (vcode == VL_NOENT) {
5168 "vlserver does not support the remove flag or ");
5171 fprintf(STDERR, "Could not change server %s to server %s\n",
5172 as->parms[0].items->data, as->parms[1].items->data);
5174 PrintError("", vcode);
5179 fprintf(STDOUT, "Removed server %s from the VLDB\n",
5180 as->parms[0].items->data);
5182 fprintf(STDOUT, "Changed server %s to server %s\n",
5183 as->parms[0].items->data, as->parms[1].items->data);
5189 print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
5194 struct VLCallBack vlcb;
5197 ListAddrByAttributes m_attrs;
5198 afs_int32 m_nentries, *m_addrp;
5199 afs_int32 base, index;
5203 afsUUID_to_string(m_uuid, buf, sizeof(buf));
5204 printf("UUID: %s\n", buf);
5207 /* print out the list of all the server */
5208 addrp = (afs_int32 *) addrs->bulkaddrs_val;
5209 for (i = 0; i < nentries; i++, addrp++) {
5210 /* If it is a multihomed address, then we will need to
5211 * get the addresses for this multihomed server from
5212 * the vlserver and print them.
5214 if (((*addrp & 0xff000000) == 0xff000000) && ((*addrp) & 0xffff)) {
5215 /* Get the list of multihomed fileservers */
5216 base = (*addrp >> 16) & 0xff;
5217 index = (*addrp) & 0xffff;
5219 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
5220 && (index <= VL_MHSRV_PERBLK)) {
5221 m_attrs.Mask = VLADDR_INDEX;
5222 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
5224 m_addrs.bulkaddrs_val = 0;
5225 m_addrs.bulkaddrs_len = 0;
5227 ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, &m_uuid,
5228 (afs_int32 *)&vlcb, &m_nentries, &m_addrs);
5231 "vos: could not list the multi-homed server addresses\n");
5232 PrintError("", vcode);
5235 /* Print the list */
5236 m_addrp = (afs_int32 *) m_addrs.bulkaddrs_val;
5237 for (j = 0; j < m_nentries; j++, m_addrp++) {
5238 *m_addrp = htonl(*m_addrp);
5241 printf("%s ", afs_inet_ntoa_r(*m_addrp, hoststr));
5243 printf("%s ", hostutil_GetNameByINet(*m_addrp));
5247 printf("<unknown>\n");
5256 /* Otherwise, it is a non-multihomed entry and contains
5257 * the IP address of the server - print it.
5259 *addrp = htonl(*addrp);
5262 printf("%s\n", afs_inet_ntoa_r(*addrp, hoststr));
5264 printf("%s\n", hostutil_GetNameByINet(*addrp));
5275 ListAddrs(register struct cmd_syndesc *as, void *arock)
5278 afs_int32 i, printuuid = 0;
5279 struct VLCallBack vlcb;
5282 ListAddrByAttributes m_attrs;
5283 afsUUID m_uuid, askuuid;
5284 afs_int32 m_nentries;
5286 memset(&m_attrs, 0, sizeof(struct ListAddrByAttributes));
5287 m_attrs.Mask = VLADDR_INDEX;
5289 memset(&m_addrs, 0, sizeof(bulkaddrs));
5290 memset(&askuuid, 0, sizeof(afsUUID));
5291 if (as->parms[0].items) {
5293 if (afsUUID_from_string(as->parms[0].items->data, &askuuid) < 0) {
5294 fprintf(STDERR, "vos: invalid UUID '%s'\n",
5295 as->parms[0].items->data);
5298 m_attrs.Mask = VLADDR_UUID;
5299 m_attrs.uuid = askuuid;
5301 if (as->parms[1].items) {
5305 he = hostutil_GetHostByName((char *)as->parms[1].items->data);
5307 fprintf(STDERR, "vos: Can't get host info for '%s'\n",
5308 as->parms[1].items->data);
5311 memcpy(&saddr, he->h_addr, 4);
5312 m_attrs.Mask = VLADDR_IPADDR;
5313 m_attrs.ipaddr = ntohl(saddr);
5315 if (as->parms[2].items) {
5319 m_addrs.bulkaddrs_val = 0;
5320 m_addrs.bulkaddrs_len = 0;
5323 ubik_Call_New(VL_GetAddrs, cstruct, 0, 0, 0, &vlcb, &nentries,
5326 fprintf(STDERR, "vos: could not list the server addresses\n");
5327 PrintError("", vcode);
5332 m_addrs.bulkaddrs_val = 0;
5333 m_addrs.bulkaddrs_len = 0;
5339 ubik_Call_New(VL_GetAddrsU, cstruct, 0, &m_attrs, &m_uuid,
5340 &vlcb, &m_nentries, &m_addrs);
5342 if (vcode == VL_NOENT) {
5343 if (m_attrs.Mask == VLADDR_UUID) {
5344 fprintf(STDERR, "vos: no entry for UUID '%s' found in VLDB\n",
5345 as->parms[0].items->data);
5347 } else if (m_attrs.Mask == VLADDR_IPADDR) {
5348 fprintf(STDERR, "vos: no entry for host '%s' [0x%08x] found in VLDB\n",
5349 as->parms[1].items->data, m_attrs.ipaddr);
5358 if (vcode == VL_INDEXERANGE) {
5363 fprintf(STDERR, "vos: could not list the server addresses\n");
5364 PrintError("", vcode);
5368 print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid);
5371 if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
5379 LockEntry(register struct cmd_syndesc *as, void *arock)
5382 afs_int32 vcode, err;
5384 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5387 PrintError("", err);
5389 fprintf(STDERR, "vos: can't find volume '%s'\n",
5390 as->parms[0].items->data);
5393 vcode = ubik_VL_SetLock(cstruct, 0, avolid, -1, VLOP_DELETE);
5395 fprintf(STDERR, "Could not lock VLDB entry for volume %s\n",
5396 as->parms[0].items->data);
5397 PrintError("", vcode);
5400 fprintf(STDOUT, "Locked VLDB entry for volume %s\n",
5401 as->parms[0].items->data);
5406 ConvertRO(register struct cmd_syndesc *as, void *arock)
5408 afs_int32 partition = -1;
5410 afs_int32 server, code, i, same;
5411 struct nvldbentry entry, storeEntry;
5413 afs_int32 rwindex = 0;
5414 afs_int32 rwserver = 0;
5415 afs_int32 rwpartition = 0;
5416 afs_int32 roindex = 0;
5417 afs_int32 roserver = 0;
5418 afs_int32 ropartition = 0;
5420 struct rx_connection *aconn;
5423 server = GetServer(as->parms[0].items->data);
5425 fprintf(STDERR, "vos: host '%s' not found in host table\n",
5426 as->parms[0].items->data);
5429 partition = volutil_GetPartitionID(as->parms[1].items->data);
5430 if (partition < 0) {
5431 fprintf(STDERR, "vos: could not interpret partition name '%s'\n",
5432 as->parms[1].items->data);
5435 if (!IsPartValid(partition, server, &code)) {
5437 PrintError("", code);
5440 "vos : partition %s does not exist on the server\n",
5441 as->parms[1].items->data);
5444 volid = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &code);
5447 PrintError("", code);
5449 fprintf(STDERR, "Unknown volume ID or name '%s'\n",
5450 as->parms[0].items->data);
5453 if (as->parms[3].items)
5456 vcode = VLDB_GetEntryByID(volid, -1, &entry);
5459 "Could not fetch the entry for volume %lu from VLDB\n",
5460 (unsigned long)volid);
5461 PrintError("convertROtoRW", code);
5465 /* use RO volid even if user specified RW or BK volid */
5467 if (volid != entry.volumeId[ROVOL])
5468 volid = entry.volumeId[ROVOL];
5470 MapHostToNetwork(&entry);
5471 for (i = 0; i < entry.nServers; i++) {
5472 if (entry.serverFlags[i] & ITSRWVOL) {
5474 rwserver = entry.serverNumber[i];
5475 rwpartition = entry.serverPartition[i];
5477 if (entry.serverFlags[i] & ITSROVOL) {
5478 same = VLDB_IsSameAddrs(server, entry.serverNumber[i], &code);
5481 "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
5487 roserver = entry.serverNumber[i];
5488 ropartition = entry.serverPartition[i];
5494 fprintf(STDERR, "Warning: RO volume didn't exist in vldb!\n");
5496 if (ropartition != partition) {
5498 "Warning: RO volume should be in partition %d instead of %d (vldb)\n",
5499 ropartition, partition);
5504 "VLDB indicates that a RW volume exists already on %s in partition %s.\n",
5505 hostutil_GetNameByINet(rwserver),
5506 volutil_PartitionName(rwpartition));
5508 fprintf(STDERR, "Overwrite this VLDB entry? [y|n] (n)\n");
5510 while (!(dc == EOF || dc == '\n'))
5511 dc = getchar(); /* goto end of line */
5512 if ((c != 'y') && (c != 'Y')) {
5513 fprintf(STDERR, "aborted.\n");
5520 ubik_VL_SetLock(cstruct, 0, entry.volumeId[RWVOL], RWVOL,
5522 aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
5523 code = AFSVolConvertROtoRWvolume(aconn, partition, volid);
5526 "Converting RO volume %lu to RW volume failed with code %d\n",
5527 (unsigned long)volid, code);
5528 PrintError("convertROtoRW ", code);
5531 entry.serverFlags[roindex] = ITSRWVOL;
5532 entry.flags |= RW_EXISTS;
5533 entry.flags &= ~BACK_EXISTS;
5536 if (rwindex != entry.nServers) {
5537 entry.serverNumber[rwindex] = entry.serverNumber[entry.nServers];
5538 entry.serverPartition[rwindex] =
5539 entry.serverPartition[entry.nServers];
5540 entry.serverFlags[rwindex] = entry.serverFlags[entry.nServers];
5541 entry.serverNumber[entry.nServers] = 0;
5542 entry.serverPartition[entry.nServers] = 0;
5543 entry.serverFlags[entry.nServers] = 0;
5546 entry.flags &= ~RO_EXISTS;
5547 for (i = 0; i < entry.nServers; i++) {
5548 if (entry.serverFlags[i] & ITSROVOL) {
5549 if (!(entry.serverFlags[i] & (RO_DONTUSE | NEW_REPSITE)))
5550 entry.flags |= RO_EXISTS;
5553 MapNetworkToHost(&entry, &storeEntry);
5555 VLDB_ReplaceEntry(entry.volumeId[RWVOL], RWVOL, &storeEntry,
5556 (LOCKREL_OPCODE | LOCKREL_AFSID |
5557 LOCKREL_TIMESTAMP));
5560 "Warning: volume converted, but vldb update failed with code %d!\n",
5563 vcode = UV_LockRelease(entry.volumeId[RWVOL]);
5565 PrintDiagnostics("unlock", vcode);
5571 Sizes(register struct cmd_syndesc *as, void *arock)
5574 afs_int32 aserver, apart, voltype, fromdate = 0, code, err, i;
5575 struct nvldbentry entry;
5576 volintSize vol_size;
5578 rx_SetRxDeadTime(60 * 10);
5579 for (i = 0; i < MAXSERVERS; i++) {
5580 struct rx_connection *rxConn = ubik_GetRPCConn(cstruct, i);
5583 rx_SetConnDeadTime(rxConn, rx_connDeadTime);
5584 if (rxConn->service)
5585 rxConn->service->connDeadTime = rx_connDeadTime;
5588 avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
5591 PrintError("", err);
5593 fprintf(STDERR, "vos: can't find volume '%s'\n",
5594 as->parms[0].items->data);
5598 if (as->parms[1].items || as->parms[2].items) {
5599 if (!as->parms[1].items || !as->parms[2].items) {
5601 "Must specify both -server and -partition options\n");
5604 aserver = GetServer(as->parms[2].items->data);
5606 fprintf(STDERR, "Invalid server name\n");
5609 apart = volutil_GetPartitionID(as->parms[1].items->data);
5611 fprintf(STDERR, "Invalid partition name\n");
5615 code = GetVolumeInfo(avolid, &aserver, &apart, &voltype, &entry);
5622 if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
5623 code = ktime_DateToInt32(as->parms[4].items->data, &fromdate);
5625 fprintf(STDERR, "vos: failed to parse date '%s' (error=%d))\n",
5626 as->parms[4].items->data, code);
5631 fprintf(STDOUT, "Volume: %s\n", as->parms[0].items->data);
5633 if (as->parms[3].items) { /* do the dump estimate */
5634 #ifdef AFS_64BIT_ENV
5635 vol_size.dump_size = 0;
5637 FillInt64(vol_size.dump_size,0, 1);
5639 code = UV_GetSize(avolid, aserver, apart, fromdate, &vol_size);
5641 PrintDiagnostics("size", code);
5644 /* presumably the size info is now gathered in pntr */
5645 /* now we display it */
5647 fprintf(STDOUT, "dump_size: %llu\n", vol_size.dump_size);
5656 PrintDiagnostics(char *astring, afs_int32 acode)
5658 if (acode == EACCES) {
5660 "You are not authorized to perform the 'vos %s' command (%d)\n",
5663 fprintf(STDERR, "Error in vos %s command.\n", astring);
5664 PrintError("", acode);
5671 MyBeforeProc(struct cmd_syndesc *as, void *arock)
5673 register char *tcell;
5674 register afs_int32 code;
5675 register afs_int32 sauth;
5677 /* Initialize the ubik_client connection */
5678 rx_SetRxDeadTime(90);
5679 cstruct = (struct ubik_client *)0;
5683 if (as->parms[12].items) /* if -cell specified */
5684 tcell = as->parms[12].items->data;
5685 if (as->parms[14].items) /* -serverauth specified */
5687 if (as->parms[16].items) /* -crypt specified */
5690 vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
5691 &cstruct, UV_SetSecurity))) {
5692 fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
5693 (unsigned long)code);
5697 if (as->parms[15].items) /* -verbose flag set */
5701 if (as->parms[17].items) /* -noresolve flag set */
5711 /* this sucks but it works for now.
5716 #include "AFS_component_version_number.c"
5722 register afs_int32 code;
5724 register struct cmd_syndesc *ts;
5726 #ifdef AFS_AIX32_ENV
5728 * The following signal action for AIX is necessary so that in case of a
5729 * crash (i.e. core is generated) we can include the user's data section
5730 * in the core dump. Unfortunately, by default, only a partial core is
5731 * generated which, in many cases, isn't too useful.
5733 struct sigaction nsa;
5735 sigemptyset(&nsa.sa_mask);
5736 nsa.sa_handler = SIG_DFL;
5737 nsa.sa_flags = SA_FULLDUMP;
5738 sigaction(SIGSEGV, &nsa, NULL);
5741 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
5743 cmd_SetBeforeProc(MyBeforeProc, NULL);
5745 ts = cmd_CreateSyntax("create", CreateVolume, NULL, "create a new volume");
5746 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5747 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5748 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "volume name");
5749 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL,
5750 "initial quota (KB)");
5752 cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
5756 ts = cmd_CreateSyntax("remove", DeleteVolume, NULL, "delete a volume");
5757 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5758 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5759 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5763 ts = cmd_CreateSyntax("move", MoveVolume, NULL, "move a volume");
5764 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5765 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5766 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5767 "partition name on source");
5768 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5769 "machine name on destination");
5770 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5771 "partition name on destination");
5772 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5773 "copy live volume without cloning");
5776 ts = cmd_CreateSyntax("copy", CopyVolume, NULL, "copy a volume");
5777 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5778 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5779 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5780 "partition name on source");
5781 cmd_AddParm(ts, "-toname", CMD_SINGLE, 0, "volume name on destination");
5782 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5783 "machine name on destination");
5784 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5785 "partition name on destination");
5786 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5787 "leave new volume offline");
5788 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5789 "make new volume read-only");
5790 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5791 "copy live volume without cloning");
5794 ts = cmd_CreateSyntax("shadow", ShadowVolume, NULL,
5795 "make or update a shadow volume");
5796 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID on source");
5797 cmd_AddParm(ts, "-fromserver", CMD_SINGLE, 0, "machine name on source");
5798 cmd_AddParm(ts, "-frompartition", CMD_SINGLE, 0,
5799 "partition name on source");
5800 cmd_AddParm(ts, "-toserver", CMD_SINGLE, 0,
5801 "machine name on destination");
5802 cmd_AddParm(ts, "-topartition", CMD_SINGLE, 0,
5803 "partition name on destination");
5804 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5805 "volume name on destination");
5806 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5807 "volume ID on destination");
5808 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5809 "leave shadow volume offline");
5810 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5811 "make shadow volume read-only");
5812 cmd_AddParm(ts, "-live", CMD_FLAG, CMD_OPTIONAL,
5813 "copy live volume without cloning");
5814 cmd_AddParm(ts, "-incremental", CMD_FLAG, CMD_OPTIONAL,
5815 "do incremental update if target exists");
5818 ts = cmd_CreateSyntax("backup", BackupVolume, NULL,
5819 "make backup of a volume");
5820 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5823 ts = cmd_CreateSyntax("clone", CloneVolume, NULL,
5824 "make clone of a volume");
5825 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5826 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5827 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5828 cmd_AddParm(ts, "-toname", CMD_SINGLE, CMD_OPTIONAL,
5829 "volume name on destination");
5830 cmd_AddParm(ts, "-toid", CMD_SINGLE, CMD_OPTIONAL,
5831 "volume ID on destination");
5832 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5833 "leave clone volume offline");
5834 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5835 "make clone volume read-only, not readwrite");
5838 ts = cmd_CreateSyntax("release", ReleaseVolume, NULL, "release a volume");
5839 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5840 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5841 "force a complete release");
5844 ts = cmd_CreateSyntax("dump", DumpVolume, NULL, "dump a volume");
5845 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5846 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
5847 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5848 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "server");
5849 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition");
5850 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL,
5851 "dump a clone of the volume");
5852 cmd_AddParm(ts, "-omitdirs", CMD_FLAG, CMD_OPTIONAL,
5853 "omit unchanged directories from an incremental dump");
5856 ts = cmd_CreateSyntax("restore", RestoreVolume, NULL, "restore a volume");
5857 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5858 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5859 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of volume to be restored");
5860 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "dump file");
5861 cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
5862 cmd_AddParm(ts, "-overwrite", CMD_SINGLE, CMD_OPTIONAL,
5863 "abort | full | incremental");
5864 cmd_AddParm(ts, "-offline", CMD_FLAG, CMD_OPTIONAL,
5865 "leave restored volume offline");
5866 cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
5867 "make restored volume read-only");
5868 cmd_AddParm(ts, "-creation", CMD_SINGLE, CMD_OPTIONAL,
5869 "dump | keep | new");
5870 cmd_AddParm(ts, "-lastupdate", CMD_SINGLE, CMD_OPTIONAL,
5871 "dump | keep | new");
5872 cmd_AddParm(ts, "-nodelete", CMD_FLAG, CMD_OPTIONAL,
5873 "do not delete old site when restoring to a new site");
5876 ts = cmd_CreateSyntax("unlock", LockReleaseCmd, NULL,
5877 "release lock on VLDB entry for a volume");
5878 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5881 ts = cmd_CreateSyntax("changeloc", ChangeLocation, NULL,
5882 "change an RW volume's location in the VLDB");
5883 cmd_AddParm(ts, "-server", CMD_SINGLE, 0,
5884 "machine name for new location");
5885 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5886 "partition name for new location");
5887 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5890 ts = cmd_CreateSyntax("addsite", AddSite, NULL, "add a replication site");
5891 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name for new site");
5892 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0,
5893 "partition name for new site");
5894 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5895 cmd_AddParm(ts, "-valid", CMD_FLAG, CMD_OPTIONAL, "publish as an up-to-date site in VLDB");
5898 ts = cmd_CreateSyntax("remsite", RemoveSite, NULL,
5899 "remove a replication site");
5900 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5901 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5902 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5905 ts = cmd_CreateSyntax("listpart", ListPartitions, NULL, "list partitions");
5906 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5909 ts = cmd_CreateSyntax("listvol", ListVolumes, NULL,
5910 "list volumes on server (bypass VLDB)");
5911 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5912 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5913 cmd_AddParm(ts, "-fast", CMD_FLAG, CMD_OPTIONAL, "minimal listing");
5914 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
5915 "list all normal volume fields");
5916 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
5917 "generate minimal information");
5918 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5919 "list extended volume fields");
5920 #ifdef FULL_LISTVOL_SWITCH
5921 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5922 "machine readable format");
5923 #endif /* FULL_LISTVOL_SWITCH */
5926 ts = cmd_CreateSyntax("syncvldb", SyncVldb, NULL,
5927 "synchronize VLDB with server");
5928 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
5929 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5930 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5931 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5934 ts = cmd_CreateSyntax("syncserv", SyncServer, NULL,
5935 "synchronize server with VLDB");
5936 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5937 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
5938 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "report without updating");
5941 ts = cmd_CreateSyntax("examine", ExamineVolume, NULL,
5942 "everything about the volume");
5943 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5944 cmd_AddParm(ts, "-extended", CMD_FLAG, CMD_OPTIONAL,
5945 "list extended volume fields");
5946 #ifdef FULL_LISTVOL_SWITCH
5947 cmd_AddParm(ts, "-format", CMD_FLAG, CMD_OPTIONAL,
5948 "machine readable format");
5949 #endif /* FULL_LISTVOL_SWITCH */
5951 cmd_CreateAlias(ts, "volinfo");
5953 ts = cmd_CreateSyntax("setfields", SetFields, NULL,
5954 "change volume info fields");
5955 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5956 cmd_AddParm(ts, "-maxquota", CMD_SINGLE, CMD_OPTIONAL, "quota (KB)");
5957 cmd_AddParm(ts, "-clearuse", CMD_FLAG, CMD_OPTIONAL, "clear dayUse");
5958 cmd_AddParm(ts, "-clearVolUpCounter", CMD_FLAG, CMD_OPTIONAL, "clear volUpdateCounter");
5961 ts = cmd_CreateSyntax("offline", volOffline, NULL, "force the volume status to offline");
5962 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5963 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5964 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5965 cmd_AddParm(ts, "-sleep", CMD_SINGLE, CMD_OPTIONAL, "seconds to sleep");
5966 cmd_AddParm(ts, "-busy", CMD_FLAG, CMD_OPTIONAL, "busy volume");
5969 ts = cmd_CreateSyntax("online", volOnline, NULL, "force the volume status to online");
5970 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "server name");
5971 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5972 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
5975 ts = cmd_CreateSyntax("zap", VolumeZap, NULL,
5976 "delete the volume, don't bother with VLDB");
5977 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5978 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
5979 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume ID");
5980 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
5981 "force deletion of bad volumes");
5982 cmd_AddParm(ts, "-backup", CMD_FLAG, CMD_OPTIONAL,
5983 "also delete backup volume if one is found");
5986 ts = cmd_CreateSyntax("status", VolserStatus, NULL,
5987 "report on volser status");
5988 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
5991 ts = cmd_CreateSyntax("rename", RenameVolume, NULL, "rename a volume");
5992 cmd_AddParm(ts, "-oldname", CMD_SINGLE, 0, "old volume name ");
5993 cmd_AddParm(ts, "-newname", CMD_SINGLE, 0, "new volume name ");
5996 ts = cmd_CreateSyntax("listvldb", ListVLDB, NULL,
5997 "list volumes in the VLDB");
5998 cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "volume name or ID");
5999 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6000 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6001 cmd_AddParm(ts, "-locked", CMD_FLAG, CMD_OPTIONAL, "locked volumes only");
6002 cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL,
6003 "generate minimal information");
6004 cmd_AddParm(ts, "-nosort", CMD_FLAG, CMD_OPTIONAL,
6005 "do not alphabetically sort the volume names");
6008 ts = cmd_CreateSyntax("backupsys", BackSys, NULL, "en masse backups");
6009 cmd_AddParm(ts, "-prefix", CMD_LIST, CMD_OPTIONAL,
6010 "common prefix on volume(s)");
6011 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6012 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6013 cmd_AddParm(ts, "-exclude", CMD_FLAG, CMD_OPTIONAL,
6014 "exclude common prefix volumes");
6015 cmd_AddParm(ts, "-xprefix", CMD_LIST, CMD_OPTIONAL,
6016 "negative prefix on volume(s)");
6017 cmd_AddParm(ts, "-dryrun", CMD_FLAG, CMD_OPTIONAL, "no action");
6020 ts = cmd_CreateSyntax("delentry", DeleteEntry, NULL,
6021 "delete VLDB entry for a volume");
6022 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "volume name or ID");
6023 cmd_AddParm(ts, "-prefix", CMD_SINGLE, CMD_OPTIONAL,
6024 "prefix of the volume whose VLDB entry is to be deleted");
6025 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6026 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6027 cmd_AddParm(ts, "-noexecute", CMD_FLAG, CMD_OPTIONAL,
6031 ts = cmd_CreateSyntax("partinfo", PartitionInfo, NULL,
6032 "list partition information");
6033 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6034 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6035 cmd_AddParm(ts, "-summary", CMD_FLAG, CMD_OPTIONAL,
6036 "print storage summary");
6039 ts = cmd_CreateSyntax("unlockvldb", UnlockVLDB, NULL,
6040 "unlock all the locked entries in the VLDB");
6041 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6042 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6045 ts = cmd_CreateSyntax("lock", LockEntry, NULL,
6046 "lock VLDB entry for a volume");
6047 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6050 ts = cmd_CreateSyntax("changeaddr", ChangeAddr, NULL,
6051 "change the IP address of a file server");
6052 cmd_AddParm(ts, "-oldaddr", CMD_SINGLE, 0, "original IP address");
6053 cmd_AddParm(ts, "-newaddr", CMD_SINGLE, CMD_OPTIONAL, "new IP address");
6054 cmd_AddParm(ts, "-remove", CMD_FLAG, CMD_OPTIONAL,
6055 "remove the IP address from the VLDB");
6058 ts = cmd_CreateSyntax("listaddrs", ListAddrs, NULL,
6059 "list the IP address of all file servers registered in the VLDB");
6060 cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
6061 cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
6062 cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
6063 "print uuid of hosts");
6066 ts = cmd_CreateSyntax("convertROtoRW", ConvertRO, NULL,
6067 "convert a RO volume into a RW volume (after loss of old RW volume)");
6068 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
6069 cmd_AddParm(ts, "-partition", CMD_SINGLE, 0, "partition name");
6070 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6071 cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL, "don't ask");
6074 ts = cmd_CreateSyntax("size", Sizes, NULL,
6075 "obtain various sizes of the volume.");
6076 cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
6077 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL, "partition name");
6078 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_OPTIONAL, "machine name");
6079 cmd_AddParm(ts, "-dump", CMD_FLAG, CMD_OPTIONAL,
6080 "Obtain the size of the dump");
6081 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
6084 code = cmd_Dispatch(argc, argv);
6086 /* Shut down the ubik_client and rx connections */
6088 (void)ubik_ClientDestroy(cstruct);
6094 exit((code ? -1 : 0));